Skip to content

Commit c2051e1

Browse files
committed
more fixes
1 parent db640bc commit c2051e1

File tree

3 files changed

+43
-52
lines changed

3 files changed

+43
-52
lines changed

src/simulation/grids.jl

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
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-
81
using ClimaCore: Geometry, Hypsography, Fields, Spaces, Meshes
92
using ClimaCore.CommonGrids:
103
ExtrudedCubedSphereGrid, ColumnGrid, Box3DGrid, SliceXZGrid, DefaultZMesh
@@ -20,15 +13,15 @@ struct LinearWarp <: MeshWarpType end
2013
struct SLEVEWarp <: MeshWarpType end
2114

2215
"""
23-
SphereGrid(FT, comms_ctx; kwargs...)
16+
SphereGrid(FT; kwargs...)
2417
2518
Create 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
"""
4841
function 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(
9689
end
9790

9891
"""
99-
ColGrid(FT, comms_ctx; kwargs...)
92+
ColGrid(FT; kwargs...)
10093
10194
Create 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
"""
113106
function 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
139132
end
140133

141134
"""
142-
BoxGrid(FT, comms_ctx; kwargs...)
135+
BoxGrid(FT; kwargs...)
143136
144137
Create 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
"""
171164
function 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(
223216
end
224217

225218
"""
226-
PlaneGrid(FT, comms_ctx; kwargs...)
219+
PlaneGrid(FT; kwargs...)
227220
228221
Create 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
"""
252245
function 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(),
@@ -305,7 +298,7 @@ end
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
310303
Create 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
)

src/solver/type_getters.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,12 @@ function get_mesh_warp_type(s)
728728
end
729729
end
730730

731-
function get_grid(parsed_args, params, comms_ctx)
731+
function get_grid(parsed_args, params, context)
732732
FT = eltype(params)
733733
if parsed_args["config"] == "sphere"
734734
SphereGrid(
735-
FT,
736-
comms_ctx;
735+
FT;
736+
context,
737737
radius = CAP.planet_radius(params),
738738
h_elem = parsed_args["h_elem"],
739739
nh_poly = parsed_args["nh_poly"],
@@ -752,17 +752,17 @@ function get_grid(parsed_args, params, comms_ctx)
752752
)
753753
elseif parsed_args["config"] == "column"
754754
ColGrid(
755-
FT,
756-
comms_ctx;
755+
FT;
756+
context,
757757
z_elem = parsed_args["z_elem"],
758758
z_max = parsed_args["z_max"],
759759
z_stretch = parsed_args["z_stretch"],
760760
dz_bottom = parsed_args["dz_bottom"],
761761
)
762762
elseif parsed_args["config"] == "box"
763763
BoxGrid(
764-
FT,
765-
comms_ctx;
764+
FT;
765+
context,
766766
x_elem = parsed_args["x_elem"],
767767
x_max = parsed_args["x_max"],
768768
y_elem = parsed_args["y_elem"],
@@ -785,8 +785,8 @@ function get_grid(parsed_args, params, comms_ctx)
785785
)
786786
elseif parsed_args["config"] == "plane"
787787
PlaneGrid(
788-
FT,
789-
comms_ctx;
788+
FT;
789+
context,
790790
x_elem = parsed_args["x_elem"],
791791
x_max = parsed_args["x_max"],
792792
z_elem = parsed_args["z_elem"],

test/utilities.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ end
355355
(; cent_space, face_space, xlim, zlim, velem, helem, npoly, quad) =
356356
get_cartesian_spaces()
357357
device = ClimaComms.CPUSingleThreaded()
358-
comms_ctx = ClimaComms.context(device)
358+
context = ClimaComms.context(device)
359359
grid = CA.BoxGrid(
360-
Float32,
361-
comms_ctx;
360+
Float32;
361+
context,
362362
x_elem = helem,
363363
x_max = xlim[2],
364364
y_elem = helem,
@@ -371,7 +371,7 @@ end
371371
periodic_x = true,
372372
periodic_y = true,
373373
)
374-
(; center_space, face_space) = CA.get_spaces(grid, comms_ctx)
374+
(; center_space, face_space) = CA.get_spaces(grid, context)
375375
@test center_space == cent_space
376376
@test face_space == face_space
377377
end

0 commit comments

Comments
 (0)