Skip to content

Commit 5a45e37

Browse files
committed
restructured code in loops for efficiency, and added comments
Signed-off-by: jtneedels <jneedels@stanford.edu>
1 parent ccd2c10 commit 5a45e37

1 file changed

Lines changed: 51 additions & 67 deletions

File tree

SU2_CFD/src/solvers/CNEMOEulerSolver.cpp

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,57 @@ void CNEMOEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_con
11461146
numerics->SetVolume(geometry->nodes->GetVolume(iPoint));
11471147
numerics->SetCoord(geometry->nodes->GetCoord(iPoint),
11481148
geometry->nodes->GetCoord(iPoint) );
1149+
1150+
/*--- Compute finite rate chemistry ---*/
1151+
1152+
if(!monoatomic){
1153+
if(!frozen){
1154+
/*--- Compute the non-equilibrium chemistry ---*/
1155+
auto residual = numerics->ComputeChemistry(config);
1156+
1157+
/*--- Check for errors before applying source to the linear system ---*/
1158+
err = false;
1159+
for (iVar = 0; iVar < nVar; iVar++)
1160+
if (residual[iVar] != residual[iVar]) err = true;
1161+
//if (implicit)
1162+
// for (iVar = 0; iVar < nVar; iVar++)
1163+
// for (jVar = 0; jVar < nVar; jVar++)
1164+
// if (Jacobian_i[iVar][jVar] != Jacobian_i[iVar][jVar]) err = true;
1165+
1166+
/*--- Apply the chemical sources to the linear system ---*/
1167+
if (!err) {
1168+
LinSysRes.SubtractBlock(iPoint, residual);
1169+
//if (implicit)
1170+
// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i);
1171+
} else
1172+
eChm_local++;
1173+
}
1174+
}
1175+
1176+
/*--- Compute vibrational energy relaxation ---*/
1177+
/// NOTE: Jacobians don't account for relaxation time derivatives
1178+
1179+
if (!monoatomic){
1180+
auto residual = numerics->ComputeVibRelaxation(config);
1181+
1182+
/*--- Check for errors before applying source to the linear system ---*/
1183+
err = false;
1184+
for (iVar = 0; iVar < nVar; iVar++)
1185+
if (residual[iVar] != residual[iVar]) err = true;
1186+
//if (implicit)
1187+
// for (iVar = 0; iVar < nVar; iVar++)
1188+
// for (jVar = 0; jVar < nVar; jVar++)
1189+
// if (Jacobian_i[iVar][jVar] != Jacobian_i[iVar][jVar]) err = true;
1190+
1191+
/*--- Apply the vibrational relaxation terms to the linear system ---*/
1192+
if (!err) {
1193+
LinSysRes.SubtractBlock(iPoint, residual);
1194+
//if (implicit)
1195+
// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i);
1196+
} else
1197+
eVib_local++;
1198+
}
1199+
11491200
}
11501201
/*--- Compute axisymmetric source terms (if needed) ---*/
11511202
if (config->GetAxisymmetric()) {
@@ -1180,18 +1231,6 @@ void CNEMOEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_con
11801231
SU2_OMP_FOR_DYN(omp_chunk_size)
11811232
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
11821233

1183-
/*--- Set solution ---*/
1184-
numerics->SetConservative(nodes->GetSolution(iPoint), nodes->GetSolution(iPoint));
1185-
1186-
/*--- Set control volume ---*/
1187-
numerics->SetVolume(geometry->nodes->GetVolume(iPoint));
1188-
1189-
/*--- Set y coordinate ---*/
1190-
numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(iPoint));
1191-
1192-
/*--- Set primitive variables for viscous terms and/or generalised source ---*/
1193-
numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nodes->GetPrimitive(iPoint));
1194-
11951234
/*--- If necessary, set variables needed for viscous computation ---*/
11961235
if (viscous) {
11971236

@@ -1216,9 +1255,6 @@ void CNEMOEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_con
12161255
/*--- Vib-el. thermal conductivity ---*/
12171256
numerics->SetThermalConductivity_ve(nodes->GetThermalConductivity_ve(iPoint), nodes->GetThermalConductivity_ve(iPoint));
12181257

1219-
/*--- Vib-el energy ---*/
1220-
numerics->SetEve(nodes->GetEve(iPoint), nodes->GetEve(iPoint));
1221-
12221258
/*--- Set turbulence kinetic energy ---*/
12231259
if (rans){
12241260
CVariable* turbNodes = solver_container[TURB_SOL]->GetNodes();
@@ -1247,58 +1283,6 @@ void CNEMOEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_con
12471283
}
12481284
}
12491285

1250-
if(!monoatomic){
1251-
if(!frozen){
1252-
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
1253-
/*--- Compute the non-equilibrium chemistry ---*/
1254-
auto residual = numerics->ComputeChemistry(config);
1255-
1256-
/*--- Check for errors before applying source to the linear system ---*/
1257-
err = false;
1258-
for (iVar = 0; iVar < nVar; iVar++)
1259-
if (residual[iVar] != residual[iVar]) err = true;
1260-
//if (implicit)
1261-
// for (iVar = 0; iVar < nVar; iVar++)
1262-
// for (jVar = 0; jVar < nVar; jVar++)
1263-
// if (Jacobian_i[iVar][jVar] != Jacobian_i[iVar][jVar]) err = true;
1264-
1265-
/*--- Apply the chemical sources to the linear system ---*/
1266-
if (!err) {
1267-
LinSysRes.SubtractBlock(iPoint, residual);
1268-
//if (implicit)
1269-
// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i);
1270-
} else
1271-
eChm_local++;
1272-
}
1273-
}
1274-
}
1275-
1276-
/*--- Compute vibrational energy relaxation ---*/
1277-
/// NOTE: Jacobians don't account for relaxation time derivatives
1278-
1279-
if (!monoatomic){
1280-
for (iPoint = 0; iPoint < nPointDomain; iPoint++) {
1281-
auto residual = numerics->ComputeVibRelaxation(config);
1282-
1283-
/*--- Check for errors before applying source to the linear system ---*/
1284-
err = false;
1285-
for (iVar = 0; iVar < nVar; iVar++)
1286-
if (residual[iVar] != residual[iVar]) err = true;
1287-
//if (implicit)
1288-
// for (iVar = 0; iVar < nVar; iVar++)
1289-
// for (jVar = 0; jVar < nVar; jVar++)
1290-
// if (Jacobian_i[iVar][jVar] != Jacobian_i[iVar][jVar]) err = true;
1291-
1292-
/*--- Apply the vibrational relaxation terms to the linear system ---*/
1293-
if (!err) {
1294-
LinSysRes.SubtractBlock(iPoint, residual);
1295-
//if (implicit)
1296-
// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i);
1297-
} else
1298-
eVib_local++;
1299-
}
1300-
}
1301-
13021286
/*--- Checking for NaN ---*/
13031287
eAxi_global = eAxi_local;
13041288
eChm_global = eChm_local;

0 commit comments

Comments
 (0)