Skip to content

Commit 58833bb

Browse files
committed
use the variable index classes in more places
1 parent 4f85841 commit 58833bb

15 files changed

Lines changed: 92 additions & 106 deletions

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,36 +4757,51 @@ void CPhysicalGeometry::SetRCM_Ordering(CConfig *config) {
47574757
vector<unsigned long> AuxQueue, Result;
47584758
Result.reserve(nPoint);
47594759

4760-
/*--- Select the node with the lowest degree in the grid. ---*/
4760+
while (Result.size() < nPointDomain) {
47614761

4762-
unsigned long AddPoint = 0;
4763-
auto MinDegree = nodes->GetnPoint(AddPoint);
4764-
for (auto iPoint = 1ul; iPoint < nPointDomain; iPoint++) {
4765-
auto Degree = nodes->GetnPoint(iPoint);
4766-
if (Degree < MinDegree) { MinDegree = Degree; AddPoint = iPoint; }
4767-
}
4762+
/*--- Select the node with the lowest degree in the grid. ---*/
47684763

4769-
/*--- Add the node in the first free position. ---*/
4764+
auto AddPoint = nPoint;
4765+
auto MinDegree = std::numeric_limits<unsigned short>::max();
4766+
for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) {
4767+
auto Degree = nodes->GetnPoint(iPoint);
4768+
if (!inQueue[iPoint] && Degree < MinDegree) {
4769+
MinDegree = Degree;
4770+
AddPoint = iPoint;
4771+
}
4772+
}
4773+
if (AddPoint == nPoint) {
4774+
SU2_MPI::Error("RCM ordering failed", CURRENT_FUNCTION);
4775+
}
47704776

4771-
Result.push_back(AddPoint); inQueue[AddPoint] = true;
4777+
/*--- Add the node in the first free position. ---*/
47724778

4773-
/*--- Loop until reorganize all the nodes ---*/
4779+
Result.push_back(AddPoint);
4780+
inQueue[AddPoint] = true;
47744781

4775-
do {
4782+
/*--- Loop until reorganize all the nodes ---*/
47764783

4777-
/*--- Add to the queue all the nodes adjacent in the increasing
4778-
order of their degree, checking if the element is already
4779-
in the Queue. ---*/
4784+
while (!Queue.empty()) {
47804785

4781-
AuxQueue.clear();
4782-
for (auto iNode = 0u; iNode < nodes->GetnPoint(AddPoint); iNode++) {
4783-
auto AdjPoint = nodes->GetPoint(AddPoint, iNode);
4784-
if ((!inQueue[AdjPoint]) && (AdjPoint < nPointDomain)) {
4785-
AuxQueue.push_back(AdjPoint);
4786-
}
4787-
}
4786+
/*--- Extract the first node from the queue and add it in the first free
4787+
position. ---*/
47884788

4789-
if (!AuxQueue.empty()) {
4789+
AddPoint = Queue.front();
4790+
Result.push_back(AddPoint);
4791+
Queue.pop();
4792+
4793+
/*--- Add to the queue all the nodes adjacent in the increasing
4794+
order of their degree, checking if the element is already
4795+
in the Queue. ---*/
4796+
4797+
AuxQueue.clear();
4798+
for (auto iNode = 0u; iNode < nodes->GetnPoint(AddPoint); iNode++) {
4799+
auto AdjPoint = nodes->GetPoint(AddPoint, iNode);
4800+
if (!inQueue[AdjPoint] && (AdjPoint < nPointDomain)) {
4801+
AuxQueue.push_back(AdjPoint);
4802+
}
4803+
}
4804+
if (AuxQueue.empty()) continue;
47904805

47914806
/*--- Sort the auxiliar queue based on the number of neighbors ---*/
47924807

@@ -4800,24 +4815,15 @@ void CPhysicalGeometry::SetRCM_Ordering(CConfig *config) {
48004815
Queue.push(iPoint);
48014816
inQueue[iPoint] = true;
48024817
}
4803-
48044818
}
4805-
4806-
/*--- Extract the first node from the queue and add it in the first free
4807-
position. ---*/
4808-
4809-
if (!Queue.empty()) {
4810-
AddPoint = Queue.front();
4811-
Result.push_back(AddPoint);
4812-
Queue.pop();
4813-
}
4814-
4815-
} while (!Queue.empty());
4819+
}
48164820

48174821
/*--- Check that all the points have been added ---*/
48184822

48194823
for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) {
4820-
if (inQueue[iPoint] == false) Result.push_back(iPoint);
4824+
if (!inQueue[iPoint]) {
4825+
SU2_MPI::Error("RCM ordering failed", CURRENT_FUNCTION);
4826+
}
48214827
}
48224828

48234829
reverse(Result.begin(), Result.end());

SU2_CFD/include/solvers/CEulerSolver.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,10 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMP
279279
void SetReferenceValues(const CConfig& config) final;
280280

281281
public:
282-
/*!
283-
* \brief Constructor of the class.
284-
*/
285-
CEulerSolver() : CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMPRESSIBLE>() {}
282+
CEulerSolver() = delete;
286283

287284
/*!
288-
* \overload Main constructor of this class.
285+
* \brief Main constructor of this class.
289286
* \param[in] geometry - Geometrical definition of the problem.
290287
* \param[in] config - Definition of the particular problem.
291288
* \param[in] iMesh - Grid level.

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class CFVMFlowSolverBase : public CSolver {
4444
}
4545

4646
protected:
47+
/*!< \brief Object with indices of primitive variables. */
48+
const typename VariableType::template CIndices<unsigned short> prim_idx;
49+
4750
static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */
4851
static constexpr size_t MAXNVAR = VariableType::MAXNVAR; /*!< \brief Max number of variables, for static arrays. */
4952

@@ -226,9 +229,10 @@ class CFVMFlowSolverBase : public CSolver {
226229
inline CVariable* GetBaseClassPointerToNodes() final { return nodes; }
227230

228231
/*!
229-
* \brief Default constructor, this class is not directly instantiable.
232+
* \brief Protected constructor, this class is not directly instantiable.
230233
*/
231-
CFVMFlowSolverBase() : CSolver() {}
234+
CFVMFlowSolverBase(const CGeometry& geometry, const CConfig& config)
235+
: CSolver(), prim_idx(geometry.GetnDim(), config.GetnSpecies()) {}
232236

233237
/*!
234238
* \brief Set reference values for pressure, forces, etc., e.g. "AeroCoeffForceRef".

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,6 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
24682468

24692469
unsigned long iVertex, iPoint, iPointNormal;
24702470
unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
2471-
unsigned short T_INDEX = 0, TVE_INDEX = 0, VEL_INDEX = 0;
24722471
su2double Viscosity = 0.0, Area, Density = 0.0, GradTemperature = 0.0, WallDistMod, FrictionVel,
24732472
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
24742473
thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0}, AxiFactor;
@@ -2477,27 +2476,19 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
24772476

24782477
string Marker_Tag, Monitoring_Tag;
24792478

2480-
su2double Alpha = config->GetAoA() * PI_NUMBER / 180.0;
2481-
su2double Beta = config->GetAoS() * PI_NUMBER / 180.0;
2482-
su2double RefLength = config->GetRefLength();
2483-
su2double RefHeatFlux = config->GetHeat_Flux_Ref();
2484-
su2double Gas_Constant = config->GetGas_ConstantND();
2479+
const su2double Alpha = config->GetAoA() * PI_NUMBER / 180.0;
2480+
const su2double Beta = config->GetAoS() * PI_NUMBER / 180.0;
2481+
const su2double RefLength = config->GetRefLength();
2482+
const su2double RefHeatFlux = config->GetHeat_Flux_Ref();
2483+
const su2double Gas_Constant = config->GetGas_ConstantND();
24852484
auto Origin = config->GetRefOriginMoment(0);
24862485

2487-
su2double Prandtl_Lam = config->GetPrandtl_Lam();
2488-
bool energy = config->GetEnergy_Equation();
2489-
bool QCR = config->GetQCR();
2490-
bool axisymmetric = config->GetAxisymmetric();
2491-
bool roughwall = (config->GetnRoughWall() > 0);
2492-
bool nemo = config->GetNEMOProblem();
2493-
2494-
/*--- Get the locations of the primitive variables for NEMO ---*/
2495-
if (nemo) {
2496-
unsigned short nSpecies = config->GetnSpecies();
2497-
T_INDEX = nSpecies;
2498-
TVE_INDEX = nSpecies+1;
2499-
VEL_INDEX = nSpecies+2;
2500-
}
2486+
const su2double Prandtl_Lam = config->GetPrandtl_Lam();
2487+
const bool energy = config->GetEnergy_Equation();
2488+
const bool QCR = config->GetQCR();
2489+
const bool axisymmetric = config->GetAxisymmetric();
2490+
const bool roughwall = (config->GetnRoughWall() > 0);
2491+
const bool nemo = config->GetNEMOProblem();
25012492

25022493
const su2double factor = 1.0 / AeroCoeffForceRef;
25032494
const su2double factorFric = config->GetRefArea() * factor;
@@ -2559,15 +2550,9 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25592550

25602551
for (iDim = 0; iDim < nDim; iDim++) {
25612552
for (jDim = 0; jDim < nDim; jDim++) {
2562-
if (!nemo) Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint, iDim + 1, jDim);
2563-
else Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint, iDim + VEL_INDEX, jDim);
2553+
Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint, prim_idx.Velocity() + iDim, jDim);
25642554
}
2565-
2566-
/// TODO: Move the temperature index logic to a function.
2567-
2568-
if (FlowRegime == ENUM_REGIME::COMPRESSIBLE) Grad_Temp[iDim] = nodes->GetGradient_Primitive(iPoint, 0, iDim);
2569-
2570-
if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE) Grad_Temp[iDim] = nodes->GetGradient_Primitive(iPoint, nDim + 1, iDim);
2555+
Grad_Temp[iDim] = nodes->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim);
25712556
}
25722557

25732558
Viscosity = nodes->GetLaminarViscosity(iPoint);
@@ -2660,8 +2645,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
26602645
const auto& thermal_conductivity_ve = nodes->GetThermalConductivity_ve(iPoint);
26612646
const auto& Grad_PrimVar = nodes->GetGradient_Primitive(iPoint);
26622647

2663-
su2double dTn = GeometryToolbox::DotProduct(nDim, Grad_PrimVar[T_INDEX], UnitNormal);
2664-
su2double dTven = GeometryToolbox::DotProduct(nDim, Grad_PrimVar[TVE_INDEX], UnitNormal);
2648+
su2double dTn = GeometryToolbox::DotProduct(nDim, Grad_PrimVar[prim_idx.Temperature()], UnitNormal);
2649+
su2double dTven = GeometryToolbox::DotProduct(nDim, Grad_PrimVar[prim_idx.Temperature_ve()], UnitNormal);
26652650

26662651
/*--- Surface energy balance: trans-rot heat flux, vib-el heat flux,
26672652
enthalpy transport due to mass diffusion ---*/

SU2_CFD/include/solvers/CIncEulerSolver.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,10 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, ENUM_REGIME
125125
void SetReferenceValues(const CConfig& config) final;
126126

127127
public:
128-
/*!
129-
* \brief Constructor of the class.
130-
*/
131-
CIncEulerSolver() : CFVMFlowSolverBase<CIncEulerVariable, ENUM_REGIME::INCOMPRESSIBLE>() {}
128+
CIncEulerSolver() = delete;
132129

133130
/*!
134-
* \overload
131+
* \brief Constructor of the class.
135132
* \param[in] geometry - Geometrical definition of the problem.
136133
* \param[in] config - Definition of the particular problem.
137134
* \param[in] iMesh - Grid level.

SU2_CFD/include/solvers/CIncNSSolver.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ class CIncNSSolver final : public CIncEulerSolver {
9898
public:
9999
/*!
100100
* \brief Constructor of the class.
101-
*/
102-
CIncNSSolver() : CIncEulerSolver() {}
103-
104-
/*!
105-
* \overload
106101
* \param[in] geometry - Geometrical definition of the problem.
107102
* \param[in] config - Definition of the particular problem.
108103
*/

SU2_CFD/include/solvers/CNEMOEulerSolver.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,13 @@ class CNEMOEulerSolver : public CFVMFlowSolverBase<CNEMOEulerVariable, ENUM_REGI
9191
void SetReferenceValues(const CConfig& config) final;
9292

9393
public:
94+
CNEMOEulerSolver() = delete;
9495

9596
/*!
96-
* \brief Constructor of the class.
97+
* \brief Contructor of the class.
98+
* \param[in] geometry - Geometrical definition of the problem.
99+
* \param[in] config - Definition of the particular problem.
97100
*/
98-
CNEMOEulerSolver() : CFVMFlowSolverBase<CNEMOEulerVariable, ENUM_REGIME::COMPRESSIBLE>() {}
99-
100-
/*!
101-
* \overload
102-
* \param[in] geometry - Geometrical definition of the problem.
103-
* \param[in] config - Definition of the particular problem.
104-
*/
105101
CNEMOEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes = false);
106102

107103
/*!

SU2_CFD/include/variables/CEulerVariable.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class CEulerVariable : public CFlowVariable {
5555
inline IndexType EddyViscosity() const { return nDim+6; }
5656
inline IndexType ThermalConductivity() const { return nDim+7; }
5757
inline IndexType CpTotal() const { return nDim+8; }
58+
59+
/*--- For compatible interface with NEMO. ---*/
60+
inline IndexType Temperature_ve() const { return std::numeric_limits<IndexType>::max(); }
5861
};
5962

6063
protected:

SU2_CFD/include/variables/CIncEulerVariable.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class CIncEulerVariable : public CFlowVariable {
5555
inline IndexType ThermalConductivity() const { return nDim+6; }
5656
inline IndexType CpTotal() const { return nDim+7; }
5757
inline IndexType CvTotal() const { return nDim+8; }
58+
59+
/*--- For compatible interface with NEMO. ---*/
60+
inline IndexType Temperature_ve() const { return std::numeric_limits<IndexType>::max(); }
5861
};
5962

6063
protected:

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,
4040
unsigned short iMesh, const bool navier_stokes) :
41-
CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMPRESSIBLE>() {
41+
CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMPRESSIBLE>(*geometry, *config) {
4242

4343
/*--- Based on the navier_stokes boolean, determine if this constructor is
4444
* being called by itself, or by its derived class CNSSolver. ---*/

0 commit comments

Comments
 (0)