Skip to content

Commit c523946

Browse files
committed
edge-based strategy for reconstructions
1 parent 2378913 commit c523946

5 files changed

Lines changed: 43 additions & 57 deletions

File tree

SU2_CFD/include/solvers/CEulerSolver.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMP
4343
Prandtl_Lam = 0.0, /*!< \brief Laminar Prandtl number. */
4444
Prandtl_Turb = 0.0; /*!< \brief Turbulent Prandtl number. */
4545

46+
su2vector<int8_t> NonPhysicalEdgeCounter; /*!< \brief Non-physical reconstruction counter for each edge. */
47+
4648
su2double AllBound_CEquivArea_Inv=0.0; /*!< \brief equivalent area coefficient (inviscid contribution) for all the boundaries. */
4749
vector<su2double> CEquivArea_Mnt; /*!< \brief Equivalent area (inviscid contribution) for each boundary. */
4850
vector<su2double> CEquivArea_Inv; /*!< \brief Equivalent area (inviscid contribution) for each boundary. */

SU2_CFD/include/solvers/CIncEulerSolver.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, ENUM_REGIME
4141
vector<CFluidModel*> FluidModel; /*!< \brief fluid model used in the solver. */
4242
StreamwisePeriodicValues SPvals, SPvalsUpdated;
4343

44+
su2vector<int8_t> NonPhysicalEdgeCounter; /*!< \brief Non-physical reconstruction counter for each edge. */
45+
4446
/*!
4547
* \brief Preprocessing actions common to the Euler and NS solvers.
4648
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,
148148

149149
Allocate(*config);
150150

151+
NonPhysicalEdgeCounter.resize(geometry->GetnEdge()) = 0;
152+
151153
/*--- MPI + OpenMP initialization. ---*/
152154

153155
HybridParallelInitialization(*config, *geometry);
@@ -1829,32 +1831,19 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
18291831
}
18301832
su2double RoeEnthalpy = (R * Primitive_j[prim_idx.Enthalpy()] + Primitive_i[prim_idx.Enthalpy()]) / (R+1);
18311833

1832-
bool neg_sound_speed = ((Gamma-1)*(RoeEnthalpy-0.5*sq_vel) < 0.0);
1833-
1834-
bool bad_i = neg_sound_speed || neg_pres_or_rho_i;
1835-
bool bad_j = neg_sound_speed || neg_pres_or_rho_j;
1836-
1837-
auto update_nonphysical = [&](){
1838-
nodes->SetNon_Physical(iPoint, bad_i);
1839-
nodes->SetNon_Physical(jPoint, bad_j);
1840-
1841-
/*--- Get updated state, in case the point recovered after the set. ---*/
1842-
bad_i = nodes->GetNon_Physical(iPoint);
1843-
bad_j = nodes->GetNon_Physical(jPoint);
1844-
};
1845-
1846-
if(ReducerStrategy){
1847-
SU2_OMP_CRITICAL
1848-
update_nonphysical();
1849-
END_SU2_OMP_CRITICAL
1850-
} else {
1851-
update_nonphysical();
1834+
const bool neg_sound_speed = ((Gamma-1)*(RoeEnthalpy-0.5*sq_vel) < 0.0);
1835+
bool bad_recon = neg_sound_speed || neg_pres_or_rho_i || neg_pres_or_rho_j;
1836+
if (bad_recon) {
1837+
/*--- Force 1st order for this edge for at least 20 iterations. ---*/
1838+
NonPhysicalEdgeCounter[iEdge] = 20;
1839+
} else if (NonPhysicalEdgeCounter[iEdge] > 0) {
1840+
--NonPhysicalEdgeCounter[iEdge];
1841+
bad_recon = true;
18521842
}
1843+
counter_local += bad_recon;
18531844

1854-
counter_local += bad_i+bad_j;
1855-
1856-
numerics->SetPrimitive(bad_i? V_i : Primitive_i, bad_j? V_j : Primitive_j);
1857-
numerics->SetSecondary(bad_i? S_i : Secondary_i, bad_j? S_j : Secondary_j);
1845+
numerics->SetPrimitive(bad_recon? V_i : Primitive_i, bad_recon? V_j : Primitive_j);
1846+
numerics->SetSecondary(bad_recon? S_i : Secondary_i, bad_recon? S_j : Secondary_j);
18581847

18591848
}
18601849

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
149149

150150
Allocate(*config);
151151

152+
NonPhysicalEdgeCounter.resize(geometry->GetnEdge()) = 0;
153+
152154
/*--- MPI + OpenMP initialization. ---*/
153155

154156
HybridParallelInitialization(*config, *geometry);
@@ -471,7 +473,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i
471473

472474
case INC_IDEAL_GAS:
473475
fluidModel = new CIncIdealGas(Specific_Heat_CpND, Gas_ConstantND, Pressure_ThermodynamicND);
474-
fluidModel->SetTDState_T(Temperature_FreeStreamND);
476+
fluidModel->SetTDState_T(Temperature_FreeStreamND);
475477
break;
476478

477479
case FLUID_MIXTURE:
@@ -490,7 +492,7 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i
490492
}
491493
fluidModel->SetTDState_T(Temperature_FreeStreamND);
492494
break;
493-
495+
494496
}
495497

496498
if (viscous) {
@@ -1254,36 +1256,27 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont
12541256
checked. Pressure is the dynamic pressure (can be negative). ---*/
12551257

12561258
if (config->GetEnergy_Equation()) {
1257-
bool neg_temperature_i = (Primitive_i[prim_idx.Temperature()] < 0.0);
1258-
bool neg_temperature_j = (Primitive_j[prim_idx.Temperature()] < 0.0);
1259-
1260-
bool neg_density_i = (Primitive_i[prim_idx.Density()] < 0.0);
1261-
bool neg_density_j = (Primitive_j[prim_idx.Density()] < 0.0);
1262-
1263-
auto update_nonphysical = [&](){
1264-
nodes->SetNon_Physical(iPoint, neg_density_i || neg_temperature_i);
1265-
nodes->SetNon_Physical(jPoint, neg_density_j || neg_temperature_j);
1266-
1267-
/* Lastly, check for existing first-order points still active from previous iterations. */
1259+
const bool neg_temperature_i = (Primitive_i[prim_idx.Temperature()] < 0.0);
1260+
const bool neg_temperature_j = (Primitive_j[prim_idx.Temperature()] < 0.0);
1261+
1262+
const bool neg_density_i = (Primitive_i[prim_idx.Density()] < 0.0);
1263+
const bool neg_density_j = (Primitive_j[prim_idx.Density()] < 0.0);
1264+
1265+
bool bad_recon = neg_temperature_i || neg_temperature_j || neg_density_i || neg_density_j;
1266+
if (bad_recon) {
1267+
/*--- Force 1st order for this edge for at least 20 iterations. ---*/
1268+
NonPhysicalEdgeCounter[iEdge] = 20;
1269+
} else if (NonPhysicalEdgeCounter[iEdge] > 0) {
1270+
--NonPhysicalEdgeCounter[iEdge];
1271+
bad_recon = true;
1272+
}
1273+
counter_local += bad_recon;
12681274

1269-
if (nodes->GetNon_Physical(iPoint)) {
1270-
counter_local++;
1271-
for (iVar = 0; iVar < nPrimVar; iVar++)
1272-
Primitive_i[iVar] = V_i[iVar];
1273-
}
1274-
if (nodes->GetNon_Physical(jPoint)) {
1275-
counter_local++;
1276-
for (iVar = 0; iVar < nPrimVar; iVar++)
1277-
Primitive_j[iVar] = V_j[iVar];
1275+
if (bad_recon) {
1276+
for (iVar = 0; iVar < nPrimVar; iVar++) {
1277+
Primitive_i[iVar] = V_i[iVar];
1278+
Primitive_j[iVar] = V_j[iVar];
12781279
}
1279-
};
1280-
1281-
if(ReducerStrategy){
1282-
SU2_OMP_CRITICAL
1283-
update_nonphysical();
1284-
END_SU2_OMP_CRITICAL
1285-
} else {
1286-
update_nonphysical();
12871280
}
12881281
}
12891282

@@ -2235,7 +2228,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
22352228
Flow_Dir = Inlet_FlowDir[val_marker][iVertex];
22362229
Flow_Dir_Mag = GeometryToolbox::Norm(nDim, Flow_Dir);
22372230

2238-
/*--- Store the unit flow direction vector.
2231+
/*--- Store the unit flow direction vector.
22392232
If requested, use the local boundary normal (negative),
22402233
instead of the prescribed flow direction in the config. ---*/
22412234

@@ -2352,7 +2345,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
23522345
V_inlet[iDim+prim_idx.Velocity()] = nodes->GetVelocity(iPoint,iDim);
23532346
/* pressure obtained from interior */
23542347
V_inlet[prim_idx.Pressure()] = nodes->GetPressure(iPoint);
2355-
}
2348+
}
23562349

23572350
/*--- Access density at the node. This is either constant by
23582351
construction, or will be set fixed implicitly by the temperature

SU2_CFD/src/solvers/CSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry,
10551055
#ifdef HAVE_MPI
10561056
/*--- Once we have recv'd a message, get the source rank. ---*/
10571057
int ind;
1058-
SU2_OMP_SAFE_GLOBAL_ACCESS(SU2_MPI::Waitany(geometry->nPeriodicRecv, eometry->req_PeriodicRecv, &ind, &status);)
1058+
SU2_OMP_SAFE_GLOBAL_ACCESS(SU2_MPI::Waitany(geometry->nPeriodicRecv, geometry->req_PeriodicRecv, &ind, &status);)
10591059
source = status.MPI_SOURCE;
10601060
#else
10611061
/*--- For serial calculations, we know the rank. ---*/

0 commit comments

Comments
 (0)