]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify MGCoarseGridIterativeSolver 17756/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 7 Oct 2024 15:37:24 +0000 (17:37 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 7 Oct 2024 15:37:24 +0000 (17:37 +0200)
include/deal.II/multigrid/mg_coarse.h

index b9d98289ba28e2a2552b6ed594c93a2b1725618e..dc234f9baf10e54ce5d3901478f9401a8bb2d8e2 100644 (file)
@@ -356,56 +356,6 @@ MGCoarseGridIterativeSolver<VectorType,
 
 
 
-namespace internal
-{
-  namespace MGCoarseGridIterativeSolver
-  {
-    template <typename VectorType,
-              typename SolverType,
-              typename MatrixType,
-              typename PreconditionerType,
-              std::enable_if_t<
-                std::is_same_v<VectorType, typename SolverType::vector_type>,
-                VectorType> * = nullptr>
-    void
-    solve(SolverType               &solver,
-          const MatrixType         &matrix,
-          const PreconditionerType &preconditioner,
-          VectorType               &dst,
-          const VectorType         &src)
-    {
-      solver.solve(matrix, dst, src, preconditioner);
-    }
-
-    template <typename VectorType,
-              typename SolverType,
-              typename MatrixType,
-              typename PreconditionerType,
-              std::enable_if_t<
-                !std::is_same_v<VectorType, typename SolverType::vector_type>,
-                VectorType> * = 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 <typename VectorType,
           typename SolverType,
           typename MatrixType,
@@ -424,8 +374,23 @@ MGCoarseGridIterativeSolver<
   Assert(preconditioner != nullptr, ExcNotInitialized());
 
   dst = 0;
-  internal::MGCoarseGridIterativeSolver::solve(
-    *solver, *matrix, *preconditioner, dst, src);
+
+  if constexpr (std::is_same_v<VectorType, typename SolverType::vector_type>)
+    {
+      solver->solve(*matrix, dst, src, *preconditioner);
+    }
+  else
+    {
+      typename SolverType::vector_type src_;
+      typename SolverType::vector_type dst_;
+
+      src_ = src;
+      dst_ = dst;
+
+      solver->solve(*matrix, dst_, src_, *preconditioner);
+
+      dst = dst_;
+    }
 }
 
 

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.