-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subcell positivity limiting of non-linear variables (#1738)
* Add positivity limiting of non-linear variables * Revise derivative function call; Add default derivative version * Adapt test to actually test pos limiter for nonlinear variables * Add unit test to test default implementation of variable_derivative * Clean up comments and code * Rename Newton-bisection variables * Implement suggestions * Relocate functions * Implement suggestions * Change error message for negative value with low-order method * Add changes from main to new limiter * Update NEWS.md * Rename is_valid_state and gradient_u --------- Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
- Loading branch information
Showing
13 changed files
with
496 additions
and
35 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
91 changes: 91 additions & 0 deletions
91
examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_sc_subcell.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,91 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
gamma = 1.4 | ||
equations = CompressibleEulerEquations2D(gamma) | ||
|
||
""" | ||
initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) | ||
A version of the classical Kelvin-Helmholtz instability based on | ||
- Andrés M. Rueda-Ramírez, Gregor J. Gassner (2021) | ||
A Subcell Finite Volume Positivity-Preserving Limiter for DGSEM Discretizations | ||
of the Euler Equations | ||
[arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) | ||
""" | ||
function initial_condition_kelvin_helmholtz_instability(x, t, | ||
equations::CompressibleEulerEquations2D) | ||
# change discontinuity to tanh | ||
# typical resolution 128^2, 256^2 | ||
# domain size is [-1,+1]^2 | ||
slope = 15 | ||
amplitude = 0.02 | ||
B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) | ||
rho = 0.5 + 0.75 * B | ||
v1 = 0.5 * (B - 1) | ||
v2 = 0.1 * sin(2 * pi * x[1]) | ||
p = 1.0 | ||
return prim2cons(SVector(rho, v1, v2, p), equations) | ||
end | ||
initial_condition = initial_condition_kelvin_helmholtz_instability | ||
|
||
surface_flux = flux_lax_friedrichs | ||
volume_flux = flux_ranocha | ||
polydeg = 3 | ||
basis = LobattoLegendreBasis(polydeg) | ||
|
||
limiter_idp = SubcellLimiterIDP(equations, basis; | ||
positivity_variables_cons = ["rho"], | ||
positivity_variables_nonlinear = [pressure]) | ||
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp; | ||
volume_flux_dg = volume_flux, | ||
volume_flux_fv = surface_flux) | ||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
coordinates_min = (-1.0, -1.0) | ||
coordinates_max = (1.0, 1.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 5, | ||
n_cells_max = 100_000) | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 3.7) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 1000 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 100, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
solution_variables = cons2prim) | ||
|
||
save_restart = SaveRestartCallback(interval = 1000, | ||
save_final_restart = true) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 0.7) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
stepsize_callback, | ||
save_restart, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback(save_errors = false)) | ||
|
||
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); | ||
summary_callback() # print the timer summary |
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
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
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
Oops, something went wrong.