]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PreconditionRelaxation: vmult/step w. relaxation 13285/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 24 Jan 2022 15:52:53 +0000 (16:52 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 24 Jan 2022 15:52:53 +0000 (16:52 +0100)
include/deal.II/lac/precondition.h

index e8c45bd90ff757d4134cae78c2f53eecc9afe389..7e292ccf916d666e48dff2eeae57cff28045f334 100644 (file)
@@ -569,6 +569,28 @@ namespace internal
     template <typename T, typename VectorType>
     const bool has_step<T, VectorType>::value;
 
+    template <typename T, typename VectorType>
+    struct has_step_omega
+    {
+    private:
+      static bool
+      detect(...);
+
+      template <typename U>
+      static decltype(
+        std::declval<U const>().step(std::declval<VectorType &>(),
+                                     std::declval<const VectorType &>(),
+                                     std::declval<const double>()))
+      detect(const U &);
+
+    public:
+      static const bool value =
+        !std::is_same<bool, decltype(detect(std::declval<T>()))>::value;
+    };
+
+    template <typename T, typename VectorType>
+    const bool has_step_omega<T, VectorType>::value;
+
     template <typename T, typename VectorType>
     struct has_Tstep
     {
@@ -590,6 +612,28 @@ namespace internal
     template <typename T, typename VectorType>
     const bool has_Tstep<T, VectorType>::value;
 
+    template <typename T, typename VectorType>
+    struct has_Tstep_omega
+    {
+    private:
+      static bool
+      detect(...);
+
+      template <typename U>
+      static decltype(
+        std::declval<U const>().Tstep(std::declval<VectorType &>(),
+                                      std::declval<const VectorType &>(),
+                                      std::declval<const double>()))
+      detect(const U &);
+
+    public:
+      static const bool value =
+        !std::is_same<bool, decltype(detect(std::declval<T>()))>::value;
+    };
+
+    template <typename T, typename VectorType>
+    const bool has_Tstep_omega<T, VectorType>::value;
+
     template <typename T, typename VectorType>
     struct has_jacobi_step
     {
@@ -923,12 +967,31 @@ namespace internal
       const std::vector<size_type> &inverse_permutation;
     };
 
-    template <
-      typename MatrixType,
-      typename PreconditionerType,
-      typename VectorType,
-      typename std::enable_if<has_step<PreconditionerType, VectorType>::value,
-                              PreconditionerType>::type * = nullptr>
+    template <typename MatrixType,
+              typename PreconditionerType,
+              typename VectorType,
+              typename std::enable_if<
+                has_step_omega<PreconditionerType, VectorType>::value,
+                PreconditionerType>::type * = nullptr>
+    void
+    step(const MatrixType &,
+         const PreconditionerType &preconditioner,
+         VectorType &              dst,
+         const VectorType &        src,
+         const double              relaxation,
+         VectorType &,
+         VectorType &)
+    {
+      preconditioner.step(dst, src, relaxation);
+    }
+
+    template <typename MatrixType,
+              typename PreconditionerType,
+              typename VectorType,
+              typename std::enable_if<
+                !has_step_omega<PreconditionerType, VectorType>::value &&
+                  has_step<PreconditionerType, VectorType>::value,
+                PreconditionerType>::type * = nullptr>
     void
     step(const MatrixType &,
          const PreconditionerType &preconditioner,
@@ -945,12 +1008,13 @@ namespace internal
       preconditioner.step(dst, src);
     }
 
-    template <
-      typename MatrixType,
-      typename PreconditionerType,
-      typename VectorType,
-      typename std::enable_if<!has_step<PreconditionerType, VectorType>::value,
-                              PreconditionerType>::type * = nullptr>
+    template <typename MatrixType,
+              typename PreconditionerType,
+              typename VectorType,
+              typename std::enable_if<
+                !has_step_omega<PreconditionerType, VectorType>::value &&
+                  !has_step<PreconditionerType, VectorType>::value,
+                PreconditionerType>::type * = nullptr>
     void
     step(const MatrixType &        A,
          const PreconditionerType &preconditioner,
@@ -970,12 +1034,31 @@ namespace internal
       dst.add(relaxation, tmp);
     }
 
-    template <
-      typename MatrixType,
-      typename PreconditionerType,
-      typename VectorType,
-      typename std::enable_if<has_Tstep<PreconditionerType, VectorType>::value,
-                              PreconditionerType>::type * = nullptr>
+    template <typename MatrixType,
+              typename PreconditionerType,
+              typename VectorType,
+              typename std::enable_if<
+                has_Tstep_omega<PreconditionerType, VectorType>::value,
+                PreconditionerType>::type * = nullptr>
+    void
+    Tstep(const MatrixType &,
+          const PreconditionerType &preconditioner,
+          VectorType &              dst,
+          const VectorType &        src,
+          const double              relaxation,
+          VectorType &,
+          VectorType &)
+    {
+      preconditioner.Tstep(dst, src, relaxation);
+    }
+
+    template <typename MatrixType,
+              typename PreconditionerType,
+              typename VectorType,
+              typename std::enable_if<
+                !has_Tstep_omega<PreconditionerType, VectorType>::value &&
+                  has_Tstep<PreconditionerType, VectorType>::value,
+                PreconditionerType>::type * = nullptr>
     void
     Tstep(const MatrixType &,
           const PreconditionerType &preconditioner,
@@ -1014,12 +1097,13 @@ namespace internal
              ExcMessage("Matrix A does not provide a Tvmult() function!"));
     }
 
-    template <
-      typename MatrixType,
-      typename PreconditionerType,
-      typename VectorType,
-      typename std::enable_if<!has_Tstep<PreconditionerType, VectorType>::value,
-                              PreconditionerType>::type * = nullptr>
+    template <typename MatrixType,
+              typename PreconditionerType,
+              typename VectorType,
+              typename std::enable_if<
+                !has_Tstep_omega<PreconditionerType, VectorType>::value &&
+                  !has_Tstep<PreconditionerType, VectorType>::value,
+                PreconditionerType>::type * = nullptr>
     void
     Tstep(const MatrixType &        A,
           const PreconditionerType &preconditioner,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.