Path: blob/main/src/equations/compressible_navier_stokes.jl
5586 views
1# Compressible Navier-Stokes equations2abstract type AbstractCompressibleNavierStokesDiffusion{NDIMS, NVARS, GradientVariables} <:3AbstractEquationsParabolic{NDIMS, NVARS, GradientVariables} end45# This enables "forwarded" accesses to e.g.`equations_parabolic.gamma` of the "underlying" `equations_hyperbolic`6# while keeping direct access to parabolic-specific fields like `mu` or `kappa`.7@inline function Base.getproperty(equations_parabolic::AbstractCompressibleNavierStokesDiffusion,8field::Symbol)9if field === :gamma || field === :inv_gamma_minus_one10return getproperty(getfield(equations_parabolic, :equations_hyperbolic), field)11else12return getfield(equations_parabolic, field)13end14end1516# Provide property names for e.g. tab-completion by combining17# the names from the underlying hyperbolic equations with the fields of this parabolic part.18@inline function Base.propertynames(equations_parabolic::AbstractCompressibleNavierStokesDiffusion,19private::Bool = false)20names_hyp = (:gamma, :inv_gamma_minus_one)21names_para = fieldnames(typeof(equations_parabolic))22names_hyp_para = (names_hyp..., names_para...)2324return names_hyp_para25end2627# TODO: can we generalize this to V(R)-MHD?28"""29struct BoundaryConditionNavierStokesWall3031Creates a wall-type boundary conditions for the compressible Navier-Stokes equations, see32[`CompressibleNavierStokesDiffusion1D`](@ref), [`CompressibleNavierStokesDiffusion2D`](@ref), and33[`CompressibleNavierStokesDiffusion3D`](@ref).34The fields `boundary_condition_velocity` and `boundary_condition_heat_flux` are intended35to be boundary condition types such as the [`NoSlip`](@ref) velocity boundary condition and the36[`Adiabatic`](@ref) or [`Isothermal`](@ref) heat boundary condition.37"""38struct BoundaryConditionNavierStokesWall{V, H}39boundary_condition_velocity::V40boundary_condition_heat_flux::H41end4243"""44struct NoSlip4546Use to create a no-slip boundary condition with [`BoundaryConditionNavierStokesWall`](@ref).47The field `boundary_value_function` should be a function with signature48`boundary_value_function(x, t, equations)` and return a `SVector{NDIMS}`49whose entries are the velocity vector at a point `x` and time `t`.50"""51struct NoSlip{F}52boundary_value_function::F # value of the velocity vector on the boundary53end5455"""56struct Slip5758Creates a symmetric velocity boundary condition which eliminates any normal velocity gradients across the boundary, i.e.,59allows only the tangential velocity gradients to be non-zero.60When combined with the heat boundary condition [`Adiabatic`](@ref), this creates a truly symmetric boundary condition.61Any boundary on which this combined boundary condition is applied thus acts as a symmetry plane for the flow.62In contrast to the [`NoSlip`](@ref) boundary condition, `Slip` does not require a function to be supplied.6364The (purely) hyperbolic equivalent boundary condition is [`boundary_condition_slip_wall`](@ref) which65permits only tangential velocities.6667This boundary condition can also be employed as a reflective wall.6869Note that in 1D this degenerates to the [`NoSlip`](@ref) boundary condition which must be used instead.7071!!! note72Currently this (velocity) boundary condition is only implemented for73[`P4estMesh`](@ref) and [`GradientVariablesPrimitive`](@ref).74"""75struct Slip end7677"""78struct Isothermal7980Used to create a no-slip boundary condition with [`BoundaryConditionNavierStokesWall`](@ref).81The field `boundary_value_function` should be a function with signature82`boundary_value_function(x, t, equations)` and return a scalar value for the83temperature at point `x` and time `t`.84"""85struct Isothermal{F}86boundary_value_function::F # value of the temperature on the boundary87end8889"""90struct Adiabatic9192Used to create a no-slip boundary condition with [`BoundaryConditionNavierStokesWall`](@ref).93The field `boundary_value_normal_flux_function` should be a function with signature94`boundary_value_normal_flux_function(x, t, equations)` and return a scalar value for the95normal heat flux at point `x` and time `t`.96"""97struct Adiabatic{F}98boundary_value_normal_flux_function::F # scaled heat flux 1/T * kappa * dT/dn99end100101"""102`GradientVariablesPrimitive` is a gradient variable type parameter for the [`CompressibleNavierStokesDiffusion1D`](@ref),103[`CompressibleNavierStokesDiffusion2D`](@ref), and [`CompressibleNavierStokesDiffusion3D`](@ref).104The other available gradient variable type parameter is [`GradientVariablesEntropy`](@ref).105By default, the gradient variables are set to be `GradientVariablesPrimitive`.106"""107struct GradientVariablesPrimitive end108109"""110`GradientVariablesEntropy` is a gradient variable type parameter for the [`CompressibleNavierStokesDiffusion1D`](@ref),111[`CompressibleNavierStokesDiffusion2D`](@ref), and [`CompressibleNavierStokesDiffusion3D`](@ref).112The other available gradient variable type parameter is [`GradientVariablesPrimitive`](@ref).113114Specifying `GradientVariablesEntropy` uses the entropy variable formulation from115- Hughes, Mallet, Franca (1986)116A new finite element formulation for computational fluid dynamics: I. Symmetric forms of the117compressible Euler and Navier-Stokes equations and the second law of thermodynamics.118[https://doi.org/10.1016/0045-7825(86)90127-1](https://doi.org/10.1016/0045-7825(86)90127-1)119120Under `GradientVariablesEntropy`, the Navier-Stokes discretization is provably entropy stable.121"""122struct GradientVariablesEntropy end123124"""125dynamic_viscosity(u, equations)126127Wrapper for the dynamic viscosity that calls128`dynamic_viscosity(u, equations.mu, equations)`, which dispatches on the type of129`equations.mu`.130For constant `equations.mu`, i.e., `equations.mu` is of `Real`-type it is returned directly.131In all other cases, `equations.mu` is assumed to be a function with arguments132`u` and `equations` and is called with these arguments.133"""134dynamic_viscosity(u, equations) = dynamic_viscosity(u, equations.mu, equations)135dynamic_viscosity(u, mu::Real, equations) = mu136dynamic_viscosity(u, mu::T, equations) where {T} = mu(u, equations)137138"""139have_constant_diffusivity(::AbstractCompressibleNavierStokesDiffusion)140141# Returns142- `False()`143144Used in parabolic CFL condition computation (see [`StepsizeCallback`](@ref)) to indicate that the145diffusivity is not constant in space and that [`max_diffusivity`](@ref) needs to be computed146at every node in every element.147148Also employed in [`linear_structure`](@ref) and [`linear_structure_parabolic`](@ref) to check149if the diffusion term is linear in the variables/constant.150"""151@inline have_constant_diffusivity(::AbstractCompressibleNavierStokesDiffusion) = False()152153include("compressible_navier_stokes_1d.jl")154include("compressible_navier_stokes_2d.jl")155include("compressible_navier_stokes_3d.jl")156157158