Skip to content

Commit 83175fc

Browse files
authored
Optimization of multigrid settings (#2772)
1 parent 2befb2d commit 83175fc

102 files changed

Lines changed: 2395 additions & 1831 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/include/CConfig.hpp

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ class CConfig {
472472
string CustomObjFunc; /*!< \brief User-defined objective function. */
473473
string CustomOutputs; /*!< \brief User-defined functions for outputs. */
474474
unsigned short nDV, /*!< \brief Number of design variables. */
475-
nObj, nObjW; /*! \brief Number of objective functions. */
475+
nObj, nObjW; /*!< \brief Number of objective functions. */
476476
unsigned short* nDV_Value; /*!< \brief Number of values for each design variable (might be different than 1 if we allow arbitrary movement). */
477477
unsigned short nFFDBox; /*!< \brief Number of ffd boxes. */
478478
unsigned short nTurboMachineryKind; /*!< \brief Number turbomachinery types specified. */
@@ -489,20 +489,14 @@ class CConfig {
489489
string *FFDTag; /*!< \brief Parameters of the design variable. */
490490
string *TagFFDBox; /*!< \brief Tag of the FFD box. */
491491
unsigned short GeometryMode; /*!< \brief Geometry mode (analysis or gradient computation). */
492-
unsigned short MGCycle; /*!< \brief Kind of multigrid cycle. */
493492
unsigned short FinestMesh; /*!< \brief Finest mesh for the full multigrid approach. */
494493
unsigned short nFFD_Fix_IDir,
495494
nFFD_Fix_JDir, nFFD_Fix_KDir; /*!< \brief Number of planes fixed in the FFD. */
496-
unsigned short nMG_PreSmooth, /*!< \brief Number of MG pre-smooth parameters found in config file. */
497-
nMG_PostSmooth, /*!< \brief Number of MG post-smooth parameters found in config file. */
498-
nMG_CorrecSmooth; /*!< \brief Number of MG correct-smooth parameters found in config file. */
499495
short *FFD_Fix_IDir,
500496
*FFD_Fix_JDir, *FFD_Fix_KDir; /*!< \brief Exact sections. */
501-
unsigned short *MG_PreSmooth, /*!< \brief Multigrid Pre smoothing. */
502-
*MG_PostSmooth, /*!< \brief Multigrid Post smoothing. */
503-
*MG_CorrecSmooth; /*!< \brief Multigrid Jacobi implicit smoothing of the correction. */
504497
su2double *LocationStations; /*!< \brief Airfoil sections in wing slicing subroutine. */
505498

499+
MG_CYCLE Kind_MGCycle; /*!< \brief Kind of multigrid cycle. */
506500
ENUM_MULTIZONE Kind_MZSolver; /*!< \brief Kind of multizone solver. */
507501
INC_DENSITYMODEL Kind_DensityModel; /*!< \brief Kind of the density model for incompressible flows. */
508502
CHT_COUPLING Kind_CHT_Coupling; /*!< \brief Kind of coupling method used at CHT interfaces. */
@@ -1132,6 +1126,10 @@ class CConfig {
11321126
unsigned long rampMUSCLCoeff[3]; /*!< \brief ramp MUSCL value coefficients for the COption class. */
11331127
} RampMUSCLParam;
11341128
su2double rampMUSCLValue; /*!< \brief Current value of the MUSCL ramp */
1129+
CMGOptions MGOptions;
1130+
/*--- Multigrid options ---*/
1131+
unsigned short nMG_PreSmooth_p{0}, nMG_PostSmooth_p{0}, nMG_CorrecSmooth_p{0};
1132+
unsigned short *MG_PreSmooth_p{nullptr}, *MG_PostSmooth_p{nullptr}, *MG_CorrecSmooth_p{nullptr};
11351133

11361134
ENUM_STREAMWISE_PERIODIC Kind_Streamwise_Periodic; /*!< \brief Kind of Streamwise periodic flow (pressure drop or massflow) */
11371135
bool Streamwise_Periodic_Temperature; /*!< \brief Use real periodicity for Energy equation or otherwise outlet source term. */
@@ -2908,7 +2906,7 @@ class CConfig {
29082906
*/
29092907
void SetMGLevels(unsigned short val_nMGLevels) {
29102908
nMGLevels = val_nMGLevels;
2911-
if (MGCycle == FULLMG_CYCLE) {
2909+
if (Kind_MGCycle == MG_CYCLE::FULL) {
29122910
SetFinestMesh(val_nMGLevels);
29132911
}
29142912
}
@@ -2925,7 +2923,7 @@ class CConfig {
29252923
* \note This variable is used in a recursive way to perform the different kind of cycles
29262924
* \return 0 or 1 depending of we are dealing with a V or W cycle.
29272925
*/
2928-
unsigned short GetMGCycle(void) const { return MGCycle; }
2926+
MG_CYCLE GetMGCycle(void) const { return Kind_MGCycle; }
29292927

29302928
/*!
29312929
* \brief Get the king of evaluation in the geometrical module.
@@ -3847,34 +3845,9 @@ class CConfig {
38473845
su2double GetNacelleLocation(unsigned short val_index) const { return nacelle_location[val_index]; }
38483846

38493847
/*!
3850-
* \brief Get the number of pre-smoothings in a multigrid strategy.
3851-
* \param[in] val_mesh - Index of the grid.
3852-
* \return Number of smoothing iterations.
3848+
* \brief Get the multigrid options struct.
38533849
*/
3854-
unsigned short GetMG_PreSmooth(unsigned short val_mesh) const {
3855-
if (nMG_PreSmooth == 0) return 1;
3856-
return MG_PreSmooth[val_mesh];
3857-
}
3858-
3859-
/*!
3860-
* \brief Get the number of post-smoothings in a multigrid strategy.
3861-
* \param[in] val_mesh - Index of the grid.
3862-
* \return Number of smoothing iterations.
3863-
*/
3864-
unsigned short GetMG_PostSmooth(unsigned short val_mesh) const {
3865-
if (nMG_PostSmooth == 0) return 0;
3866-
return MG_PostSmooth[val_mesh];
3867-
}
3868-
3869-
/*!
3870-
* \brief Get the number of implicit Jacobi smoothings of the correction in a multigrid strategy.
3871-
* \param[in] val_mesh - Index of the grid.
3872-
* \return Number of implicit smoothing iterations.
3873-
*/
3874-
unsigned short GetMG_CorrecSmooth(unsigned short val_mesh) const {
3875-
if (nMG_CorrecSmooth == 0) return 0;
3876-
return MG_CorrecSmooth[val_mesh];
3877-
}
3850+
const CMGOptions& GetMGOptions() const { return MGOptions; }
38783851

38793852
/*!
38803853
* \brief plane of the FFD (I axis) that should be fixed.
@@ -6833,12 +6806,24 @@ class CConfig {
68336806
*/
68346807
su2double GetDamp_Res_Restric(void) const { return Damp_Res_Restric; }
68356808

6809+
/*!
6810+
* \brief Set the damping factor for the residual restriction (used by adaptive MG damping).
6811+
* \param[in] val - New damping factor value.
6812+
*/
6813+
void SetDamp_Res_Restric(su2double val) { Damp_Res_Restric = val; }
6814+
68366815
/*!
68376816
* \brief Value of the damping factor for the correction prolongation.
68386817
* \return Value of the damping factor.
68396818
*/
68406819
su2double GetDamp_Correc_Prolong(void) const { return Damp_Correc_Prolong; }
68416820

6821+
/*!
6822+
* \brief Set the damping factor for the correction prolongation (used by adaptive MG damping).
6823+
* \param[in] val - New damping factor value.
6824+
*/
6825+
void SetDamp_Correc_Prolong(su2double val) { Damp_Correc_Prolong = val; }
6826+
68426827
/*!
68436828
* \brief Value of the position of the Near Field (y coordinate for 2D, and z coordinate for 3D).
68446829
* \return Value of the Near Field position.

Common/include/geometry/CGeometry.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -811,10 +811,13 @@ class CGeometry {
811811
inline virtual void MatchActuator_Disk(const CConfig* config) {}
812812

813813
/*!
814-
* \brief A virtual member.
814+
* \brief Match periodic boundary points using coordinate-based matching.
815+
* \details Gathers coordinates from all ranks via MPI, applies the rotation/translation
816+
* for the periodic pair, and finds the nearest neighbor. Works on both fine and coarse grids.
815817
* \param[in] config - Definition of the particular problem.
818+
* \param[in] val_periodic - Index of the periodic marker pair.
816819
*/
817-
inline virtual void MatchPeriodic(const CConfig* config, unsigned short val_periodic) {}
820+
virtual void MatchPeriodic(const CConfig* config, unsigned short val_periodic);
818821

819822
/*!
820823
* \brief A virtual member.
@@ -1609,12 +1612,6 @@ class CGeometry {
16091612
return AverageGridVel[val_marker][val_span];
16101613
}
16111614

1612-
/*!
1613-
* \brief A virtual member.
1614-
* \param config - Config
1615-
*/
1616-
inline virtual void Check_Periodicity(CConfig* config) {}
1617-
16181615
/*!
16191616
* \brief Get the value of the customized temperature at a specified vertex on a specified marker.
16201617
* \param[in] val_marker - Marker value

Common/include/geometry/CMultiGridGeometry.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#include "CGeometry.hpp"
3131

32+
class CMultiGridQueue;
33+
3234
/*!
3335
* \class CMultiGridGeometry
3436
* \brief Class for defining the multigrid geometry, the main dedicated part is the
@@ -75,6 +77,16 @@ class CMultiGridGeometry final : public CGeometry {
7577
*/
7678
su2double ComputeLocalCurvature(const CGeometry* fine_grid, unsigned long iPoint, unsigned short iMarker) const;
7779

80+
/*!
81+
* \brief Agglomerate high-aspect-ratio interior cells along implicit lines from wall vertices.
82+
* \param[in,out] Index_CoarseCV - Current coarse CV index, incremented as new coarse CVs are created.
83+
* \param[in] fine_grid - Fine grid geometry.
84+
* \param[in] config - Configuration.
85+
* \param[in,out] MGQueue_InnerCV - Queue for domain agglomeration; processed points are removed.
86+
*/
87+
void AgglomerateImplicitLines(unsigned long& Index_CoarseCV, const CGeometry* fine_grid, const CConfig* config,
88+
CMultiGridQueue& MGQueue_InnerCV);
89+
7890
public:
7991
/*--- This is to suppress Woverloaded-virtual, omitting it has no negative impact. ---*/
8092
using CGeometry::SetBoundControlVolume;
@@ -143,13 +155,6 @@ class CMultiGridGeometry final : public CGeometry {
143155
*/
144156
void MatchActuator_Disk(const CConfig* config) override;
145157

146-
/*!
147-
* \brief Mach the periodic boundary conditions.
148-
* \param[in] config - Definition of the particular problem.
149-
* \param[in] val_periodic - Index of the first periodic face in a pair.
150-
*/
151-
void MatchPeriodic(const CConfig* config, unsigned short val_periodic) override;
152-
153158
/*!
154159
* \brief Set a representative wall normal heat flux of the agglomerated control volume on a particular boundary
155160
* marker. \param[in] fine_grid - Geometrical definition of the problem. \param[in] val_marker - Index of the boundary

Common/include/geometry/CPhysicalGeometry.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,6 @@ class CPhysicalGeometry final : public CGeometry {
438438
*/
439439
void MatchActuator_Disk(const CConfig* config) override;
440440

441-
/*!
442-
* \brief Mach the periodic boundary conditions.
443-
* \param[in] config - Definition of the particular problem.
444-
* \param[in] val_periodic - Index of the first periodic face in a pair.
445-
*/
446-
void MatchPeriodic(const CConfig* config, unsigned short val_periodic) override;
447-
448441
/*!
449442
* \brief Set boundary vertex structure of the control volume.
450443
* \param[in] config - Definition of the particular problem.
@@ -779,12 +772,6 @@ class CPhysicalGeometry final : public CGeometry {
779772
Sensitivity(iPoint, iDim) = val;
780773
}
781774

782-
/*!
783-
* \brief Check the mesh for periodicity and deactivate multigrid if periodicity is found.
784-
* \param[in] config - Definition of the particular problem.
785-
*/
786-
void Check_Periodicity(CConfig* config) override;
787-
788775
/*!
789776
* \brief Compute an ADT including the coordinates of all viscous markers
790777
* \param[in] config - Definition of the particular problem.

Common/include/linear_algebra/CSysSolve.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class CSysSolve {
196196
* vector is kept in nrm0 and updated after operating with each vector
197197
*
198198
*/
199-
void ModGramSchmidt(bool shared_hsbg, int i, su2matrix<ScalarType>& Hsbg, std::vector<VectorType>& w) const;
199+
bool ModGramSchmidt(bool shared_hsbg, int i, su2matrix<ScalarType>& Hsbg, std::vector<VectorType>& w) const;
200200

201201
/*!
202202
* \brief writes header information for a CSysSolve residual history

Common/include/option_structure.hpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,21 @@ inline SST_ParsedOptions ParseSSTOptions(const SST_OPTIONS *SST_Options, unsigne
11011101
return SSTParsedOptions;
11021102
}
11031103

1104+
/*!
1105+
* \brief Structure containing multigrid options.
1106+
*/
1107+
struct CMGOptions {
1108+
su2double MG_Smooth_Res_Threshold{0.0}; /*!< \brief RMS reduction threshold for MG smoothing early exit. */
1109+
su2double MG_Smooth_Coeff{0.0}; /*!< \brief Jacobi smoother coefficient for coarse-grid correction. */
1110+
unsigned long MG_Min_MeshSize{0}; /*!< \brief Minimum CVs on coarsest MG level. */
1111+
std::vector<unsigned short> MG_PreSmooth; /*!< \brief Multigrid pre-smoothing iterations per level. */
1112+
std::vector<unsigned short> MG_PostSmooth; /*!< \brief Multigrid post-smoothing iterations per level. */
1113+
std::vector<unsigned short> MG_CorrecSmooth; /*!< \brief Multigrid Jacobi correction-smoothing per level. */
1114+
bool MG_Smooth_EarlyExit{false}; /*!< \brief Enable early exit for MG smoothing iterations. */
1115+
bool MG_Smooth_Output{false}; /*!< \brief Output compact per-cycle smoothing summary. */
1116+
bool MG_Implicit_Lines{false}; /*!< \brief Enable implicit-lines agglomeration from walls. */
1117+
};
1118+
11041119
/*!
11051120
* \brief SST rough-wall boundary conditions Options
11061121
*/
@@ -2281,17 +2296,17 @@ static const MapType<std::string, JUMP_DEFINITION> Jump_Map = {
22812296
/*!
22822297
* \brief Type of multigrid cycle
22832298
*/
2284-
enum MG_CYCLE {
2285-
V_CYCLE = 0, /*!< \brief V cycle. */
2286-
W_CYCLE = 1, /*!< \brief W cycle. */
2287-
FULLMG_CYCLE = 2 /*!< \brief FullMG cycle. */
2299+
enum class MG_CYCLE {
2300+
V, /*!< \brief V-cycle multigrid solver. */
2301+
W, /*!< \brief W-cycle multigrid solver. */
2302+
FULL, /*!< \brief Full multigrid (FMG) solver. */
22882303
};
2304+
22892305
static const MapType<std::string, MG_CYCLE> MG_Cycle_Map = {
2290-
MakePair("V_CYCLE", V_CYCLE)
2291-
MakePair("W_CYCLE", W_CYCLE)
2292-
MakePair("FULLMG_CYCLE", FULLMG_CYCLE)
2306+
MakePair("V_CYCLE", MG_CYCLE::V)
2307+
MakePair("W_CYCLE", MG_CYCLE::W)
2308+
MakePair("FULLMG_CYCLE", MG_CYCLE::FULL)
22932309
};
2294-
22952310
/*!
22962311
* \brief Types of design parameterizations
22972312
*/

0 commit comments

Comments
 (0)