Skip to content

Commit d1e3568

Browse files
authored
Merge pull request #1383 from su2code/feature_NEMO_Jhs
Addition of species diffusion term to surface heat flux
2 parents 58c580b + c5044a2 commit d1e3568

4 files changed

Lines changed: 54 additions & 34 deletions

File tree

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,9 +2392,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
23922392

23932393
unsigned long iVertex, iPoint, iPointNormal;
23942394
unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
2395-
unsigned short T_INDEX = 0, TVE_INDEX = 0, VEL_INDEX = 0;
2396-
su2double Viscosity = 0.0, WallDist[3] = {0.0}, Area, TauNormal, dTn, dTven,
2397-
GradTemperature, Density = 0.0, WallDistMod, FrictionVel,
2395+
unsigned short T_INDEX = 0, TVE_INDEX = 0, VEL_INDEX = 0, RHOS_INDEX = 0;
2396+
su2double Viscosity = 0.0, WallDist[3] = {0.0}, Area, Density = 0.0, GradTemperature = 0.0,
23982397
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, TauTangent[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
23992398
thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0}, AxiFactor;
24002399
const su2double *Coord = nullptr, *Coord_Normal = nullptr, *Normal = nullptr;
@@ -2527,30 +2526,25 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25272526
/*--- Compute wall shear stress (using the stress tensor). Compute wall skin friction coefficient, and heat flux
25282527
* on the wall ---*/
25292528

2530-
TauNormal = 0.0;
2531-
for (iDim = 0; iDim < nDim; iDim++) TauNormal += TauElem[iDim] * UnitNormal[iDim];
2529+
su2double TauNormal = GeometryToolbox::DotProduct(nDim, TauElem, UnitNormal);
25322530

2533-
WallShearStress[iMarker][iVertex] = 0.0;
25342531
for (iDim = 0; iDim < nDim; iDim++) {
25352532
TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim];
25362533
/* --- in case of wall functions, we have computed the skin friction in the turbulence solver --- */
25372534
/* --- Note that in the wall model, we switch off the computation when the computed y+ < 5 --- */
25382535
/* --- We put YPlus to 1.0 so we have to compute skinfriction and the actual y+ in that case as well --- */
25392536
if (!wallfunctions || (wallfunctions && YPlus[iMarker][iVertex] < 5.0))
25402537
CSkinFriction[iMarker](iVertex,iDim) = TauTangent[iDim] * factorFric;
2541-
2542-
WallShearStress[iMarker][iVertex] += TauTangent[iDim] * TauTangent[iDim];
25432538
}
2544-
WallShearStress[iMarker][iVertex] = sqrt(WallShearStress[iMarker][iVertex]);
2539+
WallShearStress[iMarker][iVertex] = GeometryToolbox::Norm(nDim, TauTangent);
25452540

25462541
for (iDim = 0; iDim < nDim; iDim++) WallDist[iDim] = (Coord[iDim] - Coord_Normal[iDim]);
2547-
WallDistMod = 0.0;
2548-
for (iDim = 0; iDim < nDim; iDim++) WallDistMod += WallDist[iDim] * WallDist[iDim];
2549-
WallDistMod = sqrt(WallDistMod);
2542+
2543+
su2double WallDistMod = GeometryToolbox::Norm(nDim, WallDist);
25502544

25512545
/*--- Compute y+ and non-dimensional velocity ---*/
25522546

2553-
FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density);
2547+
su2double FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density);
25542548

25552549
/* --- in case of wall functions, we have computed YPlus in the turbulence class --- */
25562550
/* --- Note that we do not recompute y+ when y+<5 because y+ can become > 5 again --- */
@@ -2562,35 +2556,41 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25622556
/// TODO: Move these ifs to specialized functions.
25632557
if (!nemo){
25642558

2565-
GradTemperature = 0.0;
2566-
25672559
if (FlowRegime == ENUM_REGIME::COMPRESSIBLE) {
2568-
for (iDim = 0; iDim < nDim; iDim++) GradTemperature -= Grad_Temp[iDim] * UnitNormal[iDim];
2560+
GradTemperature = -GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
25692561

25702562
Cp = (Gamma / Gamma_Minus_One) * Gas_Constant;
25712563
thermal_conductivity = Cp * Viscosity / Prandtl_Lam;
25722564
}
25732565
if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE) {
25742566
if (energy)
2575-
for (iDim = 0; iDim < nDim; iDim++) GradTemperature -= Grad_Temp[iDim] * UnitNormal[iDim];
2567+
GradTemperature = -GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
25762568

25772569
thermal_conductivity = nodes->GetThermalConductivity(iPoint);
25782570
}
2579-
25802571
HeatFlux[iMarker][iVertex] = -thermal_conductivity * GradTemperature * RefHeatFlux;
25812572

25822573
} else {
25832574

2584-
const auto thermal_conductivity_tr = nodes->GetThermalConductivity(iPoint);
2585-
const auto thermal_conductivity_ve = nodes->GetThermalConductivity_ve(iPoint);
2586-
const auto Grad_PrimVar = nodes->GetGradient_Primitive(iPoint);
2587-
2588-
dTn = 0.0; dTven = 0.0;
2589-
for (iDim = 0; iDim < nDim; iDim++) {
2590-
dTn += Grad_PrimVar[T_INDEX][iDim]*UnitNormal[iDim];
2591-
dTven += Grad_PrimVar[TVE_INDEX][iDim]*UnitNormal[iDim];
2592-
}
2593-
HeatFlux[iMarker][iVertex] = thermal_conductivity_tr*dTn + thermal_conductivity_ve*dTven;
2575+
unsigned short iSpecies, nSpecies = config->GetnSpecies();
2576+
2577+
const auto& thermal_conductivity_tr = nodes->GetThermalConductivity(iPoint);
2578+
const auto& thermal_conductivity_ve = nodes->GetThermalConductivity_ve(iPoint);
2579+
const auto& Grad_PrimVar = nodes->GetGradient_Primitive(iPoint);
2580+
const auto& Ds = nodes->GetDiffusionCoeff(iPoint);
2581+
const auto& hs = nodes->GetEnthalpys(iPoint);
2582+
2583+
/*--- Compute enthalpy transport to surface due to mass diffusion ---*/
2584+
su2double sumJhs = 0.0;
2585+
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
2586+
sumJhs += Ds[iSpecies]*hs[iSpecies]*GeometryToolbox::DotProduct(nDim, Grad_PrimVar[RHOS_INDEX+iSpecies], UnitNormal);
2587+
2588+
su2double dTn = GeometryToolbox::DotProduct(nDim, Grad_PrimVar[T_INDEX], UnitNormal);
2589+
su2double dTven = GeometryToolbox::DotProduct(nDim, Grad_PrimVar[TVE_INDEX], UnitNormal);
2590+
2591+
/*--- Surface energy balance: trans-rot heat flux, vib-el heat flux,
2592+
enthalpy transport due to mass diffusion ---*/
2593+
HeatFlux[iMarker][iVertex] = thermal_conductivity_tr*dTn + thermal_conductivity_ve*dTven + sumJhs;
25942594
}
25952595

25962596
/*--- Note that y+, and heat are computed at the

SU2_CFD/include/variables/CNEMONSVariable.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ class CNEMONSVariable final : public CNEMOEulerVariable {
4242
VectorType Viscosity_Ref; /*!< \brief Reference viscosity of the fluid. */
4343
VectorType Viscosity_Inf; /*!< \brief Viscosity of the fluid at the infinity. */
4444
MatrixType DiffusionCoeff; /*!< \brief Diffusion coefficient of the mixture. */
45-
CVectorOfMatrix Dij; /*!< \brief Binary diffusion coefficients. */
45+
CVectorOfMatrix Dij; /*!< \brief Binary diffusion coefficients. */
4646
VectorType LaminarViscosity; /*!< \brief Viscosity of the fluid. */
4747
VectorType ThermalCond; /*!< \brief T-R thermal conductivity of the gas mixture. */
4848
VectorType ThermalCond_ve; /*!< \brief V-E thermal conductivity of the gas mixture. */
49-
vector<su2double> thermalconductivities;
50-
vector<su2double> Ds;
49+
MatrixType Enthalpys; /*!< \brief Species enthalpies of the mixture. */
5150

5251
su2double inv_TimeScale; /*!< \brief Inverse of the reference time scale. */
5352

@@ -100,6 +99,12 @@ class CNEMONSVariable final : public CNEMOEulerVariable {
10099
*/
101100
inline su2double* GetDiffusionCoeff(unsigned long iPoint) override { return DiffusionCoeff[iPoint]; }
102101

102+
/*!
103+
* \brief Get the species enthalpy.
104+
* \return Value of the species enthalpy.
105+
*/
106+
inline su2double* GetEnthalpys(unsigned long iPoint) override { return Enthalpys[iPoint]; }
107+
103108
/*!
104109
* \brief Get the laminar viscosity of the flow.
105110
* \return Value of the laminar viscosity of the flow.

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,12 @@ class CVariable {
937937
*/
938938
inline virtual su2double GetMassFraction(unsigned long iPoint, unsigned long val_Species) const { return 0.0; }
939939

940+
/*!
941+
* \brief Get the species enthalpy.
942+
* \return Value of the species enthalpy.
943+
*/
944+
inline virtual su2double* GetEnthalpys(unsigned long iPoint) { return nullptr; }
945+
940946
/*!
941947
* \brief A virtual member.
942948
* \param[in] iPoint - Point index.

SU2_CFD/src/variables/CNEMONSVariable.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ CNEMONSVariable::CNEMONSVariable(su2double val_pressure,
6161
LaminarViscosity.resize(nPoint) = su2double(0.0);
6262
ThermalCond.resize(nPoint) = su2double(0.0);
6363
ThermalCond_ve.resize(nPoint) = su2double(0.0);
64+
Enthalpys.resize(nPoint, nSpecies) = su2double(0.0);
6465

6566
Max_Lambda_Visc.resize(nPoint) = su2double(0.0);
6667
inv_TimeScale = config->GetModVel_FreeStream() / config->GetRefLength();
@@ -77,7 +78,7 @@ CNEMONSVariable::CNEMONSVariable(su2double val_pressure,
7778

7879
bool CNEMONSVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) {
7980

80-
unsigned short iVar, iSpecies;
81+
unsigned long iVar, iSpecies;
8182

8283
fluidmodel = static_cast<CNEMOGas*>(FluidModel);
8384

@@ -98,13 +99,21 @@ bool CNEMONSVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel)
9899

99100
SetVelocity2(iPoint);
100101

101-
Ds = fluidmodel->GetDiffusionCoeff();
102+
const auto& Ds = fluidmodel->GetDiffusionCoeff();
102103
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
103104
DiffusionCoeff(iPoint, iSpecies) = Ds[iSpecies];
104105

106+
su2double T = Primitive(iPoint,nSpecies);
107+
su2double Tve = Primitive(iPoint,nSpecies+1);
108+
109+
su2double* val_eves = GetEve(iPoint);
110+
const auto& hs = fluidmodel->ComputeSpeciesEnthalpy(T, Tve, val_eves);
111+
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
112+
Enthalpys(iPoint, iSpecies) = hs[iSpecies];
113+
105114
LaminarViscosity(iPoint) = fluidmodel->GetViscosity();
106115

107-
thermalconductivities = fluidmodel->GetThermalConductivities();
116+
const auto& thermalconductivities = fluidmodel->GetThermalConductivities();
108117
ThermalCond(iPoint) = thermalconductivities[0];
109118
ThermalCond_ve(iPoint) = thermalconductivities[1];
110119

0 commit comments

Comments
 (0)