Coupling Solvers with Preconditioners¶
These classes provide a convenient way to couple an iterative solver and a preconditioner. This may be used both for convenience and as a building block for a composite preconditioner.
make_solver¶
-
template<class
Precond
, classIterSolver
>
classamgcl
::
make_solver
¶ Include
<amgcl/make_solver.hpp>
The class has two template parameters:
Precond
andIterSolver
, which specify the preconditioner and the iterative solver to use. During construction of the class, instances of both components are constructed and are ready to use as a whole.-
typedef typename Backend::params
backend_params
¶ The backend parameters
-
typedef typename Backend::value_type
value_type
¶ The value type of the system matrix
-
typedef typename amgcl::math::scalar_of<value_type>::type
scalar_type
¶ The scalar type corresponding to the value type. For example, when the value type is
std::complex<double>
, then the scalar type isdouble
.
-
class
params
¶ The coupled solver parameters
-
IterSolver::params
solver
¶ The iterative solver parameters
-
IterSolver::params
-
template<class
Matrix
>make_solver
(const Matrix &A, const params &prm = params(), const backend_params &bprm = backend_params())¶ The constructor
-
template<class
Matrix
, classVectorRHS
, classVectorX
>
std::tuple<size_t, scalar_type>operator()
(const Matrix &A, const VectorRHS &rhs, VectorX &x) const¶ Computes the solution for the given system matrix
A
and the right-hand siderhs
. Returns the number of iterations made and the achieved residual as astd::tuple
. The solution vectorx
provides initial approximation on input and holds the computed solution on output.The system matrix may differ from the matrix used during initialization. This may be used for the solution of non-stationary problems with slowly changing coefficients. There is a strong chance that a preconditioner built for a time step will act as a reasonably good preconditioner for several subsequent time steps [DeSh12].
-
template<class
VectorRHS
, classVectorX
>
std::tuple<size_t, scalar_type>operator()
(const VectorRHS &rhs, VectorX &x) const¶ Computes the solution for the given right-hand side
rhs
. Returns the number of iterations made and the achieved residual as astd::tuple
. The solution vectorx
provides initial approximation on input and holds the computed solution on output.
-
const IterSolver &
solver
() const¶ Returns reference to the constructed iterative solver
-
typedef typename Backend::params
make_block_solver¶
-
template<class
Precond
, classIterSolver
>
classamgcl
::
make_block_solver
¶ Include
<amgcl/make_block_solver.hpp>
Creates coupled solver which targets a block valued backend, but may be initialized with a scalar system matrix, and used with scalar vectors.
The scalar system matrix is transparently converted to the block-valued on using the
amgcl::adapter::block_matrix()
adapter in the class constructor, and the scalar vectors are reinterpreted to the block-valued ones upon application.This class may be used as a building block in a composite preconditioner, when one (or more) of the subsystems has block values, but has to be computed as a scalar matrix.
The interface is the same as that of
amgcl::make_solver
.
deflated_solver¶
-
template<class
Precond
, classIterSolver
>
classamgcl
::
deflated_solver
¶ Include
<amgcl/deflated_solver.hpp>
Creates preconditioned deflated solver. Deflated Krylov subspace methods are supposed to solve problems with large jumps in the coefficients on layered domains. It appears that the convergence of a deflated solver is independent of the size of the jump in the coefficients. The specific variant of the deflation method used here is A-DEF2 from [TNVE09].
-
typedef typename Backend::params
backend_params
¶ The backend parameters
-
typedef typename Backend::value_type
value_type
¶ The value type of the system matrix
-
typedef typename amgcl::math::scalar_of<value_type>::type
scalar_type
¶ The scalar type corresponding to the value type. For example, when the value type is
std::complex<double>
, then the scalar type isdouble
.
-
class
params
¶ The deflated solver parameters
-
int
nvec
= 0¶ The number of deflation vectors
-
scalar_type *
vec
= nullptr¶ The deflation vectors stored as a [nvec x n] matrix in row-major order
-
IterSolver::params
solver
¶ The iterative solver parameters
-
int
-
typedef typename Backend::params