From e6de7ff54bc52afea22aa7af2a476903cf621a3a Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 15 Jul 2019 19:16:08 +0200
Subject: [PATCH] Add multidomain gmres solver backend

---
 dumux/linear/seqsolverbackend.hh | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/dumux/linear/seqsolverbackend.hh b/dumux/linear/seqsolverbackend.hh
index cddcde041e..29748a9c64 100644
--- a/dumux/linear/seqsolverbackend.hh
+++ b/dumux/linear/seqsolverbackend.hh
@@ -944,6 +944,46 @@ private:
     Dune::InverseOperatorResult result_;
 };
 
+/*!
+ * \ingroup Linear
+ * \brief A simple ilu0 block diagonal preconditioned RestartedGMResSolver
+ * \note expects a system as a multi-type block-matrix
+ * | A  B |
+ * | C  D |
+ */
+class BlockDiagILU0RestartedGMResSolver : public LinearSolver
+{
+
+public:
+    using LinearSolver::LinearSolver;
+
+    // Solve saddle-point problem using a Schur complement based preconditioner
+    template<int precondBlockLevel = 2, class Matrix, class Vector>
+    bool solve(const Matrix& M, Vector& x, const Vector& b)
+    {
+        BlockDiagILU0Preconditioner<Matrix, Vector, Vector> preconditioner(M);
+        Dune::MatrixAdapter<Matrix, Vector, Vector> op(M);
+        static const int restartGMRes = getParamFromGroup<double>(this->paramGroup(), "LinearSolver.GMResRestart");
+        Dune::RestartedGMResSolver<Vector> solver(op, preconditioner, this->residReduction(), restartGMRes,
+                                                  this->maxIter(), this->verbosity());
+        auto bTmp(b);
+        solver.apply(x, bTmp, result_);
+
+        return result_.converged;
+    }
+
+    const Dune::InverseOperatorResult& result() const
+    {
+      return result_;
+    }
+
+    std::string name() const
+    { return "block-diagonal ILU0 preconditioned restarted GMRes solver"; }
+
+private:
+    Dune::InverseOperatorResult result_;
+};
+
 /*!
  * \ingroup Linear
  * \brief A simple ilu0 block diagonal preconditioner
-- 
GitLab