Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations1D(1.4)
8
9
"""
10
initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D)
11
12
A medium blast wave taken from
13
- Sebastian Hennemann, Gregor J. Gassner (2020)
14
A provably entropy stable subcell shock capturing approach for high order split form DG
15
[arXiv: 2008.12044](https://arxiv.org/abs/2008.12044)
16
"""
17
function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D)
18
# Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave"
19
# Set up polar coordinates
20
RealT = eltype(x)
21
inicenter = SVector(0)
22
x_norm = x[1] - inicenter[1]
23
r = abs(x_norm)
24
# The following code is equivalent to
25
# phi = atan(0.0, x_norm)
26
# cos_phi = cos(phi)
27
# in 1D but faster
28
cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm)
29
30
# Calculate primitive variables
31
rho = r > 0.5f0 ? one(RealT) : RealT(1.1691)
32
v1 = r > 0.5f0 ? zero(RealT) : RealT(0.1882) * cos_phi
33
p = r > 0.5f0 ? RealT(1.0E-3) : RealT(1.245)
34
35
return prim2cons(SVector(rho, v1, p), equations)
36
end
37
initial_condition = initial_condition_blast_wave
38
39
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
40
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
41
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
42
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
43
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
44
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
45
# `StepsizeCallback` (CFL-Condition) and less diffusion.
46
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
47
volume_flux = flux_ranocha
48
basis = LobattoLegendreBasis(3)
49
indicator_sc = IndicatorHennemannGassner(equations, basis,
50
alpha_max = 0.5,
51
alpha_min = 0.001,
52
alpha_smooth = true,
53
variable = density_pressure)
54
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
55
volume_flux_dg = volume_flux,
56
volume_flux_fv = surface_flux)
57
solver = DGSEM(basis, surface_flux, volume_integral)
58
59
coordinates_min = (-2.0,)
60
coordinates_max = (2.0,)
61
mesh = TreeMesh(coordinates_min, coordinates_max,
62
initial_refinement_level = 6,
63
n_cells_max = 10_000)
64
65
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
66
67
###############################################################################
68
# ODE solvers, callbacks etc.
69
70
tspan = (0.0, 12.5)
71
ode = semidiscretize(semi, tspan)
72
73
summary_callback = SummaryCallback()
74
75
analysis_interval = 100
76
77
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
78
79
alive_callback = AliveCallback(analysis_interval = analysis_interval)
80
81
save_solution = SaveSolutionCallback(interval = 100,
82
save_initial_solution = true,
83
save_final_solution = true,
84
solution_variables = cons2prim)
85
86
stepsize_callback = StepsizeCallback(cfl = 0.5)
87
88
callbacks = CallbackSet(summary_callback,
89
analysis_callback, alive_callback,
90
save_solution,
91
stepsize_callback)
92
93
###############################################################################
94
# run the simulation
95
96
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
97
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
98
ode_default_options()..., callback = callbacks);
99
100