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_2d.jl
2055 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
@doc raw"""
9
CompressibleNavierStokesDiffusion2D(equations; mu, Pr,
10
gradient_variables=GradientVariablesPrimitive())
11
12
Contains the diffusion (i.e. parabolic) terms applied
13
to mass, momenta, and total energy together with the advective terms from
14
the [`CompressibleEulerEquations2D`](@ref).
15
16
- `equations`: instance of the [`CompressibleEulerEquations2D`](@ref)
17
- `mu`: dynamic viscosity,
18
- `Pr`: Prandtl number,
19
- `gradient_variables`: which variables the gradients are taken with respect to.
20
Defaults to [`GradientVariablesPrimitive()`](@ref).
21
For an entropy stable formulation, use [`GradientVariablesEntropy()`](@ref).
22
23
Fluid properties such as the dynamic viscosity ``\mu`` can be provided in any consistent unit system, e.g.,
24
[``\mu``] = kg m⁻¹ s⁻¹.
25
The viscosity ``\mu`` may be a constant or a function of the current state, e.g.,
26
depending on temperature (Sutherland's law): ``\mu = \mu(T)``.
27
In the latter case, the function `mu` needs to have the signature `mu(u, equations)`.
28
29
The particular form of the compressible Navier-Stokes implemented is
30
```math
31
\frac{\partial}{\partial t}
32
\begin{pmatrix}
33
\rho \\ \rho \mathbf{v} \\ \rho e
34
\end{pmatrix}
35
+
36
\nabla \cdot
37
\begin{pmatrix}
38
\rho \mathbf{v} \\ \rho \mathbf{v}\mathbf{v}^T + p \underline{I} \\ (\rho e + p) \mathbf{v}
39
\end{pmatrix}
40
=
41
\nabla \cdot
42
\begin{pmatrix}
43
0 \\ \underline{\tau} \\ \underline{\tau}\mathbf{v} - \mathbf{q}
44
\end{pmatrix}
45
```
46
where the system is closed with the ideal gas assumption giving
47
```math
48
p = (\gamma - 1) \left( \rho e - \frac{1}{2} \rho (v_1^2+v_2^2) \right)
49
```
50
as the pressure. The value of the adiabatic constant `gamma` is taken from the [`CompressibleEulerEquations2D`](@ref).
51
The terms on the right hand side of the system above
52
are built from the viscous stress tensor
53
```math
54
\underline{\tau} = \mu \left(\nabla\mathbf{v} + \left(\nabla\mathbf{v}\right)^T\right) - \frac{2}{3} \mu \left(\nabla\cdot\mathbf{v}\right)\underline{I}
55
```
56
where ``\underline{I}`` is the ``2\times 2`` identity matrix and the heat flux is
57
```math
58
\mathbf{q} = -\kappa\nabla\left(T\right),\quad T = \frac{p}{R\rho}
59
```
60
where ``T`` is the temperature and ``\kappa`` is the thermal conductivity for Fick's law.
61
Under the assumption that the gas has a constant Prandtl number,
62
the thermal conductivity is
63
```math
64
\kappa = \frac{\gamma \mu R}{(\gamma - 1)\textrm{Pr}}.
65
```
66
From this combination of temperature ``T`` and thermal conductivity ``\kappa`` we see
67
that the gas constant `R` cancels and the heat flux becomes
68
```math
69
\mathbf{q} = -\kappa\nabla\left(T\right) = -\frac{\gamma \mu}{(\gamma - 1)\textrm{Pr}}\nabla\left(\frac{p}{\rho}\right)
70
```
71
which is the form implemented below in the [`flux`](@ref) function.
72
73
In two spatial dimensions we require gradients for three quantities, e.g.,
74
primitive quantities
75
```math
76
\nabla v_1,\, \nabla v_2,\, \nabla T
77
```
78
or the entropy variables
79
```math
80
\nabla w_2,\, \nabla w_3,\, \nabla w_4
81
```
82
where
83
```math
84
w_2 = \frac{\rho v_1}{p},\, w_3 = \frac{\rho v_2}{p},\, w_4 = -\frac{\rho}{p}
85
```
86
"""
87
struct CompressibleNavierStokesDiffusion2D{GradientVariables, RealT <: Real, Mu,
88
E <: AbstractCompressibleEulerEquations{2}} <:
89
AbstractCompressibleNavierStokesDiffusion{2, 4, GradientVariables}
90
# TODO: parabolic
91
# 1) For now save gamma and inv(gamma-1) again, but could potentially reuse them from the Euler equations
92
# 2) Add NGRADS as a type parameter here and in AbstractEquationsParabolic, add `ngradients(...)` accessor function
93
gamma::RealT # ratio of specific heats
94
inv_gamma_minus_one::RealT # = inv(gamma - 1); can be used to write slow divisions as fast multiplications
95
96
mu::Mu # viscosity
97
Pr::RealT # Prandtl number
98
kappa::RealT # thermal diffusivity for Fick's law
99
100
equations_hyperbolic::E # CompressibleEulerEquations2D
101
gradient_variables::GradientVariables # GradientVariablesPrimitive or GradientVariablesEntropy
102
end
103
104
# default to primitive gradient variables
105
function CompressibleNavierStokesDiffusion2D(equations::CompressibleEulerEquations2D;
106
mu, Prandtl,
107
gradient_variables = GradientVariablesPrimitive())
108
gamma = equations.gamma
109
inv_gamma_minus_one = equations.inv_gamma_minus_one
110
111
# Under the assumption of constant Prandtl number the thermal conductivity
112
# constant is kappa = gamma μ / ((gamma-1) Prandtl).
113
# Important note! Factor of μ is accounted for later in `flux`.
114
# This avoids recomputation of kappa for non-constant μ.
115
kappa = gamma * inv_gamma_minus_one / Prandtl
116
117
CompressibleNavierStokesDiffusion2D{typeof(gradient_variables), typeof(gamma),
118
typeof(mu),
119
typeof(equations)}(gamma, inv_gamma_minus_one,
120
mu, Prandtl, kappa,
121
equations,
122
gradient_variables)
123
end
124
125
# TODO: parabolic
126
# This is the flexibility a user should have to select the different gradient variable types
127
# varnames(::typeof(cons2prim) , ::CompressibleNavierStokesDiffusion2D) = ("v1", "v2", "T")
128
# varnames(::typeof(cons2entropy), ::CompressibleNavierStokesDiffusion2D) = ("w2", "w3", "w4")
129
130
function varnames(variable_mapping,
131
equations_parabolic::CompressibleNavierStokesDiffusion2D)
132
varnames(variable_mapping, equations_parabolic.equations_hyperbolic)
133
end
134
135
# we specialize this function to compute gradients of primitive variables instead of
136
# conservative variables.
137
function gradient_variable_transformation(::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
138
cons2prim
139
end
140
function gradient_variable_transformation(::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
141
cons2entropy
142
end
143
144
# Explicit formulas for the diffusive Navier-Stokes fluxes are available, e.g., in Section 2
145
# of the paper by Rueda-Ramírez, Hennemann, Hindenlang, Winters, and Gassner
146
# "An Entropy Stable Nodal Discontinuous Galerkin Method for the resistive
147
# MHD Equations. Part II: Subcell Finite Volume Shock Capturing"
148
# where one sets the magnetic field components equal to 0.
149
function flux(u, gradients, orientation::Integer,
150
equations::CompressibleNavierStokesDiffusion2D)
151
# Here, `u` is assumed to be the "transformed" variables specified by `gradient_variable_transformation`.
152
_, v1, v2, _ = convert_transformed_to_primitive(u, equations)
153
# Here `gradients` is assumed to contain the gradients of the primitive variables (rho, v1, v2, T)
154
# either computed directly or reverse engineered from the gradient of the entropy variables
155
# by way of the `convert_gradient_variables` function.
156
_, dv1dx, dv2dx, dTdx = convert_derivative_to_primitive(u, gradients[1], equations)
157
_, dv1dy, dv2dy, dTdy = convert_derivative_to_primitive(u, gradients[2], equations)
158
159
# Components of viscous stress tensor
160
161
# (4 * (v1)_x / 3 - 2 * (v2)_y / 3)
162
tau_11 = 4 * dv1dx / 3 - 2 * dv2dy / 3
163
# ((v1)_y + (v2)_x)
164
# stress tensor is symmetric
165
tau_12 = dv1dy + dv2dx # = tau_21
166
# (4/3 * (v2)_y - 2/3 * (v1)_x)
167
tau_22 = 4 * dv2dy / 3 - 2 * dv1dx / 3
168
169
# Fick's law q = -kappa * grad(T) = -kappa * grad(p / (R rho))
170
# with thermal diffusivity constant kappa = gamma μ R / ((gamma-1) Pr)
171
# Note, the gas constant cancels under this formulation, so it is not present
172
# in the implementation
173
q1 = equations.kappa * dTdx
174
q2 = equations.kappa * dTdy
175
176
# In the simplest cases, the user passed in `mu` or `mu()`
177
# (which returns just a constant) but
178
# more complex functions like Sutherland's law are possible.
179
# `dynamic_viscosity` is a helper function that handles both cases
180
# by dispatching on the type of `equations.mu`.
181
mu = dynamic_viscosity(u, equations)
182
183
if orientation == 1
184
# viscous flux components in the x-direction
185
f1 = 0
186
f2 = tau_11 * mu
187
f3 = tau_12 * mu
188
f4 = (v1 * tau_11 + v2 * tau_12 + q1) * mu
189
190
return SVector(f1, f2, f3, f4)
191
else # if orientation == 2
192
# viscous flux components in the y-direction
193
# Note, symmetry is exploited for tau_12 = tau_21
194
g1 = 0
195
g2 = tau_12 * mu # tau_21 * mu
196
g3 = tau_22 * mu
197
g4 = (v1 * tau_12 + v2 * tau_22 + q2) * mu
198
199
return SVector(g1, g2, g3, g4)
200
end
201
end
202
203
# Convert conservative variables to primitive
204
@inline function cons2prim(u, equations::CompressibleNavierStokesDiffusion2D)
205
rho, rho_v1, rho_v2, _ = u
206
207
v1 = rho_v1 / rho
208
v2 = rho_v2 / rho
209
T = temperature(u, equations)
210
211
return SVector(rho, v1, v2, T)
212
end
213
214
# Convert conservative variables to entropy
215
# TODO: parabolic. We can improve efficiency by not computing w_1, which involves logarithms
216
# This can be done by specializing `cons2entropy` and `entropy2cons` to `CompressibleNavierStokesDiffusion2D`,
217
# but this may be confusing to new users.
218
function cons2entropy(u, equations::CompressibleNavierStokesDiffusion2D)
219
cons2entropy(u, equations.equations_hyperbolic)
220
end
221
function entropy2cons(w, equations::CompressibleNavierStokesDiffusion2D)
222
entropy2cons(w, equations.equations_hyperbolic)
223
end
224
225
# the `flux` function takes in transformed variables `u` which depend on the type of the gradient variables.
226
# For CNS, it is simplest to formulate the viscous terms in primitive variables, so we transform the transformed
227
# variables into primitive variables.
228
@inline function convert_transformed_to_primitive(u_transformed,
229
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
230
return u_transformed
231
end
232
233
# TODO: parabolic. Make this more efficient!
234
@inline function convert_transformed_to_primitive(u_transformed,
235
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
236
# note: this uses CompressibleNavierStokesDiffusion2D versions of cons2prim and entropy2cons
237
return cons2prim(entropy2cons(u_transformed, equations), equations)
238
end
239
240
# Takes the solution values `u` and gradient of the entropy variables (w_2, w_3, w_4) and
241
# reverse engineers the gradients to be terms of the primitive variables (v1, v2, T).
242
# Helpful because then the diffusive fluxes have the same form as on paper.
243
# Note, the first component of `gradient_entropy_vars` contains gradient(rho) which is unused.
244
# TODO: parabolic; entropy stable viscous terms
245
@inline function convert_derivative_to_primitive(u, gradient,
246
::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
247
return gradient
248
end
249
250
# the first argument is always the "transformed" variables.
251
@inline function convert_derivative_to_primitive(w, gradient_entropy_vars,
252
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
253
254
# TODO: parabolic. This is inefficient to pass in transformed variables but then transform them back.
255
# We can fix this if we directly compute v1, v2, T from the entropy variables
256
u = entropy2cons(w, equations) # calls a "modified" entropy2cons defined for CompressibleNavierStokesDiffusion2D
257
rho, rho_v1, rho_v2, _ = u
258
259
v1 = rho_v1 / rho
260
v2 = rho_v2 / rho
261
T = temperature(u, equations)
262
263
return SVector(gradient_entropy_vars[1],
264
T * (gradient_entropy_vars[2] + v1 * gradient_entropy_vars[4]), # grad(u) = T*(grad(w_2)+v1*grad(w_4))
265
T * (gradient_entropy_vars[3] + v2 * gradient_entropy_vars[4]), # grad(v) = T*(grad(w_3)+v2*grad(w_4))
266
T * T * gradient_entropy_vars[4])
267
end
268
269
# This routine is required because `prim2cons` is called in `initial_condition`, which
270
# is called with `equations::CompressibleEulerEquations2D`. This means it is inconsistent
271
# with `cons2prim(..., ::CompressibleNavierStokesDiffusion2D)` as defined above.
272
# TODO: parabolic. Is there a way to clean this up?
273
@inline function prim2cons(u, equations::CompressibleNavierStokesDiffusion2D)
274
prim2cons(u, equations.equations_hyperbolic)
275
end
276
277
@inline function temperature(u, equations::CompressibleNavierStokesDiffusion2D)
278
rho, rho_v1, rho_v2, rho_e = u
279
280
p = (equations.gamma - 1) * (rho_e - 0.5f0 * (rho_v1^2 + rho_v2^2) / rho)
281
T = p / rho
282
return T
283
end
284
285
@inline function velocity(u, equations::CompressibleNavierStokesDiffusion2D)
286
rho = u[1]
287
v1 = u[2] / rho
288
v2 = u[3] / rho
289
return SVector(v1, v2)
290
end
291
292
@doc raw"""
293
enstrophy(u, gradients, equations::CompressibleNavierStokesDiffusion2D)
294
295
Computes the (node-wise) enstrophy, defined as
296
```math
297
\mathcal{E} = \frac{1}{2} \rho \omega \cdot \omega
298
```
299
where ``\omega = \nabla \times \boldsymbol{v}`` is the [`vorticity`](@ref).
300
In 2D, ``\omega`` is just a scalar.
301
"""
302
@inline function enstrophy(u, gradients, equations::CompressibleNavierStokesDiffusion2D)
303
# Enstrophy is 0.5 rho ω⋅ω where ω = ∇ × v
304
305
omega = vorticity(u, gradients, equations)
306
return 0.5f0 * u[1] * omega^2
307
end
308
309
@doc raw"""
310
vorticity(u, gradients, equations::CompressibleNavierStokesDiffusion2D)
311
312
Computes the (node-wise) vorticity, defined in 2D as
313
```math
314
\omega = \nabla \times \boldsymbol{v} = \frac{\partial v_2}{\partial x_1} - \frac{\partial v_1}{\partial x_2}
315
```
316
"""
317
@inline function vorticity(u, gradients, equations::CompressibleNavierStokesDiffusion2D)
318
# Ensure that we have velocity `gradients` by way of the `convert_gradient_variables` function.
319
_, _, dv2dx, _ = convert_derivative_to_primitive(u, gradients[1], equations)
320
_, dv1dy, _, _ = convert_derivative_to_primitive(u, gradients[2], equations)
321
322
return dv2dx - dv1dy
323
end
324
325
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
326
<:Adiabatic})(flux_inner,
327
u_inner,
328
normal::AbstractVector,
329
x,
330
t,
331
operator_type::Gradient,
332
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
333
v1, v2 = boundary_condition.boundary_condition_velocity.boundary_value_function(x,
334
t,
335
equations)
336
return SVector(u_inner[1], v1, v2, u_inner[4])
337
end
338
339
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
340
<:Adiabatic})(flux_inner,
341
u_inner,
342
normal::AbstractVector,
343
x,
344
t,
345
operator_type::Divergence,
346
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
347
normal_heat_flux = boundary_condition.boundary_condition_heat_flux.boundary_value_normal_flux_function(x,
348
t,
349
equations)
350
v1, v2 = boundary_condition.boundary_condition_velocity.boundary_value_function(x,
351
t,
352
equations)
353
_, tau_1n, tau_2n, _ = flux_inner # extract fluxes for 2nd and 3rd equations
354
normal_energy_flux = v1 * tau_1n + v2 * tau_2n + normal_heat_flux
355
return SVector(flux_inner[1], flux_inner[2], flux_inner[3], normal_energy_flux)
356
end
357
358
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
359
<:Isothermal})(flux_inner,
360
u_inner,
361
normal::AbstractVector,
362
x,
363
t,
364
operator_type::Gradient,
365
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
366
v1, v2 = boundary_condition.boundary_condition_velocity.boundary_value_function(x,
367
t,
368
equations)
369
T = boundary_condition.boundary_condition_heat_flux.boundary_value_function(x, t,
370
equations)
371
return SVector(u_inner[1], v1, v2, T)
372
end
373
374
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
375
<:Isothermal})(flux_inner,
376
u_inner,
377
normal::AbstractVector,
378
x,
379
t,
380
operator_type::Divergence,
381
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
382
return flux_inner
383
end
384
385
# specialized BC impositions for GradientVariablesEntropy.
386
387
# This should return a SVector containing the boundary values of entropy variables.
388
# Here, `w_inner` are the transformed variables (e.g., entropy variables).
389
#
390
# Taken from "Entropy stable modal discontinuous Galerkin schemes and wall boundary conditions
391
# for the compressible Navier-Stokes equations" by Chan, Lin, Warburton 2022.
392
# DOI: 10.1016/j.jcp.2021.110723
393
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
394
<:Adiabatic})(flux_inner,
395
w_inner,
396
normal::AbstractVector,
397
x,
398
t,
399
operator_type::Gradient,
400
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
401
v1, v2 = boundary_condition.boundary_condition_velocity.boundary_value_function(x,
402
t,
403
equations)
404
negative_rho_inv_p = w_inner[4] # w_4 = -rho / p
405
return SVector(w_inner[1], -v1 * negative_rho_inv_p, -v2 * negative_rho_inv_p,
406
negative_rho_inv_p)
407
end
408
409
# this is actually identical to the specialization for GradientVariablesPrimitive, but included for completeness.
410
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
411
<:Adiabatic})(flux_inner,
412
w_inner,
413
normal::AbstractVector,
414
x,
415
t,
416
operator_type::Divergence,
417
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
418
normal_heat_flux = boundary_condition.boundary_condition_heat_flux.boundary_value_normal_flux_function(x,
419
t,
420
equations)
421
v1, v2 = boundary_condition.boundary_condition_velocity.boundary_value_function(x,
422
t,
423
equations)
424
_, tau_1n, tau_2n, _ = flux_inner # extract fluxes for 2nd and 3rd equations
425
normal_energy_flux = v1 * tau_1n + v2 * tau_2n + normal_heat_flux
426
return SVector(flux_inner[1], flux_inner[2], flux_inner[3], normal_energy_flux)
427
end
428
429
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
430
<:Isothermal})(flux_inner,
431
w_inner,
432
normal::AbstractVector,
433
x,
434
t,
435
operator_type::Gradient,
436
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
437
v1, v2 = boundary_condition.boundary_condition_velocity.boundary_value_function(x,
438
t,
439
equations)
440
T = boundary_condition.boundary_condition_heat_flux.boundary_value_function(x, t,
441
equations)
442
443
# the entropy variables w2 = rho * v1 / p = v1 / T = -v1 * w4. Similarly for w3
444
w4 = -1 / T
445
return SVector(w_inner[1], -v1 * w4, -v2 * w4, w4)
446
end
447
448
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:NoSlip,
449
<:Isothermal})(flux_inner,
450
w_inner,
451
normal::AbstractVector,
452
x,
453
t,
454
operator_type::Divergence,
455
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesEntropy})
456
return SVector(flux_inner[1], flux_inner[2], flux_inner[3], flux_inner[4])
457
end
458
459
# Computes the mirror velocity across a symmetry plane which enforces
460
# a tangential velocity that is aligned with the symmetry plane, i.e.,
461
# which is normal to the `normal_direction`.
462
# See also `boundary_condition_slip_wall` and `rotate_to_x`.
463
@inline function velocity_symmetry_plane(normal_direction::AbstractVector, v1, v2)
464
norm_ = norm(normal_direction)
465
normal = normal_direction / norm_
466
467
# Compute alignment of velocity with normal direction
468
v_normal = v1 * normal[1] + v2 * normal[2]
469
470
v1_outer = v1 - 2 * v_normal * normal[1]
471
v2_outer = v2 - 2 * v_normal * normal[2]
472
473
return v1_outer, v2_outer
474
end
475
476
# Note: This should be used with `boundary_condition_slip_wall` for the hyperbolic (Euler) part.
477
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:Slip,
478
<:Adiabatic})(flux_inner,
479
u_inner,
480
normal::AbstractVector,
481
x,
482
t,
483
operator_type::Gradient,
484
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
485
v1_outer, v2_outer = velocity_symmetry_plane(normal,
486
u_inner[2],
487
u_inner[3])
488
489
return SVector(u_inner[1], v1_outer, v2_outer, u_inner[4])
490
end
491
492
# Note: This should be used with `boundary_condition_slip_wall` for the hyperbolic (Euler) part.
493
@inline function (boundary_condition::BoundaryConditionNavierStokesWall{<:Slip,
494
<:Adiabatic})(flux_inner,
495
u_inner,
496
normal::AbstractVector,
497
x,
498
t,
499
operator_type::Divergence,
500
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
501
normal_heat_flux = boundary_condition.boundary_condition_heat_flux.boundary_value_normal_flux_function(x,
502
t,
503
equations)
504
505
# Normal stresses should be 0. This implies also that `normal_energy_flux = normal_heat_flux`.
506
# For details, see Section 4.2 of
507
# "Entropy stable modal discontinuous Galerkin schemes and wall boundary conditions
508
# for the compressible Navier-Stokes equations" by Chan, Lin, Warburton 2022.
509
# DOI: 10.1016/j.jcp.2021.110723
510
return SVector(flux_inner[1], 0, 0, normal_heat_flux)
511
end
512
513
# Dirichlet Boundary Condition for e.g. P4est mesh
514
@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner,
515
u_inner,
516
normal::AbstractVector,
517
x, t,
518
operator_type::Gradient,
519
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
520
# BCs are usually specified as conservative variables so we convert them to primitive variables
521
# because the gradients are assumed to be with respect to the primitive variables
522
u_boundary = boundary_condition.boundary_value_function(x, t, equations)
523
524
return cons2prim(u_boundary, equations)
525
end
526
527
@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner,
528
u_inner,
529
normal::AbstractVector,
530
x, t,
531
operator_type::Divergence,
532
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
533
# for Dirichlet boundary conditions, we do not impose any conditions on the viscous fluxes
534
return flux_inner
535
end
536
end # @muladd
537
538