Documentation 6b54b78464
Loading...
Searching...
No Matches
CSysSolve< ScalarType > Class Template Reference

Class for solving linear systems using classical and Krylov-subspace iterative methods. More...

#include <CSysSolve.hpp>

Inheritance diagram for CSysSolve< ScalarType >:
[legend]

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.
 

Detailed Description

template<class ScalarType>
class CSysSolve< ScalarType >

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.

Member Typedef Documentation

◆ MatrixType

template<class ScalarType >
using CSysSolve< ScalarType >::MatrixType = CSysMatrix<ScalarType>

◆ PrecondType

template<class ScalarType >
using CSysSolve< ScalarType >::PrecondType = CPreconditioner<ScalarType>

◆ ProductType

template<class ScalarType >
using CSysSolve< ScalarType >::ProductType = CMatrixVectorProduct<ScalarType>

◆ Scalar

template<class ScalarType >
using CSysSolve< ScalarType >::Scalar = ScalarType

◆ VectorType

template<class ScalarType >
using CSysSolve< ScalarType >::VectorType = CSysVector<ScalarType>

Constructor & Destructor Documentation

◆ CSysSolve()

template<class ScalarType >
CSysSolve< ScalarType >::CSysSolve ( LINEAR_SOLVER_MODE  linear_solver_mode = LINEAR_SOLVER_MODE::STANDARD)

default constructor of the class.

Parameters
[in]linear_solver_mode- enum, to let CSysSolve know in what context it is

Member Function Documentation

◆ BCGSTAB_LinSolver()

template<class ScalarType >
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)

Parameters
[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.

◆ CG_LinSolver()

template<class ScalarType >
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.

Parameters
[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.

◆ FGCRODR_LinSolver()

template<class ScalarType >
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.

Parameters
[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.

◆ FGMRES_LinSolver()

template<class ScalarType >
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.

Parameters
[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.

◆ GetIterations()

template<class ScalarType >
unsigned long CSysSolve< ScalarType >::GetIterations ( ) const
inline

Get the number of iterations.

Returns
The number of iterations done by Solve or Solve_b

◆ GetResidual()

template<class ScalarType >
ScalarType CSysSolve< ScalarType >::GetResidual ( ) const
inline

Get the final residual.

Returns
The residual at the end of Solve or Solve_b

◆ ResetDeflation()

template<class ScalarType >
void CSysSolve< ScalarType >::ResetDeflation ( ) const
inline

Discard FGCRODR's deflation vectors for the next solve.

◆ RFGMRES_LinSolver()

template<class ScalarType >
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).

◆ SetMonitoringFrequency()

template<class ScalarType >
void CSysSolve< ScalarType >::SetMonitoringFrequency ( bool  frequency)
inline

Set the screen output frequency during monitoring.

◆ SetRecomputeResidual()

template<class ScalarType >
void CSysSolve< ScalarType >::SetRecomputeResidual ( bool  recompRes)
inline

Set whether to recompute residuals at the end (while monitoring only).

◆ SetToleranceType()

template<class ScalarType >
void CSysSolve< ScalarType >::SetToleranceType ( LinearToleranceType  type)
inline

Set the type of the tolerance for stoping the linear solvers (RELATIVE or ABSOLUTE).

◆ SetxIsZero()

template<class ScalarType >
void CSysSolve< ScalarType >::SetxIsZero ( bool  isZero)
inline

Assume the initial solution is 0 to save one product, or don't.

◆ Smoother_LinSolver()

template<class ScalarType >
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)

Parameters
[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.

◆ Solve()

template<class ScalarType >
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.

Parameters
[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.

◆ Solve_b() [1/2]

template<class ScalarType >
template<class OtherType , su2enable_if<!std::is_same_v< ScalarType, OtherType > > = 0>
unsigned long CSysSolve< ScalarType >::Solve_b ( MatrixType &  Jacobian,
const CSysVector< OtherType > &  LinSysRes,
CSysVector< OtherType > &  LinSysSol,
CGeometry *  geometry,
const CConfig *  config,
bool  directCall = true 
)
inline

◆ Solve_b() [2/2]

template<class ScalarType >
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.

Parameters
[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.

The documentation for this class was generated from the following files: