Skip to content
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7b9a40d
add positivity limiter to the amr callback
patrickersing May 9, 2025
318bfad
remove duplicate limiter! argument
patrickersing May 9, 2025
f98cd62
Merge branch 'main' into amr_limiter
patrickersing May 9, 2025
e221e40
Update src/callbacks_step/amr.jl
patrickersing May 10, 2025
5faaf4d
Merge branch 'main' into amr_limiter
DanielDoehring Jun 28, 2025
d9b6c90
Merge branch 'main' into amr_limiter
bennibolm Jul 28, 2025
544ac69
Implement synchronized shifting for child elements
bennibolm Aug 29, 2025
24d8df0
Merge branch 'main' into amr_limiter
patrickersing Aug 29, 2025
2b7dc80
Merge branch 'main' into amr_limiter
patrickersing Aug 29, 2025
009496c
Merge branch 'main' into amr_limiter
bennibolm Sep 3, 2025
f214aea
Use `compute_u_mean`; Update docstring
bennibolm Sep 3, 2025
296d883
Use `compute_u_mean` in limiter after coarsening
bennibolm Sep 3, 2025
5605be8
Rename function
bennibolm Sep 3, 2025
15a8ff2
Implement suggestions
bennibolm Sep 3, 2025
0e82f4d
Apply suggestions from code review
DanielDoehring Sep 3, 2025
26abb91
Apply suggestions from code review
DanielDoehring Sep 3, 2025
ff35db1
Apply suggestions from code review
DanielDoehring Sep 3, 2025
c32a2e1
Apply suggestions from code review
DanielDoehring Sep 3, 2025
03d2936
Update src/callbacks_stage/positivity_zhang_shu_dg1d.jl
DanielDoehring Sep 3, 2025
07a1e0c
Apply suggestions from code review
DanielDoehring Sep 3, 2025
9861aee
Update src/callbacks_stage/positivity_zhang_shu_dg2d.jl
DanielDoehring Sep 3, 2025
29ab55a
Update src/callbacks_stage/positivity_zhang_shu_dg1d.jl
DanielDoehring Sep 3, 2025
00ca066
Update src/callbacks_stage/positivity_zhang_shu_dg1d.jl
DanielDoehring Sep 3, 2025
a5485f3
Apply suggestions from code review
DanielDoehring Sep 3, 2025
fdc1337
Rename for-variables; Remove comments
bennibolm Sep 4, 2025
b035070
Remove codes as suggested
bennibolm Sep 5, 2025
e042600
add comment for amr positivity-limiting
patrickersing Sep 8, 2025
6852972
Merge branch 'main' into amr_limiter
patrickersing Sep 8, 2025
7b8d2ab
Apply limiter after refinement/coarsening for T8codeMesh (#50)
bennibolm Sep 13, 2025
5c1a1a2
doc
DanielDoehring Sep 26, 2025
6d3cbfb
Merge branch 'main' into PatrickErsingLimitedMortars
DanielDoehring Sep 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,32 @@ save_solution = SaveSolutionCallback(interval = 100,
save_final_solution = true,
solution_variables = cons2prim)

# positivity limiter necessary for this example with strong shocks
positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density,
pressure))

amr_indicator = IndicatorLöhner(semi, variable = Trixi.density)

amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 0,
med_level = 3, med_threshold = 0.05,
max_level = 6, max_threshold = 0.1)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
amr_callback)

# positivity limiter necessary for this example with strong shocks
stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density, pressure))

###############################################################################
# run the simulation
sol = solve(ode, SSPRK43(stage_limiter!);
sol = solve(ode, SSPRK43(stage_limiter! = positivity_limiter);
ode_default_options()..., callback = callbacks);
16 changes: 10 additions & 6 deletions examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,33 @@ save_solution = SaveSolutionCallback(interval = 2000,
save_final_solution = true,
solution_variables = cons2prim)

# positivity limiter necessary for this example with strong shocks
positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density,
pressure))

amr_indicator = IndicatorLöhner(semi, variable = Trixi.density)

amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 0,
med_level = 2, med_threshold = 0.05,
max_level = 5, max_threshold = 0.1)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 5,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
amr_callback)

# positivity limiter necessary for this example with strong shocks
stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density, pressure))

###############################################################################
# run the simulation
sol = solve(ode, SSPRK43(stage_limiter!);
sol = solve(ode, SSPRK43(stage_limiter! = positivity_limiter);
maxiters = 999999, ode_default_options()...,
callback = callbacks);
18 changes: 11 additions & 7 deletions examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,33 @@ save_solution = SaveSolutionCallback(interval = 1000,
save_final_solution = true,
solution_variables = cons2prim)

# positivity limiter necessary for this example with strong shocks. Very sensitive
# to the order of the limiter variables, pressure must come first.
positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-7, 1.0e-6),
variables = (pressure,
Trixi.density))

amr_indicator = IndicatorLöhner(semi, variable = Trixi.density)

amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 0,
med_level = 3, med_threshold = 0.05,
max_level = 5, max_threshold = 0.1)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
amr_callback)

# positivity limiter necessary for this example with strong shocks. Very sensitive
# to the order of the limiter variables, pressure must come first.
stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-7, 1.0e-6),
variables = (pressure, Trixi.density))

###############################################################################
# run the simulation
sol = solve(ode, SSPRK43(stage_limiter!);
sol = solve(ode, SSPRK43(stage_limiter! = positivity_limiter);
ode_default_options()..., callback = callbacks);
8 changes: 6 additions & 2 deletions examples/t8code_2d_dgsem/elixir_euler_weak_blast_wave_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ initial_condition = initial_condition_weak_blast_wave
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# `StepsizeCallback` (CFL-Condition) and less diffusion.
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
volume_flux = flux_ranocha
Expand Down Expand Up @@ -97,7 +97,11 @@ amr_controller = ControllerThreeLevel(semi, amr_indicator,
amr_callback = AMRCallback(semi, amr_controller,
interval = 5,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6,
5.0e-6),
variables = (Trixi.density,
pressure)))

stepsize_callback = StepsizeCallback(cfl = 0.5)

Expand Down
8 changes: 6 additions & 2 deletions examples/t8code_3d_dgsem/elixir_euler_weak_blast_wave_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ initial_condition = initial_condition_weak_blast_wave
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
# `StepsizeCallback` (CFL-Condition) and less diffusion.
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
volume_flux = flux_ranocha
Expand Down Expand Up @@ -99,7 +99,11 @@ amr_controller = ControllerThreeLevel(semi, amr_indicator,
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
adapt_initial_condition = false,
adapt_initial_condition_only_refine = false)
adapt_initial_condition_only_refine = false,
limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6,
5.0e-6),
variables = (Trixi.density,
pressure)))

stepsize_callback = StepsizeCallback(cfl = 0.5)

Expand Down
18 changes: 13 additions & 5 deletions examples/tree_1d_dgsem/elixir_euler_positivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,25 @@ save_solution = SaveSolutionCallback(interval = 100,
save_final_solution = true,
solution_variables = cons2prim)

positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density,
pressure))

amr_indicator = IndicatorLöhner(semi,
variable = density_pressure)

amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 4,
med_level = 0, med_threshold = 0.1, # med_level = current level
max_level = 6, max_threshold = 0.3)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 2,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

stepsize_callback = StepsizeCallback(cfl = 0.5)

Expand All @@ -100,12 +109,11 @@ callbacks = CallbackSet(summary_callback,
save_solution,
amr_callback, stepsize_callback)

stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density, pressure))

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, williamson_condition = false);
sol = solve(ode,
CarpenterKennedy2N54(stage_limiter! = positivity_limiter,
williamson_condition = false);
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
ode_default_options()..., callback = callbacks);
16 changes: 10 additions & 6 deletions examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ save_solution = SaveSolutionCallback(interval = 5000,
save_final_solution = true,
solution_variables = cons2prim)

# positivity limiter necessary for this tough example
positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density,
pressure))

amr_indicator = IndicatorHennemannGassner(semi,
alpha_max = 1.0,
alpha_min = 0.0001,
Expand All @@ -99,21 +104,20 @@ amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc,
max_level = 8, max_threshold = 0.003,
max_threshold_secondary = indicator_sc.alpha_max)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
amr_callback, save_solution)

# positivity limiter necessary for this tough example
stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density, pressure))

###############################################################################
# run the simulation
# use adaptive time stepping based on error estimates, time step roughly dt = 1e-7
sol = solve(ode, SSPRK43(stage_limiter!);
sol = solve(ode, SSPRK43(stage_limiter! = positivity_limiter);
ode_default_options()..., callback = callbacks);
16 changes: 10 additions & 6 deletions examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ save_solution = SaveSolutionCallback(interval = 1000,
save_final_solution = true,
solution_variables = cons2prim)

# positivity limiter necessary for this tough example
positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density,
pressure))

# Simulation also feasible without AMR: AMR reduces CPU time by a factor of about 2
amr_indicator = IndicatorHennemannGassner(semi,
alpha_max = 1.0,
Expand All @@ -102,21 +107,20 @@ amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc,
max_level = 8, max_threshold = 0.003,
max_threshold_secondary = indicator_sc.alpha_max)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
amr_callback, save_solution)

# positivity limiter necessary for this tough example
stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density, pressure))

###############################################################################
# run the simulation
# use adaptive time stepping based on error estimates, time step roughly dt = 5e-3
sol = solve(ode, SSPRK43(stage_limiter!);
sol = solve(ode, SSPRK43(stage_limiter! = positivity_limiter);
ode_default_options()..., callback = callbacks);
18 changes: 13 additions & 5 deletions examples/tree_2d_dgsem/elixir_euler_positivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,25 @@ save_solution = SaveSolutionCallback(interval = 100,
save_final_solution = true,
solution_variables = cons2prim)

positivity_limiter = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density,
pressure))

amr_indicator = IndicatorLöhner(semi,
variable = density_pressure)

amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 4,
med_level = 0, med_threshold = 0.1, # med_level = current level
max_level = 6, max_threshold = 0.3)

# Set `limiter! = positivity_limiter` to apply the positivity-preserving limiter after
# coarsening and refinement steps.
amr_callback = AMRCallback(semi, amr_controller,
interval = 2,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
limiter! = positivity_limiter)

stepsize_callback = StepsizeCallback(cfl = 0.8)

Expand All @@ -102,12 +111,11 @@ callbacks = CallbackSet(summary_callback,
save_solution,
amr_callback, stepsize_callback)

stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
variables = (Trixi.density, pressure))

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, williamson_condition = false);
sol = solve(ode,
CarpenterKennedy2N54(stage_limiter! = positivity_limiter,
williamson_condition = false);
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
ode_default_options()..., callback = callbacks);
Loading
Loading