-
Notifications
You must be signed in to change notification settings - Fork 135
Lower-Bound/Positivity-Preserving Limiter of Rueda-Ramirez & Gassner (1D) #2638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DanielDoehring
wants to merge
75
commits into
trixi-framework:main
Choose a base branch
from
DanielDoehring:PosPresLimiterRRG_1D_no_Doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 568cf03
work
DanielDoehring c00d38a
debug
DanielDoehring c2b1b66
one example
DanielDoehring 918b930
rm
DanielDoehring 4304665
shorten
DanielDoehring 185f24a
timings
DanielDoehring 801aefa
docstring
DanielDoehring 5d38432
mhd example
DanielDoehring d1a1f57
comment
DanielDoehring 650ff19
docs etc
DanielDoehring 3c62fbd
thread-locla storage
DanielDoehring 6fb1c31
prominent matching
DanielDoehring aff0b12
clarify
DanielDoehring b3c6ac0
typo
DanielDoehring 2d8c398
comments
DanielDoehring 9186b69
revert
DanielDoehring cbfeb01
revert
DanielDoehring 47444ab
typo
DanielDoehring ab011dd
fine tunings
DanielDoehring 9abcbd8
explian kw
DanielDoehring 70cb055
Reduce to 1D
DanielDoehring 89358d4
tests
DanielDoehring 98a277b
typo
DanielDoehring e36ce51
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring d793e99
const
DanielDoehring 535a3f2
Update src/callbacks_stage/positivity_ruedaramirez_gassner_1d.jl
DanielDoehring 4b94f1c
err
DanielDoehring 70ee1ea
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring 681ea16
ta
DanielDoehring 976f58f
ts
DanielDoehring fa38b6d
rv
DanielDoehring b4f46f0
swithc exmaples
DanielDoehring 7271a6e
rename, fmt
DanielDoehring 5185013
Update examples/tree_1d_dgsem/elixir_euler_low_density_shock.jl
DanielDoehring b21a04c
comment
DanielDoehring 26a1f37
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring ac68465
shorten
DanielDoehring bb79dba
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring 49bcb12
type assertions
DanielDoehring 1a7555b
rename
DanielDoehring 00a52a7
mv
DanielDoehring 5cf74c5
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 7b18f45
comment
DanielDoehring d5b5667
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring b137ced
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 88ca297
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 49c7637
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 60513e1
hf
DanielDoehring 4645737
hf
DanielDoehring 42ed6aa
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring ce9e420
mvec
DanielDoehring 69d5ebf
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring bd7949f
v
DanielDoehring b4445c4
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 67861c1
rm
DanielDoehring e72f94d
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring cf1bb38
rm comments
DanielDoehring 07a08ec
comment
DanielDoehring fca5847
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring fc2f8c6
IC
DanielDoehring 46bbc49
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring dce20e5
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring d0abd99
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring ff4fe6e
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring ecdb8bc
remove announcements from 1D case
DanielDoehring a90157a
Merge branch 'PosPresLimiterRRG_1D_no_Doc' of github.com:DanielDoehri…
DanielDoehring 9e610bb
comment
DanielDoehring 46eb547
Update examples/tree_1d_dgsem/elixir_euler_low_density_shock.jl
DanielDoehring 2403432
comment
DanielDoehring e71a0e1
comment
DanielDoehring 7a7cc8e
typos
DanielDoehring bf105a7
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 76d6f3d
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring 9a0d694
Merge branch 'main' into PosPresLimiterRRG_1D_no_Doc
DanielDoehring File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
examples/tree_1d_dgsem/elixir_euler_low_density_shock.jl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
DanielDoehring marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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
113
examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube_positivity.jl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.