Skip to content

Commit 8e057e7

Browse files
amruedapatrickersingandrewwinters5000
authored
Implement subcell limiting for non-conservative systems using curvilinear solvers (#2051)
* Implemented subcell limiting for non-conservative systems with the DGSEM structured solver * update calcflux_fhat, add normal direction fluxes and example * fix unit test * add calcflux_fhat for local * jump formulation * modify limiter configuration and corresponding test values * remove unnecessary pkgs from elixir * Apply suggestions from code review Co-authored-by: Andrés Rueda-Ramírez <[email protected]> * Apply suggestions from code review Co-authored-by: Andrew Winters <[email protected]> --------- Co-authored-by: Patrick Ersing <[email protected]> Co-authored-by: patrickersing <[email protected]> Co-authored-by: Andrew Winters <[email protected]>
1 parent 53c4725 commit 8e057e7

File tree

5 files changed

+1042
-6
lines changed

5 files changed

+1042
-6
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
using Trixi
2+
3+
###############################################################################
4+
# semidiscretization of the compressible ideal GLM-MHD equations
5+
gamma = 5 / 3
6+
equations = IdealGlmMhdEquations2D(gamma)
7+
8+
"""
9+
initial_condition_orszag_tang(x, t, equations::IdealGlmMhdEquations2D)
10+
11+
The classical Orszag-Tang vortex test case. Here, the setup is taken from
12+
- Dominik Derigs, Gregor J. Gassner, Stefanie Walch & Andrew R. Winters (2018)
13+
Entropy Stable Finite Volume Approximations for Ideal Magnetohydrodynamics
14+
[doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9)
15+
"""
16+
function initial_condition_orszag_tang(x, t, equations::IdealGlmMhdEquations2D)
17+
# setup taken from Derigs et al. DMV article (2018)
18+
# domain must be [0, 1] x [0, 1], γ = 5/3
19+
rho = 1
20+
v1 = -sinpi(2 * x[2])
21+
v2 = sinpi(2 * x[1])
22+
v3 = 0
23+
p = 1 / equations.gamma
24+
B1 = -sinpi(2 * x[2]) / equations.gamma
25+
B2 = sinpi(4 * x[1]) / equations.gamma
26+
B3 = 0
27+
psi = 0
28+
return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations)
29+
end
30+
initial_condition = initial_condition_orszag_tang
31+
32+
surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell_local_symmetric)
33+
volume_flux = (flux_central, flux_nonconservative_powell_local_symmetric)
34+
35+
polydeg = 3
36+
basis = LobattoLegendreBasis(polydeg)
37+
38+
limiter_idp = SubcellLimiterIDP(equations, basis;
39+
positivity_variables_cons = ["rho"],
40+
positivity_variables_nonlinear = [pressure],
41+
positivity_correction_factor = 0.9,
42+
max_iterations_newton = 20)
43+
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp;
44+
volume_flux_dg = volume_flux,
45+
volume_flux_fv = surface_flux)
46+
solver = DGSEM(basis, surface_flux, volume_integral)
47+
48+
# Get the curved quad mesh from a mapping function
49+
# Mapping as described in https://arxiv.org/abs/2012.12040
50+
function mapping(xi, eta)
51+
y = 0.5 + 0.5 * eta + 1.0 / 15.0 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta))
52+
53+
x = 0.5 + 0.5 * xi + 1.0 / 15.0 * (cos(0.5 * pi * xi) * cos(2 * pi * y))
54+
55+
return SVector(x, y)
56+
end
57+
58+
cells_per_dimension = (32, 32)
59+
60+
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
61+
62+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
63+
64+
###############################################################################
65+
# ODE solvers, callbacks etc.
66+
67+
tspan = (0.0, 0.5)
68+
ode = semidiscretize(semi, tspan)
69+
70+
summary_callback = SummaryCallback()
71+
72+
analysis_interval = 100
73+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
74+
75+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
76+
77+
save_solution = SaveSolutionCallback(interval = 100,
78+
save_initial_solution = true,
79+
save_final_solution = true,
80+
solution_variables = cons2prim,
81+
extra_node_variables = (:limiting_coefficient,))
82+
83+
cfl = 0.4
84+
stepsize_callback = StepsizeCallback(cfl = cfl)
85+
86+
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
87+
88+
callbacks = CallbackSet(summary_callback,
89+
analysis_callback,
90+
alive_callback,
91+
save_solution,
92+
stepsize_callback,
93+
glm_speed_callback)
94+
95+
###############################################################################
96+
# run the simulation
97+
98+
stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback())
99+
100+
sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks);
101+
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
102+
ode_default_options()..., callback = callbacks);

0 commit comments

Comments
 (0)