AMDiS  0.1
The Adaptive Multi-Dimensional Simulation Toolbox
PetscRunner< Matrix, Vector > Class Template Reference

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

#include <PetscRunner.hpp>

Inherits RunnerInterface< Matrix, Vector >.

Public Member Functions

 PetscRunner (std::string const &prefix)
 Constructor. More...
 
void init (M const &A) override
 Implements RunnerInterface::init()
 
void exit () override
 Implements RunnerInterface::exit()
 
int solve ([[maybe_unused]] M const &A, X &x, Y const &b, SolverInfo &solverInfo) override
 Implements RunnerInterface::solve()
 
KSP ksp ()
 
- Public Member Functions inherited from RunnerInterface< Matrix, Vector >
virtual ~RunnerInterface ()=default
 virtual destructor
 
virtual void init (M const &A)=0
 Is called at the beginning of a solution procedure.
 
virtual int solve (M const &A, X &x, Y const &b, SolverInfo &solverInfo)=0
 Solve the system A*x = b.
 
virtual int adjointSolve (M const &A, X &x, Y const &b, SolverInfo &solverInfo)
 Solve the system A*x = b.
 

Protected Member Functions

virtual void initKSP (KSP ksp, std::string prefix) const
 
virtual void initDirectSolver (KSP ksp, std::string prefix) const
 
virtual void initPC (PC pc, std::string prefix) const
 
virtual void initKSPParameters (KSP ksp, char const *ksptype, std::string prefix) const
 

Protected Attributes

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

Detailed Description

template<class Matrix, class Vector>
class AMDiS::PetscRunner< Matrix, Vector >

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

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

◆ PetscRunner()

PetscRunner ( std::string const &  prefix)
inlineexplicit

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 PetscRunner< Matrix, Vector >::exit(), and Initfile::get().


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