Skip to content

Commit 976065b

Browse files
Allow for more flexibility
1 parent 5a25f07 commit 976065b

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

src/Grids/convenience_constructors.jl

+46-9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,50 @@ function Box3DGrid(
228228
)
229229
end
230230

231+
"""
232+
SliceXMesh(
233+
::Type{<:AbstractFloat}; # defaults to Float64
234+
x_min::Real,
235+
x_max::Real,
236+
z_min::Real,
237+
z_max::Real,
238+
periodic_x::Bool,
239+
n_quad_points::Integer,
240+
x_elem::Integer,
241+
device::ClimaComms.AbstractDevice = ClimaComms.device(),
242+
context::ClimaComms.AbstractCommsContext = ClimaComms.context(device),
243+
stretch::Meshes.StretchingRule = Meshes.Uniform(),
244+
hypsography::HypsographyAdaption = Flat(),
245+
global_geometry::Geometry.AbstractGlobalGeometry = Geometry.CartesianGlobalGeometry(),
246+
quad::Quadratures.QuadratureStyle = Quadratures.GLL{n_quad_points}(),
247+
)
248+
249+
A convenience constructor, which builds a
250+
`ExtrudedFiniteDifferenceGrid` with a
251+
`FiniteDifferenceGrid` vertical grid and a
252+
`SpectralElementGrid1D` horizontal grid.
253+
- ``
254+
"""
255+
SliceXMesh(; kwargs...) = SliceXMesh(Float64; kwargs...)
256+
function SliceXMesh(
257+
::Type{FT};
258+
x_min::Real,
259+
x_max::Real,
260+
periodic_x::Bool,
261+
x_elem::Integer,
262+
) where {FT}
263+
264+
x1boundary = (:east, :west)
265+
z_boundary_names = (:bottom, :top)
266+
h_domain = Domains.IntervalDomain(
267+
Geometry.XPoint{FT}(x_min),
268+
Geometry.XPoint{FT}(x_max);
269+
periodic = periodic_x,
270+
boundary_names = (:east, :west),
271+
)
272+
return Meshes.IntervalMesh(h_domain; nelems = x_elem)
273+
end
274+
231275
"""
232276
SliceXZGrid(
233277
::Type{<:AbstractFloat}; # defaults to Float64
@@ -271,22 +315,15 @@ function SliceXZGrid(
271315
global_geometry::Geometry.AbstractGlobalGeometry = Geometry.CartesianGlobalGeometry(),
272316
quad::Quadratures.QuadratureStyle = Quadratures.GLL{n_quad_points}(),
273317
horizontal_layout_type = DataLayouts.IFH,
318+
h_mesh::Meshes.IntervalMesh = SliceXMesh(FT; x_min,x_max,periodic_x,x_elem),
274319
) where {FT}
275320
@assert horizontal_layout_type <: DataLayouts.AbstractData
276321
check_device_context(context, device)
277322

278-
x1boundary = (:east, :west)
279-
z_boundary_names = (:bottom, :top)
280-
h_domain = Domains.IntervalDomain(
281-
Geometry.XPoint{FT}(x_min),
282-
Geometry.XPoint{FT}(x_max);
283-
periodic = periodic_x,
284-
boundary_names = x1boundary,
285-
)
286-
h_mesh = Meshes.IntervalMesh(h_domain; nelems = x_elem)
287323
h_topology = Topologies.IntervalTopology(context, h_mesh)
288324
h_grid =
289325
Grids.SpectralElementGrid1D(h_topology, quad; horizontal_layout_type)
326+
z_boundary_names = (:bottom, :top)
290327
z_domain = Domains.IntervalDomain(
291328
Geometry.ZPoint{FT}(z_min),
292329
Geometry.ZPoint{FT}(z_max);

0 commit comments

Comments
 (0)