PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
petibm::linsolver::LinSolverBase Class Referenceabstract

The abstract (base) class for different iterative solvers. More...

#include <linsolver.h>

Inheritance diagram for petibm::linsolver::LinSolverBase:
[legend]

Public Member Functions

 LinSolverBase ()=default
 Default constructor. More...
 
 LinSolverBase (const std::string &solverName, const std::string &file)
 Constructor. More...
 
virtual ~LinSolverBase ()=default
 Default destructor. More...
 
virtual PetscErrorCode destroy ()
 Manually destroy the data in the current instance. More...
 
PetscErrorCode printInfo () const
 Print information to standard output. More...
 
PetscErrorCode getType (std::string &_type) const
 Get the type of this instance. More...
 
virtual PetscErrorCode setMatrix (const Mat &A)=0
 Set the coefficient matrix of the linear system. More...
 
virtual PetscErrorCode solve (Vec &x, Vec &b)=0
 Solve the linear system. More...
 
virtual PetscErrorCode getIters (PetscInt &iters)=0
 Get the number of iterations of the solver. More...
 
virtual PetscErrorCode getResidual (PetscReal &res)=0
 Get the final residual of the solver. More...
 

Protected Member Functions

virtual PetscErrorCode init ()=0
 Private initialization function. More...
 

Protected Attributes

std::string name
 Name of the linear solver. More...
 
std::string config
 Path of the solver configuration file to read. More...
 
std::string type
 Type of the linear solver. More...
 

Detailed Description

The abstract (base) class for different iterative solvers.

See also
petibm::type::LinSolver, petibm::linsolver::createLinSolver.

Definition at line 59 of file linsolver.h.

Constructor & Destructor Documentation

◆ LinSolverBase() [1/2]

petibm::linsolver::LinSolverBase::LinSolverBase ( )
default

Default constructor.

◆ LinSolverBase() [2/2]

petibm::linsolver::LinSolverBase::LinSolverBase ( const std::string &  solverName,
const std::string &  file 
)
inline

Constructor.

Parameters
solverName[in] Name of the solver.
file[in] Path of the configuration file for the solver.

Definition at line 71 of file linsolver.h.

◆ ~LinSolverBase()

virtual petibm::linsolver::LinSolverBase::~LinSolverBase ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ destroy()

PetscErrorCode petibm::linsolver::LinSolverBase::destroy ( )
virtual

Manually destroy the data in the current instance.

Reimplemented in petibm::linsolver::LinSolverAmgX, and petibm::linsolver::LinSolverKSP.

Definition at line 21 of file linsolver.cpp.

◆ getIters()

virtual PetscErrorCode petibm::linsolver::LinSolverBase::getIters ( PetscInt &  iters)
pure virtual

Get the number of iterations of the solver.

Parameters
iters[out] Number of iterations.

Implemented in petibm::linsolver::LinSolverAmgX, and petibm::linsolver::LinSolverKSP.

◆ getResidual()

virtual PetscErrorCode petibm::linsolver::LinSolverBase::getResidual ( PetscReal &  res)
pure virtual

Get the final residual of the solver.

Parameters
res[out] Residual.

Implemented in petibm::linsolver::LinSolverAmgX, and petibm::linsolver::LinSolverKSP.

◆ getType()

PetscErrorCode petibm::linsolver::LinSolverBase::getType ( std::string &  _type) const

Get the type of this instance.

Parameters
_type[out] String representing the type.

Possible returns for _type are NVIDIA AmgX or PETSc KSP.

Definition at line 49 of file linsolver.cpp.

◆ init()

virtual PetscErrorCode petibm::linsolver::LinSolverBase::init ( )
protectedpure virtual

Private initialization function.

The design of linear solver classes is that only the factory function can initialize the instances, and it doesn't allow user to declare instance first and initialize the instance later. So it seems not necessary to make initialization function public.

Implemented in petibm::linsolver::LinSolverAmgX, and petibm::linsolver::LinSolverKSP.

◆ printInfo()

PetscErrorCode petibm::linsolver::LinSolverBase::printInfo ( ) const

Print information to standard output.

Definition at line 29 of file linsolver.cpp.

◆ setMatrix()

virtual PetscErrorCode petibm::linsolver::LinSolverBase::setMatrix ( const Mat &  A)
pure virtual

Set the coefficient matrix of the linear system.

Parameters
A[in] Coefficient matrix.

Implemented in petibm::linsolver::LinSolverAmgX, and petibm::linsolver::LinSolverKSP.

◆ solve()

virtual PetscErrorCode petibm::linsolver::LinSolverBase::solve ( Vec &  x,
Vec &  b 
)
pure virtual

Solve the linear system.

Parameters
x[in, out] Vector of unknowns.
b[in] Right-hand side of the linear system.

Implemented in petibm::linsolver::LinSolverAmgX, and petibm::linsolver::LinSolverKSP.

Member Data Documentation

◆ config

std::string petibm::linsolver::LinSolverBase::config
protected

Path of the solver configuration file to read.

Definition at line 132 of file linsolver.h.

◆ name

std::string petibm::linsolver::LinSolverBase::name
protected

Name of the linear solver.

The name should match the prefix used for to configure the solver from the command line or from a configuration file. For example, if the name is "velocity", the prefix should be "_velocity".

Definition at line 129 of file linsolver.h.

◆ type

std::string petibm::linsolver::LinSolverBase::type
protected

Type of the linear solver.

Definition at line 135 of file linsolver.h.


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