From d3ad01e915b8bd4ec5194020d452f101df86f7c7 Mon Sep 17 00:00:00 2001
From: Peter Munch <peterrmuench@gmail.com>
Date: Thu, 23 Mar 2023 19:49:41 +0100
Subject: [PATCH] Remove derived classes

---
 .../deal.II/matrix_free/evaluation_kernels.h  | 48 +++++--------------
 .../deal.II/matrix_free/evaluation_selector.h |  4 +-
 .../evaluation_template_factory.templates.h   |  4 +-
 3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/include/deal.II/matrix_free/evaluation_kernels.h b/include/deal.II/matrix_free/evaluation_kernels.h
index a2c6bb29b9..bf994afb1b 100644
--- a/include/deal.II/matrix_free/evaluation_kernels.h
+++ b/include/deal.II/matrix_free/evaluation_kernels.h
@@ -2247,8 +2247,8 @@ namespace internal
 
 
   /**
-   * This class chooses an appropriate evaluation strategy based on the
-   * template parameters and the shape_info variable which contains runtime
+   * This class chooses an appropriate evaluation/integration strategy based on
+   * the template parameters and the shape_info variable which contains runtime
    * parameters for the strategy underlying FEEvaluation::evaluate(), i.e.
    * this calls internal::FEEvaluationImpl::evaluate(),
    * internal::FEEvaluationImplCollocation::evaluate() or
@@ -2264,14 +2264,21 @@ namespace internal
   template <int dim, typename Number, bool do_integrate>
   struct FEEvaluationImplSelector
   {
-    template <int fe_degree, int n_q_points_1d, typename VNumber>
+    template <int fe_degree, int n_q_points_1d, typename OtherNumber>
     static bool
     run(const unsigned int                     n_components,
         const EvaluationFlags::EvaluationFlags evaluation_flag,
-        VNumber *                              values_dofs,
+        OtherNumber *                          values_dofs,
         FEEvaluationData<dim, Number, false> & fe_eval,
         const bool                             sum_into_values_array = false)
     {
+      // `OtherNumber` is either `const Number` (evaluate()) or `Number`
+      // (integrate())
+      static_assert(
+        std::is_same<Number,
+                     typename std::remove_const<OtherNumber>::type>::value,
+        "Type of Number and of OtherNumber do not match.");
+
       const auto element_type = fe_eval.get_shape_info().element_type;
       using ElementType       = MatrixFreeFunctions::ElementType;
 
@@ -2425,12 +2432,12 @@ namespace internal
                    sum_into_values_array);
     }
 
-    template <typename T, typename VNumber>
+    template <typename T, typename OtherNumber>
     static void
     evaluate_or_integrate(
       const unsigned int                     n_components,
       const EvaluationFlags::EvaluationFlags evaluation_flag,
-      VNumber *                              values_dofs,
+      OtherNumber *                          values_dofs,
       FEEvaluationData<dim, Number, false> & fe_eval,
       const bool                             sum_into_values_array)
     {
@@ -2445,35 +2452,6 @@ namespace internal
 
 
 
-  template <int dim, typename Number>
-  struct FEEvaluationImplEvaluateSelector
-    : public FEEvaluationImplSelector<dim, Number, false>
-  {};
-
-
-
-  /**
-   * This class chooses an appropriate evaluation strategy based on the
-   * template parameters and the shape_info variable which contains runtime
-   * parameters for the strategy underlying FEEvaluation::integrate(), i.e.
-   * this calls internal::FEEvaluationImpl::integrate(),
-   * internal::FEEvaluationImplCollocation::integrate() or
-   * internal::FEEvaluationImplTransformToCollocation::integrate() with
-   * appropriate template parameters. In case the template parameters
-   * fe_degree and n_q_points_1d contain valid information (i.e. fe_degree>-1
-   * and n_q_points_1d>0), we simply pass these values to the respective
-   * template specializations.  Otherwise, we perform a runtime matching of
-   * the runtime parameters to find the correct specialization. This matching
-   * currently supports $0\leq fe\_degree \leq 9$ and $degree+1\leq
-   * n\_q\_points\_1d\leq fe\_degree+2$.
-   */
-  template <int dim, typename Number>
-  struct FEEvaluationImplIntegrateSelector
-    : public FEEvaluationImplSelector<dim, Number, true>
-  {};
-
-
-
   template <bool symmetric_evaluate,
             int  dim,
             int  fe_degree,
diff --git a/include/deal.II/matrix_free/evaluation_selector.h b/include/deal.II/matrix_free/evaluation_selector.h
index e8d164ff8f..05bb263d56 100644
--- a/include/deal.II/matrix_free/evaluation_selector.h
+++ b/include/deal.II/matrix_free/evaluation_selector.h
@@ -76,7 +76,7 @@ SelectEvaluator<dim, fe_degree, n_q_points_1d, Number>::evaluate(
 {
   Assert(fe_degree >= 0 && n_q_points_1d > 0, ExcInternalError());
 
-  internal::FEEvaluationImplEvaluateSelector<dim, Number>::template run<
+  internal::FEEvaluationImplSelector<dim, Number, false>::template run<
     fe_degree,
     n_q_points_1d>(n_components, evaluation_flag, values_dofs, eval);
 }
@@ -94,7 +94,7 @@ SelectEvaluator<dim, fe_degree, n_q_points_1d, Number>::integrate(
 {
   Assert(fe_degree >= 0 && n_q_points_1d > 0, ExcInternalError());
 
-  internal::FEEvaluationImplIntegrateSelector<dim, Number>::
+  internal::FEEvaluationImplSelector<dim, Number, true>::
     template run<fe_degree, n_q_points_1d>(
       n_components, integration_flag, values_dofs, eval, sum_into_values_array);
 }
diff --git a/include/deal.II/matrix_free/evaluation_template_factory.templates.h b/include/deal.II/matrix_free/evaluation_template_factory.templates.h
index 67eba41712..bd0f37fda6 100644
--- a/include/deal.II/matrix_free/evaluation_template_factory.templates.h
+++ b/include/deal.II/matrix_free/evaluation_template_factory.templates.h
@@ -49,7 +49,7 @@ namespace internal
     const Number *                         values_dofs,
     FEEvaluationData<dim, Number, false> & fe_eval)
   {
-    instantiation_helper_run<1, FEEvaluationImplEvaluateSelector<dim, Number>>(
+    instantiation_helper_run<1, FEEvaluationImplSelector<dim, Number, false>>(
       fe_eval.get_shape_info().data[0].fe_degree,
       fe_eval.get_shape_info().data[0].n_q_points_1d,
       n_components,
@@ -69,7 +69,7 @@ namespace internal
     FEEvaluationData<dim, Number, false> & fe_eval,
     const bool                             sum_into_values_array)
   {
-    instantiation_helper_run<1, FEEvaluationImplIntegrateSelector<dim, Number>>(
+    instantiation_helper_run<1, FEEvaluationImplSelector<dim, Number, true>>(
       fe_eval.get_shape_info().data[0].fe_degree,
       fe_eval.get_shape_info().data[0].n_q_points_1d,
       n_components,
-- 
2.39.5