![]() |
Block-Structured AMR Software Framework
|
Preconditioned conjugate gradient solver. More...
#include <AMReX_PCG.H>
Public Types | |
| using | RT = typename M::RT |
Public Member Functions | |
| PCG ()=default | |
| void | define (M &linop) |
| void | solve (V &a_sol, V const &a_rhs, RT a_tol_rel, RT a_tol_abs, int a_its=-1) |
| Solve the linear system. | |
| void | setInitialGuessNonzero (bool flag) |
| void | setVerbose (int v) |
| Sets verbosity. | |
| void | setMaxIters (int niters) |
| Sets the max number of iterations. | |
| int | getNumIters () const |
| Gets the number of iterations. | |
| int | getStatus () const |
| Gets the solver status. | |
| RT | getResidualNorm () const |
| Gets the 2-norm of the residual. | |
Preconditioned conjugate gradient solver.
Requires a symmetric positive definite operator and preconditioner. The operator type M must provide the same interface as for amrex::GMRES: makeVecRHS, makeVecLHS, norm2, dotProduct, assign, increment, linComb, scale, setToZero, apply and precond.
| using amrex::PCG< V, M >::RT = typename M::RT |
|
default |
|
inline |
|
inline |
Gets the number of iterations.
|
inline |
Gets the 2-norm of the residual.
|
inline |
Gets the solver status.
0 converged, 1 max iterations reached, 2 p.Ap is zero or has changed sign (A not definite), 3 r.z is zero or has changed sign (preconditioner not definite). The sign is taken from the first r.z, so negative definite systems are solved as well. A NaN or infinity counts as the matching breakdown.
|
inline |
Use a_sol passed to solve() as the initial guess (default: false, i.e., start from zero).
|
inline |
Sets the max number of iterations.
|
inline |
Sets verbosity.
| void amrex::PCG< V, M >::solve | ( | V & | a_sol, |
| V const & | a_rhs, | ||
| RT | a_tol_rel, | ||
| RT | a_tol_abs, | ||
| int | a_its = -1 |
||
| ) |
Solve the linear system.
The initial guess is zero unless setInitialGuessNonzero(true) was called, in which case it is the value of a_sol on entry.
| a_sol | unknowns, i.e., x in A x = b. |
| a_rhs | RHS, i.e., b in A x = b. |
| a_tol_rel | relative tolerance, relative to the initial residual norm, which is ||b|| for a zero initial guess. |
| a_tol_abs | absolute tolerance. |
| a_its | optional argument specifying the maximum number of iterations. |