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