Skip to content

Commit

Permalink
fix maxiters detection after semicolon (trixi-framework#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha authored Apr 23, 2023
1 parent 82932dd commit 2ce5a88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6)

###############################################################################
# run the simulation
sol = solve(ode, SSPRK43(stage_limiter!),
maxiters=999999; ode_default_options()...,
sol = solve(ode, SSPRK43(stage_limiter!);
maxiters=999999, ode_default_options()...,
callback=callbacks);
summary_callback() # print the timer summary
16 changes: 15 additions & 1 deletion src/auxiliary/special_elixirs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,23 @@ function insert_maxiters(expr)
if is_plain_solve || is_trixi_solve
# Do nothing if `maxiters` is already set as keyword argument...
for arg in x.args
if arg isa Expr && arg.head === Symbol("kw") && arg.args[1] === Symbol("maxiters")
# This detects the case where `maxiters` is set as keyword argument
# without or before a semicolon
if (arg isa Expr && arg.head === Symbol("kw") && arg.args[1] === Symbol("maxiters"))
return x
end

# This detects the case where maxiters is set as keyword argument
# after a semicolon
if (arg isa Expr && arg.head === Symbol("parameters"))
# We need to check each keyword argument listed here
for nested_arg in arg.args
if (nested_arg isa Expr && nested_arg.head === Symbol("kw") &&
nested_arg.args[1] === Symbol("maxiters"))
return x
end
end
end
end

# ...and insert it otherwise.
Expand Down

0 comments on commit 2ce5a88

Please sign in to comment.