Skip to content

Commit 2344442

Browse files
Merge pull request #256 from trixi-framework/shock-non-cons-in-taal
Port shock capturing with non-conservative terms into Taal
2 parents 222241f + 25367bb commit 2344442

10 files changed

+421
-95
lines changed

AUTHORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ are listed in alphabetical order:
2424
* Gregor Gassner
2525
* Julia Odenthal
2626
* Hendrik Ranocha
27+
* Andrés M. Rueda-Ramírez
2728
* Michael Schlottke-Lakemper
2829
* Andrew Winters

examples/2d/elixir_mhd_blast_wave_shockcapturing_amr.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ amr_indicator = IndicatorHennemannGassner(semi,
5252
variable=density_pressure)
5353
amr_controller = ControllerThreeLevel(semi, amr_indicator,
5454
base_level=4,
55-
max_level =6, max_threshold=0.01)
55+
max_level =7, max_threshold=0.01)
5656
amr_callback = AMRCallback(semi, amr_controller,
5757
interval=5,
5858
adapt_initial_condition=true,
5959
adapt_initial_condition_only_refine=true)
6060

61-
stepsize_callback = StepsizeCallback(cfl=0.5) # can probably be increased when shock-capturing is fixed for MHD
61+
stepsize_callback = StepsizeCallback(cfl=1.0)
6262

6363
save_solution = SaveSolutionCallback(interval=100,
6464
save_initial_solution=true,

examples/2d/elixir_mhd_orszag_tang_shockcapturing_amr.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ equations = IdealGlmMhdEquations2D(gamma)
1414

1515
initial_condition = initial_condition_orszag_tang
1616

17-
surface_flux = flux_hll
17+
surface_flux = flux_lax_friedrichs
1818
volume_flux = flux_central
1919
basis = LobattoLegendreBasis(3)
2020
indicator_sc = IndicatorHennemannGassner(equations, basis,
@@ -58,7 +58,7 @@ amr_callback = AMRCallback(semi, amr_controller,
5858
adapt_initial_condition=true,
5959
adapt_initial_condition_only_refine=true)
6060

61-
stepsize_callback = StepsizeCallback(cfl=0.25) # can probably be increased when shock-capturing is fixed for MHD
61+
stepsize_callback = StepsizeCallback(cfl=1.0)
6262

6363
save_solution = SaveSolutionCallback(interval=100,
6464
save_initial_solution=true,

examples/2d/elixir_mhd_rotor_shockcapturing_amr.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ equations = IdealGlmMhdEquations2D(1.4)
1414
initial_condition = initial_condition_rotor
1515

1616
surface_flux = flux_lax_friedrichs
17-
volume_flux = flux_central
17+
volume_flux = flux_derigs_etal
1818
basis = LobattoLegendreBasis(4)
1919
indicator_sc = IndicatorHennemannGassner(equations, basis,
2020
alpha_max=0.5,
@@ -57,7 +57,7 @@ amr_callback = AMRCallback(semi, amr_controller,
5757
adapt_initial_condition=true,
5858
adapt_initial_condition_only_refine=true)
5959

60-
stepsize_callback = StepsizeCallback(cfl=0.5) # can probably be increased when shock-capturing is fixed for MHD
60+
stepsize_callback = StepsizeCallback(cfl=0.95)
6161

6262
save_solution = SaveSolutionCallback(interval=100,
6363
save_initial_solution=true,

examples/2d/parameters_mhd_rotor.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ equations = "IdealGlmMhdEquations"
55
gamma = 1.4
66
initial_condition = "initial_condition_rotor"
77
surface_flux = "flux_lax_friedrichs"
8-
volume_flux = "flux_central"
8+
volume_flux = "flux_derigs_etal"
99

1010
amr_indicator = "blast_wave" # for now just for testing
1111

src/equations/2d/ideal_glm_mhd.jl

+49-17
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,25 @@ function flux_hll(u_ll, u_rr, orientation, equation::IdealGlmMhdEquations2D)
453453
return SVector(f1, f2, f3, f4, f5, f6, f7, f8, f9)
454454
end
455455

456-
457-
# strong form of nonconservative flux on a side, e.g., the Powell term
458-
# phi^L 1/2 (B^L+B^R) normal - phi^L B^L normal = phi^L 1/2 (B^R-B^L) normal
459-
# OBS! 1) "weak" formulation of split DG already includes the contribution -1/2(phi^L B^L normal)
460-
# so this routine only adds 1/2(phi^L B^R normal)
461-
# analogously for the Galilean nonconservative term
462-
# 2) this is non-unique along an interface! normal direction is super important
463-
function noncons_interface_flux(u_left, u_right, orientation, equation::IdealGlmMhdEquations2D)
456+
"""
457+
noncons_interface_flux(u_left, u_right, orientation, mode, equation::IdealGlmMhdEquations2D)
458+
459+
Strong form of non-conservative flux on a surface (Powell and GLM terms)
460+
```math
461+
phi^L 1/2 (B^L + B^R)_{normal} - phi^L B^L+{normal} = phi^L 1/2 (B^R - B^L)_{normal}
462+
```
463+
!!! note
464+
The non-conservative interface flux depends on the discretization. Following "modes" are available:
465+
* `:weak`: 'weak' formulation of split DG already includes the contribution
466+
``-1/2 (phi^L B^L_{normal})`` so this mode only adds ``1/2 (phi^L B^R_{normal})``,
467+
analogously for the Galilean nonconservative term
468+
* `:whole`: This mode adds the whole non-conservative term: phi^L 1/2 (B^R-B^L)
469+
* `:inner`: This mode adds the split-form DG volume integral contribution: This is equivalent to
470+
``(2)-(1) - 1/2 (phi^L B^L)``
471+
!!! warning
472+
This is non-unique along an interface! The normal direction is super important.
473+
"""
474+
@inline function noncons_interface_flux(u_left, u_right, orientation, mode, equation::IdealGlmMhdEquations2D)
464475
rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _, B1_ll, B2_ll, B3_ll, psi_ll = u_left
465476
_, _, _, _, _, B1_rr, B2_rr, _, psi_rr = u_right
466477

@@ -471,27 +482,48 @@ function noncons_interface_flux(u_left, u_right, orientation, equation::IdealGlm
471482
v_dot_B_ll = v1_ll*B1_ll + v2_ll*B2_ll + v3_ll*B3_ll
472483
# extract magnetic field variable from the right and set the normal velocity
473484
# Note, both depend upon the orientation and need psi_rr
474-
if orientation == 1 # x-direction
475-
v_normal = v1_ll
476-
B_normal = B1_rr
477-
else # y-direction
478-
v_normal = v2_ll
479-
B_normal = B2_rr
485+
if mode==:weak
486+
if orientation == 1 # x-direction
487+
v_normal = v1_ll
488+
B_normal = B1_rr
489+
else # y-direction
490+
v_normal = v2_ll
491+
B_normal = B2_rr
492+
end
493+
psi_norm = psi_rr
494+
elseif mode==:whole
495+
if orientation == 1 # x-direction
496+
v_normal = v1_ll
497+
B_normal = B1_rr - B1_ll
498+
else # y-direction
499+
v_normal = v2_ll
500+
B_normal = B2_rr - B2_ll
501+
end
502+
psi_norm = psi_rr - psi_ll
503+
else #mode==:inner
504+
if orientation == 1 # x-direction
505+
v_normal = v1_ll
506+
B_normal =-B1_ll
507+
else # y-direction
508+
v_normal = v2_ll
509+
B_normal =-B2_ll
510+
end
511+
psi_norm =-psi_ll
480512
end
513+
481514
# compute the nonconservative flux: Powell (with B_normal) and Galilean (with v_normal)
482515
noncons2 = 0.5 * B_normal * B1_ll
483516
noncons3 = 0.5 * B_normal * B2_ll
484517
noncons4 = 0.5 * B_normal * B3_ll
485-
noncons5 = 0.5 * B_normal * v_dot_B_ll + 0.5 * v_normal * psi_ll * psi_rr
518+
noncons5 = 0.5 * B_normal * v_dot_B_ll + 0.5 * v_normal * psi_ll * psi_norm
486519
noncons6 = 0.5 * B_normal * v1_ll
487520
noncons7 = 0.5 * B_normal * v2_ll
488521
noncons8 = 0.5 * B_normal * v3_ll
489-
noncons9 = 0.5 * v_normal * psi_rr
522+
noncons9 = 0.5 * v_normal * psi_norm
490523

491524
return SVector(0, noncons2, noncons3, noncons4, noncons5, noncons6, noncons7, noncons8, noncons9)
492525
end
493526

494-
495527
# 1) Determine maximum stable time step based on polynomial degree and CFL number
496528
# 2) Update the GLM cleaning wave speed c_h to be the largest value of the fast
497529
# magnetoacoustic over the entire domain (note this routine is called in a loop

0 commit comments

Comments
 (0)