Skip to content

Commit dacdc17

Browse files
committed
Add nested FGMRES inner BiCGSTAB options and logging
1 parent aaf2842 commit dacdc17

File tree

6 files changed

+180
-305
lines changed

6 files changed

+180
-305
lines changed

Common/include/CConfig.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353

5454
using namespace std;
5555

56+
/*Inner solver for nested linear solver:*/
57+
enum ENUM_LINEAR_SOLVER_INNER {
58+
INNER_SOLVER_NONE = 0,
59+
INNER_SOLVER_BCGSTAB
60+
};
61+
5662
/*!
5763
* \class CConfig
5864
* \brief Main class for defining the problem; basically this class reads the configuration file, and
@@ -430,6 +436,7 @@ class CConfig {
430436
unsigned short nQuasiNewtonSamples; /*!< \brief Number of samples used in quasi-Newton solution methods. */
431437
bool UseVectorization; /*!< \brief Whether to use vectorized numerics schemes. */
432438
bool NewtonKrylov; /*!< \brief Use a coupled Newton method to solve the flow equations. */
439+
bool Nested_Linear_Solver; /*!< \brief Enable nested Krylov linear solver (e.g. FGMRES + inner solver). */
433440
array<unsigned short,3> NK_IntParam{{20, 3, 2}}; /*!< \brief Integer parameters for NK method. */
434441
array<su2double,5> NK_DblParam{{-2.0, 0.1, -3.0, 1e-4, 1.0}}; /*!< \brief Floating-point parameters for NK method. */
435442
su2double NK_Relaxation = 1.0;
@@ -525,6 +532,7 @@ class CConfig {
525532
Kind_Deform_Linear_Solver, /*!< Numerical method to deform the grid */
526533
Kind_Deform_Linear_Solver_Prec, /*!< \brief Preconditioner of the linear solver. */
527534
Kind_Linear_Solver, /*!< \brief Numerical solver for the implicit scheme. */
535+
Kind_Linear_Solver_Inner, /*!< \brief Inner solver used in nested Krylov schemes. */
528536
Kind_Linear_Solver_Prec, /*!< \brief Preconditioner of the linear solver. */
529537
Kind_DiscAdj_Linear_Solver, /*!< \brief Linear solver for the discrete adjoint system. */
530538
Kind_DiscAdj_Linear_Prec, /*!< \brief Preconditioner of the discrete adjoint linear solver. */
@@ -4281,6 +4289,16 @@ class CConfig {
42814289
*/
42824290
unsigned short GetKind_Linear_Solver(void) const { return Kind_Linear_Solver; }
42834291

4292+
/*!
4293+
* \brief Check whether nested Krylov linear solver is enabled.
4294+
*/
4295+
bool GetNested_Linear_Solver(void) const { return Nested_Linear_Solver; }
4296+
4297+
/*!
4298+
* \brief Get the inner linear solver used in nested Krylov schemes.
4299+
*/
4300+
unsigned short GetKind_Linear_Solver_Inner(void) const { return Kind_Linear_Solver_Inner; }
4301+
42844302

42854303
/*!
42864304
* \brief Get the kind of preconditioner for the implicit solver.

Common/include/linear_algebra/CSysSolve.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,21 +348,6 @@ class CSysSolve {
348348
unsigned long BCGSTAB_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
349349
const PrecondType& precond, ScalarType tol, unsigned long m, ScalarType& residual,
350350
bool monitoring, const CConfig* config) const;
351-
/*!
352-
* \brief The nested FGMRES and BCGSTAB solver
353-
* \param[in] b - the right hand size vector
354-
* \param[in,out] x - on entry the intial guess, on exit the solution
355-
* \param[in] mat_vec - object that defines matrix-vector product
356-
* \param[in] precond - object that defines preconditioner
357-
* \param[in] tol - tolerance with which to solve the system
358-
* \param[in] m - maximum size of the search subspace
359-
* \param[out] residual - final normalized residual
360-
* \param[in] monitoring - turn on priting residuals from solver to screen.
361-
* \param[in] config - Definition of the particular problem.
362-
*/
363-
unsigned long FGMRESandBCGSTAB2_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
364-
const PrecondType& precond, ScalarType tol, unsigned long m,
365-
ScalarType& residual, bool monitoring, const CConfig* config) const;
366351

367352
/*!
368353
* \brief Generic smoother (modified Richardson iteration with preconditioner)

Common/include/option_structure.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,6 @@ enum ENUM_LINEAR_SOLVER {
23542354
CONJUGATE_GRADIENT, /*!< \brief Preconditionated conjugate gradient method for grid deformation. */
23552355
FGMRES, /*!< \brief Flexible Generalized Minimal Residual method. */
23562356
BCGSTAB, /*!< \brief BCGSTAB - Biconjugate Gradient Stabilized Method (main solver). */
2357-
FGMRESandBCGSTAB2, /*!< \brief FGMRESandBCGSTAB (main solver). */
23582357
RESTARTED_FGMRES, /*!< \brief Flexible Generalized Minimal Residual method with restart. */
23592358
SMOOTHER, /*!< \brief Iterative smoother. */
23602359
PASTIX_LDLT, /*!< \brief PaStiX LDLT (complete) factorization. */
@@ -2363,7 +2362,6 @@ enum ENUM_LINEAR_SOLVER {
23632362
static const MapType<std::string, ENUM_LINEAR_SOLVER> Linear_Solver_Map = {
23642363
MakePair("CONJUGATE_GRADIENT", CONJUGATE_GRADIENT)
23652364
MakePair("BCGSTAB", BCGSTAB)
2366-
MakePair("FGMRESandBCGSTAB2", FGMRESandBCGSTAB2)
23672365
MakePair("FGMRES", FGMRES)
23682366
MakePair("RESTARTED_FGMRES", RESTARTED_FGMRES)
23692367
MakePair("SMOOTHER", SMOOTHER)

Common/src/CConfig.cpp

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ vector<double> GEMM_Profile_MaxTime; /*!< \brief Maximum time spent for thi
6262
//#pragma omp threadprivate(Profile_Function_tp, Profile_Time_tp, Profile_ID_tp, Profile_Map_tp)
6363

6464

65+
/* --- Map from config string to inner solver enum --- */
66+
std::map<std::string, ENUM_LINEAR_SOLVER_INNER> Inner_Linear_Solver_Map = {
67+
{"NONE", INNER_SOLVER_NONE},
68+
{"BCGSTAB", INNER_SOLVER_BCGSTAB}
69+
};
70+
6571
CConfig::CConfig(char case_filename[MAX_STRING_SIZE], SU2_COMPONENT val_software, bool verb_high) {
6672

6773
/*--- Set the case name to the base config file name without extension ---*/
@@ -1906,6 +1912,20 @@ void CConfig::SetConfig_Options() {
19061912
addEnumOption("DISCADJ_LIN_PREC", Kind_DiscAdj_Linear_Prec, Linear_Solver_Prec_Map, ILU);
19071913
/* DESCRIPTION: Linear solver for the discete adjoint systems */
19081914

1915+
/*!\brief LINEAR_SOLVER_NESTED
1916+
* \n DESCRIPTION: Enable nested Krylov linear solver (e.g. FGMRES with inner solver).
1917+
* \n OPTIONS: YES, NO \ingroup Config */
1918+
addBoolOption("LINEAR_SOLVER_NESTED", Nested_Linear_Solver, false);
1919+
1920+
/*!\brief LINEAR_SOLVER_INNER
1921+
* \n DESCRIPTION: Inner linear solver used when LINEAR_SOLVER_NESTED = YES.
1922+
* \n OPTIONS: see \link Inner_Linear_Solver_Map \endlink
1923+
* \n DEFAULT: BCGSTAB \ingroup Config */
1924+
addEnumOption("LINEAR_SOLVER_INNER",
1925+
Kind_Linear_Solver_Inner,
1926+
Inner_Linear_Solver_Map,
1927+
INNER_SOLVER_BCGSTAB);
1928+
19091929
/* DESCRIPTION: Maximum update ratio value for flow density and energy variables */
19101930
addDoubleOption("MAX_UPDATE_FLOW", MaxUpdateFlow, 0.2);
19111931
/* DESCRIPTION: Maximum update ratio value for SA turbulence variable nu_tilde */
@@ -7255,15 +7275,19 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
72557275
SU2_MPI::Error("Implicit time scheme is not yet implemented with Mutation++. Use EULER_EXPLICIT.", CURRENT_FUNCTION);
72567276
switch (Kind_Linear_Solver) {
72577277
case BCGSTAB:
7258-
case FGMRESandBCGSTAB2:
72597278
case FGMRES:
72607279
case RESTARTED_FGMRES:
7261-
if (Kind_Linear_Solver == BCGSTAB)
7280+
if (Kind_Linear_Solver == BCGSTAB){
72627281
cout << "BCGSTAB is used for solving the linear system." << endl;
7263-
else if (Kind_Linear_Solver == FGMRESandBCGSTAB2)
7264-
cout << "FGMRES and BCGSTAB is used for solving the linear system." << endl;
7265-
else
7266-
cout << "FGMRES is used for solving the linear system." << endl;
7282+
}
7283+
else {
7284+
if (GetNested_Linear_Solver()){
7285+
cout << "Nested FGMRES (FGMRES with inner BiCGSTAB) is used for solving the linear system." << endl;
7286+
}
7287+
else {
7288+
cout << "FGMRES is used for solving the linear system." << endl;
7289+
}
7290+
}
72677291
switch (Kind_Linear_Solver_Prec) {
72687292
case ILU: cout << "Using a ILU("<< Linear_Solver_ILU_n <<") preconditioning."<< endl; break;
72697293
case LINELET: cout << "Using a linelet preconditioning."<< endl; break;
@@ -7316,12 +7340,6 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
73167340
cout << "Convergence criteria of the linear solver: "<< Linear_Solver_Error <<"."<< endl;
73177341
cout << "Max number of iterations: "<< Linear_Solver_Iter <<"."<< endl;
73187342
break;
7319-
case FGMRESandBCGSTAB2:
7320-
cout << "FGMRES and BCGSTAB is used for solving the linear system." << endl;
7321-
cout << "Convergence criteria of the linear solver: "<< Linear_Solver_Error <<"."<< endl;
7322-
cout << "Max number of iterations: "<< Linear_Solver_Iter <<"."<< endl;
7323-
break;
7324-
73257343
}
73267344
break;
73277345
}

0 commit comments

Comments
 (0)