diff --git a/dune/solvers/iterationsteps/cgstep.cc b/dune/solvers/iterationsteps/cgstep.cc index 50490f28aa7a7b31178acce5f20349d191f270a4..5985a01cc5bc3b60cbff72177dbb58e8c40bc38e 100644 --- a/dune/solvers/iterationsteps/cgstep.cc +++ b/dune/solvers/iterationsteps/cgstep.cc @@ -1,7 +1,8 @@ -// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=8 sw=4 sts=4: #include <dune/solvers/common/canignore.hh> +#include <dune/matrix-vector/genericvectortools.hh> template <class MatrixType, class VectorType, class Ignore> void CGStep<MatrixType, VectorType, Ignore>::check() const @@ -14,9 +15,7 @@ void CGStep<MatrixType, VectorType, Ignore>::preprocess() // Compute the residual (r starts out as the rhs) this->mat_->mmv(*x_,r_); if (this->hasIgnore()) - for (size_t i=0; i < r_.size(); ++i) - if (this->ignore()[i].any()) - r_[i] = 0; + Dune::MatrixVector::Generic::truncate(r_, this->ignore()); if (preconditioner_) { using CanIgnore_t = CanIgnore<Ignore>; @@ -47,9 +46,7 @@ void CGStep<MatrixType, VectorType, Ignore>::iterate() r_.axpy(-alpha, q); // r_1 = r_0 - alpha_0 Ap_0 if (this->hasIgnore()) - for (size_t i=0; i < r_.size(); ++i) - if (this->ignore()[i].any()) - r_[i] = 0; + Dune::MatrixVector::Generic::truncate(r_, this->ignore()); if (preconditioner_) preconditioner_->apply(q, r_);