From e40fa48a6b8549ffe26cd7cc905aecdee698569b Mon Sep 17 00:00:00 2001 From: Max Kahnt <max.kahnt@fu-berlin.de> Date: Mon, 9 Oct 2017 15:10:33 +0200 Subject: [PATCH] Use truncate to apply ignore node for arbitrary types. --- dune/solvers/iterationsteps/cgstep.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dune/solvers/iterationsteps/cgstep.cc b/dune/solvers/iterationsteps/cgstep.cc index 50490f2..5985a01 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_); -- GitLab