Skip to content

Commit cf4677b

Browse files
authored
Merge pull request #1326 from su2code/nemo_update
Fix for axisymmetric terms in NEMO + general NEMO updates
2 parents 22bb669 + 32b7c95 commit cf4677b

22 files changed

Lines changed: 299 additions & 325 deletions

Common/src/CConfig.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,14 +3601,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
36013601
SU2_MPI::Error("AUSMPW+ is extremely unstable. Feel free to fix me!", CURRENT_FUNCTION);
36023602
}
36033603

3604-
if (GetGasModel() == "ARGON" && GetKind_FluidModel() == SU2_NONEQ){
3605-
SU2_MPI::Error("ARGON is not working with SU2_NONEQ fluid model!", CURRENT_FUNCTION);
3606-
}
3607-
3608-
if (GetKind_FluidModel() == MUTATIONPP && GetFrozen() == true){
3609-
SU2_MPI::Error("The option of FROZEN_MIXTURE is not yet working with Mutation++ support.", CURRENT_FUNCTION);
3610-
}
3611-
36123604
if(GetBoolTurbomachinery()){
36133605
nBlades = new su2double[nZone];
36143606
FreeStreamTurboNormal= new su2double[3];
@@ -5042,7 +5034,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
50425034
/*--- Specifying a deforming surface requires a mesh deformation solver. ---*/
50435035
if (GetSurface_Movement(DEFORMING)) Deform_Mesh = true;
50445036

5045-
if (GetGasModel() == "ARGON") monoatomic = true;
5037+
if (GetGasModel() == "ARGON") {monoatomic = true;}
5038+
else {monoatomic = false;}
50465039

50475040
// This option is deprecated. After a grace period until 7.2.0 the usage warning should become an error.
50485041
if(OptionIsSet("CONV_CRITERIA") && rank == MASTER_NODE) {

SU2_CFD/include/fluid/CMutationTCLib.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CMutationTCLib : public CNEMOGas {
8787
/*!
8888
* \brief Compute vector of species V-E energy.
8989
*/
90-
vector<su2double>& ComputeSpeciesEve(su2double val_T) final;
90+
vector<su2double>& ComputeSpeciesEve(su2double val_T, bool vibe_only = false) final;
9191

9292
/*!
9393
* \brief Compute species net production rates.

SU2_CFD/include/fluid/CNEMOGas.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class CNEMOGas : public CFluidModel {
134134
/*!
135135
* \brief Compute vector of species V-E energy.
136136
*/
137-
virtual vector<su2double>& ComputeSpeciesEve(su2double val_T) = 0;
137+
virtual vector<su2double>& ComputeSpeciesEve(su2double val_T, bool vibe_only = false) = 0;
138138

139139
/*!
140140
* \brief Compute species enthalpies.

SU2_CFD/include/fluid/CSU2TCLib.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CSU2TCLib : public CNEMOGas {
5050
ArrheniusEta, /*!< \brief Arrhenius reaction temperature exponent */
5151
ArrheniusTheta, /*!< \brief Arrhenius reaction characteristic temperature */
5252
CharVibTemp, /*!< \brief Characteristic vibrational temperature for e_vib */
53-
RotationModes, /*!< \brief Rotational modes of energy storage */
53+
RotationModes, /*!< \brief Rotational modes of energy storage */
5454
Tcf_a, /*!< \brief Rate controlling temperature exponent (fwd) */
5555
Tcf_b, /*!< \brief Rate controlling temperature exponent (fwd) */
5656
Tcb_a, /*!< \brief Rate controlling temperature exponent (bkw) */
@@ -115,7 +115,7 @@ class CSU2TCLib : public CNEMOGas {
115115
/*!
116116
* \brief Compute species V-E energy.
117117
*/
118-
vector<su2double>& ComputeSpeciesEve(su2double val_T) final;
118+
vector<su2double>& ComputeSpeciesEve(su2double val_T, bool vibe_only = false) final;
119119

120120
/*!
121121
* \brief Compute species net production rates.

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class CFVMFlowSolverBase : public CSolver {
277277
*/
278278
void SumEdgeFluxes(const CGeometry* geometry);
279279

280+
/*!
281+
* \brief Computes and sets the required auxilliary vars (and gradients) for axisymmetric flow.
282+
*/
283+
void ComputeAxisymmetricAuxGradients(CGeometry *geometry, const CConfig* config);
284+
280285
/*!
281286
* \brief Instantiate a SIMD numerics object.
282287
*/

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,3 +2923,32 @@ su2double CFVMFlowSolverBase<V,R>::EvaluateCommonObjFunc(const CConfig& config)
29232923

29242924
return objFun;
29252925
}
2926+
2927+
template <class V, ENUM_REGIME FlowRegime>
2928+
void CFVMFlowSolverBase<V, FlowRegime>::ComputeAxisymmetricAuxGradients(CGeometry *geometry, const CConfig* config) {
2929+
2930+
/*--- Loop through all points to set the auxvargrad --*/
2931+
SU2_OMP_FOR_STAT(omp_chunk_size)
2932+
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
2933+
su2double yCoord = geometry->nodes->GetCoord(iPoint, 1);
2934+
su2double yVelocity = nodes->GetVelocity(iPoint,1);
2935+
su2double xVelocity = nodes->GetVelocity(iPoint,0);
2936+
su2double Total_Viscosity = nodes->GetLaminarViscosity(iPoint) + nodes->GetEddyViscosity(iPoint);
2937+
2938+
if (yCoord > EPS){
2939+
su2double nu_v_on_y = Total_Viscosity*yVelocity/yCoord;
2940+
nodes->SetAuxVar(iPoint, 0, nu_v_on_y);
2941+
nodes->SetAuxVar(iPoint, 1, nu_v_on_y*yVelocity);
2942+
nodes->SetAuxVar(iPoint, 2, nu_v_on_y*xVelocity);
2943+
}
2944+
}
2945+
END_SU2_OMP_FOR
2946+
2947+
/*--- Compute the auxiliary variable gradient with GG or WLS. ---*/
2948+
if (config->GetKind_Gradient_Method() == GREEN_GAUSS) {
2949+
SetAuxVar_Gradient_GG(geometry, config);
2950+
}
2951+
if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) {
2952+
SetAuxVar_Gradient_LS(geometry, config);
2953+
}
2954+
}

SU2_CFD/src/fluid/CMutationTCLib.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ CMutationTCLib::CMutationTCLib(const CConfig* config, unsigned short val_nDim):
4848
transport_model = "Gupta-Yos";
4949

5050
opt.setStateModel("ChemNonEqTTv");
51+
if (frozen) opt.setMechanism("none");
5152
opt.setViscosityAlgorithm(transport_model);
5253
opt.setThermalConductivityAlgorithm(transport_model);
5354

@@ -118,7 +119,7 @@ vector<su2double>& CMutationTCLib::ComputeMixtureEnergies(){
118119
return energies;
119120
}
120121

121-
vector<su2double>& CMutationTCLib::ComputeSpeciesEve(su2double val_T){
122+
vector<su2double>& CMutationTCLib::ComputeSpeciesEve(su2double val_T, bool vibe_only){
122123

123124
SetTDStateRhosTTv(rhos, T, val_T);
124125

SU2_CFD/src/fluid/CNEMOGas.cpp

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CNEMOGas::CNEMOGas(const CConfig* config, unsigned short val_nDim): CFluidModel(
4040
Cvtrs.resize(nSpecies,0.0);
4141
Cvves.resize(nSpecies,0.0);
4242
eves.resize(nSpecies,0.0);
43-
hs.resize(nSpecies,0.0);
43+
hs.resize(2*nSpecies,0.0);
4444
ws.resize(nSpecies,0.0);
4545
DiffusionCoeff.resize(nSpecies,0.0);
4646
Enthalpy_Formation.resize(nSpecies,0.0);
@@ -59,23 +59,21 @@ CNEMOGas::CNEMOGas(const CConfig* config, unsigned short val_nDim): CFluidModel(
5959
void CNEMOGas::SetTDStatePTTv(su2double val_pressure, const su2double *val_massfrac,
6060
su2double val_temperature, su2double val_temperature_ve){
6161

62-
su2double denom;
63-
64-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++)
62+
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
6563
MassFrac[iSpecies] = val_massfrac[iSpecies];
6664
Pressure = val_pressure;
6765
T = val_temperature;
6866
Tve = val_temperature_ve;
6967

70-
denom = 0.0;
68+
su2double denom = 0.0;
7169

7270
/*--- Calculate mixture density from supplied primitive quantities ---*/
73-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++)
74-
denom += MassFrac[iSpecies] * (Ru/MolarMass[iSpecies]) * T;
7571
for (iSpecies = 0; iSpecies < nEl; iSpecies++)
76-
denom += MassFrac[nSpecies-1] * (Ru/MolarMass[nSpecies-1]) * Tve;
72+
denom += MassFrac[iSpecies] * (Ru/MolarMass[iSpecies]) * Tve;
73+
for (iSpecies = nEl; iSpecies < nSpecies; iSpecies++)
74+
denom += MassFrac[iSpecies] * (Ru/MolarMass[iSpecies]) * T;
7775
Density = Pressure / denom;
78-
76+
7977
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++){
8078
rhos[iSpecies] = MassFrac[iSpecies]*Density;
8179
MassFrac[iSpecies] = rhos[iSpecies]/Density;
@@ -84,18 +82,16 @@ void CNEMOGas::SetTDStatePTTv(su2double val_pressure, const su2double *val_massf
8482

8583
su2double CNEMOGas::ComputeSoundSpeed(){
8684

87-
su2double conc, rhoCvtr;
88-
89-
conc = 0.0;
90-
rhoCvtr = 0.0;
85+
su2double conc = 0.0;
86+
su2double rhoCvtr = 0.0;
9187
Density = 0.0;
9288

9389
auto& Cvtrs = GetSpeciesCvTraRot();
9490

9591
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
9692
Density+=rhos[iSpecies];
9793

98-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++){
94+
for (iSpecies = nEl; iSpecies < nSpecies; iSpecies++){
9995
conc += rhos[iSpecies]/MolarMass[iSpecies];
10096
rhoCvtr += rhos[iSpecies] * Cvtrs[iSpecies];
10197
}
@@ -108,10 +104,10 @@ su2double CNEMOGas::ComputePressure(){
108104

109105
su2double P = 0.0;
110106

111-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++)
112-
P += rhos[iSpecies] * Ru/MolarMass[iSpecies] * T;
113107
for (iSpecies = 0; iSpecies < nEl; iSpecies++)
114-
P += rhos[nSpecies-1] * Ru/MolarMass[nSpecies-1] * Tve;
108+
P += rhos[iSpecies] * Ru/MolarMass[iSpecies] * Tve;
109+
for (iSpecies = nEl; iSpecies < nSpecies; iSpecies++)
110+
P += rhos[iSpecies] * Ru/MolarMass[iSpecies] * T;
115111

116112
Pressure = P;
117113

@@ -124,7 +120,7 @@ su2double CNEMOGas::ComputeGasConstant(){
124120
su2double Mass = 0.0;
125121

126122
// TODO - extend for ionization
127-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++)
123+
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
128124
Mass += MassFrac[iSpecies] * MolarMass[iSpecies];
129125
GasConstant = Ru / Mass;
130126

@@ -163,15 +159,13 @@ void CNEMOGas::ComputedPdU(su2double *V, vector<su2double>& val_eves, su2double
163159

164160
// Note: Electron energy not included properly.
165161

166-
su2double CvtrBAR, rhoCvtr, rhoCvve, rho_el, sqvel, conc, ef;
167-
168162
if (val_dPdU == NULL) {
169163
SU2_MPI::Error("Array dPdU not allocated!", CURRENT_FUNCTION);
170164
}
171165

172166
/*--- Determine the electron density (if ionized) ---*/
173-
if (ionization) { rho_el = rhos[nSpecies-1]; }
174-
else { rho_el = 0.0; }
167+
su2double rho_el = 0.0;
168+
if (ionization) { rho_el = rhos[0]; }
175169

176170
/*--- Necessary indexes to assess primitive variables ---*/
177171
unsigned long RHOS_INDEX = 0;
@@ -189,14 +183,14 @@ void CNEMOGas::ComputedPdU(su2double *V, vector<su2double>& val_eves, su2double
189183
Ref_Temperature = GetRefTemperature();
190184

191185
/*--- Rename for convenience ---*/
192-
rhoCvtr = V[RHOCVTR_INDEX];
193-
rhoCvve = V[RHOCVVE_INDEX];
186+
su2double rhoCvtr = V[RHOCVTR_INDEX];
187+
su2double rhoCvve = V[RHOCVVE_INDEX];
194188
T = V[T_INDEX];
195189

196190
/*--- Pre-compute useful quantities ---*/
197-
CvtrBAR = 0.0;
198-
sqvel = 0.0;
199-
conc = 0.0;
191+
su2double CvtrBAR = 0.0;
192+
su2double sqvel = 0.0;
193+
su2double conc = 0.0;
200194
for (iDim = 0; iDim < nDim; iDim++)
201195
sqvel += V[VEL_INDEX+iDim] * V[VEL_INDEX+iDim];
202196
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++) {
@@ -205,15 +199,16 @@ void CNEMOGas::ComputedPdU(su2double *V, vector<su2double>& val_eves, su2double
205199
}
206200

207201
/*--- Species density derivatives ---*/
208-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++) {
209-
ef = Enthalpy_Formation[iSpecies] - Ru/MolarMass[iSpecies]*Ref_Temperature[iSpecies];
202+
su2double ef = 0.0;
203+
for (iSpecies = nEl; iSpecies < nHeavy; iSpecies++) {
204+
ef = Enthalpy_Formation[iSpecies] - Ru/MolarMass[iSpecies]*Ref_Temperature[iSpecies];
210205
val_dPdU[iSpecies] = T*Ru/MolarMass[iSpecies] + Ru*conc/rhoCvtr *
211206
(-Cvtrs[iSpecies]*(T-Ref_Temperature[iSpecies]) -
212207
ef + 0.5*sqvel);
213208

214209
}
215210
if (ionization) {
216-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++) {
211+
for (iSpecies = nEl; iSpecies < nSpecies; iSpecies++) {
217212
// evibs = Ru/MolarMass[iSpecies] * thetav[iSpecies]/(exp(thetav[iSpecies]/Tve)-1.0);
218213
// num = 0.0;
219214
// denom = g[iSpecies][0] * exp(-thetae[iSpecies][0]/Tve);
@@ -223,12 +218,11 @@ void CNEMOGas::ComputedPdU(su2double *V, vector<su2double>& val_eves, su2double
223218
// }
224219
// eels = Ru/MolarMass[iSpecies] * (num/denom);
225220

226-
val_dPdU[iSpecies] -= rho_el * Ru/MolarMass[nSpecies-1] * (val_eves[iSpecies])/rhoCvve;
221+
val_dPdU[iSpecies] -= rho_el * Ru/MolarMass[0] * (val_eves[iSpecies])/rhoCvve;
227222
}
228-
ef = Enthalpy_Formation[nSpecies-1] - Ru/MolarMass[nSpecies-1]*Ref_Temperature[nSpecies-1];
229-
val_dPdU[nSpecies-1] = Ru*conc/rhoCvtr * (-ef + 0.5*sqvel)
230-
+ Ru/MolarMass[nSpecies-1]*Tve
231-
- rho_el*Ru/MolarMass[nSpecies-1] * (-3.0/2.0*Ru/MolarMass[nSpecies-1]*Tve)/rhoCvve;
223+
ef = Enthalpy_Formation[0] - Ru/MolarMass[0]*Ref_Temperature[0];
224+
val_dPdU[0] = Ru*conc/rhoCvtr * (-ef + 0.5*sqvel) + Ru/MolarMass[0]*Tve
225+
- rho_el*Ru/MolarMass[0] * (-3.0/2.0*Ru/MolarMass[0]*Tve)/rhoCvve;
232226
}
233227

234228
/*--- Momentum derivatives ---*/
@@ -240,13 +234,12 @@ void CNEMOGas::ComputedPdU(su2double *V, vector<su2double>& val_eves, su2double
240234

241235
/*--- Vib.-el energy derivative ---*/
242236
val_dPdU[nSpecies+nDim+1] = -val_dPdU[nSpecies+nDim] +
243-
rho_el*Ru/MolarMass[nSpecies-1]*1.0/rhoCvve;
237+
rho_el*Ru/MolarMass[0]*1.0/rhoCvve;
244238

245239
}
246240

247241
void CNEMOGas::ComputedTdU(su2double *V, su2double *val_dTdU){
248242

249-
su2double v2, ef, rhoCvtr;
250243
su2double Vel[3] = {0.0};
251244

252245
/*--- Necessary indexes to assess primitive variables ---*/
@@ -255,8 +248,8 @@ void CNEMOGas::ComputedTdU(su2double *V, su2double *val_dTdU){
255248
unsigned long RHOCVTR_INDEX = nSpecies+nDim+6;
256249

257250
/*--- Rename for convenience ---*/
258-
T = V[T_INDEX];
259-
rhoCvtr = V[RHOCVTR_INDEX];
251+
T = V[T_INDEX];
252+
su2double rhoCvtr = V[RHOCVTR_INDEX];
260253

261254
Cvtrs = GetSpeciesCvTraRot();
262255
Enthalpy_Formation = GetSpeciesFormationEnthalpy();
@@ -265,11 +258,11 @@ void CNEMOGas::ComputedTdU(su2double *V, su2double *val_dTdU){
265258
/*--- Calculate supporting quantities ---*/
266259
for (iDim = 0; iDim < nDim; iDim++)
267260
Vel[iDim] = V[VEL_INDEX+iDim]*V[VEL_INDEX+iDim];
268-
v2 = GeometryToolbox::SquaredNorm(nDim,Vel);
261+
su2double v2 = GeometryToolbox::SquaredNorm(nDim,Vel);
269262

270263
/*--- Species density derivatives ---*/
271-
for (iSpecies = 0; iSpecies < nHeavy; iSpecies++) {
272-
ef = Enthalpy_Formation[iSpecies] - Ru/MolarMass[iSpecies]*Ref_Temperature[iSpecies];
264+
for (iSpecies = nEl; iSpecies < nSpecies; iSpecies++) {
265+
su2double ef = Enthalpy_Formation[iSpecies] - Ru/MolarMass[iSpecies]*Ref_Temperature[iSpecies];
273266
val_dTdU[iSpecies] = (-ef + 0.5*v2 + Cvtrs[iSpecies]*(Ref_Temperature[iSpecies]-T)) / rhoCvtr;
274267
}
275268

@@ -289,13 +282,11 @@ void CNEMOGas::ComputedTdU(su2double *V, su2double *val_dTdU){
289282

290283
void CNEMOGas::ComputedTvedU(su2double *V, vector<su2double>& val_eves, su2double *val_dTvedU){
291284

292-
su2double rhoCvve;
293-
294285
/*--- Necessary indexes to assess primitive variables ---*/
295286
unsigned long RHOCVVE_INDEX = nSpecies+nDim+7;
296287

297288
/*--- Rename for convenience ---*/
298-
rhoCvve = V[RHOCVVE_INDEX];
289+
su2double rhoCvve = V[RHOCVVE_INDEX];
299290

300291
/*--- Species density derivatives ---*/
301292
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++) {

0 commit comments

Comments
 (0)