Skip to content

[WIP] Inconsistencies and improvements to SST model #2329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 75 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
2a66c54
- Added TKE production limiter constant to config
Jun 10, 2024
7582590
- Added Production and Destruction terms of SST to output
Jun 17, 2024
edce8ee
- Added user-defined lower limits of TKE and W
Jul 19, 2024
41c61ca
- Changed the Cross-Diffusion term in F1 computations
Jul 22, 2024
7b11baa
- Removed obsolete changes to TKE prod limiter
Jul 22, 2024
9482f51
- Modified the config output
Jul 22, 2024
38a02d6
- Added lower limit changes for SST in config output
Jul 22, 2024
c3e0d4b
- Added wall distance output for mesh adaptation
Jul 22, 2024
0f7558b
- Added strain magnitude as output
Jul 22, 2024
3be370d
- added production limiter flag to output
Jul 22, 2024
125fd6d
- Changed the Cross-Diffusion term in the residual of Omega
Jul 24, 2024
91cc3b8
- Added clipping of the cross-diffusion term in SST residual
Jul 24, 2024
7b78756
- changed cross diffusion term clipping in Omega residual
Jul 24, 2024
076d471
- Added CDkw and F1 as output
Jul 24, 2024
2e73f77
- Fixed Supersonic inlet BC inclusion of TKE
Jul 25, 2024
c662daf
- Corrected Riemann BC for TKE
Jul 25, 2024
41e1c16
- Fixed more BCs
Jul 25, 2024
e9dfc27
- Fixed bug with Cross diffusion in W residual
Jul 26, 2024
9a6fc06
- changed default for cross diffusion
Jul 26, 2024
251ae27
- Restored old computation of Cross-Diffusion terms in the source res…
Aug 12, 2024
9c7c950
Added BCs for SST-SUST
Aug 30, 2024
2042017
Merge branch 'develop' into feature_SSTMod
Aug 30, 2024
9d82d51
- Removed duplicate SST options
Aug 30, 2024
c10b006
- Removed not used config variables
Aug 30, 2024
be98cdd
- fixed merge error
Aug 30, 2024
fc30f5d
- Include full production and SSTm into the computation of the Stress…
Sep 2, 2024
a957ec7
Updated the freestream values for the print out
Sep 3, 2024
5546936
- Removed unused variables in turb_sources
Sep 3, 2024
1b8ee5b
- Added F2 blending function as output
Sep 3, 2024
6d3586f
- Restore previously removed variables
Sep 3, 2024
f27a7cb
- clean up of variables for Reynolds Stress Tensor computation
Sep 4, 2024
448a532
- Use full tke production term in Pw instead of only P_base
Sep 4, 2024
e9fa4e7
- Fixed Errors in AD compiling
Sep 6, 2024
c2462e8
- added tke to the numerics simd computations
Sep 9, 2024
51112fe
- Fixed UQ problem
Sep 9, 2024
576e8ee
- fix UQ implementation
Sep 9, 2024
acc21ec
- Removed unused variables
Sep 9, 2024
b5ca6ea
Merge branch 'develop' into feature_SSTMod
Sep 11, 2024
c6376cd
- Started including tke when computing the speed of sound
Sep 12, 2024
27175f8
Merge branch 'develop' into feature_SSTMod
Sep 16, 2024
d54cd39
Merge branch 'feature_SSTMod' of https://github.com/su2code/SU2 into …
Sep 16, 2024
c5aeb5a
- Start to include tke only when not m version of SST is used
Sep 16, 2024
6441eb8
Merge branch 'tmp' into HEAD
Sep 16, 2024
317f563
- Fixed tke integration in thermodynamic variables
Sep 20, 2024
d6af702
- Code improvements
Oct 2, 2024
8f97a16
- minor changes
Oct 11, 2024
fd43746
Merge branch 'develop' into feature_SSTMod
Oct 11, 2024
a8a603e
- update externals
Oct 11, 2024
340faa4
- Fixed inlet BCs when new BCs are used
Oct 11, 2024
f4cb207
Merge branch 'develop' into feature_SSTMod
Oct 22, 2024
16cac0a
Merge branch 'develop' into feature_SSTMod
bigfooted Oct 30, 2024
c4f10fe
Update Common/include/CConfig.hpp
rois1995 Oct 31, 2024
6eb02da
Merge branch 'develop' into feature_SSTMod
bigfooted Feb 3, 2025
f0e280a
changes to MLPCpp
Mar 4, 2025
3ca65bf
Merge branch 'develop' into feature_SSTMod
Mar 4, 2025
32a6eea
- Fix output GetStrainMag bug
Mar 4, 2025
89a559a
- Try fixing output bug again
Mar 4, 2025
d4ee84b
same fix
Mar 4, 2025
4162c72
go back to Jacobian modification but fix order of matrix multiplication
pcarruscag Apr 4, 2025
8a1b3da
something else we dont need?
pcarruscag Apr 4, 2025
0e1d5f9
update serial
bigfooted Apr 4, 2025
b2ae9e7
pressure forces
pcarruscag Apr 5, 2025
ac30740
Merge remote-tracking branch 'origin/symmetry_jacobian' into symmetry…
pcarruscag Apr 5, 2025
5fc0979
some updates and codeql
pcarruscag Apr 6, 2025
f81e979
more updates
pcarruscag Apr 6, 2025
5a40f57
- Added Shuzen and Hoffmann compressibility correction
Apr 10, 2025
c370f41
Merge branch 'feature_SSTMod' of https://github.com/su2code/SU2 into …
Apr 10, 2025
e9eb7ad
Merge remote-tracking branch 'origin/develop' into feature_SSTMod
Apr 10, 2025
e8d4bf3
- changed output for debug variables
Apr 10, 2025
4d2aba5
- Added term to jacobian of w
Apr 10, 2025
e4ceb0e
- Add neighbor wall distance as debug output
Apr 11, 2025
0d75465
- Remove Jacobian changes
Apr 11, 2025
f159412
- Add grad vel as output
Apr 11, 2025
939faa1
- add upper bound into BCs
Apr 11, 2025
99ac333
Merge remote-tracking branch 'origin/symmetry_jacobian' into feature_…
Apr 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ class CConfig {
nMu_Temperature_Ref, /*!< \brief Number of species reference temperature for Sutherland model. */
nMu_S, /*!< \brief Number of species reference S for Sutherland model. */
nThermal_Conductivity_Constant,/*!< \brief Number of species constant thermal conductivity. */
nPrandtl_Lam, /*!< \brief Number of species laminar Prandtl number. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original description was correct, for species transport we can have a Prandtl number for each of the species

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I do not recall changing that but for sure it was wrong in my branch. Corrected, thanks!

nPrandtl_Lam, /*!< \brief Prandtl number. */
nPrandtl_Turb, /*!< \brief Number of species turbulent Prandtl number. */
nConstant_Lewis_Number; /*!< \brief Number of species Lewis Number. */
su2double Diffusivity_Constant; /*!< \brief Constant mass diffusivity for scalar transport. */
Expand All @@ -877,6 +877,7 @@ class CConfig {
array<su2double, N_POLY_COEFFS> MuPolyCoefficientsND{{0.0}}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for viscosity. */
array<su2double, N_POLY_COEFFS> KtPolyCoefficientsND{{0.0}}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for thermal conductivity. */
su2double TurbIntensityAndViscRatioFreeStream[2]; /*!< \brief Freestream turbulent intensity and viscosity ratio for turbulence and transition models. */

su2double Energy_FreeStream, /*!< \brief Free-stream total energy of the fluid. */
ModVel_FreeStream, /*!< \brief Magnitude of the free-stream velocity of the fluid. */
ModVel_FreeStreamND, /*!< \brief Non-dimensional magnitude of the free-stream velocity of the fluid. */
Expand Down Expand Up @@ -1176,6 +1177,8 @@ class CConfig {
nHistoryOutput, nVolumeOutput; /*!< \brief Number of variables printed to the history file. */
bool Multizone_Residual; /*!< \brief Determines if memory should be allocated for the multizone residual. */
SST_ParsedOptions sstParsedOptions; /*!< \brief Additional parameters for the SST turbulence model. */
su2double prodLimConst;
su2double LDomain;
SA_ParsedOptions saParsedOptions; /*!< \brief Additional parameters for the SA turbulence model. */
LM_ParsedOptions lmParsedOptions; /*!< \brief Additional parameters for the LM transition model. */
su2double uq_delta_b; /*!< \brief Parameter used to perturb eigenvalues of Reynolds Stress Matrix */
Expand Down Expand Up @@ -9908,6 +9911,9 @@ class CConfig {
*/
SST_ParsedOptions GetSSTParsedOptions() const { return sstParsedOptions; }

su2double GetProdLimConst() const { return prodLimConst; }
su2double GetLDomain() const { return LDomain; }

/*!
* \brief Get parsed SA option data structure.
* \return SA option data structure.
Expand Down
21 changes: 18 additions & 3 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,21 +994,26 @@ enum class SST_OPTIONS {
COMP_Wilcox, /*!< \brief Menter k-w SST model with Compressibility correction of Wilcox. */
COMP_Sarkar, /*!< \brief Menter k-w SST model with Compressibility correction of Sarkar. */
DLL, /*!< \brief Menter k-w SST model with dimensionless lower limit clipping of turbulence variables. */
FULLPROD, /*!< \brief Menter k-w SST model with full production term. */
PRODLIM, /*!< \brief Menter k-w SST model with user-defined production limiter constant. */
NEWBC, /*!< \brief Menter k-w SST model with new boundary conditions. */
};
static const MapType<std::string, SST_OPTIONS> SST_Options_Map = {
MakePair("NONE", SST_OPTIONS::NONE)
MakePair("V1994m", SST_OPTIONS::V1994m)
MakePair("V2003m", SST_OPTIONS::V2003m)
/// TODO: For now we do not support "unmodified" versions of SST.
//MakePair("V1994", SST_OPTIONS::V1994)
//MakePair("V2003", SST_OPTIONS::V2003)
MakePair("V1994", SST_OPTIONS::V1994)
MakePair("V2003", SST_OPTIONS::V2003)
MakePair("SUSTAINING", SST_OPTIONS::SUST)
MakePair("VORTICITY", SST_OPTIONS::V)
MakePair("KATO-LAUNDER", SST_OPTIONS::KL)
MakePair("UQ", SST_OPTIONS::UQ)
MakePair("COMPRESSIBILITY-WILCOX", SST_OPTIONS::COMP_Wilcox)
MakePair("COMPRESSIBILITY-SARKAR", SST_OPTIONS::COMP_Sarkar)
MakePair("DIMENSIONLESS_LIMIT", SST_OPTIONS::DLL)
MakePair("FULLPROD", SST_OPTIONS::FULLPROD)
MakePair("PRODLIM", SST_OPTIONS::PRODLIM)
MakePair("NEWBC", SST_OPTIONS::NEWBC)
};

/*!
Expand All @@ -1023,6 +1028,9 @@ struct SST_ParsedOptions {
bool compWilcox = false; /*!< \brief Bool for compressibility correction of Wilcox. */
bool compSarkar = false; /*!< \brief Bool for compressibility correction of Sarkar. */
bool dll = false; /*!< \brief Bool dimensionless lower limit. */
bool fullProd = false; /*!< \brief Bool for full production term. */
bool prodLim = false; /*!< \brief Bool for user-defined production limiter constant. */
bool newBC = false; /*!< \brief Bool for new boundary conditions. */
};

/*!
Expand All @@ -1040,6 +1048,10 @@ inline SST_ParsedOptions ParseSSTOptions(const SST_OPTIONS *SST_Options, unsigne
return std::find(SST_Options, sst_options_end, option) != sst_options_end;
};

const bool found_fullProd = IsPresent(SST_OPTIONS::FULLPROD);
const bool found_prodLim = IsPresent(SST_OPTIONS::PRODLIM);
const bool found_newBC = IsPresent(SST_OPTIONS::NEWBC);

const bool found_1994 = IsPresent(SST_OPTIONS::V1994);
const bool found_2003 = IsPresent(SST_OPTIONS::V2003);
const bool found_1994m = IsPresent(SST_OPTIONS::V1994m);
Expand Down Expand Up @@ -1097,6 +1109,9 @@ inline SST_ParsedOptions ParseSSTOptions(const SST_OPTIONS *SST_Options, unsigne
SSTParsedOptions.compSarkar = sst_compSarkar;
SSTParsedOptions.dll = sst_dll;

SSTParsedOptions.fullProd = found_fullProd;
SSTParsedOptions.prodLim = found_prodLim;
SSTParsedOptions.newBC = found_newBC;
return SSTParsedOptions;
}

Expand Down
6 changes: 6 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,9 @@ void CConfig::SetConfig_Options() {
/*!\brief SST_OPTIONS \n DESCRIPTION: Specify SA turbulence model options/corrections. \n Options: see \link SA_Options_Map \endlink \n DEFAULT: NONE \ingroup Config*/
addEnumListOption("SA_OPTIONS", nSA_Options, SA_Options, SA_Options_Map);

addDoubleOption("PROD_LIM_CONST", prodLimConst, 20.0);
addDoubleOption("L_DOMAIN", LDomain, 1.0);

/*!\brief KIND_TRANS_MODEL \n DESCRIPTION: Specify transition model OPTIONS: see \link Trans_Model_Map \endlink \n DEFAULT: NONE \ingroup Config*/
addEnumOption("KIND_TRANS_MODEL", Kind_Trans_Model, Trans_Model_Map, TURB_TRANS_MODEL::NONE);
/*!\brief SST_OPTIONS \n DESCRIPTION: Specify LM transition model options/correlations. \n Options: see \link LM_Options_Map \endlink \n DEFAULT: NONE \ingroup Config*/
Expand Down Expand Up @@ -6275,6 +6278,9 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
else cout << "\nusing default hard coded lower limit clipping";

cout << "." << endl;

if (sstParsedOptions.prodLim) cout << "Changing the value of the TKE production limiter constant to " << prodLimConst << endl;

break;
}
switch (Kind_Trans_Model) {
Expand Down
4 changes: 4 additions & 0 deletions SU2_CFD/include/numerics/CNumerics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class CNumerics {

bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */

su2double ProdDistr[5];

public:
/*!
* \brief Return type used in some "ComputeResidual" overloads to give a
Expand Down Expand Up @@ -1605,6 +1607,8 @@ class CNumerics {
* \return is_bounded_scalar : scalar solver uses bounded scalar convective transport
*/
inline bool GetBoundedScalar() const { return bounded_scalar;}

inline su2double GetProdDest(int index) const {return ProdDistr[index];}
};

/*!
Expand Down
23 changes: 20 additions & 3 deletions SU2_CFD/include/numerics/turbulent/turb_sources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ class CSourcePieceWise_TurbSST final : public CNumerics {
/*--- Ambient values for SST-SUST. ---*/
const su2double kAmb, omegaAmb;

su2double Pk, Dk, Pw, Dw;

su2double F1_i, F2_i, CDkw_i;
su2double Residual[2];
su2double* Jacobian_i[2];
Expand Down Expand Up @@ -869,15 +871,20 @@ class CSourcePieceWise_TurbSST final : public CNumerics {
const su2double prod_limit = prod_lim_const * beta_star * Density_i * ScalarVar_i[1] * ScalarVar_i[0];

su2double P = Eddy_Viscosity_i * pow(P_Base, 2);
if (sstParsedOptions.fullProd) P -= Eddy_Viscosity_i * diverg*diverg * 2.0/3.0;
if (!sstParsedOptions.modified) P -= Density_i * ScalarVar_i[0] * diverg * 2.0/3.0;

su2double PLim = 0.0;
if ( P > prod_limit ) PLim = 1.0;
su2double pk = max(0.0, min(P, prod_limit));

const auto& eddy_visc_var = sstParsedOptions.version == SST_OPTIONS::V1994 ? VorticityMag : StrainMag_i;
const su2double eddy_visc_var = sstParsedOptions.version == SST_OPTIONS::V1994 ? VorticityMag : StrainMag_i;
const su2double zeta = max(ScalarVar_i[1], eddy_visc_var * F2_i / a1);

/*--- Production limiter only for V2003, recompute for V1994. ---*/
su2double pw;
if (sstParsedOptions.version == SST_OPTIONS::V1994) {
pw = alfa_blended * Density_i * pow(P_Base, 2);
pw = alfa_blended * Density_i * P / Eddy_Viscosity_i;
} else {
pw = (alfa_blended * Density_i / Eddy_Viscosity_i) * pk;
}
Expand Down Expand Up @@ -912,17 +919,26 @@ class CSourcePieceWise_TurbSST final : public CNumerics {
}

/*--- Add the production terms to the residuals. ---*/
Pk = pk;
Pw = pw;

Residual[0] += pk * Volume;
Residual[1] += pw * Volume;

/*--- Add the dissipation terms to the residuals.---*/
Dk = dk;
Dw = dw;

Residual[0] -= dk * Volume;
Residual[1] -= dw * Volume;

/*--- Cross diffusion ---*/
ProdDistr[0] = Pk;
ProdDistr[1] = Dk;
ProdDistr[2] = Pw;
ProdDistr[3] = Dw;
ProdDistr[4] = PLim;

/*--- Cross diffusion ---*/
Residual[1] += (1.0 - F1_i) * CDkw_i * Volume;

/*--- Contribution due to 2D axisymmetric formulation ---*/
Expand All @@ -932,6 +948,7 @@ class CSourcePieceWise_TurbSST final : public CNumerics {
/*--- Implicit part ---*/

Jacobian_i[0][0] = -beta_star * ScalarVar_i[1] * Volume * (1.0 + zetaFMt);
if (!sstParsedOptions.modified) Jacobian_i[0][0] -= diverg * Volume*2.0/3.0;
Jacobian_i[0][1] = -beta_star * ScalarVar_i[0] * Volume * (1.0 + zetaFMt);
Jacobian_i[1][0] = 0.0;
Jacobian_i[1][1] = -2.0 * beta_blended * ScalarVar_i[1] * Volume * (1.0 - 0.09/beta_blended * zetaFMt);
Expand Down
11 changes: 11 additions & 0 deletions SU2_CFD/include/numerics_simd/flow/convection/centered.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class CCenteredBase : public Base {
const bool dynamicGrid;
const su2double stretchParam = 0.3;

using Base::turbVars;

/*!
* \brief Constructor, store some constants and forward args to base.
*/
Expand Down Expand Up @@ -96,6 +98,8 @@ class CCenteredBase : public Base {
const bool implicit = (config.GetKind_TimeIntScheme() == EULER_IMPLICIT);
const auto& solution = static_cast<const CEulerVariable&>(solution_);

const bool tkeNeeded = config.GetKind_Turb_Model() == TURB_MODEL::SST;

const auto iPoint = geometry.edges->GetNode(iEdge,0);
const auto jPoint = geometry.edges->GetNode(iEdge,1);

Expand All @@ -119,6 +123,13 @@ class CCenteredBase : public Base {
avgV.all(iVar) = 0.5 * (V.i.all(iVar) + V.j.all(iVar));
}

if (tkeNeeded) {
V.i.allTurb = gatherVariables<1>(iPoint, turbVars->GetSolution());
V.j.allTurb = gatherVariables<1>(jPoint, turbVars->GetSolution());

avgV.allTurb(0) = 0.5*(V.i.allTurb(0)+V.j.allTurb(0));
}

/*--- Compute conservative variables. ---*/

CPair<CCompressibleConservatives<nDim> > U;
Expand Down
8 changes: 7 additions & 1 deletion SU2_CFD/include/numerics_simd/flow/convection/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ FORCEINLINE CPair<ReconVarType> reconstructPrimitives(Int iEdge, Int iPoint, Int
bool muscl, LIMITER limiterType,
const CPair<PrimVarType>& V1st,
const VectorDbl<nDim>& vector_ij,
const VariableType& solution) {
const VariableType& solution,
const bool tkeNeeded) {
static_assert(ReconVarType::nVar <= PrimVarType::nVar,"");

const auto& gradients = solution.GetGradient_Reconstruction();
Expand All @@ -125,6 +126,11 @@ FORCEINLINE CPair<ReconVarType> reconstructPrimitives(Int iEdge, Int iPoint, Int
V.i.all(iVar) = V1st.i.all(iVar);
V.j.all(iVar) = V1st.j.all(iVar);
}
// Only first order for turbulence
if (tkeNeeded) {
V.i.allTurb(0) = V1st.i.allTurb(0);
V.j.allTurb(0) = V1st.j.allTurb(0);
}

if (muscl) {
/*--- Recompute density and enthalpy instead of reconstructing. ---*/
Expand Down
13 changes: 12 additions & 1 deletion SU2_CFD/include/numerics_simd/flow/convection/roe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class CRoeBase : public Base {
const bool muscl;
const LIMITER typeLimiter;

using Base::turbVars;

/*!
* \brief Constructor, store some constants and forward args to base.
*/
Expand Down Expand Up @@ -98,6 +100,8 @@ class CRoeBase : public Base {
const bool implicit = (config.GetKind_TimeIntScheme() == EULER_IMPLICIT);
const auto& solution = static_cast<const CEulerVariable&>(solution_);

const bool tkeNeeded = config.GetKind_Turb_Model() == TURB_MODEL::SST;

const auto iPoint = geometry.edges->GetNode(iEdge,0);
const auto jPoint = geometry.edges->GetNode(iEdge,1);

Expand All @@ -118,8 +122,13 @@ class CRoeBase : public Base {
V1st.i.all = gatherVariables<nPrimVar>(iPoint, solution.GetPrimitive());
V1st.j.all = gatherVariables<nPrimVar>(jPoint, solution.GetPrimitive());

if (tkeNeeded) {
V1st.i.allTurb = gatherVariables(iPoint, turbVars->GetSolution());
V1st.j.allTurb = gatherVariables(jPoint, turbVars->GetSolution());
}

auto V = reconstructPrimitives<CCompressiblePrimitives<nDim,nPrimVarGrad> >(
iEdge, iPoint, jPoint, gamma, gasConst, muscl, typeLimiter, V1st, vector_ij, solution);
iEdge, iPoint, jPoint, gamma, gasConst, muscl, typeLimiter, V1st, vector_ij, solution, tkeNeeded);

/*--- Compute conservative variables. ---*/

Expand Down Expand Up @@ -231,6 +240,8 @@ class CRoeScheme : public CRoeBase<CRoeScheme<Decorator>,Decorator> {
using Base::kappa;
const ENUM_ROELOWDISS typeDissip;

using Base::turbVars;

public:
/*!
* \brief Constructor, store some constants and forward to base.
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/include/numerics_simd/flow/diffusion/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ FORCEINLINE void correctGradient(const PrimitiveType& V,
*/
template<size_t nVar, size_t nDim>
FORCEINLINE MatrixDbl<nDim> stressTensor(Double viscosity,
const MatrixDbl<nVar,nDim>& grad) {
const MatrixDbl<nVar,nDim>& grad, Double density=0.0, Double tke=0.0) {
/*--- Hydrostatic term. ---*/
Double velDiv = 0.0;
for (size_t iDim = 0; iDim < nDim; ++iDim) {
velDiv += grad(iDim+1,iDim);
}
Double pTerm = 2.0/3.0 * viscosity * velDiv;
Double pTerm = 2.0/3.0 * (viscosity * velDiv + density * tke);

MatrixDbl<nDim> tau;
for (size_t iDim = 0; iDim < nDim; ++iDim) {
Expand Down
17 changes: 13 additions & 4 deletions SU2_CFD/include/numerics_simd/flow/diffusion/viscous_fluxes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CNoViscousFlux : public CNumericsSIMD {
protected:
static constexpr size_t nDim = NDIM;
static constexpr size_t nPrimVar = 0;
const CVariable* turbVars = nullptr;

template<class... Ts>
CNoViscousFlux(Ts&...) {}
Expand Down Expand Up @@ -140,6 +141,8 @@ class CCompressibleViscousFluxBase : public CNumericsSIMD {
const auto& solution = static_cast<const CNSVariable&>(solution_);
const auto& gradient = solution.GetGradient_Primitive();

const bool tkeNeeded = (config.GetKind_Turb_Model() == TURB_MODEL::SST) && !(config.GetSSTParsedOptions().modified);

/*--- Compute distance and handle zero without "ifs" by making it large. ---*/

auto dist2_ij = squaredNorm(vector_ij);
Expand All @@ -152,12 +155,15 @@ class CCompressibleViscousFluxBase : public CNumericsSIMD {
if(correct) correctGradient(V, vector_ij, dist2_ij, avgGrad);

/*--- Stress and heat flux tensors. ---*/

auto tau = stressTensor(avgV.laminarVisc() + (uq? Double(0.0) : avgV.eddyVisc()), avgGrad);
Double turb_ke = 0.0;
Double density = avgV.density();
if (tkeNeeded) turb_ke = 0.5*(gatherVariables(iPoint, turbVars->GetSolution()) +
gatherVariables(jPoint, turbVars->GetSolution()));
auto tau = stressTensor(avgV.laminarVisc() + (uq? Double(0.0) : avgV.eddyVisc()), avgGrad, density, turb_ke);
if(useSA_QCR) addQCR(avgGrad, tau);
if(uq) {
Double turb_ke = 0.5*(gatherVariables(iPoint, turbVars->GetSolution()) +
gatherVariables(jPoint, turbVars->GetSolution()));
turb_ke = 0.5*(gatherVariables(iPoint, turbVars->GetSolution()) +
gatherVariables(jPoint, turbVars->GetSolution()));
addPerturbedRSM(avgV, avgGrad, turb_ke, tau,
uq_eigval_comp, uq_permute, uq_delta_b, uq_urlx);
}
Expand Down Expand Up @@ -263,6 +269,7 @@ class CCompressibleViscousFlux : public CCompressibleViscousFluxBase<NDIM, CComp
using Base::prandtlLam;
using Base::prandtlTurb;
using Base::cp;
using Base::turbVars;

/*!
* \brief Constructor, initialize constants and booleans.
Expand Down Expand Up @@ -319,6 +326,8 @@ class CGeneralCompressibleViscousFlux : public CCompressibleViscousFluxBase<NDIM
static constexpr size_t nSecVar = 4;
using Base = CCompressibleViscousFluxBase<NDIM, CGeneralCompressibleViscousFlux<NDIM> >;
using Base::prandtlTurb;
using Base::turbVars;
;

/*!
* \brief Constructor, initialize constants and booleans.
Expand Down
Loading
Loading