Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_2d_dgsem/elixir_navierstokes_blast_reflective.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the ideal compressible Navier-Stokes equations
6
7
prandtl_number() = 0.72
8
mu() = 1e-4
9
10
equations = CompressibleEulerEquations2D(1.4)
11
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(),
12
Prandtl = prandtl_number())
13
14
function initial_condition_weak_blast_wave(x, t, equations::CompressibleEulerEquations2D)
15
# Set up polar coordinates
16
inicenter = SVector(0.0, 0.0)
17
x_norm = x[1] - inicenter[1]
18
y_norm = x[2] - inicenter[2]
19
r = sqrt(x_norm^2 + y_norm^2)
20
21
r0 = 0.2
22
E = 1
23
p0_inner = 3
24
p0_outer = 1
25
26
# Calculate primitive variables
27
rho = 1.1
28
v1 = 0.0
29
v2 = 0.0
30
p = r > r0 ? p0_outer : p0_inner
31
32
return prim2cons(SVector(rho, v1, v2, p), equations)
33
end
34
initial_condition = initial_condition_weak_blast_wave
35
36
surface_flux = flux_hlle
37
volume_flux = flux_ranocha
38
polydeg = 4
39
basis = LobattoLegendreBasis(polydeg)
40
indicator_sc = IndicatorHennemannGassner(equations, basis,
41
alpha_max = 1.0,
42
alpha_min = 0.001,
43
alpha_smooth = true,
44
variable = density_pressure)
45
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
46
volume_flux_dg = volume_flux,
47
volume_flux_fv = surface_flux)
48
49
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
50
volume_integral = volume_integral)
51
52
# Realize reflective walls via slip walls which permit only tangential velocity
53
boundary_conditions = Dict(:x_neg => boundary_condition_slip_wall,
54
:y_neg => boundary_condition_slip_wall,
55
:y_pos => boundary_condition_slip_wall,
56
:x_pos => boundary_condition_slip_wall)
57
58
# The "Slip" boundary condition rotates all velocities into tangential direction
59
# and thus acts as a reflective wall here.
60
velocity_bc = Slip()
61
heat_bc = Adiabatic((x, t, equations_parabolic) -> zero(eltype(x)))
62
boundary_conditions_visc = BoundaryConditionNavierStokesWall(velocity_bc, heat_bc)
63
64
boundary_conditions_parabolic = Dict(:x_neg => boundary_conditions_visc,
65
:x_pos => boundary_conditions_visc,
66
:y_neg => boundary_conditions_visc,
67
:y_pos => boundary_conditions_visc)
68
69
###############################################################################
70
71
coordinates_min = (-1.0, -1.0)
72
coordinates_max = (1.0, 1.0)
73
74
trees_per_dimension = (4, 4)
75
mesh = P4estMesh(trees_per_dimension,
76
polydeg = 1, initial_refinement_level = 3,
77
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
78
periodicity = false)
79
80
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
81
initial_condition, solver;
82
boundary_conditions = (boundary_conditions,
83
boundary_conditions_parabolic))
84
85
###############################################################################
86
87
tspan = (0.0, 0.7)
88
ode = semidiscretize(semi, tspan)
89
90
summary_callback = SummaryCallback()
91
92
analysis_interval = 300
93
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
94
95
alive_callback = AliveCallback(analysis_interval = analysis_interval)
96
97
callbacks = CallbackSet(summary_callback,
98
analysis_callback,
99
alive_callback)
100
101
callbacks = CallbackSet(summary_callback,
102
analysis_callback,
103
alive_callback)
104
105
###############################################################################
106
107
# 5th-order RKM optimized for compressible Navier-Stokes equations, see also
108
# https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Low-Storage-Methods
109
ode_alg = CKLLSRK65_4M_4R()
110
111
abstol = 1e-6
112
reltol = 1e-4
113
sol = solve(ode, ode_alg; abstol = abstol, reltol = reltol,
114
ode_default_options()..., callback = callbacks);
115
116