]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce quadrature_points_indices() function for FEPointEvaluation 14927/head
authorMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Tue, 21 Mar 2023 10:16:45 +0000 (11:16 +0100)
committerMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Tue, 21 Mar 2023 10:18:09 +0000 (11:18 +0100)
include/deal.II/matrix_free/fe_point_evaluation.h
tests/non_matching/mapping_info.cc

index 76e714638d375772621dece63cfa6744929002f5..5542e2702701312ae669c54016f81a460a0331d4 100644 (file)
@@ -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<unsigned int, unsigned int>
+  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<n_components, dim, spacedim, Number>::unit_point(
   return unit_points[point_index];
 }
 
+
+
+template <int n_components, int dim, int spacedim, typename Number>
+inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+FEPointEvaluation<n_components, dim, spacedim, Number>::
+  quadrature_point_indices() const
+{
+  return {0U, n_q_points};
+}
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
index f6c7988feae0108bdfbcf443ba8b214af222f974..612ed9185e9872db121d658d32bbb6d9beef6361 100644 (file)
@@ -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) -

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.