]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Enable different VectorTypes in MGCoarseGridIterativeSolver 12562/head
authorPeter Munch <peterrmuench@gmail.com>
Sun, 11 Jul 2021 06:01:07 +0000 (08:01 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 11 Jul 2021 06:01:07 +0000 (08:01 +0200)
include/deal.II/multigrid/mg_coarse.h

index 8095f24bc89f7c192b44f9a46adab10639dbc8a4..735fd9151919e143efc6b8aad879eef46be5d543 100644 (file)
@@ -356,6 +356,58 @@ MGCoarseGridIterativeSolver<VectorType,
 
 
 
+namespace internal
+{
+  namespace MGCoarseGridIterativeSolver
+  {
+    template <
+      class VectorType,
+      class SolverType,
+      class MatrixType,
+      class PreconditionerType,
+      typename std::enable_if<
+        std::is_same<VectorType, typename SolverType::vector_type>::value,
+        VectorType>::type * = nullptr>
+    void
+    solve(SolverType &              solver,
+          const MatrixType &        matrix,
+          const PreconditionerType &preconditioner,
+          VectorType &              dst,
+          const VectorType &        src)
+    {
+      solver.solve(matrix, dst, src, preconditioner);
+    }
+
+    template <
+      class VectorType,
+      class SolverType,
+      class MatrixType,
+      class PreconditionerType,
+      typename std::enable_if<
+        !std::is_same<VectorType, typename SolverType::vector_type>::value,
+        VectorType>::type * = nullptr>
+    void
+    solve(SolverType &              solver,
+          const MatrixType &        matrix,
+          const PreconditionerType &preconditioner,
+          VectorType &              dst,
+          const VectorType &        src)
+    {
+      typename SolverType::vector_type src_;
+      typename SolverType::vector_type dst_;
+
+      src_ = src;
+      dst_ = dst;
+
+      solver.solve(matrix, dst_, src_, preconditioner);
+
+      dst = dst_;
+    }
+  } // namespace MGCoarseGridIterativeSolver
+} // namespace internal
+
+
+
 template <class VectorType,
           class SolverType,
           class MatrixType,
@@ -372,7 +424,9 @@ operator()(const unsigned int /*level*/,
   Assert(solver != nullptr, ExcNotInitialized());
   Assert(matrix != nullptr, ExcNotInitialized());
   Assert(preconditioner != nullptr, ExcNotInitialized());
-  solver->solve(*matrix, dst, src, *preconditioner);
+
+  internal::MGCoarseGridIterativeSolver::solve(
+    *solver, *matrix, *preconditioner, dst, src);
 }
 
 

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.