Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_2d_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 = CompressibleEulerEquations2D(1.4)
8
9
"""
10
initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D)
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::CompressibleEulerEquations2D)
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, 0)
22
x_norm = x[1] - inicenter[1]
23
y_norm = x[2] - inicenter[2]
24
r = sqrt(x_norm^2 + y_norm^2)
25
phi = atan(y_norm, x_norm)
26
sin_phi, cos_phi = sincos(phi)
27
28
# Calculate primitive variables
29
rho = r > 0.5f0 ? one(RealT) : RealT(1.1691)
30
v1 = r > 0.5f0 ? zero(RealT) : RealT(0.1882) * cos_phi
31
v2 = r > 0.5f0 ? zero(RealT) : RealT(0.1882) * sin_phi
32
p = r > 0.5f0 ? RealT(1.0E-3) : RealT(1.245)
33
34
return prim2cons(SVector(rho, v1, v2, p), equations)
35
end
36
initial_condition = initial_condition_blast_wave
37
38
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
39
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
40
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
41
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
42
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
43
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
44
# `StepsizeCallback` (CFL-Condition) and less diffusion.
45
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
46
volume_flux = flux_ranocha
47
basis = LobattoLegendreBasis(3)
48
indicator_sc = IndicatorHennemannGassner(equations, basis,
49
alpha_max = 0.5,
50
alpha_min = 0.001,
51
alpha_smooth = true,
52
variable = density_pressure)
53
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
54
volume_flux_dg = volume_flux,
55
volume_flux_fv = surface_flux)
56
solver = DGSEM(basis, surface_flux, volume_integral)
57
58
coordinates_min = (-2.0, -2.0)
59
coordinates_max = (2.0, 2.0)
60
mesh = TreeMesh(coordinates_min, coordinates_max,
61
initial_refinement_level = 6,
62
n_cells_max = 10_000)
63
64
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
65
66
###############################################################################
67
# ODE solvers, callbacks etc.
68
69
tspan = (0.0, 12.5)
70
ode = semidiscretize(semi, tspan)
71
72
summary_callback = SummaryCallback()
73
74
analysis_interval = 100
75
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
76
77
alive_callback = AliveCallback(analysis_interval = analysis_interval)
78
79
save_solution = SaveSolutionCallback(interval = 100,
80
save_initial_solution = true,
81
save_final_solution = true,
82
solution_variables = cons2prim)
83
84
stepsize_callback = StepsizeCallback(cfl = 0.9)
85
86
callbacks = CallbackSet(summary_callback,
87
analysis_callback, alive_callback,
88
save_solution,
89
stepsize_callback)
90
91
###############################################################################
92
# run the simulation
93
94
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
95
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
96
ode_default_options()..., callback = callbacks);
97
98