Skip to content

Commit e823be7

Browse files
authored
Merge pull request #1249 from su2code/fix_grad_recon_issues
Fix some reconstruction gradient issues on periodic boundaries (when NUM_METHOD_GRAD != NUM_METHOD_GRAD_RECON))
2 parents 533a2c4 + 36a0050 commit e823be7

File tree

16 files changed

+333
-1044
lines changed

16 files changed

+333
-1044
lines changed

Common/include/option_structure.hpp

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,6 @@ enum BC_TYPE {
11151115
OUTLET_FLOW = 5, /*!< \brief Boundary outlet flow definition. */
11161116
PERIODIC_BOUNDARY = 6, /*!< \brief Periodic boundary definition. */
11171117
NEARFIELD_BOUNDARY = 7, /*!< \brief Near-Field boundary definition. */
1118-
ELECTRODE_BOUNDARY = 8, /*!< \brief Electrode boundary definition. */
1119-
DIELEC_BOUNDARY = 9, /*!< \brief Dipoisson boundary definition. */
11201118
CUSTOM_BOUNDARY = 10, /*!< \brief custom boundary definition. */
11211119
INTERFACE_BOUNDARY = 11, /*!< \brief Domain interface boundary definition. */
11221120
DIRICHLET = 12, /*!< \brief Boundary Euler wall definition. */
@@ -2107,57 +2105,62 @@ static const MapType<string, ENUM_INPUT_REF> Input_Ref_Map = {
21072105
* \brief Vertex-based quantities exchanged during periodic marker communications.
21082106
*/
21092107
enum PERIODIC_QUANTITIES {
2110-
PERIODIC_NONE = 99, /*!< \brief No periodic communication required. */
2111-
PERIODIC_VOLUME = 1, /*!< \brief Volume communication for summing total CV (periodic only). */
2112-
PERIODIC_NEIGHBORS = 2, /*!< \brief Communication of the number of neighbors for centered schemes (periodic only). */
2113-
PERIODIC_RESIDUAL = 3, /*!< \brief Residual and Jacobian communication (periodic only). */
2114-
PERIODIC_LAPLACIAN = 4, /*!< \brief Undivided Laplacian communication for JST (periodic only). */
2115-
PERIODIC_MAX_EIG = 5, /*!< \brief Maximum eigenvalue communication (periodic only). */
2116-
PERIODIC_SENSOR = 6, /*!< \brief Dissipation sensor communication (periodic only). */
2117-
PERIODIC_SOL_GG = 7, /*!< \brief Solution gradient communication for Green-Gauss (periodic only). */
2118-
PERIODIC_PRIM_GG = 8, /*!< \brief Primitive gradient communication for Green-Gauss (periodic only). */
2119-
PERIODIC_SOL_LS = 9, /*!< \brief Solution gradient communication for weighted Least Squares (periodic only). */
2120-
PERIODIC_PRIM_LS = 10, /*!< \brief Primitive gradient communication for weighted Least Squares (periodic only). */
2121-
PERIODIC_LIM_SOL_1 = 11, /*!< \brief Solution limiter communication phase 1 of 2 (periodic only). */
2122-
PERIODIC_LIM_SOL_2 = 12, /*!< \brief Solution limiter communication phase 2 of 2 (periodic only). */
2123-
PERIODIC_LIM_PRIM_1 = 13, /*!< \brief Primitive limiter communication phase 1 of 2 (periodic only). */
2124-
PERIODIC_LIM_PRIM_2 = 14, /*!< \brief Primitive limiter communication phase 2 of 2 (periodic only). */
2125-
PERIODIC_IMPLICIT = 15, /*!< \brief Implicit update communication to ensure consistency across periodic boundaries. */
2126-
PERIODIC_SOL_ULS = 16, /*!< \brief Solution gradient communication for unwieghted Least Squares (periodic only). */
2127-
PERIODIC_PRIM_ULS = 17 /*!< \brief Primitive gradient communication for unweighted Least Squares (periodic only). */
2108+
PERIODIC_NONE , /*!< \brief No periodic communication required. */
2109+
PERIODIC_VOLUME , /*!< \brief Volume communication for summing total CV (periodic only). */
2110+
PERIODIC_NEIGHBORS , /*!< \brief Communication of the number of neighbors for centered schemes (periodic only). */
2111+
PERIODIC_RESIDUAL , /*!< \brief Residual and Jacobian communication (periodic only). */
2112+
PERIODIC_LAPLACIAN , /*!< \brief Undivided Laplacian communication for JST (periodic only). */
2113+
PERIODIC_MAX_EIG , /*!< \brief Maximum eigenvalue communication (periodic only). */
2114+
PERIODIC_SENSOR , /*!< \brief Dissipation sensor communication (periodic only). */
2115+
PERIODIC_SOL_GG , /*!< \brief Solution gradient communication for Green-Gauss (periodic only). */
2116+
PERIODIC_PRIM_GG , /*!< \brief Primitive gradient communication for Green-Gauss (periodic only). */
2117+
PERIODIC_SOL_LS , /*!< \brief Solution gradient communication for weighted Least Squares (periodic only). */
2118+
PERIODIC_PRIM_LS , /*!< \brief Primitive gradient communication for weighted Least Squares (periodic only). */
2119+
PERIODIC_SOL_ULS , /*!< \brief Solution gradient communication for unwieghted Least Squares (periodic only). */
2120+
PERIODIC_PRIM_ULS , /*!< \brief Primitive gradient communication for unweighted Least Squares (periodic only). */
2121+
PERIODIC_SOL_GG_R , /*!< \brief Same but reconstruction. */
2122+
PERIODIC_PRIM_GG_R , /*!< \brief Same but reconstruction. */
2123+
PERIODIC_SOL_LS_R , /*!< \brief Same but reconstruction. */
2124+
PERIODIC_PRIM_LS_R , /*!< \brief Same but reconstruction. */
2125+
PERIODIC_SOL_ULS_R , /*!< \brief Same but reconstruction. */
2126+
PERIODIC_PRIM_ULS_R , /*!< \brief Same but reconstruction. */
2127+
PERIODIC_LIM_SOL_1 , /*!< \brief Solution limiter communication phase 1 of 2 (periodic only). */
2128+
PERIODIC_LIM_SOL_2 , /*!< \brief Solution limiter communication phase 2 of 2 (periodic only). */
2129+
PERIODIC_LIM_PRIM_1 , /*!< \brief Primitive limiter communication phase 1 of 2 (periodic only). */
2130+
PERIODIC_LIM_PRIM_2 , /*!< \brief Primitive limiter communication phase 2 of 2 (periodic only). */
2131+
PERIODIC_IMPLICIT , /*!< \brief Implicit update communication to ensure consistency across periodic boundaries. */
21282132
};
21292133

21302134
/*!
21312135
* \brief Vertex-based quantities exchanged in MPI point-to-point communications.
21322136
*/
21332137
enum MPI_QUANTITIES {
2134-
SOLUTION = 0, /*!< \brief Conservative solution communication. */
2135-
SOLUTION_OLD = 1, /*!< \brief Conservative solution old communication. */
2136-
SOLUTION_GRADIENT = 2, /*!< \brief Conservative solution gradient communication. */
2137-
SOLUTION_LIMITER = 3, /*!< \brief Conservative solution limiter communication. */
2138-
SOLUTION_GEOMETRY = 7, /*!< \brief Geometry solution communication. */
2139-
PRIMITIVE_GRADIENT = 8, /*!< \brief Primitive gradient communication. */
2140-
PRIMITIVE_LIMITER = 9, /*!< \brief Primitive limiter communication. */
2141-
UNDIVIDED_LAPLACIAN = 10, /*!< \brief Undivided Laplacian communication. */
2142-
MAX_EIGENVALUE = 11, /*!< \brief Maximum eigenvalue communication. */
2143-
SENSOR = 12, /*!< \brief Dissipation sensor communication. */
2144-
AUXVAR_GRADIENT = 13, /*!< \brief Auxiliary variable gradient communication. */
2145-
COORDINATES = 14, /*!< \brief Vertex coordinates communication. */
2146-
COORDINATES_OLD = 15, /*!< \brief Old vertex coordinates communication. */
2147-
MAX_LENGTH = 16, /*!< \brief Maximum length communication. */
2148-
GRID_VELOCITY = 17, /*!< \brief Grid velocity communication. */
2149-
CROSS_TERM = 18, /*!< \brief Cross term communication. */
2150-
CROSS_TERM_GEOMETRY = 19, /*!< \brief Geometric cross term communication. */
2151-
REF_GEOMETRY = 20, /*!< \brief Reference geometry communication. */
2152-
SOLUTION_EDDY = 21, /*!< \brief Turbulent solution plus eddy viscosity communication. */
2153-
SOLUTION_MATRIX = 22, /*!< \brief Matrix solution communication. */
2154-
SOLUTION_MATRIXTRANS = 23, /*!< \brief Matrix transposed solution communication. */
2155-
NEIGHBORS = 24, /*!< \brief Neighbor point count communication (for JST). */
2156-
SOLUTION_FEA = 25, /*!< \brief FEA solution communication. */
2157-
MESH_DISPLACEMENTS = 27, /*!< \brief Mesh displacements at the interface. */
2158-
SOLUTION_TIME_N = 28, /*!< \brief Solution at time n. */
2159-
SOLUTION_TIME_N1 = 29, /*!< \brief Solution at time n-1. */
2160-
PRIMITIVE = 30 /*!< \brief Primitive solution communication. */
2138+
SOLUTION , /*!< \brief Conservative solution communication. */
2139+
SOLUTION_OLD , /*!< \brief Conservative solution old communication. */
2140+
SOLUTION_GRADIENT , /*!< \brief Conservative solution gradient communication. */
2141+
SOLUTION_GRAD_REC , /*!< \brief Conservative solution reconstruction gradient communication. */
2142+
SOLUTION_LIMITER , /*!< \brief Conservative solution limiter communication. */
2143+
SOLUTION_GEOMETRY , /*!< \brief Geometry solution communication. */
2144+
PRIMITIVE_GRADIENT , /*!< \brief Primitive gradient communication. */
2145+
PRIMITIVE_GRAD_REC , /*!< \brief Primitive reconstruction gradient communication. */
2146+
PRIMITIVE_LIMITER , /*!< \brief Primitive limiter communication. */
2147+
UNDIVIDED_LAPLACIAN , /*!< \brief Undivided Laplacian communication. */
2148+
MAX_EIGENVALUE , /*!< \brief Maximum eigenvalue communication. */
2149+
SENSOR , /*!< \brief Dissipation sensor communication. */
2150+
AUXVAR_GRADIENT , /*!< \brief Auxiliary variable gradient communication. */
2151+
COORDINATES , /*!< \brief Vertex coordinates communication. */
2152+
COORDINATES_OLD , /*!< \brief Old vertex coordinates communication. */
2153+
MAX_LENGTH , /*!< \brief Maximum length communication. */
2154+
GRID_VELOCITY , /*!< \brief Grid velocity communication. */
2155+
SOLUTION_EDDY , /*!< \brief Turbulent solution plus eddy viscosity communication. */
2156+
SOLUTION_MATRIX , /*!< \brief Matrix solution communication. */
2157+
SOLUTION_MATRIXTRANS , /*!< \brief Matrix transposed solution communication. */
2158+
NEIGHBORS , /*!< \brief Neighbor point count communication (for JST). */
2159+
SOLUTION_FEA , /*!< \brief FEA solution communication. */
2160+
MESH_DISPLACEMENTS , /*!< \brief Mesh displacements at the interface. */
2161+
SOLUTION_TIME_N , /*!< \brief Solution at time n. */
2162+
SOLUTION_TIME_N1 , /*!< \brief Solution at time n-1. */
2163+
PRIMITIVE /*!< \brief Primitive solution communication. */
21612164
};
21622165

21632166
/*!

Common/src/CConfig.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,6 +4935,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
49354935

49364936
}
49374937

4938+
if (ReconstructionGradientRequired && GetFluidProblem() && Kind_ConvNumScheme_Flow == SPACE_CENTERED)
4939+
SU2_MPI::Error("For centered schemes the option NUM_METHOD_GRAD_RECON should not be set.", CURRENT_FUNCTION);
4940+
49384941
/* Simpler boolean to control allocation of least-squares memory. */
49394942

49404943
LeastSquaresRequired = false;
@@ -4954,21 +4957,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
49544957
/* Protect against using CFL adaption for non-flow or certain
49554958
unsteady flow problems. */
49564959

4957-
bool fvm_flow = ((Kind_Solver == INC_EULER) ||
4958-
(Kind_Solver == INC_NAVIER_STOKES) ||
4959-
(Kind_Solver == INC_RANS) ||
4960-
(Kind_Solver == EULER) ||
4961-
(Kind_Solver == NAVIER_STOKES) ||
4962-
(Kind_Solver == NEMO_EULER) ||
4963-
(Kind_Solver == NEMO_NAVIER_STOKES) ||
4964-
(Kind_Solver == RANS) ||
4965-
(Kind_Solver == DISC_ADJ_EULER) ||
4966-
(Kind_Solver == DISC_ADJ_RANS) ||
4967-
(Kind_Solver == DISC_ADJ_NAVIER_STOKES) ||
4968-
(Kind_Solver == DISC_ADJ_INC_EULER) ||
4969-
(Kind_Solver == DISC_ADJ_INC_RANS) ||
4970-
(Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES));
4971-
if (CFL_Adapt && !fvm_flow) {
4960+
if (CFL_Adapt && !GetFluidProblem()) {
49724961
SU2_MPI::Error(string("CFL adaption only available for finite-volume fluid solvers.\n") +
49734962
string("Please select CFL_ADAPT = NO."),
49744963
CURRENT_FUNCTION);

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ class CFVMFlowSolverBase : public CSolver {
10971097
* \param[in] config - Definition of the particular problem.
10981098
* \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction.
10991099
*/
1100-
void SetPrimitive_Gradient_LS(CGeometry* geometry, const CConfig* config, bool reconstruction = false) override;
1100+
void SetPrimitive_Gradient_LS(CGeometry* geometry, const CConfig* config, bool reconstruction = false) final;
11011101

11021102
/*!
11031103
* \brief Compute the limiter of the primitive variables.

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,29 +366,35 @@ void CFVMFlowSolverBase<V, R>::SetPrimitive_Gradient_GG(CGeometry* geometry, con
366366
bool reconstruction) {
367367
const auto& primitives = nodes->GetPrimitive();
368368
auto& gradient = reconstruction ? nodes->GetGradient_Reconstruction() : nodes->GetGradient_Primitive();
369+
const auto comm = reconstruction? PRIMITIVE_GRAD_REC : PRIMITIVE_GRADIENT;
370+
const auto commPer = reconstruction? PERIODIC_PRIM_GG_R : PERIODIC_PRIM_GG;
369371

370-
computeGradientsGreenGauss(this, PRIMITIVE_GRADIENT, PERIODIC_PRIM_GG, *geometry, *config, primitives, 0,
371-
nPrimVarGrad, gradient);
372+
computeGradientsGreenGauss(this, comm, commPer, *geometry, *config, primitives, 0, nPrimVarGrad, gradient);
372373
}
373374

374375
template <class V, ENUM_REGIME R>
375376
void CFVMFlowSolverBase<V, R>::SetPrimitive_Gradient_LS(CGeometry* geometry, const CConfig* config,
376377
bool reconstruction) {
377378
/*--- Set a flag for unweighted or weighted least-squares. ---*/
378379
bool weighted;
380+
PERIODIC_QUANTITIES commPer;
379381

380-
if (reconstruction)
382+
if (reconstruction) {
381383
weighted = (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES);
382-
else
384+
commPer = weighted? PERIODIC_PRIM_LS_R : PERIODIC_PRIM_ULS_R;
385+
}
386+
else {
383387
weighted = (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES);
388+
commPer = weighted? PERIODIC_PRIM_LS : PERIODIC_PRIM_ULS;
389+
}
384390

385391
const auto& primitives = nodes->GetPrimitive();
386392
auto& rmatrix = nodes->GetRmatrix();
387393
auto& gradient = reconstruction ? nodes->GetGradient_Reconstruction() : nodes->GetGradient_Primitive();
388-
PERIODIC_QUANTITIES kindPeriodicComm = weighted ? PERIODIC_PRIM_LS : PERIODIC_PRIM_ULS;
394+
const auto comm = reconstruction? PRIMITIVE_GRAD_REC : PRIMITIVE_GRADIENT;
389395

390-
computeGradientsLeastSquares(this, PRIMITIVE_GRADIENT, kindPeriodicComm, *geometry, *config, weighted, primitives, 0,
391-
nPrimVarGrad, gradient, rmatrix);
396+
computeGradientsLeastSquares(this, comm, commPer, *geometry, *config, weighted,
397+
primitives, 0, nPrimVarGrad, gradient, rmatrix);
392398
}
393399

394400
template <class V, ENUM_REGIME R>

SU2_CFD/include/solvers/CNEMONSSolver.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ class CNEMONSSolver final : public CNEMOEulerSolver {
8585
const CConfig *config,
8686
bool reconstruction = false) override;
8787

88-
/*!
89-
* \brief Compute the gradient of the primitive variables using a Least-Squares method,
90-
* and stores the result in the <i>Gradient_Primitive</i> variable.
91-
* \param[in] geometry - Geometrical definition of the problem.
92-
* \param[in] config - Definition of the particular problem.
93-
* \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction.
94-
*/
95-
void SetPrimitive_Gradient_LS(CGeometry *geometry,
96-
const CConfig *config,
97-
bool reconstruction = false) override;
98-
9988
/*!
10089
* \brief Restart residual and compute gradients.
10190
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,34 +1305,6 @@ class CSolver {
13051305
CConfig *config,
13061306
unsigned short val_marker) { }
13071307

1308-
/*!
1309-
* \brief Impose the symmetry boundary condition using the residual.
1310-
* \param[in] geometry - Geometrical definition of the problem.
1311-
* \param[in] solver_container - Container vector with all the solutions.
1312-
* \param[in] numerics - Description of the numerical method.
1313-
* \param[in] config - Definition of the particular problem.
1314-
* \param[in] val_marker - Surface marker where the boundary condition is applied.
1315-
*/
1316-
inline virtual void BC_Dielec(CGeometry *geometry,
1317-
CSolver **solver_container,
1318-
CNumerics *numerics,
1319-
CConfig *config,
1320-
unsigned short val_marker) { }
1321-
1322-
/*!
1323-
* \brief A virtual member.
1324-
* \param[in] geometry - Geometrical definition of the problem.
1325-
* \param[in] solver_container - Container vector with all the solutions.
1326-
* \param[in] numerics - Description of the numerical method.
1327-
* \param[in] config - Definition of the particular problem.
1328-
* \param[in] val_marker - Surface marker where the boundary condition is applied.
1329-
*/
1330-
inline virtual void BC_Electrode(CGeometry *geometry,
1331-
CSolver **solver_container,
1332-
CNumerics *numerics,
1333-
CConfig *config,
1334-
unsigned short val_marker) { }
1335-
13361308
/*!
13371309
* \brief A virtual member.
13381310
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/include/variables/CAdjEulerVariable.hpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,28 +164,6 @@ class CAdjEulerVariable : public CVariable {
164164
return HB_Source(iPoint,iVar);
165165
}
166166

167-
/*!
168-
* \brief Get the value of the reconstruction variables gradient at a node.
169-
* \param[in] iPoint - Index of the current node.
170-
* \param[in] iVar - Index of the variable.
171-
* \param[in] iDim - Index of the dimension.
172-
* \return Value of the reconstruction variables gradient at a node.
173-
*/
174-
inline su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final {
175-
return Gradient_Reconstruction(iPoint,iVar,iDim);
176-
}
177-
178-
/*!
179-
* \brief Get the value of the reconstruction variables gradient at a node.
180-
* \param[in] iPoint - Index of the current node.
181-
* \param[in] iVar - Index of the variable.
182-
* \param[in] iDim - Index of the dimension.
183-
* \param[in] value - Value of the reconstruction gradient component.
184-
*/
185-
inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final {
186-
Gradient_Reconstruction(iPoint,iVar,iDim) = value;
187-
}
188-
189167
/*!
190168
* \brief Get the array of the reconstruction variables gradient at a node.
191169
* \param[in] iPoint - Index of the current node.
@@ -197,6 +175,7 @@ class CAdjEulerVariable : public CVariable {
197175
* \brief Get the reconstruction gradient for variables at all points.
198176
* \return Reference to reconstruction gradient.
199177
*/
200-
inline CVectorOfMatrix& GetGradient_Reconstruction(void) final { return Gradient_Reconstruction; }
178+
inline CVectorOfMatrix& GetGradient_Reconstruction() final { return Gradient_Reconstruction; }
179+
inline const CVectorOfMatrix& GetGradient_Reconstruction() const final { return Gradient_Reconstruction; }
201180

202181
};

0 commit comments

Comments
 (0)