Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver > Class Template Reference

Convenience class that bundles together a preconditioner and an iterative solver. More...

#include </__w/arcaneframework.github.io/arcaneframework.github.io/framework/arccore/src/alina/arccore/alina/PreconditionedSolver.h>

Inheritance diagram for Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >:
Collaboration diagram for Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >:

Classes

struct  params
 Combined parameters of the bundled preconditioner and the iterative solver. More...

Public Types

typedef IterativeSolver::backend_type backend_type
typedef backend_type::matrix matrix
typedef backend_type::value_type value_type
typedef backend_type::col_type col_type
typedef backend_type::ptr_type ptr_type
typedef backend_type::params backend_params
typedef BuiltinBackend< value_type, col_type, ptr_type >::matrix build_matrix
typedef math::scalar_of< value_type >::type scalar_type

Public Member Functions

template<class Matrix>
 PreconditionedSolver (const Matrix &A, const params &prm=params(), const backend_params &bprm=backend_params())
 Sets up the preconditioner and creates the iterative solver.
 PreconditionedSolver (std::shared_ptr< build_matrix > A, const params &prm=params(), const backend_params &bprm=backend_params())
template<class Matrix, class Vec1, class Vec2>
SolverResult operator() (const Matrix &A, const Vec1 &rhs, Vec2 &&x) const
template<class Vec1, class Vec2>
SolverResult operator() (const Vec1 &rhs, Vec2 &&x) const
template<class Vec1, class Vec2>
void apply (const Vec1 &rhs, Vec2 &&x) const
const Precond & precond () const
 Returns reference to the constructed preconditioner.
Precond & precond ()
 Returns reference to the constructed preconditioner.
const IterativeSolver & solver () const
 Returns reference to the constructed iterative solver.
IterativeSolver & solver ()
 Returns reference to the constructed iterative solver.
std::shared_ptr< typename Precond::matrix > system_matrix_ptr () const
 Returns the system matrix in the backend format.
Precond::matrix const & system_matrix () const
void get_params (Alina::PropertyTree &p) const
 Stores the parameters used during construction into the property tree p.
size_t size () const
 Returns the size of the system matrix.
size_t bytes () const

Public Attributes

struct Arcane::Alina::PreconditionedSolver::params prm

Private Attributes

size_t n
Precond P
IterativeSolver S

Friends

std::ostream & operator<< (std::ostream &os, const PreconditionedSolver &p)

Additional Inherited Members

Protected Member Functions inherited from Arcane::Alina::detail::non_copyable
 non_copyable (non_copyable const &)=delete
void operator= (non_copyable const &x)=delete

Detailed Description

template<class Precond, class IterativeSolver>
class Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >

Convenience class that bundles together a preconditioner and an iterative solver.

Definition at line 41 of file PreconditionedSolver.h.

Member Typedef Documentation

◆ backend_params

template<class Precond, class IterativeSolver>
typedef backend_type::params Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::backend_params

Definition at line 57 of file PreconditionedSolver.h.

◆ backend_type

template<class Precond, class IterativeSolver>
typedef IterativeSolver::backend_type Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::backend_type

Definition at line 51 of file PreconditionedSolver.h.

◆ build_matrix

template<class Precond, class IterativeSolver>
typedef BuiltinBackend<value_type,col_type,ptr_type>::matrix Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::build_matrix

Definition at line 58 of file PreconditionedSolver.h.

◆ col_type

template<class Precond, class IterativeSolver>
typedef backend_type::col_type Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::col_type

Definition at line 55 of file PreconditionedSolver.h.

◆ matrix

template<class Precond, class IterativeSolver>
typedef backend_type::matrix Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::matrix

Definition at line 52 of file PreconditionedSolver.h.

◆ ptr_type

template<class Precond, class IterativeSolver>
typedef backend_type::ptr_type Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::ptr_type

Definition at line 56 of file PreconditionedSolver.h.

◆ scalar_type

template<class Precond, class IterativeSolver>
typedef math::scalar_of<value_type>::type Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::scalar_type

Definition at line 60 of file PreconditionedSolver.h.

◆ value_type

template<class Precond, class IterativeSolver>
typedef backend_type::value_type Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::value_type

Definition at line 54 of file PreconditionedSolver.h.

Constructor & Destructor Documentation

◆ PreconditionedSolver() [1/2]

template<class Precond, class IterativeSolver>
template<class Matrix>
Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::PreconditionedSolver ( const Matrix & A,
const params & prm = params(),
const backend_params & bprm = backend_params() )
inline

Sets up the preconditioner and creates the iterative solver.

Definition at line 90 of file PreconditionedSolver.h.

◆ PreconditionedSolver() [2/2]

template<class Precond, class IterativeSolver>
Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::PreconditionedSolver ( std::shared_ptr< build_matrix > A,
const params & prm = params(),
const backend_params & bprm = backend_params() )
inline

Definition at line 101 of file PreconditionedSolver.h.

Member Function Documentation

◆ apply()

template<class Precond, class IterativeSolver>
template<class Vec1, class Vec2>
void Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::apply ( const Vec1 & rhs,
Vec2 && x ) const
inline

Acts as a preconditioner. That is, applies the solver to the right-hand side rhs to get the solution x with zero initial approximation. Iterative methods usually use estimated residual for exit condition. For some problems the value of the estimated residual can get too far from the true residual due to round-off errors. Nesting iterative solvers in this way may allow to shave the last bits off the error. The method should not be used directly but rather allows nesting make_solver classes as in the following example:

\rst .. code-block:: cpp

typedef Arcane::Alina::PreconditionedSolver< Arcane::Alina::PreconditionedSolver< Arcane::Alina::AMG< Backend, ::Arcane::Alina::coarsening::smoothed_aggregation, ::Arcane::Alina::relaxation::spai0 >, ::Arcane::Alina::solver::cg<Backend> >, ::Arcane::Alina::solver::cg<Backend> > NestedSolver; \endrst

Definition at line 167 of file PreconditionedSolver.h.

◆ bytes()

template<class Precond, class IterativeSolver>
size_t Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::bytes ( ) const
inline

Definition at line 220 of file PreconditionedSolver.h.

◆ get_params()

template<class Precond, class IterativeSolver>
void Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::get_params ( Alina::PropertyTree & p) const
inline

Stores the parameters used during construction into the property tree p.

Definition at line 209 of file PreconditionedSolver.h.

◆ operator()() [1/2]

template<class Precond, class IterativeSolver>
template<class Matrix, class Vec1, class Vec2>
SolverResult Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::operator() ( const Matrix & A,
const Vec1 & rhs,
Vec2 && x ) const
inline

Computes the solution for the given system matrix A and the right-hand side rhs. Returns the number of iterations made and the achieved residual as a std::tuple. The solution vector x provides initial approximation in input and holds the computed solution on output.

\rst 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]_. \endrst

Definition at line 125 of file PreconditionedSolver.h.

◆ operator()() [2/2]

template<class Precond, class IterativeSolver>
template<class Vec1, class Vec2>
SolverResult Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::operator() ( const Vec1 & rhs,
Vec2 && x ) const
inline

Computes the solution for the given right-hand side rhs. Returns the number of iterations made and the achieved residual as a std::tuple. The solution vector x provides initial approximation in input and holds the computed solution on output.

Definition at line 136 of file PreconditionedSolver.h.

◆ precond() [1/2]

template<class Precond, class IterativeSolver>
Precond & Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::precond ( )
inline

Returns reference to the constructed preconditioner.

Definition at line 180 of file PreconditionedSolver.h.

◆ precond() [2/2]

template<class Precond, class IterativeSolver>
const Precond & Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::precond ( ) const
inline

Returns reference to the constructed preconditioner.

Definition at line 174 of file PreconditionedSolver.h.

◆ size()

template<class Precond, class IterativeSolver>
size_t Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::size ( ) const
inline

Returns the size of the system matrix.

Definition at line 215 of file PreconditionedSolver.h.

◆ solver() [1/2]

template<class Precond, class IterativeSolver>
IterativeSolver & Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::solver ( )
inline

Returns reference to the constructed iterative solver.

Definition at line 192 of file PreconditionedSolver.h.

◆ solver() [2/2]

template<class Precond, class IterativeSolver>
const IterativeSolver & Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::solver ( ) const
inline

Returns reference to the constructed iterative solver.

Definition at line 186 of file PreconditionedSolver.h.

◆ system_matrix()

template<class Precond, class IterativeSolver>
Precond::matrix const & Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::system_matrix ( ) const
inline

Definition at line 203 of file PreconditionedSolver.h.

◆ system_matrix_ptr()

template<class Precond, class IterativeSolver>
std::shared_ptr< typename Precond::matrix > Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::system_matrix_ptr ( ) const
inline

Returns the system matrix in the backend format.

Definition at line 198 of file PreconditionedSolver.h.

◆ operator<<

template<class Precond, class IterativeSolver>
std::ostream & operator<< ( std::ostream & os,
const PreconditionedSolver< Precond, IterativeSolver > & p )
friend

Definition at line 225 of file PreconditionedSolver.h.

Member Data Documentation

◆ n

template<class Precond, class IterativeSolver>
size_t Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::n
private

Definition at line 235 of file PreconditionedSolver.h.

◆ P

template<class Precond, class IterativeSolver>
Precond Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::P
private

Definition at line 236 of file PreconditionedSolver.h.

◆ S

template<class Precond, class IterativeSolver>
IterativeSolver Arcane::Alina::PreconditionedSolver< Precond, IterativeSolver >::S
private

Definition at line 237 of file PreconditionedSolver.h.


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