ParGeMSLR
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pargemslr::SolverClass< MatrixType, VectorType, DataType > Class Template Referenceabstract

The base solver class. More...

#include <solver.hpp>

Inheritance diagram for pargemslr::SolverClass< MatrixType, VectorType, DataType >:
pargemslr::FlexGmresClass< MatrixType, VectorType, DataType > pargemslr::GemslrSchurSolveClass< MatrixType, VectorType, DataType > pargemslr::IluClass< MatrixType, VectorType, DataType > pargemslr::ParallelGemslrSchurSolveClass< MatrixType, VectorType, DataType >

Public Member Functions

 SolverClass ()
 The constructor of solver class. More...
 
 SolverClass (const SolverClass< MatrixType, VectorType, DataType > &solver)
 The copy constructor of solver class. More...
 
 SolverClass (SolverClass< MatrixType, VectorType, DataType > &&solver)
 The move constructor of solver class. More...
 
SolverClass< MatrixType, VectorType, DataType > & operator= (const SolverClass< MatrixType, VectorType, DataType > &solver)
 The = operator of solver class. More...
 
SolverClass< MatrixType, VectorType, DataType > & operator= (SolverClass< MatrixType, VectorType, DataType > &&solver)
 The = operator of solver class. More...
 
virtual int Clear ()
 Free the current solver. More...
 
virtual ~SolverClass ()
 The destructor of solver class. More...
 
virtual int Setup (VectorType &x, VectorType &rhs)=0
 Setup the solver phase, include building the preconditioner. Call this function before Solve, after SetPreconditioner. More...
 
virtual int Solve (VectorType &x, VectorType &rhs)=0
 Solve phase. Call this function after Setup. More...
 
virtual int Solve (DenseMatrixClass< DataType > &x, DenseMatrixClass< DataType > &rhs)
 Solve phase with multiple right-hand-sides. Call this function after Setup. More...
 
virtual long int GetNumNonzeros ()
 Get the total number of nonzeros. More...
 
MatrixType * GetMatrix ()
 Get pointer to the matrix. More...
 
SolverClass< MatrixType, VectorType, DataType > * GetPreconditioner ()
 Get pointer to the preconditioner. More...
 
virtual int SetWithParameterArray (double *params)
 Setup with parameter array. More...
 
virtual int SetSolveLocation (const int &location)=0
 Set the data location that the solver apply to. Will also be applied to the preconditioner. More...
 
int SetMatrix (MatrixType &matrix)
 Set the target matrix for the current solver. More...
 
int SetMatrixP (MatrixType *matrix)
 Set the target matrix for the current solver. More...
 
int SetPreconditioner (SolverClass< MatrixType, VectorType, DataType > &precond)
 Set the preconditioner for the current solver. More...
 
int SetPreconditionerP (SolverClass< MatrixType, VectorType, DataType > *precond)
 Set the preconditioner for the current solver. More...
 
bool IsReady () const
 Check if the solver is ready to be used. More...
 
int SetOwnMatrix (bool own_matrix)
 Set if the matrix is owned by this solver, if so, matrix is freed when free the solver. More...
 
int SetOwnPreconditioner (bool own_preconditioner)
 Set if the preconditioner is owned by this solver, if so, preconditioner is freed when free the solver. More...
 
int SetPrintOption (int print_option)
 Set the print option. More...
 
PrecisionEnum GerPrecision () const
 Get the precision. More...
 
SolverTypeEnum GetSolverType () const
 Get the solver type. More...
 

Protected Member Functions

int CheckReadySetups (const char *str) const
 Return error is the preconditioner is ready. More...
 

Protected Attributes

PrecisionEnum _solver_precision
 The precision of the solver. More...
 
SolverTypeEnum _solver_type
 The type of the solver. More...
 
bool _is_mixed
 Is the preconditioner a mixed precision preconditioner? More...
 
MatrixType * _matrix
 The matrix. More...
 
bool _own_matrix
 If the matrix is owned by this solver, default is false. More...
 
SolverClass< MatrixType, VectorType, DataType > * _preconditioner
 The preconditioner. More...
 
bool _own_preconditioner
 If the preconditioner is owned by this solver, default is false. More...
 
VectorType * _solution
 Pointer to the solution, note that this vector is not going to be freed. More...
 
VectorType * _right_hand_side
 Pointer to the right-hand-size, note that this vector is not going to be freed. More...
 
bool _ready
 If the solver is ready. More...
 
int _print_option
 The print option. More...
 

Detailed Description

template<class MatrixType, class VectorType, typename DataType>
class pargemslr::SolverClass< MatrixType, VectorType, DataType >

The base solver class. Matrix type is the type of the matrix, PreconditionerType is the type of the preconditioner, VectorType is the type of the vector, DataType is the data type.
To develope a new solver type, user typically needs to implement the following:
_location, MoveData() or SetSolveLocation() function: to control the solver location (host/device).
Setup() function: setup the solver.
Solve() function: apply the solve.

Constructor & Destructor Documentation

◆ SolverClass() [1/3]

template<class MatrixType , class VectorType , typename DataType >
pargemslr::SolverClass< MatrixType, VectorType, DataType >::SolverClass ( )
inline

The constructor of solver class.

◆ SolverClass() [2/3]

template<class MatrixType , class VectorType , typename DataType >
pargemslr::SolverClass< MatrixType, VectorType, DataType >::SolverClass ( const SolverClass< MatrixType, VectorType, DataType > &  solver)
inline

The copy constructor of solver class.

Parameters
[in]solverThe solver.

◆ SolverClass() [3/3]

template<class MatrixType , class VectorType , typename DataType >
pargemslr::SolverClass< MatrixType, VectorType, DataType >::SolverClass ( SolverClass< MatrixType, VectorType, DataType > &&  solver)
inline

The move constructor of solver class.

Parameters
[in]solverThe solver.

◆ ~SolverClass()

template<class MatrixType , class VectorType , typename DataType >
virtual pargemslr::SolverClass< MatrixType, VectorType, DataType >::~SolverClass ( )
inlinevirtual

The destructor of solver class.

Member Function Documentation

◆ CheckReadySetups()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::CheckReadySetups ( const char *  str) const
inlineprotected

Return error is the preconditioner is ready.

Returns
Return true if the solver is ready.

◆ Clear()

template<class MatrixType , class VectorType , typename DataType >
virtual int pargemslr::SolverClass< MatrixType, VectorType, DataType >::Clear ( )
inlinevirtual

◆ GerPrecision()

template<class MatrixType , class VectorType , typename DataType >
PrecisionEnum pargemslr::SolverClass< MatrixType, VectorType, DataType >::GerPrecision ( ) const
inline

Get the precision.

Returns
Return the precision.

◆ GetMatrix()

template<class MatrixType , class VectorType , typename DataType >
MatrixType* pargemslr::SolverClass< MatrixType, VectorType, DataType >::GetMatrix ( )
inline

Get pointer to the matrix.

Returns
Return pointer to the matrix.

◆ GetNumNonzeros()

template<class MatrixType , class VectorType , typename DataType >
virtual long int pargemslr::SolverClass< MatrixType, VectorType, DataType >::GetNumNonzeros ( )
inlinevirtual

◆ GetPreconditioner()

template<class MatrixType , class VectorType , typename DataType >
SolverClass<MatrixType, VectorType, DataType>* pargemslr::SolverClass< MatrixType, VectorType, DataType >::GetPreconditioner ( )
inline

Get pointer to the preconditioner.

Returns
Return pointer to the preconditioner.

◆ GetSolverType()

template<class MatrixType , class VectorType , typename DataType >
SolverTypeEnum pargemslr::SolverClass< MatrixType, VectorType, DataType >::GetSolverType ( ) const
inline

Get the solver type.

Returns
Return the solver type.

◆ IsReady()

template<class MatrixType , class VectorType , typename DataType >
bool pargemslr::SolverClass< MatrixType, VectorType, DataType >::IsReady ( ) const
inline

Check if the solver is ready to be used.

Returns
Return true if the solver is ready.

◆ operator=() [1/2]

template<class MatrixType , class VectorType , typename DataType >
SolverClass<MatrixType, VectorType, DataType>& pargemslr::SolverClass< MatrixType, VectorType, DataType >::operator= ( const SolverClass< MatrixType, VectorType, DataType > &  solver)
inline

The = operator of solver class.

Parameters
[in]solverThe solver.
Returns
Return the solver

◆ operator=() [2/2]

template<class MatrixType , class VectorType , typename DataType >
SolverClass<MatrixType, VectorType, DataType>& pargemslr::SolverClass< MatrixType, VectorType, DataType >::operator= ( SolverClass< MatrixType, VectorType, DataType > &&  solver)
inline

The = operator of solver class.

Parameters
[in]solverThe solver.
Returns
Return the solver.

◆ SetMatrix()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetMatrix ( MatrixType &  matrix)
inline

Set the target matrix for the current solver.

Parameters
[in]matrixThe target matrix.
Returns
Return error message.

◆ SetMatrixP()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetMatrixP ( MatrixType *  matrix)
inline

Set the target matrix for the current solver.

Parameters
[in]matrixThe pointer to the target matrix.
Returns
Return error message.

◆ SetOwnMatrix()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetOwnMatrix ( bool  own_matrix)
inline

Set if the matrix is owned by this solver, if so, matrix is freed when free the solver.

Parameters
[in]own_matrixThe boolean value.
Returns
Return error message.

◆ SetOwnPreconditioner()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetOwnPreconditioner ( bool  own_preconditioner)
inline

Set if the preconditioner is owned by this solver, if so, preconditioner is freed when free the solver.

Parameters
[in]own_preconditionerThe boolean value.
Returns
Return error message.

◆ SetPreconditioner()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetPreconditioner ( SolverClass< MatrixType, VectorType, DataType > &  precond)
inline

Set the preconditioner for the current solver.

Parameters
[in]precondThe preconditioner.
Returns
Return error message.

◆ SetPreconditionerP()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetPreconditionerP ( SolverClass< MatrixType, VectorType, DataType > *  precond)
inline

Set the preconditioner for the current solver.

Parameters
[in]precondThe pointer to the preconditioner.
Returns
Return error message.

◆ SetPrintOption()

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetPrintOption ( int  print_option)
inline

Set the print option. 0: minimal output. 1: detailed output.

Parameters
[in]print_optionThe print option.
Returns
Return error message.

◆ SetSolveLocation()

template<class MatrixType , class VectorType , typename DataType >
virtual int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetSolveLocation ( const int &  location)
pure virtual

◆ Setup()

template<class MatrixType , class VectorType , typename DataType >
virtual int pargemslr::SolverClass< MatrixType, VectorType, DataType >::Setup ( VectorType &  x,
VectorType &  rhs 
)
pure virtual

◆ SetWithParameterArray()

template<class MatrixType , class VectorType , typename DataType >
virtual int pargemslr::SolverClass< MatrixType, VectorType, DataType >::SetWithParameterArray ( double *  params)
inlinevirtual

◆ Solve() [1/2]

template<class MatrixType , class VectorType , typename DataType >
virtual int pargemslr::SolverClass< MatrixType, VectorType, DataType >::Solve ( DenseMatrixClass< DataType > &  x,
DenseMatrixClass< DataType > &  rhs 
)
inlinevirtual

Solve phase with multiple right-hand-sides. Call this function after Setup.

Parameters
[in,out]xThe initial guess.
[in]rhsThe right-hand-side.
Returns
Return error message.

◆ Solve() [2/2]

template<class MatrixType , class VectorType , typename DataType >
virtual int pargemslr::SolverClass< MatrixType, VectorType, DataType >::Solve ( VectorType &  x,
VectorType &  rhs 
)
pure virtual

Member Data Documentation

◆ _is_mixed

template<class MatrixType , class VectorType , typename DataType >
bool pargemslr::SolverClass< MatrixType, VectorType, DataType >::_is_mixed
protected

Is the preconditioner a mixed precision preconditioner?

◆ _matrix

template<class MatrixType , class VectorType , typename DataType >
MatrixType* pargemslr::SolverClass< MatrixType, VectorType, DataType >::_matrix
protected

The matrix.

◆ _own_matrix

template<class MatrixType , class VectorType , typename DataType >
bool pargemslr::SolverClass< MatrixType, VectorType, DataType >::_own_matrix
protected

If the matrix is owned by this solver, default is false.

◆ _own_preconditioner

template<class MatrixType , class VectorType , typename DataType >
bool pargemslr::SolverClass< MatrixType, VectorType, DataType >::_own_preconditioner
protected

If the preconditioner is owned by this solver, default is false.

◆ _preconditioner

template<class MatrixType , class VectorType , typename DataType >
SolverClass<MatrixType, VectorType, DataType>* pargemslr::SolverClass< MatrixType, VectorType, DataType >::_preconditioner
protected

The preconditioner.

◆ _print_option

template<class MatrixType , class VectorType , typename DataType >
int pargemslr::SolverClass< MatrixType, VectorType, DataType >::_print_option
protected

The print option.

◆ _ready

template<class MatrixType , class VectorType , typename DataType >
bool pargemslr::SolverClass< MatrixType, VectorType, DataType >::_ready
protected

If the solver is ready.

◆ _right_hand_side

template<class MatrixType , class VectorType , typename DataType >
VectorType* pargemslr::SolverClass< MatrixType, VectorType, DataType >::_right_hand_side
protected

Pointer to the right-hand-size, note that this vector is not going to be freed.

◆ _solution

template<class MatrixType , class VectorType , typename DataType >
VectorType* pargemslr::SolverClass< MatrixType, VectorType, DataType >::_solution
protected

Pointer to the solution, note that this vector is not going to be freed.

◆ _solver_precision

template<class MatrixType , class VectorType , typename DataType >
PrecisionEnum pargemslr::SolverClass< MatrixType, VectorType, DataType >::_solver_precision
protected

The precision of the solver.

◆ _solver_type

template<class MatrixType , class VectorType , typename DataType >
SolverTypeEnum pargemslr::SolverClass< MatrixType, VectorType, DataType >::_solver_type
protected

The type of the solver.


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