FV3 Bundle
LBGMRESRMinimizer.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_ASSIMILATION_LBGMRESRMINIMIZER_H_
12 #define OOPS_ASSIMILATION_LBGMRESRMINIMIZER_H_
13 
14 #include <cmath>
15 #include <string>
16 #include <vector>
17 
18 #include "eckit/config/Configuration.h"
26 #include "oops/util/dot_product.h"
27 #include "oops/util/formats.h"
28 #include "oops/util/Logger.h"
29 
30 namespace oops {
31 
32 /// LBGMRESR Minimizer
33 /*!
34  * \brief Left B Preconditioned GMRESR solver.
35  *
36  * On entry:
37  * - dx = starting point, \f$ dx_{0} \f$.
38  * - rr = \f$ (sum dx^{b}_{i} + ) B H^T R^{-1} d \f$
39  *
40  * Iteration will stop if the maximum iteration limit "maxiter" is reached
41  * or if the residual norm reduces by a factor of "tolerance".
42  *
43  * Each matrix must implement a method:
44  * - void multiply(const VECTOR&, VECTOR&) const
45  *
46  * which applies the matrix to the first argument, and returns the
47  * matrix-vector product in the second. (Note: the const is optional, but
48  * recommended.)
49  */
50 
51 // -----------------------------------------------------------------------------
52 
53 template<typename MODEL> class LBGMRESRMinimizer : public LBMinimizer<MODEL> {
57 
58  public:
59  const std::string classname() const override {return "LBGMRESRMinimizer";}
60  LBGMRESRMinimizer(const eckit::Configuration &, const CostFct_ &);
62 
63  private:
64  void solve(CtrlInc_ &, CtrlInc_ &, const LBHessianMatrix_ &,
65  const int, const double) override;
66 };
67 
68 // =============================================================================
69 
70 template<typename MODEL>
72  const CostFct_ & J)
73  : LBMinimizer<MODEL>(J)
74 {}
75 
76 // -----------------------------------------------------------------------------
77 
78 template<typename MODEL>
80  const LBHessianMatrix_ & LBHessian,
81  const int maxiter, const double tolerance) {
83  dx.zero();
84  GMRESR(dx, rr, LBHessian, Id, maxiter, tolerance);
85 }
86 
87 // -----------------------------------------------------------------------------
88 
89 } // namespace oops
90 
91 #endif // OOPS_ASSIMILATION_LBGMRESRMINIMIZER_H_
double GMRESR(VECTOR &xx, const VECTOR &bb, const AMATRIX &A, const PMATRIX &precond, const int maxiter, const double tolerance)
Definition: GMRESR.h:63
LB (Left B-preconditioned) Minimizers.
Definition: LBMinimizer.h:38
LBGMRESRMinimizer(const eckit::Configuration &, const CostFct_ &)
CostFunction< MODEL > CostFct_
Definition: conf.py:1
The Hessian matrix: .
Cost Function.
Definition: CostFunction.h:56
void solve(CtrlInc_ &, CtrlInc_ &, const LBHessianMatrix_ &, const int, const double) override
The namespace for the main oops code.
const std::string classname() const override
LBGMRESR Minimizer.
real(fp), parameter, public tolerance
ControlIncrement< MODEL > CtrlInc_
GMRESR solver for Ax=b.
Identity matrix.
LBHessianMatrix< MODEL > LBHessianMatrix_
void zero()
Linear algebra operators.