Skip to content

Commit 795de5e

Browse files
authored
Fix wrong default in ReactantExt for ImmersedBoundaryGrid (#4177)
* Fix wrong default in ReactantExt * Add another test with SplitExplicit * Comment out problematic test
1 parent 45db620 commit 795de5e

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

ext/OceananigansReactantExt/Grids.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function reactant_immersed_boundary_grid(grid, ib; active_cells_map, active_z_co
115115
end
116116

117117
function ImmersedBoundaryGrid(grid::ReactantUnderlyingGrid, ib::AbstractImmersedBoundary;
118-
active_cells_map::Bool=true,
118+
active_cells_map::Bool=false,
119119
active_z_columns::Bool=active_cells_map)
120120

121121
return reactant_immersed_boundary_grid(grid, ib; active_cells_map, active_z_columns)

test/test_reactant.jl

+32-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,23 @@ using Random
2020

2121
OceananigansReactantExt = Base.get_extension(Oceananigans, :OceananigansReactantExt)
2222

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)
2426
r_arch = ReactantState()
2527
r_grid = GridType(r_arch; grid_kw...)
26-
r_model = ModelType(; grid=r_grid, model_kw...)
27-
2828
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...)
2940
model = ModelType(; grid=grid, model_kw...)
3041

3142
ui = randn(size(model.velocities.u)...)
@@ -83,7 +94,7 @@ function test_reactant_model_correctness(GridType, ModelType, grid_kw, model_kw)
8394
@test parent(v) parent(rv)
8495
@test parent(w) parent(rw)
8596

86-
return nothing
97+
return r_simulation
8798
end
8899

89100
function add_one!(f)
@@ -188,15 +199,18 @@ end
188199
end
189200

190201
@testset "Reactant Super Simple Simulation Tests" begin
202+
@info "Performing Reactanigans super simple simulation tests..."
191203
nonhydrostatic_model_kw = (; advection=WENO())
192204
hydrostatic_model_kw = (; momentum_advection=WENO())
193205
Nx, Ny, Nz = (10, 10, 10) # number of cells
194206
halo = (7, 7, 7)
195207
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]
196209
latitude = (0, 4)
197210
z = (-1, 0)
198211
lat_lon_kw = (; size=(Nx, Ny, Nz), halo, longitude, latitude, z)
199212
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)
200214

201215
# FFTs are not supported by Reactant so we don't run this test:
202216
# @info "Testing RectilinearGrid + NonhydrostaticModel Reactant correctness"
@@ -205,10 +219,24 @@ end
205219
@info "Testing RectilinearGrid + HydrostaticFreeSurfaceModel Reactant correctness"
206220
hydrostatic_model_kw = (; free_surface=ExplicitFreeSurface(gravitational_acceleration=1))
207221
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)
208223

209224
@info "Testing LatitudeLongitudeGrid + HydrostaticFreeSurfaceModel Reactant correctness"
210225
hydrostatic_model_kw = (; momentum_advection=WENO())
211226
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+
=#
212240

213241
#=
214242
equation_of_state = TEOS10EquationOfState()

0 commit comments

Comments
 (0)