Skip to content
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
888fcc8
start rrg pos limiter
DanielDoehring Nov 1, 2025
568cf03
work
DanielDoehring Nov 2, 2025
c00d38a
debug
DanielDoehring Nov 2, 2025
c2b1b66
one example
DanielDoehring Nov 2, 2025
918b930
rm
DanielDoehring Nov 2, 2025
4304665
shorten
DanielDoehring Nov 2, 2025
185f24a
timings
DanielDoehring Nov 2, 2025
801aefa
docstring
DanielDoehring Nov 2, 2025
5d38432
mhd example
DanielDoehring Nov 2, 2025
d1a1f57
comment
DanielDoehring Nov 2, 2025
650ff19
docs etc
DanielDoehring Nov 3, 2025
3c62fbd
thread-locla storage
DanielDoehring Nov 3, 2025
6fb1c31
prominent matching
DanielDoehring Nov 3, 2025
aff0b12
clarify
DanielDoehring Nov 3, 2025
b3c6ac0
typo
DanielDoehring Nov 3, 2025
2d8c398
comments
DanielDoehring Nov 3, 2025
9186b69
revert
DanielDoehring Nov 3, 2025
cbfeb01
revert
DanielDoehring Nov 3, 2025
47444ab
typo
DanielDoehring Nov 3, 2025
ab011dd
fine tunings
DanielDoehring Nov 4, 2025
9abcbd8
explian kw
DanielDoehring Nov 4, 2025
70cb055
Reduce to 1D
DanielDoehring Nov 4, 2025
89358d4
tests
DanielDoehring Nov 4, 2025
98a277b
typo
DanielDoehring Nov 4, 2025
e36ce51
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 4, 2025
d793e99
const
DanielDoehring Nov 4, 2025
535a3f2
Update src/callbacks_stage/positivity_ruedaramirez_gassner_1d.jl
DanielDoehring Nov 4, 2025
4b94f1c
err
DanielDoehring Nov 4, 2025
70ee1ea
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Nov 4, 2025
681ea16
ta
DanielDoehring Nov 4, 2025
976f58f
ts
DanielDoehring Nov 4, 2025
fa38b6d
rv
DanielDoehring Nov 4, 2025
b4f46f0
swithc exmaples
DanielDoehring Nov 4, 2025
7271a6e
rename, fmt
DanielDoehring Nov 4, 2025
5185013
Update examples/tree_1d_dgsem/elixir_euler_low_density_shock.jl
DanielDoehring Nov 4, 2025
b21a04c
comment
DanielDoehring Nov 5, 2025
26a1f37
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 6, 2025
ac68465
shorten
DanielDoehring Nov 6, 2025
bb79dba
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Nov 6, 2025
49bcb12
type assertions
DanielDoehring Nov 10, 2025
1a7555b
rename
DanielDoehring Nov 10, 2025
00a52a7
mv
DanielDoehring Nov 10, 2025
5cf74c5
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 10, 2025
7b18f45
comment
DanielDoehring Nov 10, 2025
d5b5667
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Nov 10, 2025
b137ced
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 14, 2025
88ca297
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 14, 2025
49c7637
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 17, 2025
60513e1
hf
DanielDoehring Nov 17, 2025
4645737
hf
DanielDoehring Nov 17, 2025
42ed6aa
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 19, 2025
ce9e420
mvec
DanielDoehring Nov 20, 2025
69d5ebf
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Nov 20, 2025
bd7949f
v
DanielDoehring Nov 20, 2025
b4445c4
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 20, 2025
67861c1
rm
DanielDoehring Nov 20, 2025
e72f94d
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Nov 20, 2025
cf1bb38
rm comments
DanielDoehring Nov 20, 2025
07a08ec
comment
DanielDoehring Nov 20, 2025
fca5847
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 26, 2025
fc2f8c6
IC
DanielDoehring Nov 28, 2025
46bbc49
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Nov 28, 2025
dce20e5
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Nov 29, 2025
d0abd99
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Dec 1, 2025
ff4fe6e
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Dec 2, 2025
ecdb8bc
remove announcements from 1D case
DanielDoehring Dec 2, 2025
a90157a
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring Dec 2, 2025
9e610bb
comment
DanielDoehring Dec 2, 2025
46eb547
Update examples/tree_1d_dgsem/elixir_euler_low_density_shock.jl
DanielDoehring Dec 2, 2025
2403432
comment
DanielDoehring Dec 2, 2025
e71a0e1
comment
DanielDoehring Dec 2, 2025
7a7cc8e
typos
DanielDoehring Dec 2, 2025
bf105a7
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Dec 3, 2025
76d6f3d
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Dec 4, 2025
9a0d694
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring Dec 6, 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
110 changes: 110 additions & 0 deletions examples/tree_1d_dgsem/elixir_euler_low_density_shock.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using Trixi

###############################################################################
# semidiscretization of the compressible Euler equations

equations = CompressibleEulerEquations1D(5 / 3)

"""
initial_condition_low_density_shock(x, t, equations::CompressibleEulerEquations1D)

Leblanc shock tube problem inspired initial condition.
Uses much lower pressure but much higher pressure on the right side.
"""
function initial_condition_low_density_shock(x, t, equations::CompressibleEulerEquations1D)
rho = x[1] <= 3 ? 1 : 1e-5
rho_v1 = 0
rho_e = x[1] <= 3 ? 1e-1 : 1e-4

return SVector(rho, rho_v1, rho_e)
end
initial_condition = initial_condition_low_density_shock

###############################################################################
# Specify non-periodic boundary conditions

boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition)

function boundary_condition_outflow(u_inner, orientation, direction, x, t,
surface_flux_function,
equations::CompressibleEulerEquations1D)
# Calculate the boundary flux entirely from the internal solution state
return flux(u_inner, orientation, equations)
end

boundary_conditions = (x_neg = boundary_condition_inflow,
x_pos = boundary_condition_outflow)

surface_flux = flux_hllc
volume_flux = flux_ranocha
basis = LobattoLegendreBasis(4)
indicator_sc = IndicatorHennemannGassner(equations, basis,
alpha_max = 0.5,
alpha_min = 0.001,
alpha_smooth = true,
variable = density_pressure)
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)

coordinates_min = (0.0,)
coordinates_max = (9.0,)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 6,
n_cells_max = 10_000,
periodicity = false)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 1.2)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 500
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

amr_indicator = IndicatorLöhner(semi,
variable = density_pressure)
amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 4,
med_level = 0, med_threshold = 0.1,
max_level = 6, max_threshold = 0.3)
amr_callback = AMRCallback(semi, amr_controller,
interval = 2,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)

stepsize_callback = StepsizeCallback(cfl = 0.2)

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

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

# Positivity-preserving limiter setup
# - `alpha_max` is increased above the value used in the volume integral
# to allow room for positivity limiting.
# - `beta_rho` set to 0.7 to provoke density correction
# - `root_tol` can be set to this relatively high value while still ensuring positivity
# - `use_density_init` set to false to use zero initial guess for pressure correction
limiter! = LowerBoundPreservingLimiterRuedaRamirezGassner(semi;
alpha_max = 0.9,
beta_rho = 0.7,
root_tol = 1e-8,
use_density_init = false)

stage_callbacks = (limiter!,)

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks);
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
callback = callbacks);
113 changes: 113 additions & 0 deletions examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube_positivity.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
gamma = 5 / 3
equations = IdealGlmMhdEquations1D(gamma)

"""
initial_condition_shu_osher_shock_tube(x, t, equations::IdealGlmMhdEquations1D)

Extended version of the test of Shu and Osher for one dimensional ideal MHD equations.
Taken from Section 4.1 of
- Derigs et al. (2016)
A Novel High-Order, Entropy Stable, 3D AMR MHD Solver withGuaranteed Positive Pressure
[DOI: 10.1016/j.jcp.2016.04.048](https://doi.org/10.1016/j.jcp.2016.04.048)

with further decreased pressure in the right state to make the test more challenging/
requiring positivity preservation limiting.
"""
function initial_condition_shu_osher_shock_tube(x, t, equations::IdealGlmMhdEquations1D)
# domain must be set to [-5, 5], γ = 5/3, final time = 0.7
# initial shock location is taken to be at x = -4
RealT = eltype(x)
x_0 = -4
rho = x[1] <= x_0 ? RealT(3.5) : 1 + RealT(0.2) * sin(5 * x[1])
v1 = x[1] <= x_0 ? RealT(5.8846) : zero(RealT)
v2 = x[1] <= x_0 ? RealT(1.1198) : zero(RealT)
v3 = 0
p = x[1] <= x_0 ? RealT(42.0267) : RealT(0.1) # Right state is 1 in reference
B1 = 1
B2 = x[1] <= x_0 ? RealT(3.6359) : one(RealT)
B3 = 0

return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations)
end
initial_condition = initial_condition_shu_osher_shock_tube

boundary_conditions = BoundaryConditionDirichlet(initial_condition)

surface_flux = flux_hlle
volume_flux = flux_hindenlang_gassner
basis = LobattoLegendreBasis(4)

indicator_sc = IndicatorHennemannGassner(equations, basis,
alpha_max = 0.5,
alpha_min = 0.001,
alpha_smooth = true,
variable = density_pressure)
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
solver = DGSEM(basis, surface_flux, volume_integral)

coordinates_min = -5.0
coordinates_max = 5.0
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 10_000,
periodicity = false)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.7)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 1000
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
extra_analysis_integrals = (energy_kinetic,
energy_internal,
energy_magnetic,
cross_helicity))

alive_callback = AliveCallback(analysis_interval = analysis_interval)

amr_controller = ControllerThreeLevel(semi, indicator_sc,
base_level = 4,
max_level = 7, max_threshold = 0.01)
amr_callback = AMRCallback(semi, amr_controller,
interval = 10,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)

stepsize_callback = StepsizeCallback(cfl = 0.4)

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

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

# Positivity-preserving limiter setup
# - `alpha_max` is increased above the value used in the volume integral
# to allow room for positivity limiting.
# - `root_tol` can be set to this relatively high value while still ensuring positivity
# - `use_density_init` is set to false since in the modification of the initial condition
# only the pressure is decreased, i.e., density should be non-critical
# and is probably not corrected at all.
limiter! = LowerBoundPreservingLimiterRuedaRamirezGassner(semi;
alpha_max = 0.7,
root_tol = 1e-8,
use_density_init = false)
stage_callbacks = (limiter!,)

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks);
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
callback = callbacks);
3 changes: 2 additions & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ export load_mesh, load_time, load_timestep, load_timestep!, load_dt,
export ControllerThreeLevel, ControllerThreeLevelCombined,
IndicatorLöhner, IndicatorLoehner, IndicatorMax

export PositivityPreservingLimiterZhangShu, EntropyBoundedLimiter
export LowerBoundPreservingLimiterRuedaRamirezGassner, PositivityPreservingLimiterZhangShu,
EntropyBoundedLimiter

export trixi_include, examples_dir, get_examples, default_example,
default_example_unstructured, ode_default_options
Expand Down
3 changes: 2 additions & 1 deletion src/callbacks_stage/callbacks_stage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
@muladd begin
#! format: noindent

include("entropy_bounded_limiter.jl")
include("lowerbound_ruedaramirez_gassner.jl")
include("positivity_zhang_shu.jl")
include("subcell_limiter_idp_correction.jl")
include("subcell_bounds_check.jl")
include("entropy_bounded_limiter.jl")
end # @muladd
Loading
Loading