Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_2d_dgsem/elixir_euler_richtmyer_meshkov.jl
5586 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations2D(1.4)
8
9
@doc raw"""
10
smoothed_discontinuity(x, a, b; slope = 15)
11
12
A smoothed discontinuity function that transitions from `a` to `b` around `x = 0`.
13
The `slope` parameter controls how sharp the transition is; larger values result in a steeper transition.
14
This is the function ``d_{a,b}`` from the paper
15
- Chan, Ranocha, Rueda-Ramírez, Gassner, Warburton (2022):
16
On the entropy projection and the robustness of high order entropy stable discontinuous Galerkin schemes for under-resolved flows.
17
[DOI: 10.3389/fphy.2022.898028](https://doi.org/10.3389/fphy.2022.898028)
18
"""
19
@inline function smoothed_discontinuity(x, a, b; slope = 15)
20
return a + 0.5f0 * (1 + tanh(slope * x)) * (b - a)
21
end
22
23
"""
24
initial_condition_richtmyer_meshkov_instability(x, t,
25
equations::CompressibleEulerEquations2D)
26
27
Initial condition for the Richtmyer-Meshkov instability test case in two dimensions.
28
Taken from section 3.1.3 of the paper
29
- Chan, Ranocha, Rueda-Ramírez, Gassner, Warburton (2022):
30
On the entropy projection and the robustness of high order entropy stable discontinuous Galerkin schemes for under-resolved flows.
31
[DOI: 10.3389/fphy.2022.898028](https://doi.org/10.3389/fphy.2022.898028)
32
"""
33
@inline function initial_condition_richtmyer_meshkov_instability(x, t,
34
equations::CompressibleEulerEquations2D)
35
slope = 2
36
37
L_x = 40.0
38
argument_1 = x[2] - (18 + 2 * cospi(6 * x[1] / L_x))
39
rho_summand_1 = smoothed_discontinuity(argument_1, 1, 0.25, slope = slope)
40
41
argument_2 = abs(x[2] - 4) - 2
42
rho_summand_2 = smoothed_discontinuity(argument_2, 3.22, 0, slope = slope)
43
44
rho = rho_summand_1 + rho_summand_2
45
46
p = smoothed_discontinuity(argument_2, 4.9, 1.0, slope = slope)
47
48
u = 0
49
v = 0
50
return prim2cons(SVector(rho, u, v, p), equations)
51
end
52
53
polydeg = 3
54
surface_flux = flux_hllc
55
volume_flux = flux_ranocha
56
57
basis = LobattoLegendreBasis(polydeg)
58
59
indicator_sc = IndicatorHennemannGassner(equations, basis,
60
alpha_max = 0.5,
61
alpha_min = 0.01,
62
alpha_smooth = false,
63
variable = Trixi.density_pressure)
64
65
volume_integral = VolumeIntegralShockCapturingRRG(basis, indicator_sc;
66
volume_flux_dg = volume_flux,
67
volume_flux_fv = surface_flux,
68
slope_limiter = monotonized_central)
69
70
dg = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
71
volume_integral = volume_integral)
72
73
num_elements_x = 38
74
cells_per_dimension = (num_elements_x, 3 * num_elements_x)
75
coordinates_min = (0.0, 0.0)
76
coordinates_max = (40.0 / 3, 40.0)
77
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max,
78
periodicity = false)
79
80
initial_condition = initial_condition_richtmyer_meshkov_instability
81
82
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg;
83
boundary_conditions = boundary_condition_slip_wall)
84
85
###############################################################################
86
# ODE solvers, callbacks etc.
87
88
tspan = (0.0, 30.0)
89
ode = semidiscretize(semi, tspan)
90
91
summary_callback = SummaryCallback()
92
93
analysis_interval = 100
94
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
95
96
alive_callback = AliveCallback(analysis_interval = analysis_interval)
97
98
save_solution = SaveSolutionCallback(interval = analysis_interval,
99
solution_variables = cons2prim)
100
101
callbacks = CallbackSet(summary_callback,
102
analysis_callback,
103
save_solution,
104
alive_callback)
105
106
###############################################################################
107
# run the simulation
108
109
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-5, reltol = 1.0e-5,
110
adaptive = true, dt = 1e-2,
111
ode_default_options()..., callback = callbacks)
112
113