Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_3d_dgsem/elixir_euler_sedov_scO2.jl
5586 views
1
using OrdinaryDiffEqSSPRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations3D(1.4)
8
9
"""
10
initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D)
11
12
The Sedov blast wave setup based on example 35.1.4 from Flash
13
- https://flash.rochester.edu/site/flashcode/user_support/flash4_ug_4p8.pdf
14
"""
15
function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D)
16
# Set up polar coordinates
17
RealT = eltype(x)
18
inicenter = SVector(0, 0, 0)
19
x_norm = x[1] - inicenter[1]
20
y_norm = x[2] - inicenter[2]
21
z_norm = x[3] - inicenter[3]
22
r = sqrt(x_norm^2 + y_norm^2 + z_norm^2)
23
24
# Setup based on example 35.1.4 in https://flash.rochester.edu/site/flashcode/user_support/flash4_ug_4p8.pdf
25
r0 = 0.21875f0 # = 3.5 * smallest dx (for domain length=4 and max-ref=6)
26
E = 1
27
nu = 3 # dims
28
p0_inner = 3 * (equations.gamma - 1) * E / ((nu + 1) * convert(RealT, pi) * r0^nu)
29
p0_outer = convert(RealT, 1.0e-5) # = true Sedov setup
30
31
# Calculate primitive variables
32
rho = 1
33
v1 = 0
34
v2 = 0
35
v3 = 0
36
p = r > r0 ? p0_outer : p0_inner
37
38
return prim2cons(SVector(rho, v1, v2, v3, p), equations)
39
end
40
initial_condition = initial_condition_sedov_blast_wave
41
42
surface_flux = flux_lax_friedrichs
43
volume_flux = flux_chandrashekar
44
basis = LobattoLegendreBasis(3)
45
indicator_sc = IndicatorHennemannGassner(equations, basis,
46
alpha_max = 0.5,
47
alpha_min = 0.001,
48
alpha_smooth = true,
49
variable = density_pressure)
50
volume_integral = VolumeIntegralShockCapturingRRG(basis, indicator_sc;
51
volume_flux_dg = volume_flux,
52
volume_flux_fv = surface_flux,
53
slope_limiter = minmod)
54
55
solver = DGSEM(basis, surface_flux, volume_integral)
56
57
coordinates_min = (-2.0, -2.0, -2.0)
58
coordinates_max = (2.0, 2.0, 2.0)
59
mesh = TreeMesh(coordinates_min, coordinates_max,
60
initial_refinement_level = 4,
61
n_cells_max = 1_000_000, periodicity = true)
62
63
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
64
boundary_conditions = boundary_condition_periodic)
65
66
###############################################################################
67
# ODE solvers, callbacks etc.
68
69
tspan = (0.0, 1.0)
70
ode = semidiscretize(semi, tspan)
71
72
summary_callback = SummaryCallback()
73
74
analysis_interval = 1000
75
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
76
77
alive_callback = AliveCallback(alive_interval = 20)
78
79
amr_indicator = IndicatorHennemannGassner(semi,
80
alpha_max = 1.0,
81
alpha_min = 0.0,
82
alpha_smooth = false,
83
variable = density_pressure)
84
85
amr_controller = ControllerThreeLevel(semi, amr_indicator,
86
base_level = 2,
87
max_level = 6, max_threshold = 0.0003)
88
89
amr_callback = AMRCallback(semi, amr_controller,
90
interval = 2,
91
adapt_initial_condition = true,
92
adapt_initial_condition_only_refine = true)
93
94
stepsize_callback = StepsizeCallback(cfl = 0.5)
95
96
callbacks = CallbackSet(summary_callback,
97
analysis_callback, alive_callback,
98
amr_callback, stepsize_callback)
99
100
###############################################################################
101
# run the simulation
102
103
sol = solve(ode, SSPRK54(thread = Trixi.True()); dt = 1.0,
104
ode_default_options()..., callback = callbacks);
105
106