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_NACA0012airfoil_mach08.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
# Laminar transonic flow around a NACA0012 airfoil.
8
9
# This test is taken from the paper of Swanson and Langer. The values for the drag and lift coefficients
10
# from Case 5 in Table 3 are used to validate the scheme and computation of surface forces.
11
12
# References:
13
# - Roy Charles Swanson, Stefan Langer (2016)
14
# Structured and Unstructured Grid Methods (2016)
15
# [https://ntrs.nasa.gov/citations/20160003623] (https://ntrs.nasa.gov/citations/20160003623)
16
# - Deep Ray, Praveen Chandrashekar (2017)
17
# An entropy stable finite volume scheme for the
18
# two dimensional Navier–Stokes equations on triangular grids
19
# [DOI:10.1016/j.amc.2017.07.020](https://doi.org/10.1016/j.amc.2017.07.020)
20
21
equations = CompressibleEulerEquations2D(1.4)
22
23
prandtl_number() = 0.72
24
mu() = 0.0031959974968701088
25
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(),
26
Prandtl = prandtl_number())
27
28
rho_inf() = 1.0
29
p_inf() = 2.85
30
aoa() = 10.0 * pi / 180.0 # 10 degree angle of attack
31
l_inf() = 1.0
32
mach_inf() = 0.8
33
u_inf(equations) = mach_inf() * sqrt(equations.gamma * p_inf() / rho_inf())
34
@inline function initial_condition_mach08_flow(x, t, equations)
35
# set the freestream flow parameters
36
gamma = equations.gamma
37
u_inf = mach_inf() * sqrt(gamma * p_inf() / rho_inf())
38
39
v1 = u_inf * cos(aoa())
40
v2 = u_inf * sin(aoa())
41
42
prim = SVector(rho_inf(), v1, v2, p_inf())
43
return prim2cons(prim, equations)
44
end
45
46
initial_condition = initial_condition_mach08_flow
47
48
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
49
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
50
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
51
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
52
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
53
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
54
# `StepsizeCallback` (CFL-Condition) and less diffusion.
55
surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)
56
57
polydeg = 3
58
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux)
59
60
mesh_file = Trixi.download("https://gist.githubusercontent.com/Arpit-Babbar/339662b4b46164a016e35c81c66383bb/raw/8bf94f5b426ba907ace87405cfcc1dcc2ef7cbda/NACA0012.inp",
61
joinpath(@__DIR__, "NACA0012.inp"))
62
63
mesh = P4estMesh{2}(mesh_file, initial_refinement_level = 1)
64
65
# The boundary values across outer boundary are constant but subsonic, so we cannot compute the
66
# boundary flux from the external information alone. Thus, we use the numerical flux to distinguish
67
# between inflow and outflow characteristics
68
@inline function boundary_condition_subsonic_constant(u_inner,
69
normal_direction::AbstractVector, x,
70
t,
71
surface_flux_function,
72
equations::CompressibleEulerEquations2D)
73
u_boundary = initial_condition_mach08_flow(x, t, equations)
74
75
return flux_hll(u_inner, u_boundary, normal_direction, equations)
76
end
77
78
boundary_conditions = Dict(:Left => boundary_condition_subsonic_constant,
79
:Right => boundary_condition_subsonic_constant,
80
:Top => boundary_condition_subsonic_constant,
81
:Bottom => boundary_condition_subsonic_constant,
82
:AirfoilBottom => boundary_condition_slip_wall,
83
:AirfoilTop => boundary_condition_slip_wall)
84
85
velocity_airfoil = NoSlip((x, t, equations_parabolic) -> SVector(0.0, 0.0))
86
87
heat_airfoil = Adiabatic((x, t, equations_parabolic) -> 0.0)
88
89
boundary_conditions_airfoil = BoundaryConditionNavierStokesWall(velocity_airfoil,
90
heat_airfoil)
91
92
function velocities_initial_condition_mach08_flow(x, t, equations)
93
u_cons = initial_condition_mach08_flow(x, t, equations)
94
return SVector(u_cons[2] / u_cons[1], u_cons[3] / u_cons[1])
95
end
96
97
velocity_bc_square = NoSlip((x, t, equations_parabolic) -> velocities_initial_condition_mach08_flow(x,
98
t,
99
equations))
100
101
heat_bc_square = Adiabatic((x, t, equations_parabolic) -> 0.0)
102
boundary_condition_square = BoundaryConditionNavierStokesWall(velocity_bc_square,
103
heat_bc_square)
104
105
boundary_conditions_parabolic = Dict(:Left => boundary_condition_square,
106
:Right => boundary_condition_square,
107
:Top => boundary_condition_square,
108
:Bottom => boundary_condition_square,
109
:AirfoilBottom => boundary_conditions_airfoil,
110
:AirfoilTop => boundary_conditions_airfoil)
111
112
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
113
initial_condition, solver;
114
boundary_conditions = (boundary_conditions,
115
boundary_conditions_parabolic))
116
117
###############################################################################
118
# ODE solvers
119
120
# Run for a long time to reach a state where forces stabilize up to 3 digits
121
tspan = (0.0, 10.0)
122
ode = semidiscretize(semi, tspan)
123
124
# Callbacks
125
126
summary_callback = SummaryCallback()
127
128
analysis_interval = 2000
129
130
force_boundary_names = (:AirfoilBottom, :AirfoilTop)
131
drag_coefficient = AnalysisSurfaceIntegral(force_boundary_names,
132
DragCoefficientPressure2D(aoa(), rho_inf(),
133
u_inf(equations),
134
l_inf()))
135
136
lift_coefficient = AnalysisSurfaceIntegral(force_boundary_names,
137
LiftCoefficientPressure2D(aoa(), rho_inf(),
138
u_inf(equations),
139
l_inf()))
140
141
drag_coefficient_shear_force = AnalysisSurfaceIntegral(force_boundary_names,
142
DragCoefficientShearStress2D(aoa(),
143
rho_inf(),
144
u_inf(equations),
145
l_inf()))
146
147
lift_coefficient_shear_force = AnalysisSurfaceIntegral(force_boundary_names,
148
LiftCoefficientShearStress2D(aoa(),
149
rho_inf(),
150
u_inf(equations),
151
l_inf()))
152
153
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
154
output_directory = "out",
155
save_analysis = true,
156
analysis_errors = Symbol[],
157
analysis_integrals = (drag_coefficient,
158
lift_coefficient,
159
drag_coefficient_shear_force,
160
lift_coefficient_shear_force))
161
162
alive_callback = AliveCallback(analysis_interval = analysis_interval)
163
164
save_solution = SaveSolutionCallback(interval = 500,
165
save_initial_solution = true,
166
save_final_solution = true,
167
solution_variables = cons2prim)
168
169
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)
170
171
###############################################################################
172
# run the simulation
173
174
sol = solve(ode, RDPK3SpFSAL49(thread = Trixi.True());
175
abstol = 1e-8, reltol = 1e-8,
176
ode_default_options()..., callback = callbacks)
177
178