From bfd1ef02af2cf9be27eec8094c1df982d2caa78a Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Wed, 8 Dec 2021 13:49:44 -0500 Subject: [PATCH] Move compute_mapping_data into internal namespace --- .../deal.II/matrix_free/fe_point_evaluation.h | 116 +++++++----------- source/matrix_free/fe_point_evaluation.cc | 7 +- tests/matrix_free/point_evaluation_15.cc | 9 +- tests/matrix_free/point_evaluation_16.cc | 9 +- 4 files changed, 64 insertions(+), 77 deletions(-) diff --git a/include/deal.II/matrix_free/fe_point_evaluation.h b/include/deal.II/matrix_free/fe_point_evaluation.h index ddd9007e0e..ad4141bfd0 100644 --- a/include/deal.II/matrix_free/fe_point_evaluation.h +++ b/include/deal.II/matrix_free/fe_point_evaluation.h @@ -364,18 +364,52 @@ namespace internal template std::vector> get_polynomial_space(const FiniteElement &fe); + + /** + * Compute the mapping related data for the given @p mapping, + * @p cell and @p unit_points that is required by the FEPointEvaluation + * class. + */ + template + void + compute_mapping_data_for_generic_points( + const Mapping & mapping, + const typename Triangulation::cell_iterator &cell, + const ArrayView> & unit_points, + const UpdateFlags update_flags, + internal::FEValuesImplementation::MappingRelatedData + &mapping_data) + { + UpdateFlags update_flags_mapping = update_default; + // translate update flags + if (update_flags & update_jacobians) + update_flags_mapping |= update_jacobians; + if (update_flags & update_gradients || + update_flags & update_inverse_jacobians) + update_flags_mapping |= update_inverse_jacobians; + if (update_flags & update_quadrature_points) + update_flags_mapping |= update_quadrature_points; + + if (const MappingQ *mapping_q = + dynamic_cast *>(&mapping)) + { + mapping_q->fill_mapping_data_for_generic_points(cell, + unit_points, + update_flags_mapping, + mapping_data); + } + else if (const MappingCartesian *mapping_cartesian = + dynamic_cast *>( + &mapping)) + { + mapping_cartesian->fill_mapping_data_for_generic_points( + cell, unit_points, update_flags_mapping, mapping_data); + } + } } // namespace FEPointEvaluation } // namespace internal -template -void -compute_mapping_data( - const Mapping & mapping, - const typename Triangulation::cell_iterator &cell, - const ArrayView> & unit_points, - dealii::internal::FEValuesImplementation::MappingRelatedData - &mapping_data); - /** * This class provides an interface to the evaluation of interpolated solution * values and gradients on cells on arbitrary reference point positions. These @@ -461,8 +495,8 @@ public: * a precomputed @p mapping_data object. This function can be used * to avoid duplicated evaluation of the mapping if multiple * FEPointEvaluation objects for the different components of the same FESystem - * are used. You can retrieve the mapping data from a FEPointEvaluation object - * using the get_mapping_data() function. + * are used. You can precompute the mapping data + * using the function internal::FEPointEvaluation::compute_mapping_data(). * * @param[in] cell An iterator to the current cell * @@ -479,18 +513,6 @@ public: const dealii::internal::FEValuesImplementation:: MappingRelatedData &mapping_data); - /** - * Returns the mapping data that was computed during the last call to - * the reinit() function. This can be useful if multiple FEPointEvaluation - * objects are used for multiple components of a FESystem. The mapping data - * can be retrieved from the first FEPointEvaluation object and subsequently - * passed to the other objects, avoiding the need to recompute the mapping - * data. - */ - const dealii::internal::FEValuesImplementation::MappingRelatedData & - get_mapping_data() const; - /** * This function interpolates the finite element solution, represented by * `solution_values`, on the cell and `unit_points` passed to reinit(). @@ -811,43 +833,6 @@ FEPointEvaluation::FEPointEvaluation( } -template -void -compute_mapping_data_for_generic_points( - const Mapping & mapping, - const typename Triangulation::cell_iterator &cell, - const ArrayView> & unit_points, - const UpdateFlags update_flags, - dealii::internal::FEValuesImplementation::MappingRelatedData - &mapping_data) -{ - UpdateFlags update_flags_mapping = update_default; - // translate update flags - if (update_flags & update_jacobians) - update_flags_mapping |= update_jacobians; - if (update_flags & update_gradients || - update_flags & update_inverse_jacobians) - update_flags_mapping |= update_inverse_jacobians; - if (update_flags & update_quadrature_points) - update_flags_mapping |= update_quadrature_points; - - if (const MappingQ *mapping_q = - dynamic_cast *>(&mapping)) - { - mapping_q->fill_mapping_data_for_generic_points(cell, - unit_points, - update_flags_mapping, - mapping_data); - } - else if (const MappingCartesian *mapping_cartesian = - dynamic_cast *>(&mapping)) - { - mapping_cartesian->fill_mapping_data_for_generic_points( - cell, unit_points, update_flags_mapping, mapping_data); - } -} - - template void @@ -857,7 +842,7 @@ FEPointEvaluation::reinit( { // If using the fast path, we need to precompute the mapping data. if (!poly.empty()) - compute_mapping_data_for_generic_points( + internal::FEPointEvaluation::compute_mapping_data_for_generic_points( *mapping, cell, unit_points, update_flags_mapping, mapping_data); // then call the other version of this function with the precomputed data @@ -930,15 +915,6 @@ FEPointEvaluation::reinit( } -template -const dealii::internal::FEValuesImplementation::MappingRelatedData & -FEPointEvaluation::get_mapping_data() const -{ - return mapping_data; -} - - template void diff --git a/source/matrix_free/fe_point_evaluation.cc b/source/matrix_free/fe_point_evaluation.cc index 3770f18435..cbe0ef2fcb 100644 --- a/source/matrix_free/fe_point_evaluation.cc +++ b/source/matrix_free/fe_point_evaluation.cc @@ -83,14 +83,11 @@ namespace internal bool is_fast_path_supported(const Mapping &mapping) { - if (const MappingQ *mapping_q = - dynamic_cast *>(&mapping)) + if (dynamic_cast *>(&mapping)) { return true; } - else if (const MappingCartesian *mapping_cartesian = - dynamic_cast *>( - &mapping)) + else if (dynamic_cast *>(&mapping)) { return true; } diff --git a/tests/matrix_free/point_evaluation_15.cc b/tests/matrix_free/point_evaluation_15.cc index 8383e3870e..cb68738bad 100644 --- a/tests/matrix_free/point_evaluation_15.cc +++ b/tests/matrix_free/point_evaluation_15.cc @@ -112,7 +112,14 @@ test() evaluator1.evaluate(solution_values, EvaluationFlags::values | EvaluationFlags::gradients); - const auto &mapping_data = evaluator1.get_mapping_data(); + internal::FEValuesImplementation::MappingRelatedData mapping_data; + internal::FEPointEvaluation::compute_mapping_data_for_generic_points( + mapping, + cell, + unit_points, + update_values | update_gradients, + mapping_data); + evaluator2.reinit(cell, unit_points, mapping_data); evaluator2.evaluate(solution_values, EvaluationFlags::values | EvaluationFlags::gradients); diff --git a/tests/matrix_free/point_evaluation_16.cc b/tests/matrix_free/point_evaluation_16.cc index a7d8891b4f..dc01e6f75f 100644 --- a/tests/matrix_free/point_evaluation_16.cc +++ b/tests/matrix_free/point_evaluation_16.cc @@ -112,7 +112,14 @@ test(const unsigned int degree) evaluator.evaluate(solution_values, EvaluationFlags::values | EvaluationFlags::gradients); - const auto &mapping_data = evaluator.get_mapping_data(); + internal::FEValuesImplementation::MappingRelatedData mapping_data; + internal::FEPointEvaluation::compute_mapping_data_for_generic_points( + mapping, + cell, + unit_points, + update_values | update_gradients, + mapping_data); + evaluator2.reinit(cell, unit_points, mapping_data); evaluator2.evaluate(solution_values, EvaluationFlags::values | EvaluationFlags::gradients); -- 2.39.5