30#include "../scalar/scalar_edge_flux.hpp"
42template <
class Double,
class FlowIndices,
int nDim,
size_t nVar>
44 :
public CUpwScalarBase<Double, CScalarFlux_SA<Double, FlowIndices, nDim, nVar>, FlowIndices, nDim, nVar> {
55 negativeSA(config.GetSAParsedOptions().version ==
SA_OPTIONS::
NEG),
56 accurateJacobians(config.GetUse_Accurate_Turb_Jacobians()) {}
65 const bool negativeSA;
66 const bool accurateJacobians;
72 template <
class VariableType,
size_t Size>
77 const Double flux = a0 * phi.i.all(0) + a1 * phi.j.all(0);
93 const Double avg = 0.5 * (a0 + a1);
94 for (
size_t iVar = 1; iVar < res.
nVar; ++iVar) {
95 const Double flux_bs = avg * (phi.i.all(iVar) + phi.j.all(iVar));
97 res.
flux_i(iVar) += flux_bs;
101 res.
jac_ii(iVar, iVar) += avg;
103 res.
jac_ij(iVar, iVar) += avg;
104 res.
jac_ji(iVar, iVar) -= avg;
105 res.
jac_jj(iVar, iVar) -= avg;
116 if (!negativeSA || zeta >= 0.0)
return 1.0;
117 const Double zeta3 = zeta * zeta * zeta;
118 return (cn1 + zeta3) / (cn1 - zeta3);
127 template <
class VariableType>
138 const Double nu_ij = 0.5 * (nu_i + nu_j);
139 const Double nuTilde_ij = 0.5 * (nuTilde_i + nuTilde_j);
144 const Double fn_i =
fn(((1.0 + cb2) * nuTilde_ij - cb2 * nuTilde_i) / nu_ij);
145 const Double fn_j =
fn(((1.0 + cb2) * nuTilde_ij - cb2 * nuTilde_j) / nu_ij);
148 D_i(0) = (nu_ij + (1.0 + cb2) * nuTilde_ij * fn_i - cb2 * nuTilde_i * fn_i) / sigma;
149 D_j(0) = (nu_ij + (1.0 + cb2) * nuTilde_ij * fn_j - cb2 * nuTilde_j * fn_j) / sigma;
150 for (
size_t iVar = 1; iVar <
nVar; ++iVar) {
164 template <
class Coefficients,
size_t Size>
167 if (negativeSA || !accurateJacobians)
return;
173 const Double dDC_dNuTilde_i = ((1.0 + cb2) * 0.5 - cb2) / sigma;
174 const Double dDC_dNuTilde_j = (1.0 + cb2) * 0.5 / sigma;
176 res.
jac_ii(0, 0) -= dDC_dNuTilde_i * projGrad(0);
179 res.
jac_ij(0, 0) -= dDC_dNuTilde_j * projGrad(0);
180 res.
jac_ji(0, 0) += dDC_dNuTilde_j * projGrad(0);
181 res.
jac_jj(0, 0) += dDC_dNuTilde_i * projGrad(0);
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
su2double GetPrimitive(unsigned long iPoint, unsigned long iVar) const final
Get a primitive variable.
Definition CFlowVariable.hpp:95
Convection and diffusion of the Spalart-Allmaras model, non-conservative and with a diagonal (but asy...
Definition turb_sa_edge_flux.hpp:44
CPair< Vector< Double, nVar > > coefficients(const FlowIndices &idx, Int iPoint, const EdgeSide< VariableType > &side_i, Int jPoint, const EdgeSide< VariableType > &side_j, const CPair< Double > &rho) const
Diffusion coefficients of both orientations of the edge.
Definition turb_sa_edge_flux.hpp:128
static constexpr bool Conservative
Definition turb_sa_edge_flux.hpp:46
static constexpr bool DiagonalDiffusion
Definition turb_sa_edge_flux.hpp:47
void finalizeFlux(const FlowIndices &, const ScalarFluxOptions &opt, Int, const EdgeSide< VariableType > &, Int, const EdgeSide< VariableType > &, const Double &a0, const Double &a1, const CPair< Double > &, const CPair< CScalarValues< Double, Size > > &phi, EdgeResidual< Double, nVar > &res) const
SA convection, plus the centered advection of the backscatter equations when nVar > 1.
Definition turb_sa_edge_flux.hpp:73
typename Base::Int Int
Definition turb_sa_edge_flux.hpp:51
Double fn(const Double &zeta) const
fn, the positivity-preserving correction to the SA-neg diffusion coefficient (Allmaras,...
Definition turb_sa_edge_flux.hpp:115
static constexpr bool DiffusionReadsDensity
The kinematic viscosities below.
Definition turb_sa_edge_flux.hpp:48
CScalarFlux_SA(const CConfig &config)
Definition turb_sa_edge_flux.hpp:53
void coefficientJacobians(const ScalarFluxOptions &opt, const Coefficients &, const Vector< Double, Size > &projGrad, EdgeResidual< Double, nVar > &res) const
Extra Jacobian terms from the dependence of the diffusion coefficient on nu_tilde.
Definition turb_sa_edge_flux.hpp:165
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
static constexpr size_t nVar
Definition scalar_edge_flux.hpp:321
double passivedouble
Definition code_config.hpp:129
#define FORCEINLINE
Definition code_config.hpp:44
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
SA_OPTIONS
SA Options.
Definition option_structure.hpp:1264
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131
Thin wrapper giving a Vector the all(iVar) accessor the MUSCL reconstruction helpers expect (see CCom...
Definition scalar_edge_flux.hpp:133
Residual of one edge, accumulated by the convective and the diffusive terms.
Definition util.hpp:169
Vector< Double, Size > flux_j
Definition util.hpp:176
Matrix< Double, Size, Size > jac_jj
Definition util.hpp:177
Matrix< Double, Size, Size > jac_ji
Definition util.hpp:177
const size_t nVar
Definition util.hpp:178
Vector< Double, Size > flux_i
Definition util.hpp:176
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 implicit
Whether the Jacobians are assembled, and so computed.
Definition scalar_edge_flux.hpp:60
bool oneSided
Whether only the row of i is assembled.
Definition scalar_edge_flux.hpp:63