From 6eb61e07661b0e76f2fed88117384dfcf357a694 Mon Sep 17 00:00:00 2001
From: Max Kahnt <max.kahnt@fu-berlin.de>
Date: Mon, 9 Oct 2017 14:50:11 +0200
Subject: [PATCH] Allow custom ignore type in cgstep.

---
 dune/solvers/iterationsteps/cgstep.cc | 14 +++++++-------
 dune/solvers/iterationsteps/cgstep.hh | 12 +++++++-----
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/dune/solvers/iterationsteps/cgstep.cc b/dune/solvers/iterationsteps/cgstep.cc
index 9dae98fd..50490f28 100644
--- a/dune/solvers/iterationsteps/cgstep.cc
+++ b/dune/solvers/iterationsteps/cgstep.cc
@@ -3,13 +3,13 @@
 
 #include <dune/solvers/common/canignore.hh>
 
-template <class MatrixType, class VectorType>
-void CGStep<MatrixType, VectorType>::check() const
+template <class MatrixType, class VectorType, class Ignore>
+void CGStep<MatrixType, VectorType, Ignore>::check() const
 {
 }
 
-template <class MatrixType, class VectorType>
-void CGStep<MatrixType, VectorType>::preprocess()
+template <class MatrixType, class VectorType, class Ignore>
+void CGStep<MatrixType, VectorType, Ignore>::preprocess()
 {
     // Compute the residual (r starts out as the rhs)
     this->mat_->mmv(*x_,r_);
@@ -19,7 +19,7 @@ void CGStep<MatrixType, VectorType>::preprocess()
                 r_[i] = 0;
 
     if (preconditioner_) {
-        using CanIgnore_t = CanIgnore<DefaultBitVector_t<VectorType>>;
+        using CanIgnore_t = CanIgnore<Ignore>;
         CanIgnore_t *asCanIgnore = dynamic_cast<CanIgnore_t*>(preconditioner_);
         if (asCanIgnore != nullptr and this->hasIgnore())
             asCanIgnore->setIgnore(this->ignore());
@@ -32,8 +32,8 @@ void CGStep<MatrixType, VectorType>::preprocess()
     r_squared_old_ = p_*r_;
 }
 
-template <class MatrixType, class VectorType>
-void CGStep<MatrixType, VectorType>::iterate()
+template <class MatrixType, class VectorType, class Ignore>
+void CGStep<MatrixType, VectorType, Ignore>::iterate()
 {
     // Avoid divide-by-zero. If r_squared was zero, we're done anyway.
     if (r_squared_old_ <= 0)
diff --git a/dune/solvers/iterationsteps/cgstep.hh b/dune/solvers/iterationsteps/cgstep.hh
index 366544f8..6d7bc3ec 100644
--- a/dune/solvers/iterationsteps/cgstep.hh
+++ b/dune/solvers/iterationsteps/cgstep.hh
@@ -4,16 +4,18 @@
 #define DUNE_SOLVERS_ITERATIONSTEPS_CGSTEP_HH
 
 #include <dune/solvers/common/preconditioner.hh>
+#include <dune/solvers/common/defaultbitvector.hh>
 #include <dune/solvers/iterationsteps/lineariterationstep.hh>
 
 namespace Dune {
     namespace Solvers {
 
         //! A conjugate gradient solver
-        template <class MatrixType, class VectorType>
-        class CGStep : public LinearIterationStep<MatrixType,VectorType>
+        template <class MatrixType, class VectorType, class Ignore = DefaultBitVector_t<VectorType>>
+        class CGStep : public LinearIterationStep<MatrixType,VectorType,Ignore>
         {
-            using Base = LinearIterationStep<MatrixType,VectorType>;
+            using Base = LinearIterationStep<MatrixType,VectorType,Ignore>;
+            using Preconditioner = Dune::Solvers::Preconditioner<MatrixType, VectorType, Ignore>;
 
         public:
             CGStep()
@@ -30,7 +32,7 @@ namespace Dune {
             CGStep(const MatrixType& matrix,
                    VectorType& x,
                    const VectorType& rhs,
-                   Preconditioner<MatrixType, VectorType>& preconditioner)
+                   Preconditioner& preconditioner)
                 : Base(matrix,x), p_(rhs.size()), r_(rhs),
                   preconditioner_(&preconditioner)
             {}
@@ -54,7 +56,7 @@ namespace Dune {
             VectorType r_; // residual
             using Base::x_;
             double r_squared_old_;
-            Preconditioner<MatrixType, VectorType>* preconditioner_;
+            Preconditioner* preconditioner_;
         };
 
 
-- 
GitLab