AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
LinearSolver< Mat, VecX, VecY > Class Template Reference

Implementation of LinearSolverInterface for EIGEN solvers. More...

#include <LinearSolver.hpp>

Inherits LinearSolverInterface< Mat, VecX, VecX >, LinearSolverInterface< Mat, VecX, VecX >, LinearSolverInterface< Mat, VecX, VecX >, and LinearSolverInterface< Matrix, VectorX, VectorY >.

Public Member Functions

 LinearSolver (std::string const &name, std::string const &prefix)
 
void init (Mat const &A) override
 Implements LinearSolverInterface::init() More...
 
void finish () override
 Implements LinearSolverInterface::finish() More...
 
void apply (VecX &x, VecY const &b, Dune::InverseOperatorResult &stat) override
 Implements LinearSolverInterface::apply()
 
 LinearSolver (std::string const &name, std::string const &prefix)
 
void init (Mat const &A) override
 Prepare the solve (and preconditioner), e.g. make a factorization of the matrix, or extract its diagonal in a jacobian precon. More...
 
void finish () override
 Cleanup the solver, e.g. free the previously created factorization. More...
 
void apply (VecX &x, VecY const &b, Dune::InverseOperatorResult &stat) override
 Implements Dune::InverseOperator::apply()
 
 LinearSolver (std::string const &name, std::string const &prefix)
 
void init (Mat const &A) override
 Implements LinearSolverInterface::init() More...
 
void finish () override
 Implements LinearSolverInterface::finish() More...
 
void apply (VecX &x, VecY const &b, Dune::InverseOperatorResult &stat) override
 Implements LinearSolverInterface::apply()
 
 LinearSolver (std::string const &, std::string const &prefix)
 Constructor. More...
 
void init (Matrix const &A) override
 Implements LinearSolverInterface::init() More...
 
void finish () override
 Implements LinearSolverInterface::finish() More...
 
void apply (VectorX &x, VectorY const &b, Dune::InverseOperatorResult &stat) override
 Implements LinearSolverInterface::apply() More...
 
KSP ksp ()
 
- Public Member Functions inherited from LinearSolverInterface< Mat, VecX, VecX >
virtual void init (Mat const &A)=0
 Prepare the solve (and preconditioner), e.g. make a factorization of the matrix, or extract its diagonal in a jacobian precon. More...
 
virtual void finish ()=0
 Cleanup the solver, e.g. free the previously created factorization. More...
 
virtual void apply (VecX &x, VecX const &b, Dune::InverseOperatorResult &res)=0
 Apply the inverse operator to the rhs vector b.
 
virtual void init (Matrix const &A)=0
 Prepare the solve (and preconditioner), e.g. make a factorization of the matrix, or extract its diagonal in a jacobian precon. More...
 
virtual void finish ()=0
 Cleanup the solver, e.g. free the previously created factorization. More...
 
virtual void apply (VectorX &x, VectorY const &b, Dune::InverseOperatorResult &res)=0
 Apply the inverse operator to the rhs vector b. More...
 

Protected Member Functions

virtual void initKSP (KSP ksp, std::string prefix) const
 

Protected Attributes

std::string prefix_
 
int info_ = 0
 
KSP ksp_
 
bool initialized_ = false
 

Detailed Description

template<class Mat, class VecX, class VecY = VecX>
class AMDiS::LinearSolver< Mat, VecX, VecY >

Implementation of LinearSolverInterface for EIGEN solvers.

Wrapper around PETSc KSP and PC objects to solve a linear system.

Implementation of LinearSolverInterface for MTL solvers.

Implementation of RunnerInterface for ISTL solvers.

Configure the KSP and PC types using initfile parameters, based on an initfile prefix [prefix]: All parameters are names as the PETSc command-line parameters with underscore replaced by space and removing the type postfix, e.g. instead of ksp_type write ksp, instead of mat_solver_type write mat solver.

Examples:

[prefix]->max it: 100 % maximum solver iterations
[prefix]->rtol: 1.e-10 % relative residual tolerance
[prefix]->pc: bjacobi % preconditioner type
[prefix]->pc->sub ksp: preonly % sub KSP type used on the blocks
[prefix]->pc->sub ksp->pc: ilu % preconditioner of the sub KSP type

For the configuration of sub PC types and sub KSP types, one can use the current parameter as new prefix, e.g. [sub-prefix] := [prefix]->pc, or [sub-sub-prefix] := [prefix]->pc->sub ksp. Those sub PC and sub KSP types can be configured with all the possible parameters.

For the configuration using command-line arguments possible a ksp-prefix or pc-prefix must be assigned to distinguish different KSP and PC objects. Therefore, for each initfile prefix, a PETSc prefix can be set: [prefix]->prefix: name, where name can be used on the commandline, e.g. -name_ksp_type fgmres.

Constructor & Destructor Documentation

◆ LinearSolver()

LinearSolver ( std::string const &  ,
std::string const &  prefix 
)
inline

Constructor.

Stores the initfile prefix to configure the ksp and pc solver.

Reads an info flag [prefix]->info: 0 ... No solver convergence information 1 ... Minimal output, print residual every 10th iteration 2 ... Full convergence output. Print residual, true residual and rel. residual every iteration.

References Initfile::get().

Member Function Documentation

◆ apply()

void apply ( VectorX &  x,
VectorY const &  b,
Dune::InverseOperatorResult &  stat 
)
inlineoverridevirtual

◆ finish() [1/4]

void finish ( )
inlineoverridevirtual

◆ finish() [2/4]

void finish ( )
inlineoverridevirtual

Cleanup the solver, e.g. free the previously created factorization.

Implements LinearSolverInterface< Mat, VecX, VecX >.

◆ finish() [3/4]

void finish ( )
inlineoverridevirtual

◆ finish() [4/4]

void finish ( )
inlineoverridevirtual

◆ init() [1/4]

void init ( Mat const &  A)
inlineoverridevirtual

◆ init() [2/4]

void init ( Mat const &  A)
inlineoverridevirtual

Prepare the solve (and preconditioner), e.g. make a factorization of the matrix, or extract its diagonal in a jacobian precon.

Implements LinearSolverInterface< Mat, VecX, VecX >.

◆ init() [3/4]

void init ( Mat const &  A)
inlineoverridevirtual

◆ init() [4/4]

void init ( Matrix const &  A)
inlineoverridevirtual

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