From 38d070d0fde671a27920042b90a1d6ff86414e6a Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Wed, 13 Jul 2016 11:55:15 +0200
Subject: [PATCH] ISTLSeqSSORStep: Add. Works (mostly)

IgnoreNodes are not handled.
---
 dune/solvers/iterationsteps/CMakeLists.txt    |  1 +
 dune/solvers/iterationsteps/Makefile.am       |  1 +
 .../solvers/iterationsteps/istlseqssorstep.hh | 57 +++++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 dune/solvers/iterationsteps/istlseqssorstep.hh

diff --git a/dune/solvers/iterationsteps/CMakeLists.txt b/dune/solvers/iterationsteps/CMakeLists.txt
index 3b61c85..5fde9a8 100644
--- a/dune/solvers/iterationsteps/CMakeLists.txt
+++ b/dune/solvers/iterationsteps/CMakeLists.txt
@@ -6,6 +6,7 @@ install(FILES
     cgstep.cc
     cgstep.hh
     istlseqilu0step.hh
+    istlseqssorstep.hh
     iterationstep.hh
     lineariterationstep.hh
     linegsstep.cc
diff --git a/dune/solvers/iterationsteps/Makefile.am b/dune/solvers/iterationsteps/Makefile.am
index ed94666..e08f928 100644
--- a/dune/solvers/iterationsteps/Makefile.am
+++ b/dune/solvers/iterationsteps/Makefile.am
@@ -7,6 +7,7 @@ iterationsteps_HEADERS = amgstep.hh \
                          cgstep.hh \
                          cgstep.cc \
                          istlseqilu0step.hh \
+                         istlseqssorstep.hh \
                          iterationstep.hh \
                          lineariterationstep.hh \
                          linegsstep.hh \
diff --git a/dune/solvers/iterationsteps/istlseqssorstep.hh b/dune/solvers/iterationsteps/istlseqssorstep.hh
new file mode 100644
index 0000000..06f169f
--- /dev/null
+++ b/dune/solvers/iterationsteps/istlseqssorstep.hh
@@ -0,0 +1,57 @@
+// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// vi: set et ts=8 sw=4 sts=4:
+#ifndef ISTL_SEQSSOR_STEP_HH
+#define ISTL_SEQSSOR_STEP_HH
+
+/** \file
+    \brief A wrapper class for the ISTL SeqSSOR implementation
+ */
+
+#include <memory>
+
+#include <dune/solvers/iterationsteps/lineariterationstep.hh>
+
+#include <dune/istl/preconditioners.hh>
+
+/** \brief A wrapper class for the ISTL SeqSSOR implementation
+ */
+template <class MatrixType, class VectorType>
+class ISTLSeqSSORStep
+    // FIXME: ignoreNodes are not handled
+    : public LinearIterationStep<MatrixType, VectorType>
+{
+    typedef Dune::SeqSSOR<MatrixType,VectorType,VectorType> SeqSSOR;
+
+public:
+    ISTLSeqSSORStep (int iterations, double relaxationFactor)
+        : iterations_(iterations), relaxationFactor_(relaxationFactor)
+    {}
+
+    /** \brief Sets up an algebraic hierarchy
+     */
+    virtual void preprocess() override {
+        seqSSOR_ = std::make_unique<SeqSSOR>(*this->mat_, iterations_,
+                                             relaxationFactor_);
+
+        // Note: as of now, pre() is a dummy
+        mutable_rhs = *this->rhs_;
+        seqSSOR_->pre(*this->x_, mutable_rhs);
+    }
+
+    /** \brief Perform one iteration */
+    virtual void iterate() override {
+        mutable_rhs = *this->rhs_;
+        seqSSOR_->apply(*this->x_, mutable_rhs);
+    }
+
+private:
+
+    /** \brief The dune-istl sequential SSOR preconditioner */
+    std::unique_ptr<SeqSSOR> seqSSOR_;
+
+    VectorType mutable_rhs;
+
+    int const iterations_;
+    double const relaxationFactor_;
+};
+#endif
-- 
GitLab