Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_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
- 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::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 https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.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
# Get the curved quad mesh from a mapping function
65
# Mapping as described in https://arxiv.org/abs/2012.12040
66
function mapping(xi, eta)
67
y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta))
68
69
x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y))
70
71
return SVector(x, y)
72
end
73
74
cells_per_dimension = (16, 16)
75
76
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
77
78
# create the semidiscretization
79
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
80
81
###############################################################################
82
# ODE solvers, callbacks etc.
83
84
tspan = (0.0, 12.5)
85
ode = semidiscretize(semi, tspan)
86
87
summary_callback = SummaryCallback()
88
89
analysis_interval = 300
90
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
91
92
alive_callback = AliveCallback(analysis_interval = analysis_interval)
93
94
save_solution = SaveSolutionCallback(interval = 300,
95
save_initial_solution = true,
96
save_final_solution = true)
97
98
stepsize_callback = StepsizeCallback(cfl = 0.5)
99
100
callbacks = CallbackSet(summary_callback,
101
analysis_callback,
102
alive_callback,
103
save_solution,
104
stepsize_callback)
105
106
###############################################################################
107
# run the simulation
108
109
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
110
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
111
ode_default_options()..., callback = callbacks);
112
113