FV3 Bundle
|
Preconditioned Conjugate Gradients solver. More...
#include <cmath>
#include <vector>
#include "oops/util/dot_product.h"
#include "oops/util/formats.h"
#include "oops/util/Logger.h"
Go to the source code of this file.
Namespaces | |
oops | |
The namespace for the main oops code. | |
Functions | |
template<typename VECTOR , typename AMATRIX , typename PMATRIX > | |
double | oops::PCG (VECTOR &x, const VECTOR &b, const AMATRIX &A, const PMATRIX &precond, const int maxiter, const double tolerance) |
Preconditioned Conjugate Gradients solver.
This solver is based on the standard Preconditioned Conjugate Gradients solver for Ax=b
A must be square, symmetric, positive definite. A preconditioner must be supplied that, given a vector q, returns an approximate solution of Ap=q.
On entry:
On exit, x will contain the solution \( x \)
The return value is the achieved reduction in preconditioned residual norm.
Iteration will stop if the maximum iteration limit "maxiter" is reached or if the preconditioned residual norm reduces by a factor of "tolerance".
VECTOR must implement:
Each of AMATRIX and PMATRIX must implement a method:
which applies the matrix to the first argument, and returns the matrix-vector product in the second. (Note: the const is optional, but recommended.)
Definition in file PCG.h.