![]() |
OGS
|
|
A class of linear solver based on PETSc routines.
All command-line options that are not recognized by OGS are passed on to PETSc, i.e., they potentially affect the linear solver. The linear solver options in the project file take precedence over the command-line options, because the former are processed at a later stage.
Definition at line 25 of file PETScLinearSolver.h.
#include <PETScLinearSolver.h>
Public Member Functions | |
| PETScLinearSolver (std::string const &prefix, std::string const &petsc_options) | |
| ~PETScLinearSolver () | |
| bool | solve (PETScMatrix &A, PETScVector &b, PETScVector &x) |
| PetscInt | getNumberOfIterations () const |
| Get number of iterations. | |
| double | getElapsedTime () const |
| Get elapsed wall clock time. | |
| bool | canSolveRectangular () const |
| Get, if the solver can handle rectangular equation systems. | |
| bool | willCompute (MathLib::LinearSolverBehaviour const) const |
| Provided for compatibility with Eigen linear solvers. | |
Private Member Functions | |
| bool | canSolverHandleRectangular (std::string_view ksp_type) |
Private Attributes | |
| KSP | solver_ |
| Solver type. | |
| PC | pc_ |
| Preconditioner type. | |
| bool | can_solve_rectangular_ = false |
| double | elapsed_ctime_ = 0.0 |
| Clock time. | |
| MathLib::PETScLinearSolver::PETScLinearSolver | ( | std::string const & | prefix, |
| std::string const & | petsc_options ) |
Constructor
| prefix | Name used to distinguish the options in the command line for this solver. It can be the name of the PDE that owns an instance of this class. |
| petsc_options | PETSc options string which is passed to PETSc lib and inserted in the PETSc option database (see https://petsc.org/release/manualpages/Sys/PetscOptionsInsertString/). |
Definition at line 10 of file PETScLinearSolver.cpp.
References can_solve_rectangular_, canSolverHandleRectangular(), pc_, and solver_.
|
inline |
Definition at line 40 of file PETScLinearSolver.h.
References solver_.
|
inline |
Get, if the solver can handle rectangular equation systems.
Definition at line 59 of file PETScLinearSolver.h.
References can_solve_rectangular_.
|
inlineprivate |
Definition at line 69 of file PETScLinearSolver.h.
Referenced by PETScLinearSolver().
|
inline |
Get elapsed wall clock time.
Definition at line 56 of file PETScLinearSolver.h.
References elapsed_ctime_.
|
inline |
Get number of iterations.
Definition at line 48 of file PETScLinearSolver.h.
References solver_.
| bool MathLib::PETScLinearSolver::solve | ( | PETScMatrix & | A, |
| PETScVector & | b, | ||
| PETScVector & | x ) |
Definition at line 39 of file PETScLinearSolver.cpp.
References BaseLib::RunTime::elapsed(), elapsed_ctime_, MathLib::PETScMatrix::getRawMatrix(), MathLib::PETScVector::getRawVector(), pc_, solver_, and BaseLib::RunTime::start().
|
inline |
Provided for compatibility with Eigen linear solvers.
Definition at line 62 of file PETScLinearSolver.h.
|
private |
Definition at line 83 of file PETScLinearSolver.h.
Referenced by PETScLinearSolver(), and canSolveRectangular().
|
private |
Clock time.
Definition at line 85 of file PETScLinearSolver.h.
Referenced by getElapsedTime(), and solve().
|
private |
Preconditioner type.
Definition at line 81 of file PETScLinearSolver.h.
Referenced by PETScLinearSolver(), and solve().
|
private |
Solver type.
Definition at line 80 of file PETScLinearSolver.h.
Referenced by PETScLinearSolver(), ~PETScLinearSolver(), getNumberOfIterations(), and solve().