Skip to content

Commit c16f63d

Browse files
Fix closure over global non-constant dt
1 parent fbf6942 commit c16f63d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

examples/hybrid/sphere/deformation_flow.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ zelem = 36
5050
helem = 4
5151
npoly = 4
5252
t_end = FT(60 * 60 * 24 * 12) # 12 days of simulation time
53-
dt = FT(60 * 60) # 1 hour timestep
53+
_dt = FT(60 * 60) # 1 hour timestep
5454
ode_algorithm = ExplicitAlgorithm(SSP33ShuOsher())
5555

5656
# Operators used in increment!
@@ -139,7 +139,7 @@ function horizontal_tendency!(Yₜ, Y, cache, t)
139139
end
140140

141141
function vertical_tendency!(Yₜ, Y, cache, t)
142-
(; q_n, face_u, face_uₕ, face_uᵥ, fct_op) = cache
142+
(; q_n, face_u, face_uₕ, face_uᵥ, fct_op, dt) = cache
143143
face_coord = Fields.coordinate_field(face_u)
144144
@. face_u = local_velocity(face_coord, t)
145145
@. face_uₕ = Geometry.project(Geometry.Covariant12Axis(), face_u)
@@ -196,7 +196,7 @@ function dss!(Y, cache, t)
196196
Spaces.weighted_dss!(Y.c)
197197
end
198198

199-
function run_deformation_flow(use_limiter, fct_op)
199+
function run_deformation_flow(use_limiter, fct_op, dt)
200200
vert_domain = Domains.IntervalDomain(
201201
Geometry.ZPoint{FT}(0),
202202
Geometry.ZPoint{FT}(z_top);
@@ -262,6 +262,7 @@ function run_deformation_flow(use_limiter, fct_op)
262262
face_uᵥ = Fields.Field(Geometry.Covariant3Vector{FT}, face_space),
263263
limiter = use_limiter ? Limiters.QuasiMonotoneLimiter(Y.c.ρq) : nothing,
264264
fct_op,
265+
dt,
265266
)
266267

267268
problem = ODEProblem(
@@ -303,12 +304,12 @@ tracer_ranges(sol) =
303304
return maximum(q_n) - minimum(q_n)
304305
end
305306

306-
third_upwind_sol = run_deformation_flow(false, upwind3)
307-
fct_sol = run_deformation_flow(false, FCTZalesak)
308-
lim_third_upwind_sol = run_deformation_flow(true, upwind3)
309-
lim_fct_sol = run_deformation_flow(true, FCTZalesak)
310-
lim_first_upwind_sol = run_deformation_flow(true, upwind1)
311-
lim_centered_sol = run_deformation_flow(true, nothing)
307+
third_upwind_sol = run_deformation_flow(false, upwind3, _dt)
308+
fct_sol = run_deformation_flow(false, FCTZalesak, _dt)
309+
lim_third_upwind_sol = run_deformation_flow(true, upwind3, _dt)
310+
lim_fct_sol = run_deformation_flow(true, FCTZalesak, _dt)
311+
lim_first_upwind_sol = run_deformation_flow(true, upwind1, _dt)
312+
lim_centered_sol = run_deformation_flow(true, nothing, _dt)
312313

313314
third_upwind_ρ_err, third_upwind_ρq_errs = conservation_errors(third_upwind_sol)
314315
fct_ρ_err, fct_ρq_errs = conservation_errors(fct_sol)

0 commit comments

Comments
 (0)