Documentation 6b54b78464
Loading...
Searching...
No Matches
turb_sst_edge_flux.hpp
Go to the documentation of this file.
1/*!
2 * \file turb_sst_edge_flux.hpp
3 * \brief Menter SST model as a third-layer scalar flux, see numerics/scalar/scalar_edge_flux.hpp.
4 * \author P. Gomes
5 * \version 8.5.0 "Harrier"
6 *
7 * SU2 Project Website: https://su2code.github.io
8 *
9 * The SU2 Project is maintained by the SU2 Foundation
10 * (http://su2foundation.org)
11 *
12 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
13 *
14 * SU2 is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SU2 is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#pragma once
29
30#include "../scalar/scalar_edge_flux.hpp"
31
32/*!
33 * \class CScalarFlux_SST
34 * \ingroup ViscDiscr
35 * \brief Convection and diffusion of the Menter SST model, conservative with a coupled (but
36 * neither symmetric nor diagonal) 2x2 diffusion matrix.
37 * \note SST writes no finalizeFlux of its own: the inherited CUpwScalarFlux one is exactly
38 * flux(iVar) = a0*rho_i*phi_i(iVar) + a1*rho_j*phi_j(iVar), Conservative weighting by
39 * density, which is the model's whole convective term.
40 */
41template <class Double, class FlowIndices, int nDim, size_t nVar = 2>
43 : public CUpwScalarBase<Double, CScalarFlux_SST<Double, FlowIndices, nDim, nVar>, FlowIndices, nDim, nVar> {
44 public:
45 static constexpr bool Conservative = true;
46 static constexpr bool DiagonalDiffusion = false;
47
49 using Int = typename Base::Int;
50 using Base::Base;
51
52 private:
53 /*--- Fixed regardless of SST_OPTIONS::version: only the production-limiter and source-term
54 * constants (alfa/gamma) differ by version, not these. ---*/
55 static constexpr passivedouble sigma_k1 = 0.85;
56 static constexpr passivedouble sigma_k2 = 1.0;
57 static constexpr passivedouble sigma_om1 = 0.5;
58 static constexpr passivedouble sigma_om2 = 0.856;
59
60 public:
61 /*!
62 * \brief Diffusion coefficients of both orientations of the edge, and the terms of the cross
63 * diffusion that the Jacobian correction below needs, so that neither the gathers nor
64 * the blending are repeated for it.
65 * \note The cross term reads the transported omega of whichever point its row is being written
66 * for, so it is not symmetric: i, read by i's row, uses omega at i; j, read by j's row,
67 * uses omega at j. Every other entry is an i/j average, so it is the same in both.
68 */
73
74 template <class VariableType>
75 FORCEINLINE CCoefficients coefficients(const FlowIndices& idx, Int iPoint, const EdgeSide<VariableType>& side_i,
76 Int jPoint, const EdgeSide<VariableType>& side_j,
77 const CPair<Double>& rho) const {
78 const Double mu_i = gatherVariables(iPoint, side_i.flowNodes->GetPrimitive(), idx.LaminarViscosity());
79 const Double mu_j = gatherVariables(jPoint, side_j.flowNodes->GetPrimitive(), idx.LaminarViscosity());
80 const Double muT_i = gatherVariables(iPoint, side_i.flowNodes->GetPrimitive(), idx.EddyViscosity());
81 const Double muT_j = gatherVariables(jPoint, side_j.flowNodes->GetPrimitive(), idx.EddyViscosity());
82
83 const Double F1_i = gatherVariables(iPoint, side_i.scalarNodes.GetF1blending());
84 const Double F1_j = gatherVariables(jPoint, side_j.scalarNodes.GetF1blending());
85
87 D.omega_i = gatherVariables(iPoint, side_i.scalarNodes.GetSolution(), 1);
88 D.omega_j = gatherVariables(jPoint, side_j.scalarNodes.GetSolution(), 1);
89
90 const Double sigma_kine_i = F1_i * sigma_k1 + (1.0 - F1_i) * sigma_k2;
91 const Double sigma_kine_j = F1_j * sigma_k1 + (1.0 - F1_j) * sigma_k2;
92 const Double sigma_omega_i = F1_i * sigma_om1 + (1.0 - F1_i) * sigma_om2;
93 const Double sigma_omega_j = F1_j * sigma_om1 + (1.0 - F1_j) * sigma_om2;
94
95 const Double diff_kine = 0.5 * ((mu_i + sigma_kine_i * muT_i) + (mu_j + sigma_kine_j * muT_j));
96 const Double diff_omega = 0.5 * ((mu_i + sigma_omega_i * muT_i) + (mu_j + sigma_omega_j * muT_j));
97
98 const Double lambda_i = 2.0 * (1.0 - F1_i) * rho.i * sigma_omega_i;
99 const Double lambda_j = 2.0 * (1.0 - F1_j) * rho.j * sigma_omega_j;
100 D.lambda_ij = 0.5 * (lambda_i + lambda_j);
101 const Double w_ij = 0.5 * (D.omega_i + D.omega_j);
102
103 /*--- Cross-diffusion coefficient: a divergence-theorem term (diff_omega_T2) plus a cell
104 * centre correction (diff_omega_T3) that reads the transported omega of the row's own point. ---*/
105 const Double diff_omega_T2 = D.lambda_ij;
106 const Double diff_omega_T3_i = -D.omega_i * D.lambda_ij / w_ij;
107 const Double diff_omega_T3_j = -D.omega_j * D.lambda_ij / w_ij;
108
109 /*--- D.i(0,1) and D.j(0,1) are left zero: there is no diffusive coupling from omega into
110 * the k row. ---*/
111 D.i = Double(0.0);
112 D.j = Double(0.0);
113 D.i(0, 0) = diff_kine;
114 D.i(1, 1) = diff_omega;
115 D.i(1, 0) = diff_omega_T2 + diff_omega_T3_i;
116
117 D.j(0, 0) = diff_kine;
118 D.j(1, 1) = diff_omega;
119 D.j(1, 0) = diff_omega_T2 + diff_omega_T3_j;
120
121 return D;
122 }
123
124 /*!
125 * \brief Extra Jacobian terms from the dependence of the cross-diffusion coefficient on omega.
126 * \note diff_omega_T3_i and diff_omega_T3_j both depend on omega_i and omega_j through w_ij, so
127 * each of the four blocks needs a correction beyond the one diffusionTerms already applies
128 * through projGrad. The correction only depends on which point's omega is being
129 * differentiated against, not on which row it lands in: differentiating against omega_i
130 * gives +E_j in both jac_ii and jac_ji, differentiating against omega_j gives -E_i in both
131 * jac_ij and jac_jj.
132 */
133 template <size_t Size>
135 const Vector<Double, Size>& projGrad, EdgeResidual<Double, nVar>& res) const {
136 const Double denom = pow(D.omega_i + D.omega_j, 2.0);
137 const Double E_i = 2.0 * D.lambda_ij * D.omega_i / denom * projGrad(0);
138 const Double E_j = 2.0 * D.lambda_ij * D.omega_j / denom * projGrad(0);
139
140 res.jac_ii(1, 1) += E_j;
141 if (opt.oneSided) return;
142
143 res.jac_ij(1, 1) -= E_i;
144 res.jac_ji(1, 1) += E_j;
145 res.jac_jj(1, 1) -= E_i;
146 }
147};
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
su2double GetPrimitive(unsigned long iPoint, unsigned long iVar) const final
Get a primitive variable.
Definition CFlowVariable.hpp:95
Convection and diffusion of the Menter SST model, conservative with a coupled (but neither symmetric ...
Definition turb_sst_edge_flux.hpp:43
CCoefficients coefficients(const FlowIndices &idx, Int iPoint, const EdgeSide< VariableType > &side_i, Int jPoint, const EdgeSide< VariableType > &side_j, const CPair< Double > &rho) const
Definition turb_sst_edge_flux.hpp:75
static constexpr bool DiagonalDiffusion
Definition turb_sst_edge_flux.hpp:46
typename Base::Int Int
Definition turb_sst_edge_flux.hpp:49
static constexpr bool Conservative
Definition turb_sst_edge_flux.hpp:45
void coefficientJacobians(const ScalarFluxOptions &opt, const CCoefficients &D, const Vector< Double, Size > &projGrad, EdgeResidual< Double, nVar > &res) const
Extra Jacobian terms from the dependence of the cross-diffusion coefficient on omega.
Definition turb_sst_edge_flux.hpp:134
Upwind convection and diffusion of a transported scalar, accumulated into one residual,...
Definition scalar_edge_flux.hpp:316
typename CLaneTraits< Double_ >::Int Int
Definition scalar_edge_flux.hpp:319
Double_ Double
Definition scalar_edge_flux.hpp:318
const FlowIndices idx
Definition scalar_edge_flux.hpp:338
double passivedouble
Definition code_config.hpp:129
#define FORCEINLINE
Definition code_config.hpp:44
FORCEINLINE ARRAY_T pow(const ARRAY_T &a, const ARRAY_T &b)
Definition special_vectorization.hpp:179
Double gatherVariables(Int iPoint, const Container &vars, size_t iVar=0)
Gather a single variable, from column iVar (0 by default) of row iPoint of a 2D container,...
Definition util.hpp:277
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131
Diffusion coefficients of both orientations of the edge, and the terms of the cross diffusion that th...
Definition turb_sst_edge_flux.hpp:69
Double omega_i
Definition turb_sst_edge_flux.hpp:71
Double omega_j
Definition turb_sst_edge_flux.hpp:71
Matrix< Double, nVar, nVar > i
Definition turb_sst_edge_flux.hpp:70
Double lambda_ij
Definition turb_sst_edge_flux.hpp:71
Matrix< Double, nVar, nVar > j
Definition turb_sst_edge_flux.hpp:70
Residual of one edge, accumulated by the convective and the diffusive terms.
Definition util.hpp:169
Matrix< Double, Size, Size > jac_jj
Definition util.hpp:177
Matrix< Double, Size, Size > jac_ji
Definition util.hpp:177
Matrix< Double, Size, Size > jac_ii
Definition util.hpp:177
Matrix< Double, Size, Size > jac_ij
Definition util.hpp:177
Locates the data of one endpoint of an edge.
Definition scalar_edge_flux.hpp:42
const CFlowVariable * flowNodes
Flow variables, null for solid heat transfer.
Definition scalar_edge_flux.hpp:44
const VariableType & scalarNodes
Scalar solver variables.
Definition scalar_edge_flux.hpp:43
Loop invariant flags for a scalar edge flux, built once outside the edge loop so the compiler can uns...
Definition scalar_edge_flux.hpp:55
bool oneSided
Whether only the row of i is assembled.
Definition scalar_edge_flux.hpp:63