From f8416edbb8c5d29752651b0af4680e9609b07889 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Sat, 18 May 2019 12:28:58 +0200
Subject: [PATCH] [linear] Add solver for block-diagonal matrices from explicit
 time stepping schemes

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

diff --git a/dumux/linear/seqsolverbackend.hh b/dumux/linear/seqsolverbackend.hh
index cddcde041e..b0e051dd3f 100644
--- a/dumux/linear/seqsolverbackend.hh
+++ b/dumux/linear/seqsolverbackend.hh
@@ -701,6 +701,41 @@ public:
 
         return IterativePreconditionedSolverImpl::template solveWithGMRes<Preconditioner, Solver>(*this, A, x, b, this->paramGroup());
     }
+
+    std::string name() const
+    {
+        return "ILUn preconditioned GMRes solver";
+    }
+};
+
+/*!
+ * \ingroup Linear
+ * \brief Solver for simple block-diagonal matrices (e.g. from explicit time stepping schemes)
+ *
+ * Solver: Single Jacobi iteration
+ * Preconditioner: Unity
+ */
+class ExplicitDiagonalSolver : public LinearSolver
+{
+public:
+    using LinearSolver::LinearSolver;
+
+    // precondBlockLevel: set this to more than one if the matrix to solve is nested multiple times
+    template<int precondBlockLevel = 1, class Matrix, class Vector>
+    bool solve(const Matrix& A, Vector& x, const Vector& b)
+    {
+        Vector rhs(b);
+        Dune::SeqJac<Matrix, Vector, Vector, precondBlockLevel> jac(A, 1, 1.0);
+        jac.pre(x, rhs);
+        jac.apply(x, rhs);
+        jac.post(x);
+        return true;
+    }
+
+    std::string name() const
+    {
+        return "Explicit diagonal matrix solver";
+    }
 };
 
 #if HAVE_SUPERLU
-- 
GitLab