]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove VectorType from FEFaceEvaluationSelector 10889/head
authorPeter Munch <peterrmuench@gmail.com>
Thu, 3 Sep 2020 21:52:20 +0000 (23:52 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 4 Sep 2020 04:54:49 +0000 (06:54 +0200)
include/deal.II/matrix_free/evaluation_kernels.h
include/deal.II/matrix_free/fe_evaluation.h

index 120f8fe705b7774c358ef21f97621e52e94087fa..6a41e028ed952e0c8fc539ee497d93445f03eff3 100644 (file)
@@ -2042,44 +2042,10 @@ namespace internal
           data, temp1, values_array, integrate_gradients, face_no);
     }
 
-    template <std::size_t n_face_orientations,
-              typename VectorType,
-              typename std::enable_if<
-                !internal::has_begin<VectorType>::value ||
-                  !std::is_same<decltype(std::declval<VectorType>().begin()),
-                                Number2 *>::value,
-                VectorType>::type * = nullptr>
-    static bool
-    gather_evaluate(const VectorType &,
-                    const MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> &,
-                    const MatrixFreeFunctions::DoFInfo &,
-                    VectorizedArrayType *,
-                    VectorizedArrayType *,
-                    VectorizedArrayType *,
-                    const bool,
-                    const bool,
-                    const unsigned int,
-                    const unsigned int,
-                    const std::array<unsigned int, n_face_orientations>,
-                    const std::array<unsigned int, n_face_orientations>,
-                    const unsigned int,
-                    const MatrixFreeFunctions::DoFInfo::DoFAccessIndex,
-                    const std::array<unsigned int, n_face_orientations>,
-                    const Table<2, unsigned int> &)
-    {
-      return false;
-    }
-
-    template <std::size_t n_face_orientations,
-              typename VectorType,
-              typename std::enable_if<
-                internal::has_begin<VectorType>::value &&
-                  std::is_same<decltype(std::declval<VectorType>().begin()),
-                               Number2 *>::value,
-                VectorType>::type * = nullptr>
+    template <std::size_t n_face_orientations>
     static bool
     gather_evaluate(
-      const VectorType &                                         src,
+      const Number2 *                                            src_ptr,
       const MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> &data,
       const MatrixFreeFunctions::DoFInfo &                       dof_info,
       VectorizedArrayType *                                      values_quad,
@@ -2096,13 +2062,14 @@ namespace internal
       const std::array<unsigned int, n_face_orientations> face_orientations,
       const Table<2, unsigned int> &                      orientation_map)
     {
-      static_assert((std::is_same<decltype(std::declval<VectorType>().begin()),
-                                  Number2 *>::value),
-                    "Types do not match.");
+      if (src_ptr == nullptr)
+        {
+          return false;
+        }
 
       return process_and_io( //
         false /*=evaluate*/,
-        src.begin(),
+        src_ptr,
         data,
         dof_info,
         values_quad,
@@ -2204,63 +2171,10 @@ namespace internal
         });
     }
 
-    template <std::size_t n_face_orientations,
-              typename VectorType,
-              typename std::enable_if<
-                !internal::has_begin<VectorType>::value ||
-                  !std::is_same<decltype(std::declval<VectorType>().begin()),
-                                Number2 *>::value,
-                VectorType>::type * = nullptr>
+    template <std::size_t n_face_orientations>
     static bool
     integrate_scatter(
-      VectorType &,
-      const MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> &data,
-      const MatrixFreeFunctions::DoFInfo &,
-      VectorizedArrayType *values_array,
-      VectorizedArrayType *values_quad,
-      VectorizedArrayType *gradients_quad,
-      VectorizedArrayType *scratch_data,
-      const bool           integrate_values,
-      const bool           integrate_gradients,
-      const unsigned int,
-      const unsigned int,
-      const std::array<unsigned int, n_face_orientations>,
-      const std::array<unsigned int, n_face_orientations> face_nos,
-      const unsigned int                                  subface_index,
-      const MatrixFreeFunctions::DoFInfo::DoFAccessIndex,
-      const std::array<unsigned int, n_face_orientations> face_orientations,
-      const Table<2, unsigned int> &                      orientation_map)
-    {
-      AssertDimension(face_nos.size(), 1);
-      AssertDimension(face_orientations.size(), 1);
-
-      // for block vectors simply integrate
-      integrate(data,
-                values_array,
-                values_quad,
-                gradients_quad,
-                scratch_data,
-                integrate_values,
-                integrate_gradients,
-                face_nos[0],
-                subface_index,
-                face_orientations[0],
-                orientation_map);
-
-      // default vector access
-      return false;
-    }
-
-    template <std::size_t n_face_orientations,
-              typename VectorType,
-              typename std::enable_if<
-                internal::has_begin<VectorType>::value &&
-                  std::is_same<decltype(std::declval<VectorType>().begin()),
-                               Number2 *>::value,
-                VectorType>::type * = nullptr>
-    static bool
-    integrate_scatter(
-      VectorType &                                               dst,
+      Number2 *                                                  dst_ptr,
       const MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> &data,
       const MatrixFreeFunctions::DoFInfo &                       dof_info,
       VectorizedArrayType *                                      values_array,
@@ -2278,13 +2192,31 @@ namespace internal
       const std::array<unsigned int, n_face_orientations> face_orientations,
       const Table<2, unsigned int> &                      orientation_map)
     {
-      static_assert((std::is_same<decltype(std::declval<VectorType>().begin()),
-                                  Number2 *>::value),
-                    "Types do not match.");
+      if (dst_ptr == nullptr)
+        {
+          AssertDimension(face_nos.size(), 1);
+          AssertDimension(face_orientations.size(), 1);
+
+          // for block vectors simply integrate
+          integrate(data,
+                    values_array,
+                    values_quad,
+                    gradients_quad,
+                    scratch_data,
+                    integrate_values,
+                    integrate_gradients,
+                    face_nos[0],
+                    subface_index,
+                    face_orientations[0],
+                    orientation_map);
+
+          // default vector access
+          return false;
+        }
 
       return process_and_io( //
         true /*=integrate*/,
-        dst.begin(),
+        dst_ptr,
         data,
         dof_info,
         values_quad,
index b91ba87259d86071a206d47377bf340b963b7f7c..aa4bc939e392af823a0773fc07a96ad8af5f19cd 100644 (file)
@@ -7499,6 +7499,44 @@ namespace internal
   {
     return false;
   }
+
+  template <typename Number,
+            typename VectorType,
+            typename std::enable_if<
+              internal::has_begin<VectorType>::value &&
+                (std::is_same<decltype(std::declval<VectorType>().begin()),
+                              const double *>::value ||
+                 std::is_same<decltype(std::declval<VectorType>().begin()),
+                              double *>::value ||
+                 std::is_same<decltype(std::declval<VectorType>().begin()),
+                              const float *>::value ||
+                 std::is_same<decltype(std::declval<VectorType>().begin()),
+                              float *>::value),
+              VectorType>::type * = nullptr>
+  decltype(std::declval<VectorType>().begin())
+  get_beginning(VectorType &vec)
+  {
+    return vec.begin();
+  }
+
+  template <typename Number,
+            typename VectorType,
+            typename std::enable_if<
+              !internal::has_begin<VectorType>::value ||
+                !(std::is_same<decltype(std::declval<VectorType>().begin()),
+                               const double *>::value ||
+                  std::is_same<decltype(std::declval<VectorType>().begin()),
+                               double *>::value ||
+                  std::is_same<decltype(std::declval<VectorType>().begin()),
+                               const float *>::value ||
+                  std::is_same<decltype(std::declval<VectorType>().begin()),
+                               float *>::value),
+              VectorType>::type * = nullptr>
+  typename VectorType::value_type *
+  get_beginning(VectorType &)
+  {
+    return nullptr;
+  }
 } // namespace internal
 
 template <int dim,
@@ -8227,7 +8265,7 @@ FEFaceEvaluation<dim,
                                                   n_components,
                                                   Number,
                                                   VectorizedArrayType>::
-          gather_evaluate(input_vector,
+          gather_evaluate(internal::get_beginning<Number>(input_vector),
                           *this->data,
                           *this->dof_info,
                           this->begin_values(),
@@ -8253,7 +8291,7 @@ FEFaceEvaluation<dim,
                                                   n_components,
                                                   Number,
                                                   VectorizedArrayType>::
-          gather_evaluate(input_vector,
+          gather_evaluate(internal::get_beginning<Number>(input_vector),
                           *this->data,
                           *this->dof_info,
                           this->begin_values(),
@@ -8345,7 +8383,7 @@ FEFaceEvaluation<dim,
                                           n_components,
                                           Number,
                                           VectorizedArrayType>::
-        integrate_scatter(destination,
+        integrate_scatter(internal::get_beginning<Number>(destination),
                           *this->data,
                           *this->dof_info,
                           this->begin_dof_values(),

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.