|
Fluid Dynamics Library
|
Conjugate gradient solver for MAC grid linear algebra. More...
#include <macpcgsolver.hpp>
Public Member Functions | |
| MACPCGSolver (int nx, int ny, int nz) | |
| Allocate scratch space for linear system with given MAC dimensions. | |
| MACPCGSolver (const MACPCGSolver< scalar_t > &S) | |
| Copy constructor. | |
| virtual void | resize (int nx, int ny, int nz) |
| Reallocate solver space for given MAC dimensions. | |
| int | xdim () const |
| int | ydim () const |
| int | zdim () const |
| void | setTolerance (scalar_t tol) |
| void | setMaxIter (unsigned max) |
| scalar_t | getTolerance () const |
| unsigned | getMaxIter () const |
| unsigned | LastIter () const |
| Number of iterations that cgsolve() has performed. | |
| scalar_t | ResNorm () const |
-norm of | |
| void | pcgsolve (MACPrecond< scalar_t > &A, const MACVector< scalar_t > &b, MACVector< scalar_t > &x) |
Conjugate gradient for . | |
Protected Member Functions | |
| scalar_t | macheps () |
| Estimate "machine epsilon.". | |
Protected Attributes | |
| int | nx_ |
| int | ny_ |
| int | nz_ |
| MACVector< scalar_t > | res |
| Residue vector in iterative linear solver. | |
| MACVector< scalar_t > | p0 |
| MACVector< scalar_t > | p1 |
| MACVector< scalar_t > | q |
| MACVector< scalar_t > | z |
| scalar_t | tol_ |
| Stopping tolerance. | |
| unsigned | maxiter_ |
| Iteration bound. | |
| scalar_t | rnorm_ |
| Current residue norm. | |
| unsigned | iter_ |
| Iteration counter. | |
Conjugate gradient solver for MAC grid linear algebra.
The main utility of the class is to encapsulate (and manage) the scratch vectors used in the iterative algorithm. Hence the salient constructor parameters are the MAC grid dimensions. However dimension checking for all terms is performed at the outset of each call to of cgsolve(). Dimension mismatch will throw a standar error.
Convergence is measured by the usual criterion
where
denotes the residue vector of the n-th iteration, and
is set by setTolerance. Failure to converge is handled in one of two ways:
-DABORT_ON_DIVERGENCE when compiling the solver.The tolerance
is initialized in dependence on "machine epsilon," specifically
for the template paramter.
Definition at line 58 of file macpcgsolver.hpp.
| void fdl::MACPCGSolver< scalar_t >::pcgsolve | ( | MACPrecond< scalar_t > & | A, |
| const MACVector< scalar_t > & | rhs, | ||
| MACVector< scalar_t > & | soln | ||
| ) |
Conjugate gradient for
.
Follows structure of Algorithm 10.2.1 from Matrix Computations.
Definition at line 159 of file macpcgsolver.hpp.
1.7.4