Path: blob/main/examples/p4est_2d_dgsem/elixir_navierstokes_NACA0012airfoil_mach08.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible Euler equations56# Laminar transonic flow around a NACA0012 airfoil.78# This test is taken from the paper of Swanson and Langer. The values for the drag and lift coefficients9# from Case 5 in Table 3 are used to validate the scheme and computation of surface forces.1011# References:12# - Roy Charles Swanson, Stefan Langer (2016)13# Structured and Unstructured Grid Methods (2016)14# [https://ntrs.nasa.gov/citations/20160003623] (https://ntrs.nasa.gov/citations/20160003623)15# - Deep Ray, Praveen Chandrashekar (2017)16# An entropy stable finite volume scheme for the17# two dimensional Navier–Stokes equations on triangular grids18# [DOI:10.1016/j.amc.2017.07.020](https://doi.org/10.1016/j.amc.2017.07.020)1920equations = CompressibleEulerEquations2D(1.4)2122prandtl_number() = 0.7223mu() = 0.003195997496870108824equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(),25Prandtl = prandtl_number())2627rho_inf() = 1.028p_inf() = 2.8529aoa() = 10.0 * pi / 180.0 # 10 degree angle of attack30l_inf() = 1.031mach_inf() = 0.832u_inf(equations) = mach_inf() * sqrt(equations.gamma * p_inf() / rho_inf())33@inline function initial_condition_mach08_flow(x, t, equations)34# set the freestream flow parameters35gamma = equations.gamma36u_inf = mach_inf() * sqrt(gamma * p_inf() / rho_inf())3738v1 = u_inf * cos(aoa())39v2 = u_inf * sin(aoa())4041prim = SVector(rho_inf(), v1, v2, p_inf())42return prim2cons(prim, equations)43end4445initial_condition = initial_condition_mach08_flow4647# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of48# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.49# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.50# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.51# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.52# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the53# `StepsizeCallback` (CFL-Condition) and less diffusion.54surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)5556polydeg = 357solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux)5859mesh_file = Trixi.download("https://gist.githubusercontent.com/Arpit-Babbar/339662b4b46164a016e35c81c66383bb/raw/8bf94f5b426ba907ace87405cfcc1dcc2ef7cbda/NACA0012.inp",60joinpath(@__DIR__, "NACA0012.inp"))6162mesh = P4estMesh{2}(mesh_file, initial_refinement_level = 1)6364# The boundary values across outer boundary are constant but subsonic, so we cannot compute the65# boundary flux from the external information alone. Thus, we use the numerical flux to distinguish66# between inflow and outflow characteristics67@inline function boundary_condition_subsonic_constant(u_inner,68normal_direction::AbstractVector, x,69t,70surface_flux_function,71equations::CompressibleEulerEquations2D)72u_boundary = initial_condition_mach08_flow(x, t, equations)7374return flux_hll(u_inner, u_boundary, normal_direction, equations)75end7677boundary_conditions = Dict(:Left => boundary_condition_subsonic_constant,78:Right => boundary_condition_subsonic_constant,79:Top => boundary_condition_subsonic_constant,80:Bottom => boundary_condition_subsonic_constant,81:AirfoilBottom => boundary_condition_slip_wall,82:AirfoilTop => boundary_condition_slip_wall)8384velocity_airfoil = NoSlip((x, t, equations_parabolic) -> SVector(0.0, 0.0))8586heat_airfoil = Adiabatic((x, t, equations_parabolic) -> 0.0)8788boundary_conditions_airfoil = BoundaryConditionNavierStokesWall(velocity_airfoil,89heat_airfoil)9091function velocities_initial_condition_mach08_flow(x, t, equations)92u_cons = initial_condition_mach08_flow(x, t, equations)93return SVector(u_cons[2] / u_cons[1], u_cons[3] / u_cons[1])94end9596velocity_bc_square = NoSlip((x, t, equations_parabolic) -> velocities_initial_condition_mach08_flow(x,97t,98equations))99100heat_bc_square = Adiabatic((x, t, equations_parabolic) -> 0.0)101boundary_condition_square = BoundaryConditionNavierStokesWall(velocity_bc_square,102heat_bc_square)103104boundary_conditions_parabolic = Dict(:Left => boundary_condition_square,105:Right => boundary_condition_square,106:Top => boundary_condition_square,107:Bottom => boundary_condition_square,108:AirfoilBottom => boundary_conditions_airfoil,109:AirfoilTop => boundary_conditions_airfoil)110111semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),112initial_condition, solver;113boundary_conditions = (boundary_conditions,114boundary_conditions_parabolic))115116###############################################################################117# ODE solvers118119# Run for a long time to reach a state where forces stabilize up to 3 digits120tspan = (0.0, 10.0)121ode = semidiscretize(semi, tspan)122123# Callbacks124125summary_callback = SummaryCallback()126127analysis_interval = 2000128129force_boundary_names = (:AirfoilBottom, :AirfoilTop)130drag_coefficient = AnalysisSurfaceIntegral(force_boundary_names,131DragCoefficientPressure2D(aoa(), rho_inf(),132u_inf(equations),133l_inf()))134135lift_coefficient = AnalysisSurfaceIntegral(force_boundary_names,136LiftCoefficientPressure2D(aoa(), rho_inf(),137u_inf(equations),138l_inf()))139140drag_coefficient_shear_force = AnalysisSurfaceIntegral(force_boundary_names,141DragCoefficientShearStress2D(aoa(),142rho_inf(),143u_inf(equations),144l_inf()))145146lift_coefficient_shear_force = AnalysisSurfaceIntegral(force_boundary_names,147LiftCoefficientShearStress2D(aoa(),148rho_inf(),149u_inf(equations),150l_inf()))151152analysis_callback = AnalysisCallback(semi, interval = analysis_interval,153output_directory = "out",154save_analysis = true,155analysis_errors = Symbol[],156analysis_integrals = (drag_coefficient,157lift_coefficient,158drag_coefficient_shear_force,159lift_coefficient_shear_force))160161alive_callback = AliveCallback(analysis_interval = analysis_interval)162163save_solution = SaveSolutionCallback(interval = 500,164save_initial_solution = true,165save_final_solution = true,166solution_variables = cons2prim)167168callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)169170###############################################################################171# run the simulation172173sol = solve(ode, RDPK3SpFSAL49(thread = Trixi.True());174abstol = 1e-8, reltol = 1e-8,175ode_default_options()..., callback = callbacks)176177178