From: Peter Munch Date: Thu, 23 Mar 2023 18:34:19 +0000 (+0100) Subject: Introduce FEEvaluationImplSelector X-Git-Tag: v9.5.0-rc1~415^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=396808862ae9ffcdc9f8e416f713fcf5ce45868b;p=dealii.git Introduce FEEvaluationImplSelector --- diff --git a/include/deal.II/matrix_free/evaluation_kernels.h b/include/deal.II/matrix_free/evaluation_kernels.h index f58e20fc10..a2c6bb29b9 100644 --- a/include/deal.II/matrix_free/evaluation_kernels.h +++ b/include/deal.II/matrix_free/evaluation_kernels.h @@ -2261,15 +2261,16 @@ namespace internal * currently supports $0\leq fe\_degree \leq 9$ and $degree+1\leq * n\_q\_points\_1d\leq fe\_degree+2$. */ - template - struct FEEvaluationImplEvaluateSelector + template + struct FEEvaluationImplSelector { - template + template static bool run(const unsigned int n_components, const EvaluationFlags::EvaluationFlags evaluation_flag, - const Number * values_dofs, - FEEvaluationData & fe_eval) + VNumber * values_dofs, + FEEvaluationData & fe_eval, + const bool sum_into_values_array = false) { const auto element_type = fe_eval.get_shape_info().element_type; using ElementType = MatrixFreeFunctions::ElementType; @@ -2283,8 +2284,13 @@ namespace internal if (fe_degree >= 0 && fe_degree + 1 == n_q_points_1d && element_type == ElementType::tensor_symmetric_collocation) { - FEEvaluationImplCollocation::evaluate( - n_components, evaluation_flag, values_dofs, fe_eval); + evaluate_or_integrate< + FEEvaluationImplCollocation>( + n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } // '<=' on type means tensor_symmetric or tensor_symmetric_hermite, see // shape_info.h for more details @@ -2292,90 +2298,160 @@ namespace internal use_collocation_evaluation(fe_degree, n_q_points_1d) && element_type <= ElementType::tensor_symmetric) { - FEEvaluationImplTransformToCollocation< - dim, - fe_degree, - n_q_points_1d, - Number>::evaluate(n_components, - evaluation_flag, - values_dofs, - fe_eval); + evaluate_or_integrate< + FEEvaluationImplTransformToCollocation>( + n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } else if (fe_degree >= 0 && element_type <= ElementType::tensor_symmetric_no_collocation) { - FEEvaluationImpl::evaluate(n_components, - evaluation_flag, - values_dofs, - fe_eval); + evaluate_or_integrate>( + n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } else if (element_type == ElementType::tensor_symmetric_plus_dg0) { - FEEvaluationImpl::evaluate(n_components, - evaluation_flag, - values_dofs, - fe_eval); + evaluate_or_integrate< + FEEvaluationImpl>(n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } else if (element_type == ElementType::truncated_tensor) { - FEEvaluationImpl::evaluate(n_components, - evaluation_flag, - values_dofs, - fe_eval); + evaluate_or_integrate>( + n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } else if (element_type == ElementType::tensor_none) { - FEEvaluationImpl::evaluate(n_components, - evaluation_flag, - values_dofs, - fe_eval); + evaluate_or_integrate>( + n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } else if (element_type == ElementType::tensor_raviart_thomas) { - FEEvaluationImpl< - ElementType::tensor_raviart_thomas, - dim, - (fe_degree == -1) ? 1 : fe_degree, - (n_q_points_1d < 1) ? 1 : n_q_points_1d, - Number>::template evaluate_or_integrate(evaluation_flag, - const_cast( - values_dofs), - fe_eval); + FEEvaluationImpl:: + template evaluate_or_integrate(evaluation_flag, + const_cast( + values_dofs), + fe_eval, + sum_into_values_array); } else { - FEEvaluationImpl::evaluate(n_components, - evaluation_flag, - values_dofs, - fe_eval); + evaluate_or_integrate>( + n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); } return false; } + + private: + template + static void + evaluate_or_integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const Number * values_dofs, + FEEvaluationData & fe_eval, + const bool sum_into_values_array, + std::integral_constant) + { + (void)sum_into_values_array; + + T::evaluate(n_components, evaluation_flag, values_dofs, fe_eval); + } + + template + static void + evaluate_or_integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + Number * values_dofs, + FEEvaluationData & fe_eval, + const bool sum_into_values_array, + std::integral_constant) + { + T::integrate(n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array); + } + + template + static void + evaluate_or_integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + VNumber * values_dofs, + FEEvaluationData & fe_eval, + const bool sum_into_values_array) + { + evaluate_or_integrate(n_components, + evaluation_flag, + values_dofs, + fe_eval, + sum_into_values_array, + std::integral_constant()); + } }; + template + struct FEEvaluationImplEvaluateSelector + : public FEEvaluationImplSelector + {}; + + + /** * This class chooses an appropriate evaluation strategy based on the * template parameters and the shape_info variable which contains runtime @@ -2393,128 +2469,8 @@ namespace internal */ template struct FEEvaluationImplIntegrateSelector - { - template - static bool - run(const unsigned int n_components, - const EvaluationFlags::EvaluationFlags integration_flag, - Number * values_dofs, - FEEvaluationData & fe_eval, - const bool sum_into_values_array) - { - const auto element_type = fe_eval.get_shape_info().element_type; - using ElementType = MatrixFreeFunctions::ElementType; - - Assert(fe_eval.get_shape_info().data.size() == 1 || - (fe_eval.get_shape_info().data.size() == dim && - element_type == ElementType::tensor_general) || - element_type == ElementType::tensor_raviart_thomas, - ExcNotImplemented()); - - if (fe_degree >= 0 && fe_degree + 1 == n_q_points_1d && - element_type == ElementType::tensor_symmetric_collocation) - { - FEEvaluationImplCollocation::integrate( - n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - // '<=' on type means tensor_symmetric or tensor_symmetric_hermite, see - // shape_info.h for more details - else if (fe_degree >= 0 && - use_collocation_evaluation(fe_degree, n_q_points_1d) && - element_type <= ElementType::tensor_symmetric) - { - FEEvaluationImplTransformToCollocation< - dim, - fe_degree, - n_q_points_1d, - Number>::integrate(n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - else if (fe_degree >= 0 && - element_type <= ElementType::tensor_symmetric_no_collocation) - { - FEEvaluationImpl::integrate(n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - else if (element_type == ElementType::tensor_symmetric_plus_dg0) - { - FEEvaluationImpl::integrate(n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - else if (element_type == ElementType::truncated_tensor) - { - FEEvaluationImpl::integrate(n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - else if (element_type == ElementType::tensor_none) - { - FEEvaluationImpl::integrate(n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - else if (element_type == ElementType::tensor_raviart_thomas) - { - FEEvaluationImpl:: - template evaluate_or_integrate(integration_flag, - const_cast( - values_dofs), - fe_eval, - sum_into_values_array); - } - else - { - FEEvaluationImpl::integrate(n_components, - integration_flag, - values_dofs, - fe_eval, - sum_into_values_array); - } - - return false; - } - }; + : public FEEvaluationImplSelector + {};