Skip to content

Commit 0baf91d

Browse files
authored
Merge pull request #1177 from su2code/reduce_more_duplication
Reduce flow solver triplication (comp, incomp, nemo)
2 parents 99b07fb + 5914c1f commit 0baf91d

22 files changed

Lines changed: 2041 additions & 3471 deletions

Common/include/linear_algebra/CSysMatrix.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,8 @@ class CSysMatrix {
708708
* \param[in] val_block - Block to add to the diagonal of the matrix.
709709
* \param[in] alpha - Scale factor.
710710
*/
711-
template<class OtherType, bool Overwrite = true>
712-
inline void SetBlock2Diag(unsigned long block_i, const OtherType* const* val_block, OtherType alpha = 1.0) {
711+
template<class OtherType, bool Overwrite = true, class T = ScalarType>
712+
inline void SetBlock2Diag(unsigned long block_i, const OtherType& val_block, T alpha = 1.0) {
713713

714714
auto mat_ii = &matrix[dia_ptr[block_i]*nVar*nEqn];
715715

@@ -723,17 +723,17 @@ class CSysMatrix {
723723
/*!
724724
* \brief Non overwrite version of SetBlock2Diag, also with scaling.
725725
*/
726-
template<class OtherType>
727-
inline void AddBlock2Diag(unsigned long block_i, const OtherType* const* val_block, OtherType alpha = 1.0) {
726+
template<class OtherType, class T = ScalarType>
727+
inline void AddBlock2Diag(unsigned long block_i, const OtherType& val_block, T alpha = 1.0) {
728728
SetBlock2Diag<OtherType,false>(block_i, val_block, alpha);
729729
}
730730

731731
/*!
732732
* \brief Short-hand to AddBlock2Diag with alpha = -1, i.e. subtracts from the current diagonal.
733733
*/
734734
template<class OtherType>
735-
inline void SubtractBlock2Diag(unsigned long block_i, const OtherType* const* val_block) {
736-
AddBlock2Diag(block_i, val_block, OtherType(-1));
735+
inline void SubtractBlock2Diag(unsigned long block_i, const OtherType& val_block) {
736+
AddBlock2Diag(block_i, val_block, -1.0);
737737
}
738738

739739
/*!
@@ -748,6 +748,18 @@ class CSysMatrix {
748748
matrix[dia_ptr[block_i]*nVar*nVar + iVar*(nVar+1)] += PassiveAssign(val_matrix);
749749
}
750750

751+
/*!
752+
* \brief Adds the specified value to the diagonal of the (i, i) subblock
753+
* of the matrix-by-blocks structure.
754+
* \param[in] block_i - Diagonal index.
755+
* \param[in] iVar - Variable index.
756+
* \param[in] val - Value to add to the diagonal elements of A(i, i).
757+
*/
758+
template<class OtherType>
759+
inline void AddVal2Diag(unsigned long block_i, unsigned long iVar, OtherType val) {
760+
matrix[dia_ptr[block_i]*nVar*nVar + iVar*(nVar+1)] += PassiveAssign(val);
761+
}
762+
751763
/*!
752764
* \brief Sets the specified value to the diagonal of the (i, i) subblock
753765
* of the matrix-by-blocks structure.

SU2_CFD/include/solvers/CEulerSolver.hpp

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
114114

115115
vector<CFluidModel*> FluidModel; /*!< \brief fluid model used in the solver. */
116116

117-
unsigned long ErrorCounter = 0; /*!< \brief Counter for number of un-physical states. */
118-
119-
su2double Global_Delta_Time = 0.0, /*!< \brief Time-step for TIME_STEPPING time marching strategy. */
120-
Global_Delta_UnstTimeND = 0.0; /*!< \brief Unsteady time step for the dual time strategy. */
121-
122117
/*--- Turbomachinery Solver Variables ---*/
123118

124119
su2double ***AverageFlux = nullptr,
@@ -160,12 +155,6 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
160155

161156
/*--- End of Turbomachinery Solver Variables ---*/
162157

163-
/*!
164-
* \brief Generic implementation of explicit iterations (RK, Classic RK and EULER).
165-
*/
166-
template<ENUM_TIME_INT IntegrationType>
167-
void Explicit_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep);
168-
169158
/*!
170159
* \brief Preprocessing actions common to the Euler and NS solvers.
171160
* \param[in] geometry - Geometrical definition of the problem.
@@ -239,7 +228,7 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
239228
* \param[in] geometry - Geometrical definition of the problem.
240229
* \param[in] config - Definition of the particular problem.
241230
*/
242-
void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config);
231+
void SetMax_Eigenvalue(CGeometry *geometry, const CConfig *config);
243232

244233
/*!
245234
* \brief Compute the undivided laplacian for the solution.
@@ -266,11 +255,10 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
266255
* \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity.
267256
* \param[in] solver_container - Container vector with all the solutions.
268257
* \param[in] config - Definition of the particular problem.
269-
* \param[in] Output - boolean to determine whether to print output.
270258
* \return - The number of non-physical points.
271259
*/
272260
virtual unsigned long SetPrimitive_Variables(CSolver **solver_container,
273-
CConfig *config, bool Output);
261+
const CConfig *config);
274262

275263
/*!
276264
* \brief Set gradients of coefficients for fixed CL mode
@@ -285,6 +273,13 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
285273
*/
286274
void InstantiateEdgeNumerics(const CSolver* const* solvers, const CConfig* config) final;
287275

276+
/*!
277+
* \brief Set the solver nondimensionalization.
278+
* \param[in] config - Definition of the particular problem.
279+
* \param[in] iMesh - Index of the mesh in multigrid computations.
280+
*/
281+
void SetNondimensionalization(CConfig *config, unsigned short iMesh);
282+
288283
public:
289284
/*!
290285
* \brief Constructor of the class.
@@ -305,13 +300,6 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
305300
*/
306301
~CEulerSolver(void) override;
307302

308-
/*!
309-
* \brief Set the solver nondimensionalization.
310-
* \param[in] config - Definition of the particular problem.
311-
* \param[in] iMesh - Index of the mesh in multigrid computations.
312-
*/
313-
void SetNondimensionalization(CConfig *config, unsigned short iMesh) final;
314-
315303
/*!
316304
* \brief Compute the pressure at the infinity.
317305
* \return Value of the pressure at the infinity.
@@ -459,8 +447,7 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
459447
* \param[in,out] preconditioner - The preconditioner matrix, must be allocated outside.
460448
*/
461449
void SetPreconditioner(const CConfig *config, unsigned long iPoint,
462-
su2double delta, su2double** preconditioner) const;
463-
using CSolver::SetPreconditioner; /*--- Silence warning. ---*/
450+
su2double delta, su2activematrix& preconditioner) const;
464451

465452
/*!
466453
* \brief Parallelization of Undivided Laplacian.
@@ -1084,22 +1071,6 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
10841071
*/
10851072
void UpdateCustomBoundaryConditions(CGeometry **geometry_container, CConfig *config) final;
10861073

1087-
/*!
1088-
* \brief Set the total residual adding the term that comes from the Dual Time Strategy.
1089-
* \param[in] geometry - Geometrical definition of the problem.
1090-
* \param[in] solver_container - Container vector with all the solutions.
1091-
* \param[in] config - Definition of the particular problem.
1092-
* \param[in] iRKStep - Current step of the Runge-Kutta iteration.
1093-
* \param[in] iMesh - Index of the mesh in multigrid computations.
1094-
* \param[in] RunTime_EqSystem - System of equations which is going to be solved.
1095-
*/
1096-
void SetResidual_DualTime(CGeometry *geometry,
1097-
CSolver **solver_container,
1098-
CConfig *config,
1099-
unsigned short iRKStep,
1100-
unsigned short iMesh,
1101-
unsigned short RunTime_EqSystem) final;
1102-
11031074
/*!
11041075
* \brief Load a solution from a restart file.
11051076
* \param[in] geometry - Geometrical definition of the problem.
@@ -1130,7 +1101,7 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
11301101
* \brief Set the solution using the Freestream values.
11311102
* \param[in] config - Definition of the particular problem.
11321103
*/
1133-
void SetFreeStream_Solution(CConfig *config) final;
1104+
void SetFreeStream_Solution(const CConfig *config) final;
11341105

11351106
/*!
11361107
* \brief Initilize turbo containers.

SU2_CFD/include/solvers/CFEM_DG_EulerSolver.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ class CFEM_DG_EulerSolver : public CSolver {
306306
void SetNondimensionalization(CConfig *config,
307307
unsigned short iMesh,
308308
const bool writeOutput);
309-
using CSolver::SetNondimensionalization;
310309

311310
/*!
312311
* \brief Get a pointer to the vector of the solution degrees of freedom.

0 commit comments

Comments
 (0)