@@ -20,12 +20,23 @@ using Random
20
20
21
21
OceananigansReactantExt = Base. get_extension (Oceananigans, :OceananigansReactantExt )
22
22
23
- function test_reactant_model_correctness (GridType, ModelType, grid_kw, model_kw)
23
+ bottom_height (x, y) = - 0.5
24
+
25
+ function test_reactant_model_correctness (GridType, ModelType, grid_kw, model_kw; immersed_boundary_grid= true )
24
26
r_arch = ReactantState ()
25
27
r_grid = GridType (r_arch; grid_kw... )
26
- r_model = ModelType (; grid= r_grid, model_kw... )
27
-
28
28
grid = GridType (CPU (); grid_kw... )
29
+
30
+ if immersed_boundary_grid
31
+ grid = ImmersedBoundaryGrid (grid, GridFittedBottom (bottom_height))
32
+ r_grid = ImmersedBoundaryGrid (r_grid, GridFittedBottom (bottom_height))
33
+ @test isnothing (r_grid. interior_active_cells)
34
+ @test isnothing (r_grid. active_z_columns)
35
+ @test isnothing (grid. interior_active_cells)
36
+ @test isnothing (grid. active_z_columns)
37
+ end
38
+
39
+ r_model = ModelType (; grid= r_grid, model_kw... )
29
40
model = ModelType (; grid= grid, model_kw... )
30
41
31
42
ui = randn (size (model. velocities. u)... )
@@ -83,7 +94,7 @@ function test_reactant_model_correctness(GridType, ModelType, grid_kw, model_kw)
83
94
@test parent (v) ≈ parent (rv)
84
95
@test parent (w) ≈ parent (rw)
85
96
86
- return nothing
97
+ return r_simulation
87
98
end
88
99
89
100
function add_one! (f)
@@ -188,15 +199,18 @@ end
188
199
end
189
200
190
201
@testset " Reactant Super Simple Simulation Tests" begin
202
+ @info " Performing Reactanigans super simple simulation tests..."
191
203
nonhydrostatic_model_kw = (; advection= WENO ())
192
204
hydrostatic_model_kw = (; momentum_advection= WENO ())
193
205
Nx, Ny, Nz = (10 , 10 , 10 ) # number of cells
194
206
halo = (7 , 7 , 7 )
195
207
longitude = (0 , 4 )
208
+ stretched_longitude = [0 , 0.1 , 0.2 , 0.3 , 0.4 , 0.6 , 1.3 , 2.5 , 2.6 , 3.5 , 4.0 ]
196
209
latitude = (0 , 4 )
197
210
z = (- 1 , 0 )
198
211
lat_lon_kw = (; size= (Nx, Ny, Nz), halo, longitude, latitude, z)
199
212
rectilinear_kw = (; size= (Nx, Ny, Nz), halo, x= (0 , 1 ), y= (0 , 1 ), z= (0 , 1 ))
213
+ stretched_lat_lon_kw = (; size= (Nx, Ny, Nz), halo, longitude= stretched_longitude, latitude, z)
200
214
201
215
# FFTs are not supported by Reactant so we don't run this test:
202
216
# @info "Testing RectilinearGrid + NonhydrostaticModel Reactant correctness"
@@ -205,10 +219,24 @@ end
205
219
@info " Testing RectilinearGrid + HydrostaticFreeSurfaceModel Reactant correctness"
206
220
hydrostatic_model_kw = (; free_surface= ExplicitFreeSurface (gravitational_acceleration= 1 ))
207
221
test_reactant_model_correctness (RectilinearGrid, HydrostaticFreeSurfaceModel, rectilinear_kw, hydrostatic_model_kw)
222
+ test_reactant_model_correctness (RectilinearGrid, HydrostaticFreeSurfaceModel, rectilinear_kw, hydrostatic_model_kw, immersed_boundary_grid= true )
208
223
209
224
@info " Testing LatitudeLongitudeGrid + HydrostaticFreeSurfaceModel Reactant correctness"
210
225
hydrostatic_model_kw = (; momentum_advection= WENO ())
211
226
test_reactant_model_correctness (LatitudeLongitudeGrid, HydrostaticFreeSurfaceModel, lat_lon_kw, hydrostatic_model_kw)
227
+ test_reactant_model_correctness (LatitudeLongitudeGrid, HydrostaticFreeSurfaceModel, lat_lon_kw, hydrostatic_model_kw, immersed_boundary_grid= true )
228
+
229
+ #=
230
+ # This test takes too long
231
+ @info "Testing LatitudeLongitudeGrid + SplitExplicitFreeSurface + HydrostaticFreeSurfaceModel Reactant correctness"
232
+ hydrostatic_model_kw = (; momentum_advection=WENOVectorInvariant(), free_surface=SplitExplicitFreeSurface(substeps=4))
233
+ test_reactant_model_correctness(LatitudeLongitudeGrid, HydrostaticFreeSurfaceModel, lat_lon_kw, hydrostatic_model_kw)
234
+ simulation = test_reactant_model_correctness(LatitudeLongitudeGrid, HydrostaticFreeSurfaceModel, lat_lon_kw, hydrostatic_model_kw, immersed_boundary_grid=true)
235
+ η = simulation.model.free_surface.η
236
+ η_grid = η.grid
237
+ @test isnothing(η_grid.interior_active_cells)
238
+ @test isnothing(η_grid.active_z_columns)
239
+ =#
212
240
213
241
#=
214
242
equation_of_state = TEOS10EquationOfState()
0 commit comments