Concepts interface to Trilinos Belos solver with different ifpack2 preconditioners and different iterative solvers. More...

#include <belosSolver.hh>

Inheritance diagram for concepts::BelosSolver< T >:
concepts::VecOperator< T > concepts::Operator< T >

Public Types

typedef Cmplxtype< T >::type c_type
 Real type of data type. More...
 
typedef Tpetra::CrsMatrix< T, int, int > CRSmat
 
typedef BelosLinProb< T, MV, OPLP
 
typedef Tpetra::MultiVector< T, int > MV
 
typedef Tpetra::Operator< T > OP
 
typedef Realtype< T >::type r_type
 Real type of data type. More...
 
typedef Belos::SolverManager< T, MV, OPsolverManager
 
typedef T type
 Type of data, e.g. matrix entries. More...
 

Public Member Functions

 BelosSolver (concepts::SparseMatrix< T > &sparse, Teuchos::RCP< const Teuchos::Comm< int > > comm)
 Constructor for the root thread. More...
 
 BelosSolver (Teuchos::RCP< const Teuchos::Comm< int > > comm)
 Constructor for other threads wich don't know the concets::SparseMatrix. More...
 
virtual const uint dimX () const
 Returns the size of the image space of the operator (number of rows of the corresponding matrix) More...
 
virtual const uint dimY () const
 Returns the size of the source space of the operator (number of columns of the corresponding matrix) More...
 
Teuchos::RCP< LPgetLinearProblem ()
 
Teuchos::RCP< Teuchos::ParameterList > getPrecParam ()
 Gets the parameter list for the preconditioner. More...
 
std::string getPrecType ()
 
Teuchos::RCP< solverManagergetSolverManager ()
 Gets the solver via solver manager. More...
 
Teuchos::RCP< Teuchos::ParameterList > getSolverParam ()
 Get solver parameter list. More...
 
std::string getSolverType ()
 Getter for the solver type. More...
 
virtual void operator() ()
 Solving operator for other the non-root threads. More...
 
virtual void operator() (const Function< c_type > &fncY, Function< c_type > &fncX)
 Application operator for complex function fncY. More...
 
virtual void operator() (const Function< r_type > &fncY, Function< T > &fncX)
 Application operator for real function fncY. More...
 
void operator() (const Matrix< c_type > &mX, Matrix< c_type > &mY)
 Application method to complex matrices. Calls apply_() More...
 
void operator() (const Matrix< r_type > &mX, Matrix< T > &mY)
 Application method to real matrices. Calls function apply() More...
 
virtual void operator() (const Vector< c_type > &fncY, Vector< c_type > &fncX)
 Application operator for complex function fncY. More...
 
virtual void operator() (const Vector< r_type > &fncY, Vector< T > &fncX)
 Application operator for real vector fncY. More...
 
virtual void operator() (const Vector< T > &fncY, Vector< T > &fncX)
 Solving operator for the root thread. More...
 
void prepare ()
 Builds the Preconditioner and the solver (sets prepare to true) More...
 
void setPrecParam (double fill, double tol=1e-5, int absTresh=0, int relTresh=1, double relax=0)
 Set preconditoner parameter list via values. More...
 
void setPrecParam (Teuchos::RCP< Teuchos::ParameterList > param)
 Set preconditioner parameter list via Teuchos::parameter list. More...
 
void setPrecType (std::string type)
 Sets the preconditioner Type to one of the followings. More...
 
void setSolverManager (Teuchos::RCP< solverManager > manager)
 Sets the solver via solver manager. More...
 
void setSolverParam (int maxIter, int maxRestarts, double tol=1e-10, int blockSize=1, int outFreq=1)
 Set Solver parameter list via values. More...
 
void setSolverParam (Teuchos::RCP< Teuchos::ParameterList > param)
 Set Solver parameter list via Teuchos::parameter list. More...
 
void setSolverType (std::string type)
 Sets the solver type to one of the followings. More...
 
virtual void show_messages ()
 
virtual ~BelosSolver ()
 

Protected Member Functions

virtual std::ostream & info (std::ostream &os) const
 

Protected Attributes

uint dimX_
 Dimension of image space and the source space. More...
 
uint dimY_
 

Private Member Functions

virtual void apply_ ()
 Version for the other threads i.e. MyPID != 0. More...
 
virtual void apply_ (const Vector< T > &fncY, Vector< T > &fncX)
 Version for the master thread i.e. MyPID = 0. More...
 
bool createPrec_ ()
 Creates Preconditioner with given params sets by setSolverParam and setSolverType. More...
 
bool createSolver_ ()
 Creates Solver with given params sets by setPrecParam and setPrecType. More...
 
bool phasePrecInit_ (bool verbose=true)
 Builds the preconditioner. More...
 
bool phaseSolve_ (bool verbose=true)
 Solving. More...
 

Private Attributes

Teuchos::RCP< const Teuchos::Comm< int > > Comm_
 Communicator of the mpi thread. More...
 
Teuchos::RCP< LPlp_
 Linear Problem as Belos::LinearProblem. More...
 
Teuchos::RCP< Ifpack2::Preconditioner< T, int > > prec_
 The Preconditionier. More...
 
Teuchos::RCP< Teuchos::ParameterList > precParam_
 
std::string precType_
 
bool prepared_
 is preconditioner and all opions set More...
 
Teuchos::RCP< solverManagersolverManager_
 Of Type Belos::Solvermanager Handles choice of solver like CG or gmRes. More...
 
Teuchos::RCP< Teuchos::ParameterList > solverParam_
 Parameter for solver and preconditioner. More...
 
std::string solverType_
 

Detailed Description

template<class T>
class concepts::BelosSolver< T >

Concepts interface to Trilinos Belos solver with different ifpack2 preconditioners and different iterative solvers.

Author
Holger Brandsmeier, ETHZ, 2011
Christian Heier, TUB, 2012

Definition at line 32 of file belosSolver.hh.

Member Typedef Documentation

◆ c_type

typedef Cmplxtype<T >::type concepts::VecOperator< T >::c_type
inherited

Real type of data type.

Definition at line 120 of file compositions.hh.

◆ CRSmat

template<class T >
typedef Tpetra::CrsMatrix<T, int, int> concepts::BelosSolver< T >::CRSmat

Definition at line 38 of file belosSolver.hh.

◆ LP

template<class T >
typedef BelosLinProb<T, MV, OP> concepts::BelosSolver< T >::LP

Definition at line 39 of file belosSolver.hh.

◆ MV

template<class T >
typedef Tpetra::MultiVector<T, int> concepts::BelosSolver< T >::MV

Definition at line 36 of file belosSolver.hh.

◆ OP

template<class T >
typedef Tpetra::Operator<T> concepts::BelosSolver< T >::OP

Definition at line 37 of file belosSolver.hh.

◆ r_type

typedef Realtype<T >::type concepts::VecOperator< T >::r_type
inherited

Real type of data type.

Definition at line 118 of file compositions.hh.

◆ solverManager

template<class T >
typedef Belos::SolverManager<T, MV, OP> concepts::BelosSolver< T >::solverManager

Definition at line 40 of file belosSolver.hh.

◆ type

typedef T concepts::Operator< T >::type
inherited

Type of data, e.g. matrix entries.

Definition at line 45 of file compositions.hh.

Constructor & Destructor Documentation

◆ BelosSolver() [1/2]

template<class T >
concepts::BelosSolver< T >::BelosSolver ( concepts::SparseMatrix< T > &  sparse,
Teuchos::RCP< const Teuchos::Comm< int > >  comm 
)

Constructor for the root thread.

Definition at line 257 of file belosSolver.hh.

◆ BelosSolver() [2/2]

template<class T >
concepts::BelosSolver< T >::BelosSolver ( Teuchos::RCP< const Teuchos::Comm< int > >  comm)

Constructor for other threads wich don't know the concets::SparseMatrix.

Definition at line 267 of file belosSolver.hh.

◆ ~BelosSolver()

template<class T >
virtual concepts::BelosSolver< T >::~BelosSolver ( )
inlinevirtual

Definition at line 48 of file belosSolver.hh.

Member Function Documentation

◆ apply_() [1/2]

template<class T >
void concepts::BelosSolver< T >::apply_
privatevirtual

Version for the other threads i.e. MyPID != 0.

Implements concepts::VecOperator< T >.

Definition at line 193 of file belosSolver_decl.hh.

◆ apply_() [2/2]

template<class T >
void concepts::BelosSolver< T >::apply_ ( const Vector< T > &  fncY,
Vector< T > &  fncX 
)
privatevirtual

Version for the master thread i.e. MyPID = 0.

Implements concepts::VecOperator< T >.

Definition at line 179 of file belosSolver_decl.hh.

◆ createPrec_()

template<class T >
bool concepts::BelosSolver< T >::createPrec_
private

Creates Preconditioner with given params sets by setSolverParam and setSolverType.

Definition at line 107 of file belosSolver_decl.hh.

◆ createSolver_()

template<class T >
bool concepts::BelosSolver< T >::createSolver_
private

Creates Solver with given params sets by setPrecParam and setPrecType.

Definition at line 113 of file belosSolver_decl.hh.

◆ dimX()

virtual const uint concepts::Operator< T >::dimX
inlinevirtualinherited

Returns the size of the image space of the operator (number of rows of the corresponding matrix)

Definition at line 93 of file compositions.hh.

◆ dimY()

virtual const uint concepts::Operator< T >::dimY
inlinevirtualinherited

Returns the size of the source space of the operator (number of columns of the corresponding matrix)

Definition at line 98 of file compositions.hh.

◆ getLinearProblem()

template<class T >
Teuchos::RCP<LP> concepts::BelosSolver< T >::getLinearProblem ( )
inline

Definition at line 153 of file belosSolver.hh.

◆ getPrecParam()

template<class T >
Teuchos::RCP<Teuchos::ParameterList> concepts::BelosSolver< T >::getPrecParam ( )
inline

Gets the parameter list for the preconditioner.

Definition at line 131 of file belosSolver.hh.

◆ getPrecType()

template<class T >
std::string concepts::BelosSolver< T >::getPrecType ( )
inline

Definition at line 188 of file belosSolver.hh.

◆ getSolverManager()

template<class T >
Teuchos::RCP<solverManager> concepts::BelosSolver< T >::getSolverManager ( )
inline

Gets the solver via solver manager.

Definition at line 148 of file belosSolver.hh.

◆ getSolverParam()

template<class T >
Teuchos::RCP<Teuchos::ParameterList> concepts::BelosSolver< T >::getSolverParam ( )
inline

Get solver parameter list.

Definition at line 98 of file belosSolver.hh.

◆ getSolverType()

template<class T >
std::string concepts::BelosSolver< T >::getSolverType ( )
inline

Getter for the solver type.

Definition at line 169 of file belosSolver.hh.

◆ info()

template<class T >
virtual std::ostream& concepts::BelosSolver< T >::info ( std::ostream &  os) const
protectedvirtual

Reimplemented from concepts::VecOperator< T >.

◆ operator()() [1/8]

template<class T >
virtual void concepts::BelosSolver< T >::operator() ( )
inlinevirtual

Solving operator for other the non-root threads.

Reimplemented from concepts::Operator< T >.

Definition at line 53 of file belosSolver.hh.

◆ operator()() [2/8]

virtual void concepts::VecOperator< T >::operator() ( const Function< c_type > &  fncY,
Function< c_type > &  fncX 
)
virtualinherited

Application operator for complex function fncY.

Computes fncX = A(fncY) where A is this operator. fncX becomes complex.

In derived classes its enough to implement the operator() for complex Operator's. If a real counterpart is not implemented, the function fncY is splitted into real and imaginary part and the application operator for real functions is called for each. Then the result is combined.

If in a derived class the operator() for complex Operator's is not implemented, a exception is thrown from here.

Reimplemented from concepts::Operator< T >.

◆ operator()() [3/8]

virtual void concepts::VecOperator< T >::operator() ( const Function< r_type > &  fncY,
Function< T > &  fncX 
)
virtualinherited

Application operator for real function fncY.

Computes fncX = A(fncY) where A is this operator.

fncX becomes the type of the operator, for real data it becomes real, for complex data it becomes complex.

In derived classes its enough to implement the operator() for real Operator's. If a complex counterpart is not implemented, the function fncY is transformed to a complex function and then the application operator for complex functions is called.

If in a derived class the operator() for real Operator's is not implemented, a exception is thrown from here.

Reimplemented from concepts::Operator< T >.

◆ operator()() [4/8]

void concepts::VecOperator< T >::operator() ( const Matrix< c_type > &  mX,
Matrix< c_type > &  mY 
)
inherited

Application method to complex matrices. Calls apply_()

◆ operator()() [5/8]

void concepts::VecOperator< T >::operator() ( const Matrix< r_type > &  mX,
Matrix< T > &  mY 
)
inherited

Application method to real matrices. Calls function apply()

◆ operator()() [6/8]

virtual void concepts::VecOperator< T >::operator() ( const Vector< c_type > &  fncY,
Vector< c_type > &  fncX 
)
virtualinherited

Application operator for complex function fncY.

Computes fncX = A(fncY) where A is this operator. fncX becomes complex.

In derived classes its enough to implement the operator() for complex Operator's. If a real counterpart is not implemented, the vector fncY is splitted into real and imaginary part and the application operator for real vectors is called for each. Then the result is combined

If in a derived class the operator() for complex Operator's i not implemented, a exception is thrown from here.

◆ operator()() [7/8]

virtual void concepts::VecOperator< T >::operator() ( const Vector< r_type > &  fncY,
Vector< T > &  fncX 
)
virtualinherited

Application operator for real vector fncY.

Computes fncX = A(fncY) where A is this operator.

Type of fncX becomes that of the operator, for real data it becomes real, for complex data it becomes complex.

In derived classes its enough to implement the operator() for real Operator's. If a complex counterpart is not implemented, the vector fncY is transformed to a complex vector and then the application for complex vectors is called.

If in a derived class the operator() for real Operator's is not implemented, a exception is thrown from here.

◆ operator()() [8/8]

template<class T >
virtual void concepts::BelosSolver< T >::operator() ( const Vector< T > &  fncY,
Vector< T > &  fncX 
)
inlinevirtual

Solving operator for the root thread.

Parameters
fncYthe right hand side
thesolution vector

Definition at line 62 of file belosSolver.hh.

◆ phasePrecInit_()

template<class T >
bool concepts::BelosSolver< T >::phasePrecInit_ ( bool  verbose = true)
private

Builds the preconditioner.

Definition at line 121 of file belosSolver_decl.hh.

◆ phaseSolve_()

template<class T >
bool concepts::BelosSolver< T >::phaseSolve_ ( bool  verbose = true)
private

Solving.

Definition at line 146 of file belosSolver_decl.hh.

◆ prepare()

template<class T >
void concepts::BelosSolver< T >::prepare ( )
inline

Builds the Preconditioner and the solver (sets prepare to true)

Definition at line 194 of file belosSolver.hh.

◆ setPrecParam() [1/2]

template<class T >
void concepts::BelosSolver< T >::setPrecParam ( double  fill,
double  tol = 1e-5,
int  absTresh = 0,
int  relTresh = 1,
double  relax = 0 
)
inline

Set preconditoner parameter list via values.

Parameters
fillwidth of the bandmatrix used for preconditioning
toltolerance for the preconditioner

Definition at line 116 of file belosSolver.hh.

◆ setPrecParam() [2/2]

template<class T >
void concepts::BelosSolver< T >::setPrecParam ( Teuchos::RCP< Teuchos::ParameterList >  param)
inline

Set preconditioner parameter list via Teuchos::parameter list.

Parameters
paramParameterlist that contains the parameter for the preconditioner

Definition at line 106 of file belosSolver.hh.

◆ setPrecType()

template<class T >
void concepts::BelosSolver< T >::setPrecType ( std::string  type)
inline

Sets the preconditioner Type to one of the followings.

  • "DIAGONAL"
  • "RELAXATION"
  • "CHEBYSHEV"
  • "ILUT"
  • "RILUK"

Definition at line 182 of file belosSolver.hh.

◆ setSolverManager()

template<class T >
void concepts::BelosSolver< T >::setSolverManager ( Teuchos::RCP< solverManager manager)
inline

Sets the solver via solver manager.

Definition at line 139 of file belosSolver.hh.

◆ setSolverParam() [1/2]

template<class T >
void concepts::BelosSolver< T >::setSolverParam ( int  maxIter,
int  maxRestarts,
double  tol = 1e-10,
int  blockSize = 1,
int  outFreq = 1 
)
inline

Set Solver parameter list via values.

Parameters
maxItermaximal number of iterations
maxRestartsmaximal number of restarts
toltolerence for the residuum

Definition at line 80 of file belosSolver.hh.

◆ setSolverParam() [2/2]

template<class T >
void concepts::BelosSolver< T >::setSolverParam ( Teuchos::RCP< Teuchos::ParameterList >  param)
inline

Set Solver parameter list via Teuchos::parameter list.

Parameters
paramParameterlist that contains the parameters for the solver

Definition at line 70 of file belosSolver.hh.

◆ setSolverType()

template<class T >
void concepts::BelosSolver< T >::setSolverType ( std::string  type)
inline

Sets the solver type to one of the followings.

  • "GMRES"
  • "BLOCKCG"
  • "PSEUDOCG"

Definition at line 163 of file belosSolver.hh.

◆ show_messages()

virtual void concepts::Operator< T >::show_messages
inlinevirtualinherited

Definition at line 100 of file compositions.hh.

Member Data Documentation

◆ Comm_

template<class T >
Teuchos::RCP<const Teuchos::Comm<int> > concepts::BelosSolver< T >::Comm_
private

Communicator of the mpi thread.

Definition at line 231 of file belosSolver.hh.

◆ dimX_

uint concepts::Operator< T >::dimX_
protectedinherited

Dimension of image space and the source space.

Definition at line 104 of file compositions.hh.

◆ dimY_

uint concepts::Operator< T >::dimY_
protectedinherited

Definition at line 104 of file compositions.hh.

◆ lp_

template<class T >
Teuchos::RCP<LP> concepts::BelosSolver< T >::lp_
private

Linear Problem as Belos::LinearProblem.

Definition at line 234 of file belosSolver.hh.

◆ prec_

template<class T >
Teuchos::RCP<Ifpack2::Preconditioner<T, int> > concepts::BelosSolver< T >::prec_
private

The Preconditionier.

Definition at line 244 of file belosSolver.hh.

◆ precParam_

template<class T >
Teuchos::RCP<Teuchos::ParameterList> concepts::BelosSolver< T >::precParam_
private

Definition at line 238 of file belosSolver.hh.

◆ precType_

template<class T >
std::string concepts::BelosSolver< T >::precType_
private

Definition at line 248 of file belosSolver.hh.

◆ prepared_

template<class T >
bool concepts::BelosSolver< T >::prepared_
private

is preconditioner and all opions set

Definition at line 251 of file belosSolver.hh.

◆ solverManager_

template<class T >
Teuchos::RCP<solverManager> concepts::BelosSolver< T >::solverManager_
private

Of Type Belos::Solvermanager Handles choice of solver like CG or gmRes.

Definition at line 241 of file belosSolver.hh.

◆ solverParam_

template<class T >
Teuchos::RCP<Teuchos::ParameterList> concepts::BelosSolver< T >::solverParam_
private

Parameter for solver and preconditioner.

Definition at line 237 of file belosSolver.hh.

◆ solverType_

template<class T >
std::string concepts::BelosSolver< T >::solverType_
private

Definition at line 247 of file belosSolver.hh.


The documentation for this class was generated from the following files:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich