PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures

Interfaces to different libraries of linear solvers. More...

Collaboration diagram for Linear solvers:

Namespaces

namespace  petibm::linsolver
 Collection of linear solvers from different libraries.
 

Classes

class  petibm::linsolver::LinSolverBase
 The abstract (base) class for different iterative solvers. More...
 
class  petibm::linsolver::LinSolverAmgX
 Iterative solver using wrapper of AmgX. More...
 
class  petibm::linsolver::LinSolverKSP
 Iterative solver using PETSc KSP. More...
 

Typedefs

typedef std::shared_ptr< linsolver::LinSolverBasepetibm::type::LinSolver
 Type definition of LinSolver. More...
 

Functions

PetscErrorCode petibm::linsolver::createLinSolver (const std::string &solverName, const YAML::Node &node, type::LinSolver &solver)
 A factory function for creating a LinSolver. More...
 

Detailed Description

Interfaces to different libraries of linear solvers.

The design of PetIBM is to use shared pointer (std::shared_ptr) to hold instances. The class LinSolverBase is the abstract class for all kinds of linear solver classes. With an abstract class, we can unified the interfaces of different linear solver classes. Users should use the factory function petibm::linsolver::createLinSolver to create an instance, instead of initializing the instance directly.

Currently, there are two different linear solvers: PETSc KSP and NVIDIA AmgX. Please see petibm::linsolver::createLinSolver for how to create different types of linear solver instances.

The shared pointer holding a linear solver instance is defined as petibm::type::LinSolver.

Typedef Documentation

◆ LinSolver

Type definition of LinSolver.

Use petibm::linsolver::createLinSolver to create a LinSolver object.

Example Usage:

PetscErrorCode ierr;
Mat A;
Vec lhs, rhs;
.
// create LinSolver with petibm::linsolver::createLinSolver
// create matrix A, vectors lhs and rhs. See PETSc manual.
ierr = solver->setMatrix(A); CKERRQ(ierr);
ierr = solver->solve(lhs, rhs); CHKERRQ(ierr);
std::shared_ptr< linsolver::LinSolverBase > LinSolver
Type definition of LinSolver.
Definition: linsolver.h:174
See also
petibm::linsolver::createLinSolver, petibm::linsolver::LinSolverBase.

Definition at line 174 of file linsolver.h.

Function Documentation

◆ createLinSolver()

PetscErrorCode petibm::linsolver::createLinSolver ( const std::string &  solverName,
const YAML::Node &  node,
type::LinSolver solver 
)

A factory function for creating a LinSolver.

Parameters
solverName[in] Name of the linear solver.
node[in] YAML configuration node.
solver[out] The linear solver.

This function will look into the parameters and find the child key <solverName>Solver. Under <solverName>Solver, there should at least be two child keys: type and config. type indicate the type of the solver, and config provides the path to the the solver configuration file.

For example, if the name of the target LinSolver is velocity, this factory function will use node[parameters][velocitySolver][type]and node[parameters][velocitySolver][config] to determine the type and the path to the configuration file for the underlying linear solver.

Currently in PetIBM, the key type only accepts CPU and GPU.

An example of creating a LinSolver instance with KSP:

YAML::Node node;
node["parameters"]["velocitySolver"]["type"] = "CPU";
node["parameters"]["velocitySolver"]["config"] = "solversPetscOptions.info";
PetscErrorCode ierr;
"velocity", node, solver); CHKERRQ(ierr);
PetscErrorCode createLinSolver(const std::string &solverName, const YAML::Node &node, type::LinSolver &solver)
A factory function for creating a LinSolver.
Definition: linsolver.cpp:57
Returns
PetscErrorCode.
See also
petibm::type::LinSolver

Definition at line 57 of file linsolver.cpp.