Skip to content

Commit 96b19ca

Browse files
committed
fix: (drop me) add some constructor base dispatches
1 parent ff3e8e4 commit 96b19ca

8 files changed

+51
-0
lines changed

Project.toml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.95.14"
66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
9+
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
910
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
1011
CubedSphere = "7445602f-e544-4518-8976-18f8e8ae6cdb"
1112
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -52,6 +53,7 @@ OceananigansReactantExt = ["Reactant", "KernelAbstractions"]
5253
[compat]
5354
Adapt = "4.1.1"
5455
CUDA = "5"
56+
ConstructionBase = "1.5.8"
5557
Crayons = "4"
5658
CubedSphere = "0.2, 0.3"
5759
Dates = "1.9"

src/Advection/centered_reconstruction.jl

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ struct Centered{N, FT, XT, YT, ZT, CA} <: AbstractCenteredAdvectionScheme{N, FT}
3636
end
3737
end
3838

39+
# XXX: move to extension
40+
using ConstructionBase: ConstructionBase
41+
42+
function ConstructionBase.constructorof(::Type{<:Centered{N, FT}}) where {N, FT}
43+
return Centered{N, FT}
44+
end
45+
3946
function Centered(FT::DataType = Float64; grid = nothing, order = 2)
4047

4148
if !(grid isa Nothing)

src/Advection/upwind_biased_reconstruction.jl

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ struct UpwindBiased{N, FT, XT, YT, ZT, CA, SI} <: AbstractUpwindBiasedAdvectionS
3838
end
3939
end
4040

41+
# XXX: move to extension
42+
using ConstructionBase: ConstructionBase
43+
44+
function ConstructionBase.constructorof(::Type{<:UpwindBiased{N, FT}}) where {N, FT}
45+
return UpwindBiased{N, FT}
46+
end
47+
4148
function UpwindBiased(FT::DataType = Float64; grid = nothing, order = 3)
4249

4350
if !(grid isa Nothing)

src/Advection/vector_invariant_advection.jl

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ struct VectorInvariant{N, FT, M, Z, ZS, V, K, D, U} <: AbstractAdvectionScheme{N
2929
end
3030
end
3131

32+
# XXX: move to extension
33+
using ConstructionBase: ConstructionBase
34+
35+
function ConstructionBase.constructorof(::Type{<:VectorInvariant{N, FT, M}}) where {N, FT, M}
36+
return VectorInvariant{N, FT, M}
37+
end
38+
3239
"""
3340
VectorInvariant(; vorticity_scheme = EnstrophyConserving(),
3441
vorticity_stencil = VelocityStencil(),

src/Advection/weno_reconstruction.jl

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ struct WENO{N, FT, XT, YT, ZT, PP, CA, SI} <: AbstractUpwindBiasedAdvectionSchem
4040
end
4141
end
4242

43+
# XXX: move to extension
44+
using ConstructionBase: ConstructionBase
45+
46+
function ConstructionBase.constructorof(::Type{<:WENO{N, FT}}) where {N, FT}
47+
return WENO{N, FT}
48+
end
49+
4350
"""
4451
WENO([FT=Float64;]
4552
order = 5,

src/Fields/field.jl

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ struct Field{LX, LY, LZ, O, G, I, D, T, B, S, F} <: AbstractField{LX, LY, LZ, G,
3232
end
3333
end
3434

35+
# XXX: move to extension
36+
using ConstructionBase: ConstructionBase
37+
38+
function ConstructionBase.constructorof(::Type{<:Field{LX, LY, LZ}}) where {LX, LY, LZ}
39+
return Field{LX, LY, LZ}
40+
end
41+
3542
#####
3643
##### Constructor utilities
3744
#####

src/Grids/latitude_longitude_grid.jl

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ struct LatitudeLongitudeGrid{FT, TX, TY, TZ, CZ, M, MY, FX, FY, VX, VY, Arch} <:
6565
Azᶠᶜᵃ, Azᶜᶠᵃ, Azᶠᶠᵃ, Azᶜᶜᵃ, radius)
6666
end
6767

68+
# XXX: move to extension
69+
using ConstructionBase: ConstructionBase
70+
71+
function ConstructionBase.constructorof(::Type{<:LatitudeLongitudeGrid{FT, TX, TY, TZ}}) where {FT, TX, TY, TZ}
72+
return LatitudeLongitudeGrid{TX, TY, TZ}
73+
end
74+
6875
const LLG = LatitudeLongitudeGrid
6976
const XRegularLLG = LatitudeLongitudeGrid{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Number}
7077
const YRegularLLG = LatitudeLongitudeGrid{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Number}

src/Grids/rectilinear_grid.jl

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ function RectilinearGrid{TX, TY, TZ}(arch::Arch, Nx, Ny, Nz, Hx, Hy, Hz,
3838
Δyᵃᶠᵃ, Δyᵃᶜᵃ, yᵃᶠᵃ, yᵃᶜᵃ, z)
3939
end
4040

41+
# XXX: move to extension
42+
using ConstructionBase: ConstructionBase
43+
44+
function ConstructionBase.constructorof(::Type{<:RectilinearGrid{FT, TX, TY, TZ}}) where {FT, TX, TY, TZ}
45+
return RectilinearGrid{TX, TY, TZ}
46+
end
47+
4148
const RG = RectilinearGrid
4249

4350
const XRegularRG = RectilinearGrid{<:Any, <:Any, <:Any, <:Any, <:Any, <:Number}

0 commit comments

Comments
 (0)