Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/equations/compressible_navier_stokes.jl
5586 views
1
2
# Compressible Navier-Stokes equations
3
abstract type AbstractCompressibleNavierStokesDiffusion{NDIMS, NVARS, GradientVariables} <:
4
AbstractEquationsParabolic{NDIMS, NVARS, GradientVariables} end
5
6
# This enables "forwarded" accesses to e.g.`equations_parabolic.gamma` of the "underlying" `equations_hyperbolic`
7
# while keeping direct access to parabolic-specific fields like `mu` or `kappa`.
8
@inline function Base.getproperty(equations_parabolic::AbstractCompressibleNavierStokesDiffusion,
9
field::Symbol)
10
if field === :gamma || field === :inv_gamma_minus_one
11
return getproperty(getfield(equations_parabolic, :equations_hyperbolic), field)
12
else
13
return getfield(equations_parabolic, field)
14
end
15
end
16
17
# Provide property names for e.g. tab-completion by combining
18
# the names from the underlying hyperbolic equations with the fields of this parabolic part.
19
@inline function Base.propertynames(equations_parabolic::AbstractCompressibleNavierStokesDiffusion,
20
private::Bool = false)
21
names_hyp = (:gamma, :inv_gamma_minus_one)
22
names_para = fieldnames(typeof(equations_parabolic))
23
names_hyp_para = (names_hyp..., names_para...)
24
25
return names_hyp_para
26
end
27
28
# TODO: can we generalize this to V(R)-MHD?
29
"""
30
struct BoundaryConditionNavierStokesWall
31
32
Creates a wall-type boundary conditions for the compressible Navier-Stokes equations, see
33
[`CompressibleNavierStokesDiffusion1D`](@ref), [`CompressibleNavierStokesDiffusion2D`](@ref), and
34
[`CompressibleNavierStokesDiffusion3D`](@ref).
35
The fields `boundary_condition_velocity` and `boundary_condition_heat_flux` are intended
36
to be boundary condition types such as the [`NoSlip`](@ref) velocity boundary condition and the
37
[`Adiabatic`](@ref) or [`Isothermal`](@ref) heat boundary condition.
38
"""
39
struct BoundaryConditionNavierStokesWall{V, H}
40
boundary_condition_velocity::V
41
boundary_condition_heat_flux::H
42
end
43
44
"""
45
struct NoSlip
46
47
Use to create a no-slip boundary condition with [`BoundaryConditionNavierStokesWall`](@ref).
48
The field `boundary_value_function` should be a function with signature
49
`boundary_value_function(x, t, equations)` and return a `SVector{NDIMS}`
50
whose entries are the velocity vector at a point `x` and time `t`.
51
"""
52
struct NoSlip{F}
53
boundary_value_function::F # value of the velocity vector on the boundary
54
end
55
56
"""
57
struct Slip
58
59
Creates a symmetric velocity boundary condition which eliminates any normal velocity gradients across the boundary, i.e.,
60
allows only the tangential velocity gradients to be non-zero.
61
When combined with the heat boundary condition [`Adiabatic`](@ref), this creates a truly symmetric boundary condition.
62
Any boundary on which this combined boundary condition is applied thus acts as a symmetry plane for the flow.
63
In contrast to the [`NoSlip`](@ref) boundary condition, `Slip` does not require a function to be supplied.
64
65
The (purely) hyperbolic equivalent boundary condition is [`boundary_condition_slip_wall`](@ref) which
66
permits only tangential velocities.
67
68
This boundary condition can also be employed as a reflective wall.
69
70
Note that in 1D this degenerates to the [`NoSlip`](@ref) boundary condition which must be used instead.
71
72
!!! note
73
Currently this (velocity) boundary condition is only implemented for
74
[`P4estMesh`](@ref) and [`GradientVariablesPrimitive`](@ref).
75
"""
76
struct Slip end
77
78
"""
79
struct Isothermal
80
81
Used to create a no-slip boundary condition with [`BoundaryConditionNavierStokesWall`](@ref).
82
The field `boundary_value_function` should be a function with signature
83
`boundary_value_function(x, t, equations)` and return a scalar value for the
84
temperature at point `x` and time `t`.
85
"""
86
struct Isothermal{F}
87
boundary_value_function::F # value of the temperature on the boundary
88
end
89
90
"""
91
struct Adiabatic
92
93
Used to create a no-slip boundary condition with [`BoundaryConditionNavierStokesWall`](@ref).
94
The field `boundary_value_normal_flux_function` should be a function with signature
95
`boundary_value_normal_flux_function(x, t, equations)` and return a scalar value for the
96
normal heat flux at point `x` and time `t`.
97
"""
98
struct Adiabatic{F}
99
boundary_value_normal_flux_function::F # scaled heat flux 1/T * kappa * dT/dn
100
end
101
102
"""
103
`GradientVariablesPrimitive` is a gradient variable type parameter for the [`CompressibleNavierStokesDiffusion1D`](@ref),
104
[`CompressibleNavierStokesDiffusion2D`](@ref), and [`CompressibleNavierStokesDiffusion3D`](@ref).
105
The other available gradient variable type parameter is [`GradientVariablesEntropy`](@ref).
106
By default, the gradient variables are set to be `GradientVariablesPrimitive`.
107
"""
108
struct GradientVariablesPrimitive end
109
110
"""
111
`GradientVariablesEntropy` is a gradient variable type parameter for the [`CompressibleNavierStokesDiffusion1D`](@ref),
112
[`CompressibleNavierStokesDiffusion2D`](@ref), and [`CompressibleNavierStokesDiffusion3D`](@ref).
113
The other available gradient variable type parameter is [`GradientVariablesPrimitive`](@ref).
114
115
Specifying `GradientVariablesEntropy` uses the entropy variable formulation from
116
- Hughes, Mallet, Franca (1986)
117
A new finite element formulation for computational fluid dynamics: I. Symmetric forms of the
118
compressible Euler and Navier-Stokes equations and the second law of thermodynamics.
119
[https://doi.org/10.1016/0045-7825(86)90127-1](https://doi.org/10.1016/0045-7825(86)90127-1)
120
121
Under `GradientVariablesEntropy`, the Navier-Stokes discretization is provably entropy stable.
122
"""
123
struct GradientVariablesEntropy end
124
125
"""
126
dynamic_viscosity(u, equations)
127
128
Wrapper for the dynamic viscosity that calls
129
`dynamic_viscosity(u, equations.mu, equations)`, which dispatches on the type of
130
`equations.mu`.
131
For constant `equations.mu`, i.e., `equations.mu` is of `Real`-type it is returned directly.
132
In all other cases, `equations.mu` is assumed to be a function with arguments
133
`u` and `equations` and is called with these arguments.
134
"""
135
dynamic_viscosity(u, equations) = dynamic_viscosity(u, equations.mu, equations)
136
dynamic_viscosity(u, mu::Real, equations) = mu
137
dynamic_viscosity(u, mu::T, equations) where {T} = mu(u, equations)
138
139
"""
140
have_constant_diffusivity(::AbstractCompressibleNavierStokesDiffusion)
141
142
# Returns
143
- `False()`
144
145
Used in parabolic CFL condition computation (see [`StepsizeCallback`](@ref)) to indicate that the
146
diffusivity is not constant in space and that [`max_diffusivity`](@ref) needs to be computed
147
at every node in every element.
148
149
Also employed in [`linear_structure`](@ref) and [`linear_structure_parabolic`](@ref) to check
150
if the diffusion term is linear in the variables/constant.
151
"""
152
@inline have_constant_diffusivity(::AbstractCompressibleNavierStokesDiffusion) = False()
153
154
include("compressible_navier_stokes_1d.jl")
155
include("compressible_navier_stokes_2d.jl")
156
include("compressible_navier_stokes_3d.jl")
157
158