From: Martin Kronbichler Date: Mon, 19 Jun 2023 16:58:34 +0000 (+0200) Subject: Make FE_EVAL_FACTORY_DEGREE_MAX more robust X-Git-Tag: v9.5.0-rc1~85^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f072c7f0a9f524a4572528dfff09a5addd4f90bc;p=dealii.git Make FE_EVAL_FACTORY_DEGREE_MAX more robust --- diff --git a/include/deal.II/matrix_free/evaluation_kernels.h b/include/deal.II/matrix_free/evaluation_kernels.h index 0f083d655c..422c597c0a 100644 --- a/include/deal.II/matrix_free/evaluation_kernels.h +++ b/include/deal.II/matrix_free/evaluation_kernels.h @@ -5856,6 +5856,20 @@ namespace internal } }; + /** + * This struct is used to implement + * FEEvaluation::fast_evaluation_supported() and + * FEFaceEvaluation::fast_evaluation_supported(). + */ + struct FastEvaluationSupported + { + template + static bool + run() + { + return fe_degree != -1; + } + }; } // end of namespace internal diff --git a/include/deal.II/matrix_free/evaluation_template_face_factory.templates.h b/include/deal.II/matrix_free/evaluation_template_face_factory.templates.h index fa068963ba..e9c541136b 100644 --- a/include/deal.II/matrix_free/evaluation_template_face_factory.templates.h +++ b/include/deal.II/matrix_free/evaluation_template_face_factory.templates.h @@ -118,6 +118,21 @@ namespace internal fe_eval); } + + + // It is important that this file sits in the same compilation unit as the + // evaluate() and integrate() calls of this class, to ensure that all + // options choose the same code path when compiling FEFaceEvaluationFactory + // outside of deal.II. + template + bool + FEFaceEvaluationFactory::fast_evaluation_supported( + const unsigned int given_degree, + const unsigned int n_q_points_1d) + { + return instantiation_helper_run<1, FastEvaluationSupported>(given_degree, + n_q_points_1d); + } } // end of namespace internal DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/matrix_free/evaluation_template_factory.h b/include/deal.II/matrix_free/evaluation_template_factory.h index a179402e54..0d8e036c33 100644 --- a/include/deal.II/matrix_free/evaluation_template_factory.h +++ b/include/deal.II/matrix_free/evaluation_template_factory.h @@ -71,6 +71,10 @@ namespace internal const EvaluationFlags::EvaluationFlags integration_flag, Number * values_dofs, FEEvaluationData & fe_eval); + + static bool + fast_evaluation_supported(const unsigned int given_degree, + const unsigned int n_q_points_1d); }; 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 bd0f37fda6..51b98ee4d0 100644 --- a/include/deal.II/matrix_free/evaluation_template_factory.templates.h +++ b/include/deal.II/matrix_free/evaluation_template_factory.templates.h @@ -29,18 +29,6 @@ DEAL_II_NAMESPACE_OPEN namespace internal { - struct FastEvaluationSupported - { - template - static bool - run() - { - return fe_degree != -1; - } - }; - - - template void FEEvaluationFactory::evaluate( @@ -81,6 +69,10 @@ namespace internal + // It is important that this file sits in the same compilation unit as the + // evaluate() and integrate() calls of this class, to ensure that all + // options choose the same code path when compiling FEFaceEvaluationFactory + // outside of deal.II. template bool FEEvaluationFactory::fast_evaluation_supported( diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index a171bcda11..59b8f75c6b 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -1709,8 +1709,16 @@ protected: * setting the macro `FE_EVAL_FACTORY_DEGREE_MAX` to the desired integer and * instantiating the classes FEEvaluationFactory and FEFaceEvaluationFactory * (the latter for FEFaceEvaluation) creates paths to templated functions for - * a possibly larger set of degrees. You can check if fast - * evaluation/integration for a given degree/n_quadrature_points pair by calling + * a possibly larger set of degrees. This can both be set when configuring + * deal.II by passing the flag `-D FE_EVAL_FACTORY_DEGREE_MAX=8` (in case you + * want to compile all degrees up to eight; recommended setting) or by + * compiling `evaluation_template_factory.templates.h` and + * `evaluation_template_face_factory.templates.h` with the + * `FE_EVAL_FACTORY_DEGREE_MAX` overriden to the desired value. In the second + * option, symbols will be available twice, and it depends on your linker and + * dynamic library loader whether the user-specified setting takes + * precendence. You can check if fast evaluation/integration for a given + * degree/n_quadrature_points pair by calling * FEEvaluation::fast_evaluation_supported() or * FEFaceEvaluation::fast_evaluation_supported(). * @@ -9249,7 +9257,7 @@ FEFaceEvaluation:: + internal::FEFaceEvaluationFactory:: fast_evaluation_supported(given_degree, given_n_q_points_1d) : true; }