Skip to content

Commit 765be75

Browse files
committed
Test tracer conservation for TripolarGrid with and without bathymetry
1 parent 6c74724 commit 765be75

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

test/test_zstar_coordinate.jl

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -241,32 +241,34 @@ z_stretched = MutableVerticalDiscretization(collect(-20:0))
241241
end
242242
end
243243

244-
function make_tripolar_test_model(arch; with_wind = false)
244+
# Code credit:
245+
# https://github.com/PRONTOLab/GB-25/blob/682106b8487f94da24a64d93e86d34d560f33ffc/src/model_utils.jl#L65
246+
function mtn₁(λ, φ)
247+
λ₁ = 70
248+
φ₁ = 55
249+
= 5
250+
return exp(-((λ - λ₁)^2 +- φ₁)^2) / 2^2)
251+
end
245252

246-
grid = TripolarGrid(arch; size = (20, 20, 20), z = z_stretched)
253+
function mtn₂(λ, φ)
254+
λ₁ = 70
255+
λ₂ = λ₁ + 180
256+
φ₂ = 55
257+
= 5
258+
return exp(-((λ - λ₂)^2 +- φ₂)^2) / 2^2)
259+
end
247260

248-
# Code credit:
249-
# https://github.com/PRONTOLab/GB-25/blob/682106b8487f94da24a64d93e86d34d560f33ffc/src/model_utils.jl#L65
250-
function mtn₁(λ, φ)
251-
λ₁ = 70
252-
φ₁ = 55
253-
= 5
254-
return exp(-((λ - λ₁)^2 +- φ₁)^2) / 2^2)
255-
end
261+
function make_tripolar_test_model(arch; with_bathymetry = true, with_wind = false)
256262

257-
function mtn₂(λ, φ)
258-
λ₁ = 70
259-
λ₂ = λ₁ + 180
260-
φ₂ = 55
261-
= 5
262-
return exp(-((λ - λ₂)^2 +- φ₂)^2) / 2^2)
263-
end
263+
grid = TripolarGrid(arch; size = (20, 20, 20), z = z_stretched)
264264

265-
zb = - 20
266-
h = - zb + 10
267-
gaussian_islands(λ, φ) = zb + h * (mtn₁(λ, φ) + mtn₂(λ, φ))
265+
if with_bathymetry
266+
zb = - 20
267+
h = - zb + 10
268+
gaussian_islands(λ, φ) = zb + h * (mtn₁(λ, φ) + mtn₂(λ, φ))
268269

269-
grid = ImmersedBoundaryGrid(grid, GridFittedBottom(gaussian_islands))
270+
grid = ImmersedBoundaryGrid(grid, GridFittedBottom(gaussian_islands))
271+
end
270272
free_surface = SplitExplicitFreeSurface(grid; substeps=10)
271273

272274
kwargs = (;
@@ -300,21 +302,16 @@ end
300302

301303
@testset "TripolarGrid ZStar tracer conservation tests" begin
302304
for arch in archs
303-
@info "Testing ZStar coordinate with TripolarGrid on $(arch)..."
304-
305-
model = make_tripolar_test_model(arch, with_wind=false)
306-
Δt = 2minutes
307-
test_zstar_coordinate(model, 300, Δt)
308-
end
309-
end
310-
311-
@testset "ZStar tracer conservation tests with wind stress" begin
312-
for arch in archs
313-
@info "Testing ZStar coordinate with TripolarGrid and wind stress on $(arch)..."
314-
315-
model = make_tripolar_test_model(arch; with_wind=true)
316-
Δt = 2minutes
317-
test_zstar_coordinate(model, 300, Δt)
305+
for with_wind in (false, true)
306+
for with_bathymetry in (false, true)
307+
wind_str = with_wind ? "with wind" : "without wind"
308+
bathy_str = with_bathymetry ? "with bathymetry" : "without bathymetry"
309+
@info "Testing ZStar coordinate on TripolarGrid $wind_str, $bathy_str on $(arch)..."
310+
311+
model = make_tripolar_test_model(arch; with_bathymetry = with_bathymetry, with_wind = with_wind)
312+
Δt = 2minutes
313+
test_zstar_coordinate(model, 300, Δt)
314+
end
315+
end
318316
end
319317
end
320-

0 commit comments

Comments
 (0)