PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
|
Interfaces to different libraries of linear solvers. More...
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::LinSolverBase > | petibm::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... | |
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 std::shared_ptr<linsolver::LinSolverBase> petibm::type::LinSolver |
Type definition of LinSolver.
Use petibm::linsolver::createLinSolver to create a LinSolver object.
Example Usage:
Definition at line 174 of file linsolver.h.
PetscErrorCode petibm::linsolver::createLinSolver | ( | const std::string & | solverName, |
const YAML::Node & | node, | ||
type::LinSolver & | solver | ||
) |
A factory function for creating a LinSolver.
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:
Definition at line 57 of file linsolver.cpp.