![]() |
KASKADE 7 development version
|
(regularized) preconditioned conjugate gradient method More...
#include <cgImplementation.hh>
Public Types | |
| typedef X | domain_type |
| The domain type of the operator to be inverted. | |
| typedef Xstar | range_type |
| The range type of the operator to be inverted. | |
| typedef X::field_type | field_type |
| The field type of the operator to be inverted. | |
| typedef ScalarTraits< field_type >::Real | Real |
| the real field type corresponding to field_type | |
Public Member Functions | |
| CGBase (SymmetricLinearOperator< X, Xstar > &op_, SymmetricPreconditioner< X, Xstar > &prec_, PCGTerminationCriterion< Real > &terminate_, int verbose_=0, double eps_=1e-15, Timings &timer_=Timings::instance()) | |
| Set up conjugate gradient solver. | |
| CGBase (Dune::LinearOperator< X, Xstar > &op_, Dune::Preconditioner< X, Xstar > &prec_, DualPairing< X, Xstar > const &dp_, PCGTerminationCriterion< Real > &terminate_, int verbose_=0, double eps_=1e-15, Timings &timer_=Timings::instance()) | |
| Set up conjugate gradient solver. | |
| CGBase (Dune::LinearOperator< X, Xstar > &op_, Dune::Preconditioner< X, Xstar > &prec_, DualPairing< X, Xstar > const &dp_, PCGTerminationCriterion< Real > &terminate_, Functor f_, int verbose_=0, double eps_=1e-15, Timings &timer_=Timings::instance()) | |
| Set up conjugate gradient solver with a functor for an initial regularization guess. | |
| void | apply (X &u, Xstar &b) |
| virtual void | apply (X &u, Xstar &b, Real tolerance, Dune::InverseOperatorResult &res) |
| virtual void | apply (X &u, Xstar &b, Dune::InverseOperatorResult &res) |
| int | cgLoop (X &u, Xstar &b, Dune::InverseOperatorResult &res) |
| bool | encounteredNonConvexity () const |
| double | getSolutionEnergyNormEstimate () |
| virtual Dune::SolverCategory::Category | category () const override |
| returns the category of the operator | |
| Real | cond (Real *kappaUpper=nullptr) const |
| Condition number estimate \( \kappa(B^{-1} A) \) of the preconditioned system. | |
| void | resumeCGTimer () |
| void | resumeMVTimer () |
| void | resumeDPTimer () |
| void | resumeAPTimer () |
| void | resumePRTimer () |
| void | stopCGTimer () |
| void | stopMVTimer () |
| void | stopDPTimer () |
| void | stopAPTimer () |
| void | stopPRTimer () |
| void | printTimers () |
(regularized) preconditioned conjugate gradient method
This implements a preconditioned IterateType::CG iteration for an operator \( A: X\to x^* \), preconditioned by a preconditioner \( B^{-1}: X^* \to X \). The termination is based on a policy (see PCGTerminationCriterion), allowing both simple residual-based and sophisticated error-estimation based criteria (e.g. Strakos-Tichy).
The implementation follows Deuflhard/Weiser, Section 5.3.3.
The class offers two operator/preconditioner interfaces: a SymmetricLinearOperator / SymmetricPreconditioner pair (with a zero dual pairing, yielding the efficient simultaneous evaluation of matrix-vector products and dual pairings), and a generic Dune::LinearOperator / Dune::Preconditioner pair with an explicit dual pairing. The termination is policy-based (PCGTerminationCriterion), the TimerPolicy template parameter switches the (optional) timing of the sub-operations, and the regularized variants detect nonconvexity of the underlying quadratic form.
| X | the type of vectors from the primal space |
| Xstar | the type of vectors from the dual space |
| impl | the CG variant to be used (STANDARD, TRUNCATED, REGULARIZED or HYBRID) |
| TimerPolicy | enable timers for dual pairings, axpy-operations, matrix-vector products and preconditioners with struct MeasureTime (recording into Kaskade's Timings facility); the default DoNotMeasureTime measures nothing. |
| Functor | a functor used for a heuristic initial guess of the regularization parameter (advanced use) |
Definition at line 280 of file cgImplementation.hh.
| typedef X Kaskade::CGBase< X, Xstar, impl, TimerPolicy, Functor >::domain_type |
The domain type of the operator to be inverted.
Definition at line 289 of file cgImplementation.hh.
| typedef X::field_type Kaskade::CGBase< X, Xstar, impl, TimerPolicy, Functor >::field_type |
The field type of the operator to be inverted.
Definition at line 293 of file cgImplementation.hh.
| typedef Xstar Kaskade::CGBase< X, Xstar, impl, TimerPolicy, Functor >::range_type |
The range type of the operator to be inverted.
Definition at line 291 of file cgImplementation.hh.
| typedef ScalarTraits<field_type>::Real Kaskade::CGBase< X, Xstar, impl, TimerPolicy, Functor >::Real |
the real field type corresponding to field_type
Definition at line 298 of file cgImplementation.hh.
|
inline |
Set up conjugate gradient solver.
| op | the symmetric positive definite linear operator. In case a matrix is to be used, wrap the matrix into the SymmetricMatrixOperator interface. |
| prec | the preconditioner |
| terminate | the termination criterion. The object has to exist during the lifetime of the cg object as it is referenced. |
| verbose | controls the verbosity of logging to std::cout. 0 means no output at all (default). Values in 0,1,2 are valid. |
| timer_ | the Timings instance to record timing sections into, if the TimerPolicy collects timings (defaults to the global one). |
Definition at line 313 of file cgImplementation.hh.
|
inline |
Set up conjugate gradient solver.
| op | the (in fact symmetric positive definite) operator |
| prec | the preconditioner |
| dp | the dual pairing with respect to which the operator is symmetric |
| terminate | the termination criterion. The object has to exist during the lifetime of the cg object as it is referenced. |
| verbose | controls the verbosity of logging to std::cout. 0 means no output at all (default). Values in 0,1,2 are valid. |
| timer_ | the Timings instance to record timing sections into, if the TimerPolicy collects timings (defaults to the global one). |
Definition at line 340 of file cgImplementation.hh.
|
inline |
Set up conjugate gradient solver with a functor for an initial regularization guess.
| op | the (in fact symmetric positive definite) operator |
| prec | the preconditioner |
| dp | the dual pairing with respect to which the operator is symmetric |
| terminate | the termination criterion. The object has to exist during the lifetime of the cg object as it is referenced. |
| f | functor used for a heuristic initial guess of the regularization parameter |
| verbose | controls the verbosity of logging to std::cout. 0 means no output at all (default). Values in 0,1,2 are valid. |
| timer_ | the Timings instance to record timing sections into, if the TimerPolicy collects timings (defaults to the global one). |
Definition at line 369 of file cgImplementation.hh.
|
inline |
Definition at line 385 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::apply(), and Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::apply().
|
inlinevirtual |
Definition at line 403 of file cgImplementation.hh.
|
inlinevirtual |
| u | initial guess |
| b | right hand side |
| tolerance | tolerance of the termination criterion |
| res | contains, number of iterations, residual reduction, ... |
Definition at line 397 of file cgImplementation.hh.
|
inlineoverridevirtual |
returns the category of the operator
From the Dune doxygen documentation it is unclear what this is supposed to mean. We return a dummy here.
Definition at line 638 of file cgImplementation.hh.
|
inline |
Definition at line 432 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::apply().
|
inline |
Condition number estimate \( \kappa(B^{-1} A) \) of the preconditioned system.
After a call to apply(), this returns a lower bound on the condition number \( \kappa(B^{-1} A) \) of the preconditioned operator, computed from the Lanczos (Ritz) values of the Krylov space built during the CG iteration.
The CG coefficients \( \alpha_i = \sigma_i / \langle q_i, A q_i\rangle \) and \( \beta_{i+1} = \sigma_{i+1}/\sigma_i \) with \( \sigma_i = \langle r_i, B^{-1} r_i\rangle \) collected during the iteration define the symmetric tridiagonal Lanczos matrix \( T_k \) of the preconditioned operator \( B^{-1} A \) restricted to the Krylov space, with
\[ d_i = \frac{1}{\alpha_i} + \frac{\beta_i}{\alpha_{i-1}},\quad e_i = \frac{\sqrt{\beta_{i+1}}}{\alpha_i}. \]
Its eigenvalues (computed via LAPACK stev) are the Ritz values of \( B^{-1}A \) in that Krylov space. Since the Ritz values converge monotonically towards the extremal eigenvalues of \( B^{-1}A \) from the inside, \( \lambda_{\min}(T_k) \) is an upper bound on \( \lambda_{\min}(B^{-1}A) \) and \( \lambda_{\max}(T_k) \) a lower bound on \( \lambda_{\max}(B^{-1}A) \), hence the returned quotient is a lower bound on \( \kappa \) that becomes sharper with every iteration.
| kappaUpper | if non-null, an upper bound on the true condition number is stored there, obtained from the residual-based error bound on the extremal Ritz values (Saad). Thus the caller obtains the interval \( [\mathrm{cond}(), \kappa_{\mathrm{upper}}] \) containing the true \( \kappa \). |
| DetailedException | if the condition estimate is not well-defined, i.e. if the solver is not a STANDARD CG implementation (for TRUNCATED, REGULARIZED and HYBRID variants the coefficients do not describe \( B^{-1}A \) on an unmodified Krylov space), or if the iteration did not produce usable coefficients (no or a single step, or premature termination). |
Definition at line 676 of file cgImplementation.hh.
|
inline |
Definition at line 625 of file cgImplementation.hh.
|
inline |
Definition at line 630 of file cgImplementation.hh.
|
inlineinherited |
Definition at line 173 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::apply().
|
inlineinherited |
Definition at line 164 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 161 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 163 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 162 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 165 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 170 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 167 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 169 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 168 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().
|
inlineinherited |
Definition at line 171 of file cgImplementation.hh.
Referenced by Kaskade::CGBase< X, Xstar, CGImplementationType::STANDARD, TimerPolicy >::cgLoop().