From 291eabac628a326b9c2b2c4f785f69316ad0d81d Mon Sep 17 00:00:00 2001
From: Peter Munch <peterrmuench@gmail.com>
Date: Fri, 18 Dec 2020 12:12:05 +0100
Subject: [PATCH] Simplify constructor of FEEvaluationBaseData

---
 include/deal.II/matrix_free/fe_evaluation.h | 83 +++++++--------------
 1 file changed, 26 insertions(+), 57 deletions(-)

diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h
index 2018a77a27..0f42479794 100644
--- a/include/deal.II/matrix_free/fe_evaluation.h
+++ b/include/deal.II/matrix_free/fe_evaluation.h
@@ -335,22 +335,6 @@ protected:
    */
   const unsigned int quad_no;
 
-  /**
-   * The active fe index for this class for efficient indexing in the hp case.
-   */
-  const unsigned int active_fe_index;
-
-  /**
-   * The active quadrature index for this class for efficient indexing in the
-   * hp case.
-   */
-  const unsigned int active_quad_index;
-
-  /**
-   * The number of quadrature points in the current evaluation context.
-   */
-  const unsigned int n_quadrature_points;
-
   /**
    * A pointer to the underlying data.
    */
@@ -375,6 +359,22 @@ protected:
     Number,
     VectorizedArrayType> *mapping_data;
 
+  /**
+   * The active fe index for this class for efficient indexing in the hp case.
+   */
+  const unsigned int active_fe_index;
+
+  /**
+   * The active quadrature index for this class for efficient indexing in the
+   * hp case.
+   */
+  const unsigned int active_quad_index;
+
+  /**
+   * The number of quadrature points in the current evaluation context.
+   */
+  const unsigned int n_quadrature_points;
+
   /**
    * A pointer to the unit cell shape data, i.e., values, gradients and
    * Hessians in 1D at the quadrature points that constitute the tensor
@@ -3316,6 +3316,13 @@ inline FEEvaluationBaseData<dim, Number, is_face, VectorizedArrayType>::
     const unsigned int active_quad_index_in)
   : scratch_data_array(data_in.acquire_scratch_data())
   , quad_no(quad_no_in)
+  , matrix_info(&data_in)
+  , dof_info(&data_in.get_dof_info(dof_no))
+  , mapping_data(
+      internal::MatrixFreeFunctions::
+        MappingInfoCellsOrFaces<dim, Number, is_face, VectorizedArrayType>::get(
+          data_in.get_mapping_info(),
+          quad_no))
   , active_fe_index(fe_degree != numbers::invalid_unsigned_int ?
                       data_in.get_dof_info(dof_no).fe_index_from_degree(
                         first_selected_component,
@@ -3325,50 +3332,12 @@ inline FEEvaluationBaseData<dim, Number, is_face, VectorizedArrayType>::
                          0))
   , active_quad_index(
       fe_degree != numbers::invalid_unsigned_int ?
-        (is_face ? data_in.get_mapping_info()
-                     .face_data[quad_no_in]
-                     .quad_index_from_n_q_points(n_q_points) :
-                   data_in.get_mapping_info()
-                     .cell_data[quad_no_in]
-                     .quad_index_from_n_q_points(n_q_points)) :
+        (mapping_data->quad_index_from_n_q_points(n_q_points)) :
         (active_quad_index_in != numbers::invalid_unsigned_int ?
            active_quad_index_in :
            std::min<unsigned int>(active_fe_index,
-                                  (is_face ? data_in.get_mapping_info()
-                                               .face_data[quad_no_in]
-                                               .descriptor.size() :
-                                             data_in.get_mapping_info()
-                                               .cell_data[quad_no_in]
-                                               .descriptor.size()) -
-                                    1)))
-  , n_quadrature_points(
-      fe_degree != numbers::invalid_unsigned_int ?
-        n_q_points :
-        (is_face ? data_in
-                     .get_shape_info(
-                       dof_no,
-                       quad_no_in,
-                       data_in.get_dof_info(dof_no)
-                         .component_to_base_index[first_selected_component],
-                       active_fe_index,
-                       active_quad_index)
-                     .n_q_points_face :
-                   data_in
-                     .get_shape_info(
-                       dof_no,
-                       quad_no_in,
-                       data_in.get_dof_info(dof_no)
-                         .component_to_base_index[first_selected_component],
-                       active_fe_index,
-                       active_quad_index)
-                     .n_q_points))
-  , matrix_info(&data_in)
-  , dof_info(&data_in.get_dof_info(dof_no))
-  , mapping_data(
-      internal::MatrixFreeFunctions::
-        MappingInfoCellsOrFaces<dim, Number, is_face, VectorizedArrayType>::get(
-          data_in.get_mapping_info(),
-          quad_no))
+                                  mapping_data->descriptor.size() - 1)))
+  , n_quadrature_points(mapping_data->descriptor[active_quad_index].n_q_points)
   , data(&data_in.get_shape_info(
       dof_no,
       quad_no_in,
-- 
2.39.5