forked from trixi-framework/Trixi.jl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entropy bounded limiter (trixi-framework#2078)
* start working * get EB limiter to work * Refine EB limiter * fmt * 2D/3D Limiters * introduce parameter of tolerated entropy decrease * change to exp_entropy_diff * fmt * export * docstring * 3d example * exam,ples * examples * examples * fmt * adaptive * examples * fmt * tests + docu * fmt + spelling * comment * Apply suggestions from code review Co-authored-by: Benjamin Bolm <[email protected]> * Apply suggestions from code review * increase => change * fmt * spelling * revisit * revert * back to decrease * fmt * typo * comments * theta * longer sim * removed unused code * for coverage * Apply suggestions from code review * longer runtime for coverage * vals * reproducible test values * shorten * changes * testvals * test vals * Update src/callbacks_stage/entropy_bounded_limiter_2d.jl * Apply suggestions from code review * Update docs/literate/src/files/shock_capturing.jl * more iters * Apply suggestions from code review * comments * mention step_limiter! capability * Update docs/literate/src/files/shock_capturing.jl * Update src/callbacks_stage/entropy_bounded_limiter.jl * Update src/callbacks_stage/entropy_bounded_limiter.jl * Apply suggestions from code review --------- Co-authored-by: Benjamin Bolm <[email protected]>
- Loading branch information
1 parent
a05a68d
commit cdd552f
Showing
15 changed files
with
836 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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
128 changes: 128 additions & 0 deletions
128
examples/p4est_3d_dgsem/elixir_mhd_amr_entropy_bounded.jl
This file contains 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,128 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible ideal GLM-MHD equations | ||
|
||
equations = IdealGlmMhdEquations3D(1.4) | ||
|
||
""" | ||
initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations3D) | ||
Weak magnetic blast wave setup taken from Section 6.1 of the paper: | ||
- A. M. Rueda-Ramírez, S. Hennemann, F. J. Hindenlang, A. R. Winters, G. J. Gassner (2021) | ||
An entropy stable nodal discontinuous Galerkin method for the resistive MHD | ||
equations. Part II: Subcell finite volume shock capturing | ||
[doi: 10.1016/j.jcp.2021.110580](https://doi.org/10.1016/j.jcp.2021.110580) | ||
""" | ||
function initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations3D) | ||
# Center of the blast wave is selected for the domain [0, 3]^3 | ||
inicenter = (1.5, 1.5, 1.5) | ||
x_norm = x[1] - inicenter[1] | ||
y_norm = x[2] - inicenter[2] | ||
z_norm = x[3] - inicenter[3] | ||
r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) | ||
|
||
delta_0 = 0.1 | ||
r_0 = 0.3 | ||
lambda = exp(5.0 / delta_0 * (r - r_0)) | ||
|
||
prim_inner = SVector(1.2, 0.1, 0.0, 0.1, 0.9, 1.0, 1.0, 1.0, 0.0) | ||
prim_outer = SVector(1.2, 0.2, -0.4, 0.2, 0.3, 1.0, 1.0, 1.0, 0.0) | ||
prim_vars = (prim_inner + lambda * prim_outer) / (1.0 + lambda) | ||
|
||
return prim2cons(prim_vars, equations) | ||
end | ||
initial_condition = initial_condition_blast_wave | ||
|
||
surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) | ||
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) | ||
polydeg = 3 | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux) | ||
|
||
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, | ||
volume_integral = volume_integral) | ||
|
||
# Mapping as described in https://arxiv.org/abs/2012.12040 but with slightly less warping. | ||
# The mapping will be interpolated at tree level, and then refined without changing | ||
# the geometry interpolant. | ||
function mapping(xi_, eta_, zeta_) | ||
# Transform input variables between -1 and 1 onto [0,3] | ||
xi = 1.5 * xi_ + 1.5 | ||
eta = 1.5 * eta_ + 1.5 | ||
zeta = 1.5 * zeta_ + 1.5 | ||
|
||
y = eta + | ||
3 / 11 * (cos(1.5 * pi * (2 * xi - 3) / 3) * | ||
cos(0.5 * pi * (2 * eta - 3) / 3) * | ||
cos(0.5 * pi * (2 * zeta - 3) / 3)) | ||
|
||
x = xi + | ||
3 / 11 * (cos(0.5 * pi * (2 * xi - 3) / 3) * | ||
cos(2 * pi * (2 * y - 3) / 3) * | ||
cos(0.5 * pi * (2 * zeta - 3) / 3)) | ||
|
||
z = zeta + | ||
3 / 11 * (cos(0.5 * pi * (2 * x - 3) / 3) * | ||
cos(pi * (2 * y - 3) / 3) * | ||
cos(0.5 * pi * (2 * zeta - 3) / 3)) | ||
|
||
return SVector(x, y, z) | ||
end | ||
|
||
trees_per_dimension = (2, 2, 2) | ||
mesh = P4estMesh(trees_per_dimension, | ||
polydeg = 3, | ||
mapping = mapping, | ||
initial_refinement_level = 2, | ||
periodicity = true) | ||
|
||
# create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 0.5) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
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 = 2, | ||
max_level = 4, max_threshold = 0.15) | ||
amr_callback = AMRCallback(semi, amr_controller, | ||
interval = 5, | ||
adapt_initial_condition = true, | ||
adapt_initial_condition_only_refine = true) | ||
|
||
cfl = 3.0 | ||
stepsize_callback = StepsizeCallback(cfl = cfl) | ||
|
||
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, | ||
alive_callback, | ||
amr_callback, | ||
stepsize_callback, | ||
glm_speed_callback) | ||
|
||
# Stage limiter required for this high CFL | ||
stage_limiter! = EntropyBoundedLimiter(exp_entropy_decrease_max = -5e-3) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, williamson_condition = false), | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
80 changes: 80 additions & 0 deletions
80
examples/tree_1d_dgsem/elixir_euler_blast_wave_entropy_bounded.jl
This file contains 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,80 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
|
||
equations = CompressibleEulerEquations1D(1.4) | ||
|
||
""" | ||
initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) | ||
A medium blast wave taken from | ||
- Sebastian Hennemann, Gregor J. Gassner (2020) | ||
A provably entropy stable subcell shock capturing approach for high order split form DG | ||
[arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) | ||
""" | ||
function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) | ||
# Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" | ||
# Set up polar coordinates | ||
inicenter = SVector(0.0) | ||
x_norm = x[1] - inicenter[1] | ||
r = abs(x_norm) | ||
# The following code is equivalent to | ||
# phi = atan(0.0, x_norm) | ||
# cos_phi = cos(phi) | ||
# in 1D but faster | ||
cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) | ||
|
||
# Calculate primitive variables | ||
rho = r > 0.5 ? 1.0 : 1.1691 | ||
v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi | ||
p = r > 0.5 ? 1.0E-3 : 1.245 | ||
|
||
return prim2cons(SVector(rho, v1, p), equations) | ||
end | ||
initial_condition = initial_condition_blast_wave | ||
|
||
# Note: We do not need to use the shock-capturing methodology here, | ||
# in contrast to the standard `euler_blast_wave.jl` example. | ||
solver = DGSEM(polydeg = 3, surface_flux = flux_hllc) | ||
|
||
coordinates_min = (-2.0,) | ||
coordinates_max = (2.0,) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 6, | ||
n_cells_max = 10_000) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 12.5) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
|
||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 0.5) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
stepsize_callback) | ||
|
||
stage_limiter! = EntropyBoundedLimiter() | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, SSPRK33(stage_limiter!); | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
callback = callbacks); | ||
|
||
summary_callback() # print the timer summary |
Oops, something went wrong.