]> https://gitweb.dealii.org/ - dealii.git/commitdiff
templatize interface operator wrt vector type 3857/head
authorKarl Ljungkvist <k.ljungkvist@gmail.com>
Fri, 27 Jan 2017 13:08:17 +0000 (14:08 +0100)
committerKarl Ljungkvist <k.ljungkvist@gmail.com>
Fri, 27 Jan 2017 14:14:16 +0000 (15:14 +0100)
This allows MGInterfaceOperator to work with all valid vector types, and
not just LinearAlgebra::distributed::Vector

include/deal.II/matrix_free/operators.h

index 4e4d63e15cf1418b7f89ba718f5ab0b5e7eb90ed..fa27b7bee13c698b4a831106ff87aff590c24ebc 100644 (file)
@@ -313,14 +313,16 @@ namespace MatrixFreeOperators
     /**
      * vmult operator, see class description for more info.
      */
-    void vmult (LinearAlgebra::distributed::Vector<value_type> &dst,
-                const LinearAlgebra::distributed::Vector<value_type> &src) const;
+    template <typename VectorType>
+    void vmult (VectorType &dst,
+                const VectorType &src) const;
 
     /**
      * Tvmult operator, see class description for more info.
      */
-    void Tvmult (LinearAlgebra::distributed::Vector<value_type> &dst,
-                 const LinearAlgebra::distributed::Vector<value_type> &src) const;
+    template <typename VectorType>
+    void Tvmult (VectorType &dst,
+                 const VectorType &src) const;
 
   private:
     /**
@@ -1090,10 +1092,19 @@ namespace MatrixFreeOperators
 
 
   template <typename OperatorType>
+  template <typename VectorType>
   void
-  MGInterfaceOperator<OperatorType>::vmult (LinearAlgebra::distributed::Vector<typename MGInterfaceOperator<OperatorType>::value_type> &dst,
-                                            const LinearAlgebra::distributed::Vector<typename MGInterfaceOperator<OperatorType>::value_type> &src) const
+  MGInterfaceOperator<OperatorType>::vmult (VectorType &dst,
+                                            const VectorType &src) const
   {
+#ifdef DEAL_II_WITH_CXX11
+#ifndef DEAL_II_MSVC
+    static_assert (std::is_same<typename VectorType::value_type,value_type>::value,
+                   "The vector type must be based on the same value type as this"
+                   "operator");
+#endif
+#endif
+
     Assert(mf_base_operator != NULL,
            ExcNotInitialized());
 
@@ -1103,10 +1114,19 @@ namespace MatrixFreeOperators
 
 
   template <typename OperatorType>
+  template <typename VectorType>
   void
-  MGInterfaceOperator<OperatorType>::Tvmult (LinearAlgebra::distributed::Vector<typename MGInterfaceOperator<OperatorType>::value_type> &dst,
-                                             const LinearAlgebra::distributed::Vector<typename MGInterfaceOperator<OperatorType>::value_type> &src) const
+  MGInterfaceOperator<OperatorType>::Tvmult (VectorType &dst,
+                                             const VectorType &src) const
   {
+#ifdef DEAL_II_WITH_CXX11
+#ifndef DEAL_II_MSVC
+    static_assert (std::is_same<typename VectorType::value_type,value_type>::value,
+                   "The vector type must be based on the same value type as this"
+                   "operator");
+#endif
+#endif
+
     Assert(mf_base_operator != NULL,
            ExcNotInitialized());
 

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.