From 1860030fc4e941ed97cc7c7f9cc8458648682aa3 Mon Sep 17 00:00:00 2001 From: Maximilian Bergbauer Date: Tue, 21 Mar 2023 11:16:45 +0100 Subject: [PATCH] Introduce quadrature_points_indices() function for FEPointEvaluation --- .../deal.II/matrix_free/fe_point_evaluation.h | 22 +++++++++++++++++-- tests/non_matching/mapping_info.cc | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/deal.II/matrix_free/fe_point_evaluation.h b/include/deal.II/matrix_free/fe_point_evaluation.h index 76e714638d..5542e27027 100644 --- a/include/deal.II/matrix_free/fe_point_evaluation.h +++ b/include/deal.II/matrix_free/fe_point_evaluation.h @@ -630,9 +630,12 @@ public: unit_point(const unsigned int point_index) const; /** - * Number of quadrature points of the current cell/face. + * Return an object that can be thought of as an array containing all indices + * from zero to n_quadrature_points. This allows to write code using + * range-based for loops. */ - const unsigned int n_q_points; + inline std_cxx20::ranges::iota_view + quadrature_point_indices() const; private: /** @@ -646,6 +649,11 @@ private: void setup(const unsigned int first_selected_component); + /** + * Number of quadrature points of the current cell/face. + */ + const unsigned int n_q_points; + /** * Pointer to the Mapping object passed to the constructor. */ @@ -1406,6 +1414,16 @@ FEPointEvaluation::unit_point( return unit_points[point_index]; } + + +template +inline std_cxx20::ranges::iota_view +FEPointEvaluation:: + quadrature_point_indices() const +{ + return {0U, n_q_points}; +} + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/tests/non_matching/mapping_info.cc b/tests/non_matching/mapping_info.cc index f6c7988fea..612ed9185e 100644 --- a/tests/non_matching/mapping_info.cc +++ b/tests/non_matching/mapping_info.cc @@ -209,7 +209,7 @@ test(const bool filtered_compression) fe_point.evaluate(solution_values_in, EvaluationFlags::values | EvaluationFlags::gradients); - for (unsigned int q = 0; q < fe_point.n_q_points; ++q) + for (const auto q : fe_point.quadrature_point_indices()) { fe_point.submit_value(fe_point.JxW(q) * fe_point.get_value(q), q); fe_point.submit_gradient(fe_point.JxW(q) * fe_point.get_gradient(q), @@ -245,7 +245,7 @@ test(const bool filtered_compression) EvaluationFlags::values | EvaluationFlags::gradients); - for (unsigned int q = 0; q < fe_point_faces_m.n_q_points; ++q) + for (const auto q : fe_point_faces_m.quadrature_point_indices()) { fe_point_faces_m.submit_value(fe_point_faces_m.JxW(q) * (fe_point_faces_m.get_value(q) - -- 2.39.5