Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_3d_dgsem/elixir_euler_sedov.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations3D(1.4)
8
9
"""
10
initial_condition_medium_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D)
11
12
The Sedov blast wave setup based on Flash
13
- https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000
14
with smaller strength of the initial discontinuity.
15
"""
16
function initial_condition_medium_sedov_blast_wave(x, t,
17
equations::CompressibleEulerEquations3D)
18
# Set up polar coordinates
19
inicenter = SVector(0.0, 0.0, 0.0)
20
x_norm = x[1] - inicenter[1]
21
y_norm = x[2] - inicenter[2]
22
z_norm = x[3] - inicenter[3]
23
r = sqrt(x_norm^2 + y_norm^2 + z_norm^2)
24
25
# Setup based on https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000
26
r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6)
27
E = 1.0
28
p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2)
29
p0_outer = 1.0e-3
30
31
# Calculate primitive variables
32
rho = 1.0
33
v1 = 0.0
34
v2 = 0.0
35
v3 = 0.0
36
p = r > r0 ? p0_outer : p0_inner
37
38
return prim2cons(SVector(rho, v1, v2, v3, p), equations)
39
end
40
41
initial_condition = initial_condition_medium_sedov_blast_wave
42
43
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
44
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
45
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
46
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
47
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
48
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
49
# `StepsizeCallback` (CFL-Condition) and less diffusion.
50
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
51
volume_flux = flux_ranocha
52
polydeg = 3
53
basis = LobattoLegendreBasis(polydeg)
54
indicator_sc = IndicatorHennemannGassner(equations, basis,
55
alpha_max = 1.0,
56
alpha_min = 0.001,
57
alpha_smooth = true,
58
variable = density_pressure)
59
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
60
volume_flux_dg = volume_flux,
61
volume_flux_fv = surface_flux)
62
63
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
64
volume_integral = volume_integral)
65
66
# Mapping as described in https://arxiv.org/abs/2012.12040
67
function mapping(xi, eta, zeta)
68
y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta))
69
70
x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta))
71
72
z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta))
73
74
return SVector(x, y, z)
75
end
76
77
cells_per_dimension = (4, 4, 4)
78
79
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
80
81
# create the semi discretization object
82
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
83
84
###############################################################################
85
# ODE solvers, callbacks etc.
86
87
tspan = (0.0, 12.5)
88
ode = semidiscretize(semi, tspan)
89
90
summary_callback = SummaryCallback()
91
92
analysis_interval = 100
93
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
94
95
alive_callback = AliveCallback(analysis_interval = analysis_interval)
96
97
save_solution = SaveSolutionCallback(interval = 100,
98
save_initial_solution = true,
99
save_final_solution = true)
100
101
stepsize_callback = StepsizeCallback(cfl = 0.5)
102
103
callbacks = CallbackSet(summary_callback,
104
analysis_callback,
105
alive_callback,
106
save_solution,
107
stepsize_callback)
108
109
###############################################################################
110
# run the simulation
111
112
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
113
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
114
ode_default_options()..., callback = callbacks);
115
116