]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify extraction of shape info data structure
authorMartin Kronbichler <martin.kronbichler@it.uu.se>
Wed, 1 Dec 2021 13:40:17 +0000 (14:40 +0100)
committerMartin Kronbichler <martin.kronbichler@it.uu.se>
Mon, 6 Dec 2021 13:28:08 +0000 (14:28 +0100)
include/deal.II/matrix_free/fe_evaluation.h
include/deal.II/matrix_free/fe_evaluation_base_data.h

index d74ef0310780c3a78b9c4e8f5be7b6e1bbe5c832..897dc0ab4907829edb4451b64811b965871b5500 100644 (file)
@@ -3091,46 +3091,51 @@ namespace internal
 
 namespace internal
 {
-  template <typename MatrixFreeType>
-  inline unsigned int
-  get_active_fe_index(const MatrixFreeType &data,
-                      const unsigned int    dof_no,
-                      const unsigned int    fe_degree,
-                      const unsigned int    first_selected_component,
-                      const unsigned int    active_fe_index)
-  {
-    return fe_degree != numbers::invalid_unsigned_int ?
-             data.get_dof_info(dof_no).fe_index_from_degree(
-               first_selected_component, fe_degree) :
-             (active_fe_index != numbers::invalid_unsigned_int ?
-                active_fe_index :
-                0);
-  }
-
-
-
   template <bool is_face,
             int  dim,
             typename Number,
             typename VectorizedArrayType>
-  inline unsigned int
-  get_active_quad_index(const MatrixFree<dim, Number, VectorizedArrayType> &mf,
-                        const unsigned int quad_no,
-                        const unsigned int fe_degree,
-                        const unsigned int n_q_points,
-                        const unsigned int active_fe_index,
-                        const unsigned int active_quad_index)
+  inline std::tuple<
+    const internal::MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> &,
+    const internal::MatrixFreeFunctions::DoFInfo &,
+    unsigned int,
+    unsigned int>
+  get_shape_info_and_indices(
+    const MatrixFree<dim, Number, VectorizedArrayType> &data,
+    const unsigned int                                  dof_no,
+    const unsigned int first_selected_component,
+    const unsigned int quad_no,
+    const unsigned int fe_degree,
+    const unsigned int n_q_points,
+    const unsigned int active_fe_index_given,
+    const unsigned int active_quad_index_given)
   {
+    const auto &dof_info        = data.get_dof_info(dof_no);
     const auto &mapping_storage = internal::MatrixFreeFunctions::
       MappingInfoCellsOrFaces<dim, Number, is_face, VectorizedArrayType>::get(
-        mf.get_mapping_info(), quad_no);
-    if (fe_degree == numbers::invalid_unsigned_int)
-      return active_quad_index != numbers::invalid_unsigned_int ?
-               active_quad_index :
-               std::min<unsigned int>(active_fe_index,
-                                      mapping_storage.descriptor.size() - 1);
-    else
-      return mapping_storage.quad_index_from_n_q_points(n_q_points);
+        data.get_mapping_info(), quad_no);
+    const unsigned int active_fe_index =
+      fe_degree != numbers::invalid_unsigned_int ?
+        dof_info.fe_index_from_degree(first_selected_component, fe_degree) :
+        (active_fe_index_given != numbers::invalid_unsigned_int ?
+           active_fe_index_given :
+           0);
+    const unsigned int active_quad_index =
+      fe_degree == numbers::invalid_unsigned_int ?
+        (active_quad_index_given != numbers::invalid_unsigned_int ?
+           active_quad_index_given :
+           std::min<unsigned int>(active_fe_index,
+                                  mapping_storage.descriptor.size() - 1)) :
+        mapping_storage.quad_index_from_n_q_points(n_q_points);
+    return {data.get_shape_info(
+              dof_no,
+              quad_no,
+              dof_info.component_to_base_index[first_selected_component],
+              active_fe_index,
+              active_quad_index),
+            dof_info,
+            active_fe_index,
+            active_quad_index};
   }
 } // namespace internal
 
@@ -3158,54 +3163,24 @@ inline FEEvaluationBase<dim,
                    const unsigned int active_quad_index,
                    const unsigned int face_type)
   : FEEvaluationBaseData<dim, Number, is_face, VectorizedArrayType>(
-      data_in.get_shape_info(
-        dof_no,
-        quad_no,
-        data_in.get_dof_info(dof_no)
-          .component_to_base_index[first_selected_component],
-        internal::get_active_fe_index(data_in,
-                                      dof_no,
-                                      fe_degree,
-                                      first_selected_component,
-                                      active_fe_index),
-        internal::get_active_quad_index<is_face>(
-          data_in,
-          quad_no,
-          fe_degree,
-          n_q_points,
-          internal::get_active_fe_index(data_in,
-                                        dof_no,
-                                        fe_degree,
-                                        first_selected_component,
-                                        active_fe_index),
-          active_quad_index)),
-      data_in.get_dof_info(dof_no),
+      internal::get_shape_info_and_indices<is_face>(data_in,
+                                                    dof_no,
+                                                    first_selected_component,
+                                                    quad_no,
+                                                    fe_degree,
+                                                    n_q_points,
+                                                    active_fe_index,
+                                                    active_quad_index),
       internal::MatrixFreeFunctions::
         MappingInfoCellsOrFaces<dim, Number, is_face, VectorizedArrayType>::get(
           data_in.get_mapping_info(),
           quad_no),
       quad_no,
       is_interior_face,
-      internal::get_active_fe_index(data_in,
-                                    dof_no,
-                                    fe_degree,
-                                    first_selected_component,
-                                    active_fe_index),
-      internal::get_active_quad_index<is_face>(
-        data_in,
-        quad_no,
-        fe_degree,
-        n_q_points,
-        internal::get_active_fe_index(data_in,
-                                      dof_no,
-                                      fe_degree,
-                                      first_selected_component,
-                                      active_fe_index),
-        active_quad_index),
       face_type)
   , scratch_data_array(data_in.acquire_scratch_data())
   , matrix_info(&data_in)
-  , n_fe_components(data_in.get_dof_info(dof_no).start_components.back())
+  , n_fe_components(this->dof_info->start_components.back())
   , dof_values_initialized(false)
   , values_quad_initialized(false)
   , gradients_quad_initialized(false)
index dcce525ab96cd09fa1bb640bb98be176f47017d8..e95a0a9c87d565989c6b1baa5651fc62a1f91b02 100644 (file)
@@ -148,7 +148,7 @@ public:
   /**
    * Return a reference to the ShapeInfo object currently in use.
    */
-  const internal::MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> &
+  const ShapeInfoType &
   get_shape_info() const;
 
   /**
@@ -243,14 +243,14 @@ protected:
    * more than one quadrature formula selected during construction of
    * `matrix_free`, `quad_no` allows to select the appropriate formula.
    */
-  FEEvaluationBaseData(const ShapeInfoType &         shape_info,
-                       const DoFInfo &               dof_info,
-                       const MappingInfoStorageType &mapping_data,
-                       const unsigned int            quad_no,
-                       const bool                    is_interior_face,
-                       const unsigned int            active_fe_index,
-                       const unsigned int            active_quad_index,
-                       const unsigned int            face_type);
+  FEEvaluationBaseData(const std::tuple<const ShapeInfoType &,
+                                        const DoFInfo &,
+                                        unsigned int,
+                                        unsigned int> &info,
+                       const MappingInfoStorageType &  mapping_data,
+                       const unsigned int              quad_no,
+                       const bool                      is_interior_face,
+                       const unsigned int              face_type);
 
   /**
    * Constructor that comes with reduced functionality and works similar as
@@ -440,20 +440,20 @@ protected:
 
 template <int dim, typename Number, bool is_face, typename VectorizedArrayType>
 inline FEEvaluationBaseData<dim, Number, is_face, VectorizedArrayType>::
-  FEEvaluationBaseData(const ShapeInfoType &         shape_info,
-                       const DoFInfo &               dof_info,
-                       const MappingInfoStorageType &mapping_data,
-                       const unsigned int            quad_no,
-                       const bool                    is_interior_face,
-                       const unsigned int            active_fe_index,
-                       const unsigned int            active_quad_index,
-                       const unsigned int            face_type)
-  : data(&shape_info)
-  , dof_info(&dof_info)
+  FEEvaluationBaseData(const std::tuple<const ShapeInfoType &,
+                                        const DoFInfo &,
+                                        unsigned int,
+                                        unsigned int> &shape_dof_info,
+                       const MappingInfoStorageType &  mapping_data,
+                       const unsigned int              quad_no,
+                       const bool                      is_interior_face,
+                       const unsigned int              face_type)
+  : data(&std::get<0>(shape_dof_info))
+  , dof_info(&std::get<1>(shape_dof_info))
   , mapping_data(&mapping_data)
   , quad_no(quad_no)
-  , active_fe_index(active_fe_index)
-  , active_quad_index(active_quad_index)
+  , active_fe_index(std::get<2>(shape_dof_info))
+  , active_quad_index(std::get<3>(shape_dof_info))
   , descriptor(
       &mapping_data.descriptor
          [is_face ?

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.