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_SD7003airfoil.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
gamma = 1.4
8
9
U_inf = 0.2
10
aoa = 4 * pi / 180
11
rho_inf = 1.4 # with gamma = 1.4 => p_inf = 1.0
12
13
Re = 10000.0
14
airfoil_cord_length = 1.0
15
16
t_c = airfoil_cord_length / U_inf
17
18
prandtl_number() = 0.72
19
mu() = rho_inf * U_inf * airfoil_cord_length / Re
20
21
equations = CompressibleEulerEquations2D(gamma)
22
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(),
23
Prandtl = prandtl_number(),
24
gradient_variables = GradientVariablesPrimitive())
25
26
@inline function initial_condition_mach02_flow(x, t, equations)
27
# set the freestream flow parameters such that c_inf = 1.0 => Mach 0.2
28
rho_freestream = 1.4
29
30
# Values correspond to `aoa = 4 * pi / 180`
31
v1 = 0.19951281005196486 # 0.2 * cos(aoa)
32
v2 = 0.01395129474882506 # 0.2 * sin(aoa)
33
34
p_freestream = 1.0
35
36
prim = SVector(rho_freestream, v1, v2, p_freestream)
37
return prim2cons(prim, equations)
38
end
39
initial_condition = initial_condition_mach02_flow
40
41
surf_flux = flux_hllc
42
vol_flux = flux_chandrashekar
43
solver = DGSEM(polydeg = 3, surface_flux = surf_flux,
44
volume_integral = VolumeIntegralFluxDifferencing(vol_flux))
45
46
###############################################################################
47
# Get the uncurved mesh from a file (downloads the file if not available locally)
48
49
# Get quadratic meshfile
50
mesh_file_name = "SD7003_2D_Quadratic.inp"
51
52
mesh_file = Trixi.download("https://gist.githubusercontent.com/DanielDoehring/bd2aa20f7e6839848476a0e87ede9f69/raw/1bc8078b4a57634819dc27010f716e68a225c9c6/SD7003_2D_Quadratic.inp",
53
joinpath(@__DIR__, mesh_file_name))
54
55
# There is also a linear mesh file available at
56
# https://gist.githubusercontent.com/DanielDoehring/375df933da8a2081f58588529bed21f0/raw/18592aa90f1c86287b4f742fd405baf55c3cf133/SD7003_2D_Linear.inp
57
58
boundary_symbols = [:Airfoil, :FarField]
59
mesh = P4estMesh{2}(mesh_file, boundary_symbols = boundary_symbols)
60
61
boundary_condition_free_stream = BoundaryConditionDirichlet(initial_condition)
62
63
velocity_bc_airfoil = NoSlip((x, t, equations) -> SVector(0.0, 0.0))
64
heat_bc = Adiabatic((x, t, equations) -> 0.0)
65
boundary_condition_airfoil = BoundaryConditionNavierStokesWall(velocity_bc_airfoil, heat_bc)
66
67
boundary_conditions_hyp = Dict(:FarField => boundary_condition_free_stream,
68
:Airfoil => boundary_condition_slip_wall)
69
70
boundary_conditions_para = Dict(:FarField => boundary_condition_free_stream,
71
:Airfoil => boundary_condition_airfoil)
72
73
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
74
initial_condition, solver;
75
boundary_conditions = (boundary_conditions_hyp,
76
boundary_conditions_para))
77
78
###############################################################################
79
# ODE solvers, callbacks etc.
80
81
# Run simulation until initial pressure wave is gone.
82
# Note: This is a very long simulation!
83
tspan = (0.0, 30 * t_c)
84
85
# Drag/Lift coefficient measurements should then be done over the 30 to 35 t_c interval
86
# by restarting the simulation.
87
88
ode = semidiscretize(semi, tspan)
89
90
summary_callback = SummaryCallback()
91
92
f_aoa() = aoa
93
f_rho_inf() = rho_inf
94
f_U_inf() = U_inf
95
f_linf() = airfoil_cord_length
96
97
force_boundary_symbol = (:Airfoil,)
98
drag_coefficient = AnalysisSurfaceIntegral(force_boundary_symbol,
99
DragCoefficientPressure2D(f_aoa(), f_rho_inf(),
100
f_U_inf(), f_linf()))
101
102
drag_coefficient_shear_force = AnalysisSurfaceIntegral(force_boundary_symbol,
103
DragCoefficientShearStress2D(f_aoa(),
104
f_rho_inf(),
105
f_U_inf(),
106
f_linf()))
107
108
lift_coefficient = AnalysisSurfaceIntegral(force_boundary_symbol,
109
LiftCoefficientPressure2D(f_aoa(), f_rho_inf(),
110
f_U_inf(), f_linf()))
111
112
# For long simulation run, use a large interval.
113
# For measurements once the simulation has settled in, one should use a
114
# significantly smaller interval, e.g. 500 to record the drag/lift coefficients.
115
analysis_interval = 10_000
116
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
117
output_directory = "out",
118
save_analysis = true,
119
analysis_errors = Symbol[], # Turn off standard errors
120
analysis_integrals = (drag_coefficient,
121
drag_coefficient_shear_force,
122
lift_coefficient))
123
124
stepsize_callback = StepsizeCallback(cfl = 2.2)
125
126
alive_callback = AliveCallback(alive_interval = 50)
127
128
save_solution = SaveSolutionCallback(interval = analysis_interval,
129
save_initial_solution = true,
130
save_final_solution = true,
131
solution_variables = cons2prim,
132
output_directory = "out")
133
134
save_restart = SaveRestartCallback(interval = analysis_interval,
135
save_final_restart = true)
136
137
callbacks = CallbackSet(summary_callback,
138
analysis_callback,
139
alive_callback,
140
stepsize_callback,
141
save_solution,
142
save_restart);
143
144
###############################################################################
145
# run the simulation
146
147
sol = solve(ode,
148
CarpenterKennedy2N54(williamson_condition = false,
149
thread = Trixi.True());
150
dt = 1.0, ode_default_options()..., callback = callbacks)
151
152