Template Numerical Library version\ main:bb09b17
|
Iterative solver of linear systems based on the Generalized minimal residual (GMRES) method. More...
#include <TNL/Solvers/Linear/GMRES.h>
Public Types | |
using | ConstVectorViewType = typename Base::ConstVectorViewType |
Type for constant vector view. | |
using | DeviceType = typename Base::DeviceType |
Device where the solver will run on and auxillary data will alloacted on. | |
using | IndexType = typename Base::IndexType |
Type for indexing. | |
using | RealType = typename Base::RealType |
Floating point type used for computations. | |
using | VectorViewType = typename Base::VectorViewType |
Type for vector view. | |
Public Types inherited from TNL::Solvers::Linear::LinearSolver< Matrix > | |
using | ConstVectorViewType = typename Traits< Matrix >::ConstVectorViewType |
Type for constant vector view. | |
using | DeviceType = typename Matrix::DeviceType |
Device where the solver will run on and auxillary data will alloacted on. | |
using | IndexType = typename Matrix::IndexType |
Type for indexing. | |
using | MatrixPointer = std::shared_ptr< std::add_const_t< MatrixType > > |
Type of shared pointer to the matrix. | |
using | MatrixType = Matrix |
Type of the matrix representing the linear system. | |
using | PreconditionerPointer = std::shared_ptr< std::add_const_t< PreconditionerType > > |
Type of shared pointer to the preconditioner. | |
using | PreconditionerType = Preconditioners::Preconditioner< MatrixType > |
Type of preconditioner. | |
using | RealType = typename Matrix::RealType |
Floating point type used for computations. | |
using | VectorViewType = typename Traits< Matrix >::VectorViewType |
Type for vector view. | |
Public Types inherited from TNL::Solvers::IterativeSolver< Matrix::RealType, Matrix::IndexType > | |
using | SolverMonitorType |
Type of an object used for monitoring of the convergence. | |
Public Member Functions | |
bool | setup (const Config::ParameterContainer ¶meters, const String &prefix="") override |
Method for setup of the linear iterative solver based on configuration parameters. | |
bool | solve (ConstVectorViewType b, VectorViewType x) override |
Method for solving of a linear system. | |
Public Member Functions inherited from TNL::Solvers::Linear::LinearSolver< Matrix > | |
virtual | ~LinearSolver () |
Default destructor. | |
void | setMatrix (const MatrixPointer &matrix) |
Set the matrix of the linear system. | |
void | setPreconditioner (const PreconditionerPointer &preconditioner) |
Set the preconditioner. | |
Public Member Functions inherited from TNL::Solvers::IterativeSolver< Matrix::RealType, Matrix::IndexType > | |
IterativeSolver ()=default | |
Default constructor. | |
bool | checkConvergence () |
Checks whether the convergence occurred already. | |
bool | checkNextIteration () |
Checks if the solver is allowed to do the next iteration. | |
const Matrix::RealType & | getConvergenceResidue () const |
Gets the the convergence threshold. | |
const Matrix::RealType & | getDivergenceResidue () const |
Gets the limit for the divergence criterion. | |
const Matrix::IndexType & | getIterations () const |
Gets the number of iterations performed by the solver so far. | |
const Matrix::IndexType & | getMaxIterations () const |
Gets the maximal number of iterations the solver is allowed to perform. | |
const Matrix::IndexType & | getMinIterations () const |
Gets the minimal number of iterations the solver is supposed to do. | |
const Matrix::RealType & | getResidue () const |
Gets the residue reached at the current iteration. | |
bool | nextIteration () |
Proceeds to the next iteration. | |
void | resetIterations () |
Sets the the number of the current iterations to zero. | |
void | setConvergenceResidue (const Matrix::RealType &convergenceResidue) |
Sets the threshold for the convergence. | |
void | setDivergenceResidue (const Matrix::RealType &divergenceResidue) |
Sets the residue limit for the divergence criterion. | |
void | setMaxIterations (const Matrix::IndexType &maxIterations) |
Sets the maximal number of iterations the solver is allowed to perform. | |
void | setMinIterations (const Matrix::IndexType &minIterations) |
Sets the minimal number of iterations the solver is supposed to do. | |
void | setRefreshRate (const Matrix::IndexType &refreshRate) |
Sets the refresh rate (in milliseconds) for the solver monitor. | |
void | setResidue (const Matrix::RealType &residue) |
Sets the residue reached at the current iteration. | |
void | setSolverMonitor (SolverMonitorType &solverMonitor) |
Sets the solver monitor object. | |
bool | setup (const Config::ParameterContainer ¶meters, const std::string &prefix="") |
Method for setup of the iterative solver based on configuration parameters. | |
Static Public Member Functions | |
static void | configSetup (Config::ConfigDescription &config, const String &prefix="") |
This is method defines configuration entries for setup of the linear iterative solver. | |
Static Public Member Functions inherited from TNL::Solvers::Linear::LinearSolver< Matrix > | |
static void | configSetup (Config::ConfigDescription &config, const String &prefix="") |
This method defines configuration entries for setup of the linear iterative solver. | |
Static Public Member Functions inherited from TNL::Solvers::IterativeSolver< Matrix::RealType, Matrix::IndexType > | |
static void | configSetup (Config::ConfigDescription &config, const std::string &prefix="") |
This method defines configuration entries for setup of the iterative solver. | |
Protected Types | |
using | ConstDeviceView = typename Traits::ConstLocalViewType |
using | DeviceVector = typename Traits::LocalVectorType |
using | DeviceView = typename Traits::LocalViewType |
using | HostVector = typename DeviceVector::template Self< RealType, Devices::Host > |
using | HostView = typename DeviceView::template Self< RealType, Devices::Host > |
enum class | Variant { CGS , CGSR , MGS , MGSR , CWY } |
using | VectorType = typename Traits::VectorType |
Protected Member Functions | |
void | apply_givens_rotations (int i, int m) |
void | applyPlaneRotation (RealType &dx, RealType &dy, RealType &cs, RealType &sn) |
void | compute_residue (VectorViewType r, ConstVectorViewType x, ConstVectorViewType b) |
void | generatePlaneRotation (RealType &dx, RealType &dy, RealType &cs, RealType &sn) |
void | hauseholder_apply_trunc (HostView out, int i, VectorViewType y_i, ConstVectorViewType z) |
void | hauseholder_cwy (VectorViewType v, int i) |
void | hauseholder_cwy_transposed (VectorViewType z, int i, ConstVectorViewType w) |
void | hauseholder_generate (int i, VectorViewType y_i, ConstVectorViewType z) |
int | orthogonalize_CGS (int m, RealType normb, RealType beta) |
int | orthogonalize_CWY (int m, RealType normb, RealType beta) |
int | orthogonalize_MGS (int m, RealType normb, RealType beta) |
void | preconditioned_matvec (VectorViewType w, ConstVectorViewType v) |
void | setSize (const VectorViewType &x) |
template<typename Vector > | |
void | update (int k, int m, const HostVector &H, const HostVector &s, DeviceVector &V, Vector &x) |
Static Protected Member Functions | |
template<typename M > | |
static IndexType | getLocalOffset (const M &m) |
template<typename M > | |
static IndexType | getLocalOffset (const Matrices::DistributedMatrix< M > &m) |
Protected Attributes | |
VectorType | _M_tmp |
HostVector | cs |
HostVector | H |
IndexType | ldSize = 0 |
IndexType | localOffset = 0 |
VectorType | r |
int | restarting_max = 10 |
int | restarting_min = 10 |
int | restarting_step_max = 3 |
int | restarting_step_min = 3 |
HostVector | s |
IndexType | size = 0 |
HostVector | sn |
HostVector | T |
DeviceVector | V |
Variant | variant = Variant::CWY |
VectorType | w |
DeviceVector | Y |
HostVector | YL |
VectorType | z |
Protected Attributes inherited from TNL::Solvers::Linear::LinearSolver< Matrix > | |
MatrixPointer | matrix = nullptr |
PreconditionerPointer | preconditioner = nullptr |
Protected Attributes inherited from TNL::Solvers::IterativeSolver< Matrix::RealType, Matrix::IndexType > | |
Matrix::RealType | convergenceResidue |
Matrix::IndexType | currentIteration |
Matrix::RealType | currentResidue |
Matrix::RealType | divergenceResidue |
Matrix::IndexType | maxIterations |
Matrix::IndexType | minIterations |
Matrix::IndexType | refreshRate |
std::ofstream | residualHistoryFile |
std::string | residualHistoryFileName |
IterativeSolverMonitor< Matrix::RealType, Matrix::IndexType > * | solverMonitor |
Iterative solver of linear systems based on the Generalized minimal residual (GMRES) method.
This method can be used for solving of non-semmetric linear systems. This implementation offers various methods for the orthogonalization of vectors generated by the Arnoldi algorithm. The user may choose one of the following:
CGS - Classical Gramm-Schmidt,
CGSR - Classical Gramm-Schmidt with reorthogonalization,
MGS - Modified Gramm-Schmidt,
MGSR - Modified Gramm-Schmidt with reorthogonalization (the default one),
CWY - Compact WY form of the Householder reflections).
See Wikipedia for more details.
See TNL::Solvers::Linear::LinearSolver for example of showing how to use the linear solvers.
Matrix | is type of matrix describing the linear system. |
|
static |
This is method defines configuration entries for setup of the linear iterative solver.
In addition to config entries defined by IterativeSolver::configSetup, this method defines the following:
gmres-variant - Algorithm used for the orthogonalization - CGS (Classical Gramm-Schmidt), CGSR(Classical Gramm-Schmidt with reorthogonalization), MGS(Modified Gramm-Schmidt), MGSR(Modified Gramm-Schmidt with reorthogonalization), CWY(Compact WY form of the Householder reflections).
gmres-restarting-min - minimal number of iterations after which the GMRES restarts.
gmres-restarting-max - maximal number of iterations after which the GMRES restarts.
gmres-restarting-step-min - minimal adjusting step for the adaptivity of the GMRES restarting parameter.
gmres-restarting-step-max - maximal adjusting step for the adaptivity of the GMRES restarting parameter.
config | contains description of configuration parameters. |
prefix | is a prefix of particular configuration entries. |
|
overridevirtual |
Method for setup of the linear iterative solver based on configuration parameters.
parameters | contains values of the define configuration entries. |
prefix | is a prefix of particular configuration entries. |
Reimplemented from TNL::Solvers::Linear::LinearSolver< Matrix >.
|
overridevirtual |
Method for solving of a linear system.
See LinearSolver::solve for more details.
b | vector with the right-hand side of the linear system. |
x | vector for the solution of the linear system. |
Implements TNL::Solvers::Linear::LinearSolver< Matrix >.