11 #ifndef OOPS_ASSIMILATION_IPCG_H_ 12 #define OOPS_ASSIMILATION_IPCG_H_ 17 #include "oops/util/dot_product.h" 18 #include "oops/util/formats.h" 19 #include "oops/util/Logger.h" 61 template <
typename VECTOR,
typename AMATRIX,
typename PMATRIX>
62 double IPCG(VECTOR & x,
const VECTOR &
b,
63 const AMATRIX & A,
const PMATRIX & precond,
64 const int maxiter,
const double tolerance ) {
74 std::vector<VECTOR> vVEC;
75 std::vector<VECTOR> zVEC;
79 double xnrm2 = dot_product(x, x);
86 precond.multiply(r, s);
88 double dotRr0 = dot_product(r, r);
89 double dotSr0 = dot_product(r, s);
90 double normReduction = 1.0;
91 double rdots_old = dotSr0;
92 double rdots = dotSr0;
103 for (
int jiter = 0; jiter < maxiter; ++jiter) {
104 Log::info() <<
" IPCG Starting Iteration " << jiter+1 << std::endl;
111 double beta = dot_product(s, w)/rdots_old;
120 double alpha = rdots/dot_product(
p, ap);
126 for (
int iiter = 0; iiter < jiter; ++iiter) {
127 double proj = dot_product(r, zVEC[iiter]);
128 r.axpy(-proj, vVEC[iiter]);
131 precond.multiply(r, s);
134 rdots = dot_product(r, s);
143 normReduction = sqrt(dot_product(r, r)/dotRr0);
144 Log::info() <<
"IPCG end of iteration " << jiter+1 <<
". Norm reduction= " 145 << util::full_precision(normReduction) << std::endl << std::endl;
148 Log::info() <<
"IPCG: Achieved required reduction in residual norm." << std::endl;
155 return normReduction;
160 #endif // OOPS_ASSIMILATION_IPCG_H_ double IPCG(VECTOR &x, const VECTOR &b, const AMATRIX &A, const PMATRIX &precond, const int maxiter, const double tolerance)
real(r8), dimension(cast_m, cast_n) p
The namespace for the main oops code.
subroutine, public info(self)
real(fp), parameter, public tolerance