16#include "dune/istl/istlexception.hh" 
   17#include "dune/istl/operators.hh" 
   18#include "dune/istl/preconditioners.hh" 
   19#include "dune/istl/scalarproducts.hh" 
   39    template<
class L, 
class P>
 
   40    NMIIICGSolver (L& op, P& prec, 
double reduction, 
int maxit, 
int verbose) : 
 
   41      ssp(), _op(op), _sp(ssp), _reduction(reduction), _maxit(maxit), _verbose(verbose)
 
   43        dune_static_assert( 
static_cast<int>(L::category) == 
static_cast<int>(P::category),
 
   44                            "L and P must have the same category!");
 
   45        dune_static_assert( 
static_cast<int>(L::category) == 
static_cast<int>(SolverCategory::sequential),
 
   46                            "L must be sequential!");
 
   54    virtual void apply (
X& u, 
X& b, InverseOperatorResult& res)
 
   64      _op.applyscaleadd(-1,u,r);  
 
   67      double def0 = _sp.norm(r);
 
   76                        std::cout << 
"=== rate=" << res.conv_rate
 
   77                                  << 
", T=" << res.elapsed << 
", TIT=" << res.elapsed
 
   78                                  << 
", IT=0" << std::endl;
 
   84        std::cout << 
"=== NMIIICGSolver" << std::endl;
 
   86          this->printHeader(std::cout);
 
   87          this->printOutput(std::cout,0,def0);
 
   92      double def=def0, defnew=def0;   
 
   97      for ( ; i<=_maxit; i++ )
 
  101        alpha = def/_sp.dot(p,q);       
 
  107          this->printOutput(std::cout,i,defnew,def);
 
  109        if (defnew<def0*_reduction || def<1E-30)    
 
  111          res.converged  = 
true;
 
  126        this->printOutput(std::cout,i,def);
 
  129      res.reduction = def/def0;
 
  130      res.conv_rate  = pow(res.reduction,1.0/i);
 
  131      res.elapsed = watch.elapsed();
 
  135        std::cout << 
"=== rate=" << res.conv_rate
 
  136                  << 
", T=" << res.elapsed
 
  137                  << 
", TIT=" << res.elapsed/i
 
  138                  << 
", IT=" << i << std::endl;
 
  147  virtual void apply (
X& x, 
X& b, 
double reduction, InverseOperatorResult& res)
 
  149    _reduction = reduction;
 
  150    (*this).apply(x,b,res);
 
  154  SeqScalarProduct<X> ssp;
 
  155  LinearOperator<X,X>& _op;
 
  156  ScalarProduct<X>& _sp;
 
conjugate gradient method
X range_type
The range type of the operator to be inverted.
X::field_type field_type
The field type of the operator to be inverted.
X domain_type
The domain type of the operator to be inverted.
virtual void apply(X &x, X &b, double reduction, InverseOperatorResult &res)
Apply inverse operator with given reduction factor.
NMIIICGSolver(L &op, P &prec, double reduction, int maxit, int verbose)
Set up conjugate gradient solver.
virtual void apply(X &u, X &b, InverseOperatorResult &res)
Apply inverse operator.