From 9d4fae778109374dbb9ac2e4438162d758bfc579 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Wed, 8 Dec 2021 20:49:51 +0100 Subject: [PATCH] FEEvaluationImplHangingNodes: use ShapeInfo as input argument --- .../evaluation_kernels_hanging_nodes.h | 96 +++++++------------ .../matrix_free/evaluation_template_factory.h | 27 +----- ...template_factory_hanging_nodes.templates.h | 38 ++------ include/deal.II/matrix_free/fe_evaluation.h | 2 +- include/deal.II/matrix_free/tools.h | 2 +- tests/matrix_free/hanging_node_kernels_01.cc | 7 +- 6 files changed, 53 insertions(+), 119 deletions(-) diff --git a/include/deal.II/matrix_free/evaluation_kernels_hanging_nodes.h b/include/deal.II/matrix_free/evaluation_kernels_hanging_nodes.h index 850ce2f5b4..9999b81172 100644 --- a/include/deal.II/matrix_free/evaluation_kernels_hanging_nodes.h +++ b/include/deal.II/matrix_free/evaluation_kernels_hanging_nodes.h @@ -23,6 +23,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -80,19 +81,17 @@ namespace internal template + typename Number> class FEEvaluationImplHangingNodesRunner; - template + template class FEEvaluationImplHangingNodesRunner< FEEvaluationImplHangingNodesRunnerTypes::vectorized, dim, fe_degree, - Number, - is_face> + Number> { private: template @@ -187,29 +186,21 @@ namespace internal public: template static void - run_internal(const unsigned int n_components, - const FEEvaluationBaseData &fe_eval, + run_internal(const unsigned int n_components, + const MatrixFreeFunctions::ShapeInfo &shape_info, const std::array & constraint_mask, - Number * values) + Number::size()> & constraint_mask, + Number * values) { using Kinds = MatrixFreeFunctions::ConstraintKinds; const unsigned int given_degree = - fe_degree != -1 ? fe_degree : - fe_eval.get_shape_info().data.front().fe_degree; + fe_degree != -1 ? fe_degree : shape_info.data.front().fe_degree; const Number *DEAL_II_RESTRICT weights = - fe_eval.get_shape_info() - .data.front() - .subface_interpolation_matrices[0] - .data(); + shape_info.data.front().subface_interpolation_matrices[0].data(); const unsigned int points = given_degree + 1; - const unsigned int n_dofs = - fe_eval.get_shape_info().dofs_per_component_on_cell; + const unsigned int n_dofs = shape_info.dofs_per_component_on_cell; if (dim == 2) { @@ -479,11 +470,9 @@ namespace internal template static inline const std::array, 2> & - get_interpolation_matrix(const T &fe_eval) + get_interpolation_matrix(const T &shape_info) { - return fe_eval.get_shape_info() - .data.front() - .subface_interpolation_matrices_scalar; + return shape_info.data.front().subface_interpolation_matrices_scalar; } static inline DEAL_II_ALWAYS_INLINE_RELEASE unsigned int @@ -553,11 +542,9 @@ namespace internal template static inline const std::array, 2> & - get_interpolation_matrix(const T &fe_eval) + get_interpolation_matrix(const T &shape_info) { - return fe_eval.get_shape_info() - .data.front() - .subface_interpolation_matrices; + return shape_info.data.front().subface_interpolation_matrices; } static inline DEAL_II_ALWAYS_INLINE_RELEASE bool @@ -620,11 +607,9 @@ namespace internal template static inline const std::array, 2> & - get_interpolation_matrix(const T &fe_eval) + get_interpolation_matrix(const T &shape_info) { - return fe_eval.get_shape_info() - .data.front() - .subface_interpolation_matrices; + return shape_info.data.front().subface_interpolation_matrices; } static inline DEAL_II_ALWAYS_INLINE_RELEASE bool @@ -694,11 +679,9 @@ namespace internal template static inline const std::array, 2> & - get_interpolation_matrix(const T &fe_eval) + get_interpolation_matrix(const T &shape_info) { - return fe_eval.get_shape_info() - .data.front() - .subface_interpolation_matrices; + return shape_info.data.front().subface_interpolation_matrices; } static inline DEAL_II_ALWAYS_INLINE_RELEASE bool @@ -1469,13 +1452,12 @@ namespace internal }; - template + template class FEEvaluationImplHangingNodesRunner< FEEvaluationImplHangingNodesRunnerTypes::scalar, dim, fe_degree, - Number, - is_face> + Number> { public: static const VectorizationTypes VectorizationType = @@ -1537,21 +1519,17 @@ namespace internal public: template static void - run_internal(const unsigned int n_desired_components, - const FEEvaluationBaseData &fe_eval, + run_internal(const unsigned int n_desired_components, + const MatrixFreeFunctions::ShapeInfo &shape_info, const std::array & constraint_mask, - Number * values) + Number::size()> & constraint_mask, + Number * values) { const unsigned int given_degree = - fe_degree != -1 ? fe_degree : - fe_eval.get_shape_info().data.front().fe_degree; + fe_degree != -1 ? fe_degree : shape_info.data.front().fe_degree; const auto &interpolation_matrices = - Trait::get_interpolation_matrix(fe_eval); + Trait::get_interpolation_matrix(shape_info); const auto constraint_mask_sorted = Trait::create_mask(constraint_mask); @@ -1720,25 +1698,22 @@ namespace internal } } - values += fe_eval.get_shape_info().dofs_per_component_on_cell; + values += shape_info.dofs_per_component_on_cell; } } }; - template + template struct FEEvaluationImplHangingNodes { public: template static bool - run(const unsigned int n_desired_components, - const FEEvaluationBaseData &fe_eval, - const bool transpose, + run(const unsigned int n_desired_components, + const MatrixFreeFunctions::ShapeInfo &shape_info, + const bool transpose, const std::array & c_mask, Number *values) @@ -1747,17 +1722,16 @@ namespace internal FEEvaluationImplHangingNodesRunner(), dim, fe_degree, - Number, - is_face>; + Number>; if (transpose) RunnerType::template run_internal(n_desired_components, - fe_eval, + shape_info, c_mask, values); else RunnerType::template run_internal(n_desired_components, - fe_eval, + shape_info, c_mask, values); diff --git a/include/deal.II/matrix_free/evaluation_template_factory.h b/include/deal.II/matrix_free/evaluation_template_factory.h index 50ac727c87..1dbeef01a3 100644 --- a/include/deal.II/matrix_free/evaluation_template_factory.h +++ b/include/deal.II/matrix_free/evaluation_template_factory.h @@ -199,33 +199,14 @@ namespace internal typename VectorizedArrayType = VectorizedArray> struct FEEvaluationHangingNodesFactory { - /** - * For cells. - */ static void apply(const unsigned int n_components, const unsigned int fe_degree, - const FEEvaluationBaseData - & fe_eval, - const bool transpose, - const std::array &c_mask, - VectorizedArrayType * values); - - /** - * For faces. - * - * @note Not implemented. - */ - static void - apply(const unsigned int n_components, - const unsigned int fe_degree, - const FEEvaluationBaseData - & fe_eval, - const bool transpose, + const MatrixFreeFunctions::ShapeInfo &shape_info, + const bool transpose, const std::array &c_mask, - VectorizedArrayType * values); + VectorizedArrayType::size()> & c_mask, + VectorizedArrayType * values); }; } // end of namespace internal diff --git a/include/deal.II/matrix_free/evaluation_template_factory_hanging_nodes.templates.h b/include/deal.II/matrix_free/evaluation_template_factory_hanging_nodes.templates.h index 3c37bdd339..c1622f2859 100644 --- a/include/deal.II/matrix_free/evaluation_template_factory_hanging_nodes.templates.h +++ b/include/deal.II/matrix_free/evaluation_template_factory_hanging_nodes.templates.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include DEAL_II_NAMESPACE_OPEN @@ -32,38 +32,18 @@ namespace internal template void FEEvaluationHangingNodesFactory::apply( - const unsigned int n_components, - const unsigned int fe_degree, - const FEEvaluationBaseData - & fe_eval, - const bool transpose, + const unsigned int n_components, + const unsigned int fe_degree, + const MatrixFreeFunctions::ShapeInfo &shape_info, + const bool transpose, const std::array &c_mask, - VectorizedArrayType * values) + VectorizedArrayType::size()> & c_mask, + VectorizedArrayType * values) { instantiation_helper_degree_run< 1, - FEEvaluationImplHangingNodes>( - fe_degree, n_components, fe_eval, transpose, c_mask, values); - } - - - - template - void - FEEvaluationHangingNodesFactory::apply( - const unsigned int n_components, - const unsigned int fe_degree, - const FEEvaluationBaseData &fe_eval, - const bool transpose, - const std::array &c_mask, - VectorizedArrayType * values) - { - instantiation_helper_degree_run< - 1, - FEEvaluationImplHangingNodes>( - fe_degree, n_components, fe_eval, transpose, c_mask, values); + FEEvaluationImplHangingNodes>( + fe_degree, n_components, shape_info, transpose, c_mask, values); } } // end of namespace internal diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index ca1be236f1..954113378d 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -4495,7 +4495,7 @@ FEEvaluationBase:: internal::FEEvaluationHangingNodesFactory:: apply(n_components, this->data->data.front().fe_degree, - *this, + this->get_shape_info(), transpose, constraint_mask, this->values_dofs); diff --git a/include/deal.II/matrix_free/tools.h b/include/deal.II/matrix_free/tools.h index cc2cf6aa88..ef1a1c5e1a 100644 --- a/include/deal.II/matrix_free/tools.h +++ b/include/deal.II/matrix_free/tools.h @@ -489,7 +489,7 @@ namespace MatrixFreeTools phi.get_shape_info() .data.front() .fe_degree, - phi, + phi.get_shape_info(), false, constraint_mask, values_dofs.data()); diff --git a/tests/matrix_free/hanging_node_kernels_01.cc b/tests/matrix_free/hanging_node_kernels_01.cc index 3569d72c77..c51c937738 100644 --- a/tests/matrix_free/hanging_node_kernels_01.cc +++ b/tests/matrix_free/hanging_node_kernels_01.cc @@ -487,10 +487,9 @@ test(const unsigned int degree, dim, VectorizedArray, false>::template run<-1, -1>(eval, b == 1, cmask, values1.data()); - internal::FEEvaluationImplHangingNodes< - dim, - VectorizedArray, - false>::template run<-1, -1>(1, eval, b == 1, cmask, values2.data()); + internal::FEEvaluationImplHangingNodes>:: + template run<-1, -1>( + 1, eval.get_shape_info(), b == 1, cmask, values2.data()); for (const auto i : values1) deallog << i[0] << " "; -- 2.39.5