![]() |
Documentation 6b54b78464
|
Class for solving linear systems using classical and Krylov-subspace iterative methods. More...
#include <CSysSolve.hpp>
Public Types | |
| using | Scalar = ScalarType |
| using | VectorType = CSysVector< ScalarType > |
| using | MatrixType = CSysMatrix< ScalarType > |
| using | ProductType = CMatrixVectorProduct< ScalarType > |
| using | PrecondType = CPreconditioner< ScalarType > |
Public Member Functions | |
| CSysSolve (LINEAR_SOLVER_MODE linear_solver_mode=LINEAR_SOLVER_MODE::STANDARD) | |
| default constructor of the class. | |
| unsigned long | CG_LinSolver (const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const |
| Conjugate Gradient method. | |
| unsigned long | FGMRES_LinSolver (const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const |
| Flexible Generalized Minimal Residual method. | |
| unsigned long | RFGMRES_LinSolver (const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const |
| Flexible Generalized Minimal Residual method with restarts (frequency comes from config). | |
| unsigned long | FGCRODR_LinSolver (const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long max_iter, ScalarType &residual, bool monitoring, const CConfig *config, FgcrodrMode mode=FgcrodrMode::NORMAL, unsigned long custom_m=0) const |
| Flexible Generalized Conjugate Residual Method with Inner Orthogonalization and Deflated Restarting. | |
| unsigned long | BCGSTAB_LinSolver (const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const |
| Biconjugate Gradient Stabilized Method (BCGSTAB) | |
| unsigned long | Smoother_LinSolver (const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const |
| Generic smoother (modified Richardson iteration with preconditioner) | |
| unsigned long | Solve (MatrixType &Jacobian, const CSysVector< su2double > &LinSysRes, CSysVector< su2double > &LinSysSol, CGeometry *geometry, const CConfig *config) |
| Solve the linear system using a Krylov subspace method. | |
| unsigned long | Solve_b (MatrixType &Jacobian, const VectorType &LinSysRes, VectorType &LinSysSol, CGeometry *geometry, const CConfig *config, bool directCall=true) |
| Solve the adjoint linear system using a Krylov subspace method. | |
| template<class OtherType , su2enable_if<!std::is_same_v< ScalarType, OtherType > > = 0> | |
| unsigned long | Solve_b (MatrixType &Jacobian, const CSysVector< OtherType > &LinSysRes, CSysVector< OtherType > &LinSysSol, CGeometry *geometry, const CConfig *config, bool directCall=true) |
| unsigned long | GetIterations () const |
| Get the number of iterations. | |
| ScalarType | GetResidual () const |
| Get the final residual. | |
| void | SetToleranceType (LinearToleranceType type) |
| Set the type of the tolerance for stoping the linear solvers (RELATIVE or ABSOLUTE). | |
| void | SetxIsZero (bool isZero) |
| Assume the initial solution is 0 to save one product, or don't. | |
| void | SetRecomputeResidual (bool recompRes) |
| Set whether to recompute residuals at the end (while monitoring only). | |
| void | SetMonitoringFrequency (bool frequency) |
| Set the screen output frequency during monitoring. | |
| void | ResetDeflation () const |
| Discard FGCRODR's deflation vectors for the next solve. | |
Class for solving linear systems using classical and Krylov-subspace iterative methods.
The individual solvers could be stand-alone subroutines, but by creating CSysSolve objects we can more easily assign different matrix-vector products and preconditioners to different problems that may arise in a hierarchical solver (i.e. multigrid).
The methods of this class are designed to be called by multiple OpenMP threads. Beware of writes to class member variables, for example "Residual" should only be modified by one thread.
| using CSysSolve< ScalarType >::MatrixType = CSysMatrix<ScalarType> |
| using CSysSolve< ScalarType >::PrecondType = CPreconditioner<ScalarType> |
| using CSysSolve< ScalarType >::ProductType = CMatrixVectorProduct<ScalarType> |
| using CSysSolve< ScalarType >::VectorType = CSysVector<ScalarType> |
| CSysSolve< ScalarType >::CSysSolve | ( | LINEAR_SOLVER_MODE | linear_solver_mode = LINEAR_SOLVER_MODE::STANDARD | ) |
default constructor of the class.
| [in] | linear_solver_mode | - enum, to let CSysSolve know in what context it is |
| unsigned long CSysSolve< ScalarType >::BCGSTAB_LinSolver | ( | const VectorType & | b, |
| VectorType & | x, | ||
| const ProductType & | mat_vec, | ||
| const PrecondType & | precond, | ||
| ScalarType | tol, | ||
| unsigned long | m, | ||
| ScalarType & | residual, | ||
| bool | monitoring, | ||
| const CConfig * | config | ||
| ) | const |
Biconjugate Gradient Stabilized Method (BCGSTAB)
| [in] | b | - the right hand size vector |
| [in,out] | x | - on entry the intial guess, on exit the solution |
| [in] | mat_vec | - object that defines matrix-vector product |
| [in] | precond | - object that defines preconditioner |
| [in] | tol | - tolerance with which to solve the system |
| [in] | m | - maximum size of the search subspace |
| [out] | residual | - final normalized residual |
| [in] | monitoring | - turn on priting residuals from solver to screen |
| [in] | config | - Definition of the particular problem. |
| unsigned long CSysSolve< ScalarType >::CG_LinSolver | ( | const VectorType & | b, |
| VectorType & | x, | ||
| const ProductType & | mat_vec, | ||
| const PrecondType & | precond, | ||
| ScalarType | tol, | ||
| unsigned long | m, | ||
| ScalarType & | residual, | ||
| bool | monitoring, | ||
| const CConfig * | config | ||
| ) | const |
Conjugate Gradient method.
| [in] | b | - the right hand size vector |
| [in,out] | x | - on entry the intial guess, on exit the solution |
| [in] | mat_vec | - object that defines matrix-vector product |
| [in] | precond | - object that defines preconditioner |
| [in] | tol | - tolerance with which to solve the system |
| [in] | m | - maximum size of the search subspace |
| [out] | residual | - final normalized residual |
| [in] | monitoring | - turn on priting residuals from solver to screen |
| [in] | config | - Definition of the particular problem. |
| unsigned long CSysSolve< ScalarType >::FGCRODR_LinSolver | ( | const VectorType & | b, |
| VectorType & | x, | ||
| const ProductType & | mat_vec, | ||
| const PrecondType & | precond, | ||
| ScalarType | tol, | ||
| unsigned long | max_iter, | ||
| ScalarType & | residual, | ||
| bool | monitoring, | ||
| const CConfig * | config, | ||
| FgcrodrMode | mode = FgcrodrMode::NORMAL, |
||
| unsigned long | custom_m = 0 |
||
| ) | const |
Flexible Generalized Conjugate Residual Method with Inner Orthogonalization and Deflated Restarting.
| [in] | b | - the right hand size vector |
| [in,out] | x | - on entry the intial guess, on exit the solution |
| [in] | mat_vec | - object that defines matrix-vector product |
| [in] | precond | - object that defines preconditioner |
| [in] | tol | - tolerance with which to solve the system |
| [in] | max_iter | - maximum number of iterations |
| [out] | residual | - final normalized residual |
| [in] | monitoring | - turn on priting residuals from solver to screen |
| [in] | config | - Definition of the particular problem. |
| [in] | mode | - See FgcrodrMode. |
| [in] | custom_m | - alternative maximum size of the search subspace, overrides the config value if != 0. |
| unsigned long CSysSolve< ScalarType >::FGMRES_LinSolver | ( | const VectorType & | b, |
| VectorType & | x, | ||
| const ProductType & | mat_vec, | ||
| const PrecondType & | precond, | ||
| ScalarType | tol, | ||
| unsigned long | m, | ||
| ScalarType & | residual, | ||
| bool | monitoring, | ||
| const CConfig * | config | ||
| ) | const |
Flexible Generalized Minimal Residual method.
| [in] | b | - the right hand size vector |
| [in,out] | x | - on entry the intial guess, on exit the solution |
| [in] | mat_vec | - object that defines matrix-vector product |
| [in] | precond | - object that defines preconditioner |
| [in] | tol | - tolerance with which to solve the system |
| [in] | m | - maximum size of the search subspace |
| [out] | residual | - final normalized residual |
| [in] | monitoring | - turn on priting residuals from solver to screen |
| [in] | config | - Definition of the particular problem. |
|
inline |
Get the number of iterations.
|
inline |
Get the final residual.
|
inline |
Discard FGCRODR's deflation vectors for the next solve.
| unsigned long CSysSolve< ScalarType >::RFGMRES_LinSolver | ( | const VectorType & | b, |
| VectorType & | x, | ||
| const ProductType & | mat_vec, | ||
| const PrecondType & | precond, | ||
| ScalarType | tol, | ||
| unsigned long | m, | ||
| ScalarType & | residual, | ||
| bool | monitoring, | ||
| const CConfig * | config | ||
| ) | const |
Flexible Generalized Minimal Residual method with restarts (frequency comes from config).
|
inline |
Set the screen output frequency during monitoring.
|
inline |
Set whether to recompute residuals at the end (while monitoring only).
|
inline |
Set the type of the tolerance for stoping the linear solvers (RELATIVE or ABSOLUTE).
|
inline |
Assume the initial solution is 0 to save one product, or don't.
| unsigned long CSysSolve< ScalarType >::Smoother_LinSolver | ( | const VectorType & | b, |
| VectorType & | x, | ||
| const ProductType & | mat_vec, | ||
| const PrecondType & | precond, | ||
| ScalarType | tol, | ||
| unsigned long | m, | ||
| ScalarType & | residual, | ||
| bool | monitoring, | ||
| const CConfig * | config | ||
| ) | const |
Generic smoother (modified Richardson iteration with preconditioner)
| [in] | b | - the right hand size vector |
| [in,out] | x | - on entry the intial guess, on exit the solution |
| [in] | mat_vec | - object that defines matrix-vector product |
| [in] | precond | - object that defines preconditioner |
| [in] | tol | - tolerance with which to solve the system |
| [in] | m | - maximum number of iterations |
| [out] | residual | - final normalized residual |
| [in] | monitoring | - turn on priting residuals from solver to screen |
| [in] | config | - Definition of the particular problem. |
| unsigned long CSysSolve< ScalarType >::Solve | ( | MatrixType & | Jacobian, |
| const CSysVector< su2double > & | LinSysRes, | ||
| CSysVector< su2double > & | LinSysSol, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) |
Solve the linear system using a Krylov subspace method.
| [in] | Jacobian | - Jacobian Matrix for the linear system |
| [in] | LinSysRes | - Linear system residual |
| [in,out] | LinSysSol | - Linear system solution |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
|
inline |
| unsigned long CSysSolve< ScalarType >::Solve_b | ( | MatrixType & | Jacobian, |
| const VectorType & | LinSysRes, | ||
| VectorType & | LinSysSol, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config, | ||
| bool | directCall = true |
||
| ) |
Solve the adjoint linear system using a Krylov subspace method.
| [in] | Jacobian | - Jacobian Matrix for the linear system |
| [in] | LinSysRes | - Linear system residual |
| [in,out] | LinSysSol | - Linear system solution |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| [in] | directCall | - If this method is called directly, or in AD context. |