1- """
2- Grid constructors that replace the domain-based approach with direct ClimaCore.CommonGrids usage.
3-
4- These constructors handle topography integration and provide the same interface as the previous
5- domain system but use ClimaCore grids directly.
6- """
7-
81using ClimaCore: Geometry, Hypsography, Fields, Spaces, Meshes
92using ClimaCore. CommonGrids:
103 ExtrudedCubedSphereGrid, ColumnGrid, Box3DGrid, SliceXZGrid, DefaultZMesh
@@ -20,15 +13,15 @@ struct LinearWarp <: MeshWarpType end
2013struct SLEVEWarp <: MeshWarpType end
2114
2215"""
23- SphereGrid(FT, comms_ctx ; kwargs...)
16+ SphereGrid(FT; kwargs...)
2417
2518Create an ExtrudedCubedSphereGrid with topography support.
2619
2720# Arguments
2821- `FT`: Floating point type
29- - `comms_ctx`: Communications context
3022
3123# Keyword Arguments
24+ - `context`: Communications context
3225- `z_elem::Int`: Number of vertical elements
3326- `z_max::Real`: Maximum height
3427- `z_stretch::Bool`: Whether to use vertical stretching
@@ -46,8 +39,8 @@ Create an ExtrudedCubedSphereGrid with topography support.
4639- `topo_smoothing::Bool`: Apply topography smoothing
4740"""
4841function SphereGrid (
49- FT,
50- comms_ctx;
42+ FT;
43+ context = ClimaComms . context (),
5144 z_elem:: Int = 10 ,
5245 z_max:: Real = 30000.0 ,
5346 z_stretch:: Bool = true ,
@@ -71,7 +64,7 @@ function SphereGrid(
7164
7265 hypsography_fun = hypsography_function_from_topography (
7366 FT, topography, topography_damping_factor, mesh_warp_type,
74- sleve_eta, sleve_s, topo_smoothing, comms_ctx,
67+ sleve_eta, sleve_s, topo_smoothing,
7568 )
7669
7770 global_geometry = if deep_atmosphere
@@ -84,8 +77,8 @@ function SphereGrid(
8477 FT;
8578 z_elem, z_min = 0 , z_max, radius, h_elem,
8679 n_quad_points,
87- device = ClimaComms. device (comms_ctx ),
88- context = comms_ctx ,
80+ device = ClimaComms. device (context ),
81+ context,
8982 stretch,
9083 hypsography_fun,
9184 global_geometry,
@@ -96,23 +89,23 @@ function SphereGrid(
9689end
9790
9891"""
99- ColGrid(FT, comms_ctx ; kwargs...)
92+ ColGrid(FT; kwargs...)
10093
10194Create a ColumnGrid.
10295
10396# Arguments
10497- `FT`: Floating point type
105- - `comms_ctx`: Communications context
10698
10799# Keyword Arguments
100+ - `context`: Communications context
108101- `z_elem::Int`: Number of vertical elements
109102- `z_max::Real`: Maximum height
110103- `z_stretch::Bool`: Whether to use vertical stretching
111104- `dz_bottom::Real`: Bottom layer thickness for stretching
112105"""
113106function ColGrid (
114- FT,
115- comms_ctx;
107+ FT;
108+ context = ClimaComms . context (),
116109 z_elem:: Int = 10 ,
117110 z_max:: Real = 30000.0 ,
118111 z_stretch:: Bool = true ,
@@ -130,24 +123,24 @@ function ColGrid(
130123 grid = ColumnGrid (
131124 FT;
132125 z_elem, z_min = 0 , z_max, z_mesh,
133- device = ClimaComms. device (comms_ctx ),
134- context = comms_ctx ,
126+ device = ClimaComms. device (context ),
127+ context,
135128 stretch,
136129 )
137130
138131 return grid
139132end
140133
141134"""
142- BoxGrid(FT, comms_ctx ; kwargs...)
135+ BoxGrid(FT; kwargs...)
143136
144137Create a Box3DGrid with topography support.
145138
146139# Arguments
147140- `FT`: Floating point type
148- - `comms_ctx`: Communications context
149141
150142# Keyword Arguments
143+ - `context`: Communications context
151144- `x_elem::Int`: Number of x elements
152145- `x_max::Real`: Maximum x coordinate
153146- `y_elem::Int`: Number of y elements
@@ -169,8 +162,8 @@ Create a Box3DGrid with topography support.
169162- `topo_smoothing::Bool`: Apply topography smoothing
170163"""
171164function BoxGrid (
172- FT,
173- comms_ctx;
165+ FT;
166+ context = ClimaComms . context (),
174167 x_elem:: Int = 6 ,
175168 x_max:: Real = 300000.0 ,
176169 y_elem:: Int = 6 ,
@@ -198,7 +191,7 @@ function BoxGrid(
198191
199192 hypsography_fun = hypsography_function_from_topography (
200193 FT, topography, topography_damping_factor, mesh_warp_type,
201- sleve_eta, sleve_s, topo_smoothing, comms_ctx,
194+ sleve_eta, sleve_s, topo_smoothing,
202195 )
203196 z_mesh = DefaultZMesh (
204197 FT;
@@ -211,8 +204,8 @@ function BoxGrid(
211204 FT;
212205 z_elem, x_min = 0 , x_max, y_min = 0 , y_max, z_min = 0 , z_max, z_mesh,
213206 periodic_x, periodic_y, n_quad_points, x_elem, y_elem,
214- device = ClimaComms. device (comms_ctx ),
215- context = comms_ctx ,
207+ device = ClimaComms. device (context ),
208+ context,
216209 stretch,
217210 hypsography_fun,
218211 global_geometry = Geometry. CartesianGlobalGeometry (),
@@ -223,15 +216,15 @@ function BoxGrid(
223216end
224217
225218"""
226- PlaneGrid(FT, comms_ctx ; kwargs...)
219+ PlaneGrid(FT; kwargs...)
227220
228221Create a SliceXZGrid with topography support.
229222
230223# Arguments
231224- `FT`: Floating point type
232- - `comms_ctx`: Communications context
233225
234226# Keyword Arguments
227+ - `context`: Communications context
235228- `x_elem::Int`: Number of x elements
236229- `x_max::Real`: Maximum x coordinate
237230- `z_elem::Int`: Number of vertical elements
@@ -250,8 +243,8 @@ Create a SliceXZGrid with topography support.
250243- `topo_smoothing::Bool`: Apply topography smoothing
251244"""
252245function PlaneGrid (
253- FT,
254- comms_ctx;
246+ FT;
247+ context = ClimaComms . context (),
255248 x_elem:: Int = 6 ,
256249 x_max:: Real = 300000.0 ,
257250 z_elem:: Int = 10 ,
@@ -276,7 +269,7 @@ function PlaneGrid(
276269
277270 hypsography_fun = hypsography_function_from_topography (
278271 FT, topography, topography_damping_factor, mesh_warp_type,
279- sleve_eta, sleve_s, topo_smoothing, comms_ctx,
272+ sleve_eta, sleve_s, topo_smoothing,
280273 )
281274
282275 z_mesh = DefaultZMesh (
@@ -292,8 +285,8 @@ function PlaneGrid(
292285 z_elem, x_elem, x_min = 0 , x_max, z_min = 0 , z_max, z_mesh,
293286 periodic_x,
294287 n_quad_points,
295- device = ClimaComms. device (comms_ctx ),
296- context = comms_ctx ,
288+ device = ClimaComms. device (context ),
289+ context,
297290 stretch,
298291 hypsography_fun,
299292 global_geometry = Geometry. CartesianGlobalGeometry (),
305298"""
306299 hypsography_function_from_topography(
307300 topography, topography_damping_factor, mesh_warp_type,
308- sleve_eta, sleve_s, topo_smoothing, comms_ctx )
301+ sleve_eta, sleve_s, topo_smoothing, context )
309302
310303Create a hypsography function that handles topography integration.
311304"""
@@ -317,7 +310,6 @@ function hypsography_function_from_topography(
317310 sleve_eta:: Real ,
318311 sleve_s:: Real ,
319312 topo_smoothing:: Bool ,
320- comms_ctx,
321313)
322314 return function (h_grid, z_grid)
323315 topography isa NoTopography && return Hypsography. Flat ()
@@ -332,10 +324,9 @@ function hypsography_function_from_topography(
332324 end
333325
334326 if topography isa EarthTopography
327+ context = ClimaComms. context (h_space)
335328 z_surface = SpaceVaryingInput (
336- AA. earth_orography_file_path (;
337- context = ClimaComms. context (h_space),
338- ),
329+ AA. earth_orography_file_path (; context),
339330 " z" ,
340331 h_space,
341332 )
0 commit comments