Skip to content

Commit f881bb4

Browse files
committed
fixes, secret option to use it in Newton Krylov
1 parent 89fa381 commit f881bb4

6 files changed

Lines changed: 190 additions & 151 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class CConfig {
430430
unsigned short nQuasiNewtonSamples; /*!< \brief Number of samples used in quasi-Newton solution methods. */
431431
bool UseVectorization; /*!< \brief Whether to use vectorized numerics schemes. */
432432
bool NewtonKrylov; /*!< \brief Use a coupled Newton method to solve the flow equations. */
433-
array<unsigned short,3> NK_IntParam{{20, 3, 2}}; /*!< \brief Integer parameters for NK method. */
433+
array<unsigned short,4> NK_IntParam{{20, 3, 2, 0}}; /*!< \brief Integer parameters for NK method. */
434434
array<su2double,5> NK_DblParam{{-2.0, 0.1, -3.0, 1e-4, 1.0}}; /*!< \brief Floating-point parameters for NK method. */
435435
su2double NK_Relaxation = 1.0;
436436

@@ -4401,7 +4401,7 @@ class CConfig {
44014401
/*!
44024402
* \brief Get Newton-Krylov integer parameters.
44034403
*/
4404-
array<unsigned short,3> GetNewtonKrylovIntParam() const { return NK_IntParam; }
4404+
array<unsigned short,4> GetNewtonKrylovIntParam() const { return NK_IntParam; }
44054405

44064406
/*!
44074407
* \brief Get Newton-Krylov floating-point parameters.

Common/include/linear_algebra/CSysSolve.hpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ class CPreconditioner;
5454
* Absolute tolerance, target residual is tol*||b||. ---*/
5555
enum class LinearToleranceType { RELATIVE, ABSOLUTE };
5656

57+
/*!
58+
* \brief Modes of using FGCRODR.
59+
* \ingroup SpLinSys
60+
*/
61+
enum class FgcrodrMode {
62+
NORMAL, /*!< \brief Solve the linear system. */
63+
SAME_MAT, /*!< \brief "NORMAL" but knowing the matrix did not change. */
64+
};
65+
5766
/*!
5867
* \class CSysSolve
5968
* \ingroup SpLinSys
@@ -99,8 +108,8 @@ class CSysSolve {
99108
mutable VectorType v; /*!< \brief BCGSTAB "v" vector (v = A * M^-1 * p). */
100109

101110
mutable unsigned long k = 0;
102-
mutable std::vector<VectorType> W, V; /*!< \brief Large matrix used by FGMRES, w^i+1 = A * z^i. */
103-
mutable std::vector<VectorType> Z, T; /*!< \brief Large matrix used by FGMRES, preconditioned W. */
111+
mutable std::vector<VectorType> Z, V; /*!< \brief Large matrices used by FGMRES, v^i+1 = A * z^i. */
112+
mutable std::vector<VectorType> W, T; /*!< \brief Large matrices used by FGCRODR for deflation vectors. */
104113

105114
/*!< \brief Temporary used when it is necessary to interface between active and passive types. */
106115
VectorType LinSysSol_tmp;
@@ -283,7 +292,8 @@ class CSysSolve {
283292
template <class Dummy = int>
284293
unsigned long FGCRODR_LinSolverImpl(const VectorType& b, VectorType& x, const ProductType& mat_vec,
285294
const PrecondType& precond, ScalarType tol, unsigned long max_iter,
286-
ScalarType& residual, bool monitoring, const CConfig* config) const;
295+
ScalarType& residual, bool monitoring, const CConfig* config,
296+
FgcrodrMode mode) const;
287297

288298
public:
289299
/*!
@@ -341,10 +351,12 @@ class CSysSolve {
341351
* \param[out] residual - final normalized residual
342352
* \param[in] monitoring - turn on priting residuals from solver to screen.
343353
* \param[in] config - Definition of the particular problem.
354+
* \param[in] mode - See FgcrodrMode.
344355
*/
345356
unsigned long FGCRODR_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
346357
const PrecondType& precond, ScalarType tol, unsigned long max_iter,
347-
ScalarType& residual, bool monitoring, const CConfig* config) const;
358+
ScalarType& residual, bool monitoring, const CConfig* config,
359+
FgcrodrMode mode = FgcrodrMode::NORMAL) const;
348360

349361
/*!
350362
* \brief Biconjugate Gradient Stabilized Method (BCGSTAB)
@@ -436,5 +448,5 @@ class CSysSolve {
436448
/*!
437449
* \brief Discard FGCRODR's deflation vectors for the next solve.
438450
*/
439-
inline void ResetDeflation() { k = 0; }
451+
inline void ResetDeflation() const { k = 0; }
440452
};

0 commit comments

Comments
 (0)