Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_1d_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 = CompressibleEulerEquations1D(1.4)
8
9
"""
10
initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D)
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
"""
15
function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D)
16
# Set up polar coordinates
17
inicenter = SVector(0.0)
18
x_norm = x[1] - inicenter[1]
19
r = abs(x_norm)
20
21
# Setup based on https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000
22
r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6)
23
# r0 = 0.5 # = more reasonable setup
24
E = 1.0
25
p0_inner = 6 * (equations.gamma - 1) * E / (3 * pi * r0)
26
p0_outer = 1.0e-5 # = true Sedov setup
27
28
# Calculate primitive variables
29
rho = 1.0
30
v1 = 0.0
31
p = r > r0 ? p0_outer : p0_inner
32
33
return prim2cons(SVector(rho, v1, p), equations)
34
end
35
36
initial_condition = initial_condition_sedov_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
polydeg = 3
48
basis = LobattoLegendreBasis(polydeg)
49
shock_indicator_variable = density_pressure
50
indicator_sc = IndicatorHennemannGassner(equations, basis,
51
alpha_max = 1.0,
52
alpha_min = 0.001,
53
alpha_smooth = true,
54
variable = shock_indicator_variable)
55
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
56
volume_flux_dg = volume_flux,
57
volume_flux_fv = surface_flux)
58
solver = DGSEM(basis, surface_flux, volume_integral)
59
60
cells_per_dimension = (64,)
61
coordinates_min = (-2.0,)
62
coordinates_max = (2.0,)
63
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max,
64
periodicity = true)
65
66
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
67
68
###############################################################################
69
# ODE solvers, callbacks etc.
70
71
tspan = (0.0, 12.5)
72
ode = semidiscretize(semi, tspan)
73
74
summary_callback = SummaryCallback()
75
76
analysis_interval = 1000
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,
90
alive_callback,
91
save_solution,
92
stepsize_callback)
93
94
###############################################################################
95
# run the simulation
96
97
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
98
dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback
99
ode_default_options()..., callback = callbacks);
100
101