Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_2d_fdsbp/elixir_euler_vortex.jl
2055 views
1
# !!! warning "Experimental implementation (upwind SBP)"
2
# This is an experimental feature and may change in future releases.
3
4
using OrdinaryDiffEqSSPRK
5
using Trixi
6
7
###############################################################################
8
# semidiscretization of the compressible Euler equations
9
10
equations = CompressibleEulerEquations2D(1.4)
11
12
"""
13
initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D)
14
15
The classical isentropic vortex test case of
16
- Chi-Wang Shu (1997)
17
Essentially Non-Oscillatory and Weighted Essentially Non-Oscillatory
18
Schemes for Hyperbolic Conservation Laws
19
[NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543)
20
"""
21
function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D)
22
# needs appropriate mesh size, e.g. [-10,-10]x[10,10]
23
# for error convergence: make sure that the end time is such that the is back at the initial state!!
24
# for the current velocity and domain size: t_end should be a multiple of 20s
25
# initial center of the vortex
26
inicenter = SVector(0.0, 0.0)
27
# size and strength of the vortex
28
iniamplitude = 5.0
29
# base flow
30
rho = 1.0
31
v1 = 1.0
32
v2 = 1.0
33
vel = SVector(v1, v2)
34
p = 25.0
35
rt = p / rho # ideal gas equation
36
t_loc = 0.0
37
cent = inicenter + vel * t_loc # advection of center
38
# ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!)
39
40
cent = x - cent # distance to center point
41
42
#cent=cross(iniaxis,cent) # distance to axis, tangent vector, length r
43
# cross product with iniaxis = [0, 0, 1]
44
cent = SVector(-cent[2], cent[1])
45
r2 = cent[1]^2 + cent[2]^2
46
du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation
47
dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic
48
rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1))
49
vel = vel + du * cent
50
v1, v2 = vel
51
p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1))
52
prim = SVector(rho, v1, v2, p)
53
return prim2cons(prim, equations)
54
end
55
56
initial_condition = initial_condition_isentropic_vortex
57
58
D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017,
59
derivative_order = 1,
60
accuracy_order = 4,
61
xmin = -1.0, xmax = 1.0,
62
N = 16)
63
flux_splitting = splitting_steger_warming
64
solver = FDSBP(D_upw,
65
surface_integral = SurfaceIntegralUpwind(flux_splitting),
66
volume_integral = VolumeIntegralUpwind(flux_splitting))
67
68
coordinates_min = (-10.0, -10.0)
69
coordinates_max = (10.0, 10.0)
70
mesh = TreeMesh(coordinates_min, coordinates_max,
71
initial_refinement_level = 3,
72
n_cells_max = 30_000,
73
periodicity = true)
74
75
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
76
77
###############################################################################
78
# ODE solvers, callbacks etc.
79
80
tspan = (0.0, 20.0)
81
ode = semidiscretize(semi, tspan)
82
83
summary_callback = SummaryCallback()
84
85
analysis_interval = 1000
86
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
87
88
alive_callback = AliveCallback(analysis_interval = analysis_interval)
89
90
save_solution = SaveSolutionCallback(interval = 1000,
91
save_initial_solution = true,
92
save_final_solution = true,
93
solution_variables = cons2prim)
94
95
callbacks = CallbackSet(summary_callback,
96
analysis_callback,
97
save_solution,
98
alive_callback)
99
100
###############################################################################
101
# run the simulation
102
103
sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, dt = 1e-3,
104
ode_default_options()..., callback = callbacks)
105
106