Skip to content

Commit 3e86076

Browse files
committed
Change struct to a lambda function.
That has the benefit of capturing the outside variables/objects by reference using [&] which makes the input list much smaller.
1 parent 3e975d3 commit 3e86076

3 files changed

Lines changed: 11 additions & 20 deletions

File tree

SU2_CFD/include/solvers/CScalarSolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CScalarSolver : public CSolver {
8484

8585
/*!
8686
* \brief Compute the viscous flux for the turbulent equation at a particular edge.
87-
* \tparam SolverSpecificNumericsFunc - Struct, that implements solver specific contributions to numerics.
87+
* \tparam SolverSpecificNumericsFunc - lambda-function, that implements solver specific contributions to numerics.
8888
* \note The functor has to implement (*geometry, *numerics, *config, *nodes, iPoint, jPoint)
8989
* \param[in] iEdge - Edge for which we want to compute the flux
9090
* \param[in] geometry - Geometrical definition of the problem.
@@ -120,7 +120,7 @@ class CScalarSolver : public CSolver {
120120

121121
/*--- Call Numerics contribution which are Solver-Specifc. Implemented in the caller: Viscous_Residual. ---*/
122122

123-
SolverSpecificNumerics(*geometry, *numerics, *config, *nodes, iPoint, jPoint);
123+
SolverSpecificNumerics(iPoint, jPoint);
124124

125125
/*--- Compute residual, and Jacobians ---*/
126126

SU2_CFD/src/solvers/CTurbSASolver.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,11 @@ void CTurbSASolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, C
290290
CNumerics* numerics, CConfig* config) {
291291

292292
/*--- Define an object to set solver specific numerics contribution. ---*/
293-
struct SolverSpecificNumerics {
294-
295-
FORCEINLINE void operator() (const CGeometry& geometry, CNumerics& numerics, CConfig& config, const CScalarVariable& nodes, unsigned long iPoint, unsigned long jPoint) const {
296-
/*--- Roughness heights. ---*/
297-
if (config.GetKind_Turb_Model() == SA)
298-
numerics.SetRoughness(geometry.nodes->GetRoughnessHeight(iPoint), geometry.nodes->GetRoughnessHeight(jPoint));
299-
}
300-
301-
} SolverSpecificNumerics;
293+
auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) {
294+
/*--- Roughness heights. ---*/
295+
if (config->GetKind_Turb_Model() == SA)
296+
numerics->SetRoughness(geometry->nodes->GetRoughnessHeight(iPoint), geometry->nodes->GetRoughnessHeight(jPoint));
297+
};
302298

303299
/*--- Now instantiate the generic implementation with the functor above. ---*/
304300

SU2_CFD/src/solvers/CTurbSSTSolver.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,10 @@ void CTurbSSTSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry,
279279
CNumerics* numerics, CConfig* config) {
280280

281281
/*--- Define an object to set solver specific numerics contribution. ---*/
282-
struct SolverSpecificNumerics {
283-
284-
FORCEINLINE void operator() (const CGeometry& geometry, CNumerics& numerics, CConfig& config, const CScalarVariable& nodes, unsigned long iPoint, unsigned long jPoint) const {
285-
/*--- Menter's first blending function (only SST)---*/
286-
if ((config.GetKind_Turb_Model() == SST) || (config.GetKind_Turb_Model() == SST_SUST))
287-
numerics.SetF1blending(nodes.GetF1blending(iPoint), nodes.GetF1blending(jPoint));
288-
}
289-
290-
} SolverSpecificNumerics;
282+
auto SolverSpecificNumerics = [&](unsigned long iPoint, unsigned long jPoint) {
283+
/*--- Menter's first blending function (only SST)---*/
284+
numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(jPoint));
285+
};
291286

292287
/*--- Now instantiate the generic implementation with the functor above. ---*/
293288

0 commit comments

Comments
 (0)