Abstract interface to sparse linear solvers. More...
#include <solver.h>
Inherited by PardisoSolver, and UmfpackSolver.
Protected Member Functions | |
| virtual bool | is_row_oriented ()=0 |
| Must return true if the solvers expects compressed row (CSR) format. Otherwise LinSystem assumes the compressed column (CSC) format. | |
| virtual bool | handles_symmetry ()=0 |
| Must return true if the solver is capable of solving structurally symmetric matrices, ie., when only the upper half of the matrix is stored in the CSR or CSC arrays. | |
| virtual void * | new_context (bool sym) |
| Creates a new data block containing (optional) factorization data. This method is called by LinSystem on its creation. | |
| virtual void | free_context (void *ctx) |
| Frees the data block created by new_context(). Called by LinSystem on destruction. | |
| virtual bool | analyze (void *ctx, int n, int *Ap, int *Ai, scalar *Ax, bool sym) |
| After the sparse structure of the matrix is calculated, LinSystem calls this function to give the solver a chance to analyze the matrix and store the results for reuse in the execution context. If the solver does not support the reuse of structural analysis, this method does not have to be implemented. | |
| virtual bool | factorize (void *ctx, int n, int *Ap, int *Ai, scalar *Ax, bool sym) |
| Called by LinSystem after the stiffness matrix has been assembled. Direct solvers should implement this function and store the result of the factorization in the execution context, so that it can be used many times by solve() for different right hand sides. | |
| virtual bool | solve (void *ctx, int n, int *Ap, int *Ai, scalar *Ax, bool sym, scalar *RHS, scalar *vec)=0 |
| Called by LinSystem when the user requests the solution of the linear system. Direct solvers will want to use the matrix factorization stored in "ctx". Iterative solvers will probably solve the system from scratch in this call, but can expect "vec" to contain the initial guess for the solution vector. | |
| virtual void | free_data (void *ctx) |
| Must free all auxiliary data created in the calls to analyze() and/or factorize(). | |
Friends | |
| class | LinSystem |
| class | NonlinSystem |
Abstract interface to sparse linear solvers.
Solver is an abstract class defining the interface to all linear solvers used by Hermes2D. A concrete derived class (UmfpackSolver, PardisoSolver...) is instantiated by the user and passed to the LinSystem class to solve the discrete problem. The user never directly calls any of the methods of this class.
The linear solver can be direct or iterative, although the analyze() and factorize() methods are clearly designed for direct solvers. These methods are optional and do not have to be implemented by iterative solvers.
Another feature geared towards direct solvers is the possibility to store auxiliary data (usually factorization data) between the calls to analyze(), factorize() and solve() in an arbitrary data structure called "context". This way the factorization can be reused to solve for different right hand sides and/or different, but structurally identical matrices.
| virtual bool Solver::analyze | ( | void * | ctx, | |
| int | n, | |||
| int * | Ap, | |||
| int * | Ai, | |||
| scalar * | Ax, | |||
| bool | sym | |||
| ) | [inline, protected, virtual] |
After the sparse structure of the matrix is calculated, LinSystem calls this function to give the solver a chance to analyze the matrix and store the results for reuse in the execution context. If the solver does not support the reuse of structural analysis, this method does not have to be implemented.
Reimplemented in PardisoSolver.
| virtual bool Solver::factorize | ( | void * | ctx, | |
| int | n, | |||
| int * | Ap, | |||
| int * | Ai, | |||
| scalar * | Ax, | |||
| bool | sym | |||
| ) | [inline, protected, virtual] |
Called by LinSystem after the stiffness matrix has been assembled. Direct solvers should implement this function and store the result of the factorization in the execution context, so that it can be used many times by solve() for different right hand sides.
Reimplemented in PardisoSolver.
| virtual void Solver::free_context | ( | void * | ctx | ) | [inline, protected, virtual] |
Frees the data block created by new_context(). Called by LinSystem on destruction.
Reimplemented in PardisoSolver.
| virtual void Solver::free_data | ( | void * | ctx | ) | [inline, protected, virtual] |
Must free all auxiliary data created in the calls to analyze() and/or factorize().
Reimplemented in PardisoSolver.
| virtual bool Solver::handles_symmetry | ( | ) | [protected, pure virtual] |
Must return true if the solver is capable of solving structurally symmetric matrices, ie., when only the upper half of the matrix is stored in the CSR or CSC arrays.
Implemented in PardisoSolver, and UmfpackSolver.
| virtual bool Solver::is_row_oriented | ( | ) | [protected, pure virtual] |
Must return true if the solvers expects compressed row (CSR) format. Otherwise LinSystem assumes the compressed column (CSC) format.
Implemented in PardisoSolver, and UmfpackSolver.
| virtual void* Solver::new_context | ( | bool | sym | ) | [inline, protected, virtual] |
Creates a new data block containing (optional) factorization data. This method is called by LinSystem on its creation.
Reimplemented in PardisoSolver.
| virtual bool Solver::solve | ( | void * | ctx, | |
| int | n, | |||
| int * | Ap, | |||
| int * | Ai, | |||
| scalar * | Ax, | |||
| bool | sym, | |||
| scalar * | RHS, | |||
| scalar * | vec | |||
| ) | [protected, pure virtual] |
Called by LinSystem when the user requests the solution of the linear system. Direct solvers will want to use the matrix factorization stored in "ctx". Iterative solvers will probably solve the system from scratch in this call, but can expect "vec" to contain the initial guess for the solution vector.
| ctx | execution context | |
| n | [in] number of rows and columns of the matrix | |
| Ap,Ai,Ax | [in] the matrix in CSR or CSC format | |
| sym | [in] true if the matrix is symmetric and only the upper half is stored. | |
| RHS | [in] right hand side vector | |
| vec | [in/out] solution vector |
Implemented in PardisoSolver, and UmfpackSolver.
friend class LinSystem [friend] |
friend class NonlinSystem [friend] |
1.6.3