11 #ifndef OOPS_ASSIMILATION_DRGMRESRMINIMIZER_H_ 12 #define OOPS_ASSIMILATION_DRGMRESRMINIMIZER_H_ 24 #include "oops/util/dot_product.h" 25 #include "oops/util/formats.h" 26 #include "oops/util/Logger.h" 79 const std::string
classname()
const override {
return "DRGMRESRMinimizer";}
84 const double,
const double,
const int,
const double)
override;
89 template<
typename MODEL>
92 const double costJ0Jb,
const double costJ0JoJc,
93 const int maxiter,
const double tolerance) {
95 std::vector<CtrlInc_>
c;
96 std::vector<CtrlInc_> u;
97 std::vector<CtrlInc_> uh;
102 double dotRr0 = dot_product(rr, rr);
103 double normReduction = 1.0;
106 for (
int jiter = 0; jiter < maxiter; ++jiter) {
107 Log::info() <<
" DRGMRESR Starting Iteration " << jiter+1 << std::endl;
114 for (
int jj = 0; jj < jiter; ++jj) {
115 double alpha = -dot_product(
c[jj],
cc);
121 double ccnorm = sqrt(dot_product(
cc,
cc));
123 c[jiter] *= 1.0/ccnorm;
125 u[jiter] *= 1.0/ccnorm;
127 uh[jiter] *= 1.0/ccnorm;
129 double cdotr = dot_product(
c[jiter], rr);
130 xx.
axpy(cdotr, u[jiter]);
131 xh.
axpy(cdotr, uh[jiter]);
132 rr.
axpy(-cdotr,
c[jiter]);
134 normReduction = sqrt(dot_product(rr, rr)/dotRr0);
135 Log::info() <<
"DRGMRESR end of iteration " << jiter+1 <<
". Norm reduction= " 136 << util::full_precision(normReduction) << std::endl << std::endl;
139 Log::info() <<
"DRGMRESR: Achieved required reduction in residual norm." << std::endl;
143 return normReduction;
150 #endif // OOPS_ASSIMILATION_DRGMRESRMINIMIZER_H_
const std::string classname() const override
real, dimension(:,:,:), allocatable zh
HtRinvHMatrix< MODEL > HtRinvH_
double solve(CtrlInc_ &, CtrlInc_ &, CtrlInc_ &, const Bmat_ &, const HtRinvH_ &, const double, const double, const int, const double) override
The namespace for the main oops code.
void multiply(const CtrlInc_ &dx, CtrlInc_ &dz) const
subroutine, public info(self)
ControlIncrement< MODEL > CtrlInc_
real(fp), parameter, public tolerance
CostFunction< MODEL > CostFct_
void multiply(const VECTOR &a, VECTOR &b) const
Derber-Rosati GMRESR Minimizer.
DRGMRESRMinimizer(const eckit::Configuration &, const CostFct_ &J)
DR (Derber and Rosati) Minimizers.
void axpy(const double, const ControlIncrement &)
void multiply(const CtrlInc_ &x, CtrlInc_ &bx) const