Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_3d_dgsem/elixir_navierstokes_crm.jl
5586 views
1
using OrdinaryDiffEqSSPRK
2
using Trixi
3
4
# CRM = Common Research Model
5
# https://doi.org/10.2514/6.2008-6919
6
###############################################################################
7
8
gamma = 1.4
9
prandtl_number() = 0.72
10
11
# Follows problem C3.5 of the 2015 Third International Workshop on High-Order CFD Methods
12
# https://www1.grc.nasa.gov/research-and-engineering/hiocfd/
13
14
#Re = 5 * 10^6 # C3.5 testcase
15
Re = 200 * 10^6 # Increase Reynolds number to 200 million (otherwise the simulation crashes immediately due to the very coarse mesh)
16
17
chord = 7.005 # m = 275.80 inches
18
19
c = 343.0 # m/s = 13504 inches/s
20
rho() = 1.293 # kg/m^3 = 2.1199e-5 kg/inches^3
21
22
p() = c^2 * rho() / gamma
23
M = 0.85
24
U() = M * c
25
26
mu() = rho() * chord * U() / Re
27
28
equations = CompressibleEulerEquations3D(gamma)
29
equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(),
30
Prandtl = prandtl_number())
31
32
@inline function initial_condition(x, t, equations)
33
# set the freestream flow parameters
34
rho_freestream = 1.293
35
36
v1 = 291.55 # = M * c
37
v2 = 0.0
38
v3 = 0.0
39
40
p_freestream = 108657.255 # = c^2 * rho() / gamma
41
42
prim = SVector(rho_freestream, v1, v2, v3, p_freestream)
43
return prim2cons(prim, equations)
44
end
45
46
bc_farfield = BoundaryConditionDirichlet(initial_condition)
47
48
polydeg = 2
49
basis = LobattoLegendreBasis(polydeg)
50
51
shock_indicator = IndicatorHennemannGassner(equations, basis,
52
alpha_max = 0.5,
53
alpha_min = 0.001,
54
alpha_smooth = true,
55
variable = pressure)
56
57
surface_flux = flux_hll
58
volume_flux = flux_ranocha
59
60
volume_integral = VolumeIntegralShockCapturingHG(shock_indicator;
61
volume_flux_dg = volume_flux,
62
volume_flux_fv = surface_flux)
63
64
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
65
volume_integral = volume_integral)
66
67
# This is an extremely coarse mesh with only ~79k cells, thus way too coarse for real simulations.
68
# The mesh is further truncated to linear elements from third-order elements.
69
mesh_file = Trixi.download("https://gist.githubusercontent.com/DanielDoehring/fbc9d785909263ffec76983c4d520fe3/raw/68741ba6c6965b2045af04323bf73df9dab6ed6d/CRM_HIOCFD_2015_meters.inp",
70
joinpath(@__DIR__, "CRM_HIOCFD_2015_meters.inp"))
71
72
boundary_symbols = [:SYMMETRY,
73
:FARFIELD, :OUTFLOW,
74
:WING, :FUSELAGE, :WING_UP, :WING_LO]
75
76
mesh = P4estMesh{3}(mesh_file, polydeg = polydeg, boundary_symbols = boundary_symbols)
77
78
boundary_conditions_hyp = (; SYMMETRY = boundary_condition_slip_wall, # slip wall allows for tangential velocity => Sufficient for symmetry
79
FARFIELD = bc_farfield,
80
OUTFLOW = bc_farfield, # We also use farfield for "outflow" boundary
81
WING = boundary_condition_slip_wall,
82
FUSELAGE = boundary_condition_slip_wall,
83
WING_UP = boundary_condition_slip_wall,
84
WING_LO = boundary_condition_slip_wall)
85
86
velocity_bc_plane = NoSlip((x, t, equations) -> SVector(0.0, 0.0, 0.0))
87
heat_bc = Adiabatic((x, t, equations) -> 0.0)
88
bc_body = BoundaryConditionNavierStokesWall(velocity_bc_plane, heat_bc)
89
90
# The "Slip" boundary condition rotates all velocities into tangential direction
91
# and thus acts as a symmetry plane.
92
bc_symmetry_plane = BoundaryConditionNavierStokesWall(Slip(), heat_bc)
93
94
boundary_conditions_para = (; SYMMETRY = bc_symmetry_plane,
95
FARFIELD = bc_farfield,
96
OUTFLOW = bc_farfield, # We also use farfield for "outflow" boundary
97
WING = bc_body,
98
FUSELAGE = bc_body,
99
WING_UP = bc_body,
100
WING_LO = bc_body)
101
102
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
103
initial_condition, solver;
104
boundary_conditions = (boundary_conditions_hyp,
105
boundary_conditions_para))
106
107
tspan = (0.0, 1.5e-5)
108
ode = semidiscretize(semi, tspan)
109
110
###############################################################################
111
112
summary_callback = SummaryCallback()
113
114
analysis_interval = 1000
115
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
116
analysis_errors = Symbol[],
117
analysis_integrals = ())
118
119
alive_callback = AliveCallback(alive_interval = 10)
120
121
save_sol_interval = 5000
122
save_solution = SaveSolutionCallback(interval = save_sol_interval,
123
save_initial_solution = false,
124
save_final_solution = true,
125
solution_variables = cons2prim,
126
output_directory = "out")
127
128
save_restart = SaveRestartCallback(interval = save_sol_interval,
129
save_final_restart = true,
130
output_directory = "out")
131
132
cfl = 0.4
133
stepsize_callback = StepsizeCallback(cfl = cfl, interval = 5)
134
135
callbacks = CallbackSet(summary_callback,
136
alive_callback,
137
analysis_callback,
138
save_solution,
139
save_restart,
140
stepsize_callback)
141
142
###############################################################################
143
144
sol = solve(ode, SSPRK33(), dt = 42.0,
145
save_everystep = false, callback = callbacks);
146
147