Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/t8code_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 = 5
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
coordinates_min = (-1.0, -1.0, -1.0)
67
coordinates_max = (1.0, 1.0, 1.0)
68
69
trees_per_dimension = (4, 4, 4)
70
mesh = T8codeMesh(trees_per_dimension,
71
polydeg = 4, initial_refinement_level = 0,
72
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
73
periodicity = true)
74
75
# create the semi discretization object
76
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
77
78
###############################################################################
79
# ODE solvers, callbacks etc.
80
81
tspan = (0.0, 12.5)
82
ode = semidiscretize(semi, tspan)
83
84
summary_callback = SummaryCallback()
85
86
analysis_interval = 100
87
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
88
89
alive_callback = AliveCallback(analysis_interval = analysis_interval)
90
91
save_solution = SaveSolutionCallback(interval = 100,
92
save_initial_solution = true,
93
save_final_solution = true)
94
95
stepsize_callback = StepsizeCallback(cfl = 0.5)
96
97
callbacks = CallbackSet(summary_callback,
98
analysis_callback,
99
alive_callback,
100
save_solution,
101
stepsize_callback)
102
103
###############################################################################
104
# run the simulation
105
106
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
107
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
108
ode_default_options()..., callback = callbacks);
109
110