--- /dev/null
+Improved: To be consistent with the FEValues classes, one can now
+loop over all DoF and quadrature-point indices in a
+range-based loop with the help of the new functions dof_indices() and
+quadrature_point_indices().
+<br>
+(Peter Munch, 2022/02/06)
const bool integrate_gradients,
VectorType &output_vector);
+ /**
+ * Return an object that can be thought of as an array containing all indices
+ * from zero to @p dofs_per_cell. This allows to write code using
+ * range-based for loops.
+ */
+ std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+ dof_indices() const;
+
/**
* The number of degrees of freedom of a single component on the cell for
* the underlying evaluation object. Usually close to
const bool integrate_gradients,
VectorType &output_vector);
+ /**
+ * Return an object that can be thought of as an array containing all indices
+ * from zero to @p dofs_per_cell. This allows to write code using
+ * range-based for loops.
+ */
+ std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+ dof_indices() const;
+
/**
* The number of degrees of freedom of a single component on the cell for
* the underlying evaluation object. Usually close to
+template <int dim,
+ int fe_degree,
+ int n_q_points_1d,
+ int n_components_,
+ typename Number,
+ typename VectorizedArrayType>
+inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+FEEvaluation<dim,
+ fe_degree,
+ n_q_points_1d,
+ n_components_,
+ Number,
+ VectorizedArrayType>::dof_indices() const
+{
+ return {0U, dofs_per_cell};
+}
+
+
+
/*-------------------------- FEFaceEvaluation ---------------------------*/
+template <int dim,
+ int fe_degree,
+ int n_q_points_1d,
+ int n_components_,
+ typename Number,
+ typename VectorizedArrayType>
+inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+FEFaceEvaluation<dim,
+ fe_degree,
+ n_q_points_1d,
+ n_components_,
+ Number,
+ VectorizedArrayType>::dof_indices() const
+{
+ return {0U, dofs_per_cell};
+}
+
+
+
template <int dim,
int fe_degree,
int n_q_points_1d,
return face_ids;
}
+ /**
+ * Return an object that can be thought of as an array containing all indices
+ * from zero to @p n_quadrature_points. This allows to write code using
+ * range-based for loops.
+ */
+ std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+ quadrature_point_indices() const;
+
//@}
/**
+template <int dim, typename Number, bool is_face>
+inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+FEEvaluationData<dim, Number, is_face>::quadrature_point_indices() const
+{
+ return {0U, n_quadrature_points};
+}
+
+
+
namespace internal
{
template <std::size_t N,
phi_m.read_dof_values(src);
- for (unsigned int i = 0; i < phi_m.static_dofs_per_component; ++i)
+ for (const auto i : phi_m.dof_indices())
deallog << static_cast<int>(phi_m.begin_dof_values()[i][0])
<< ' ';
deallog << std::endl;
phi_m.gather_evaluate(src, EvaluationFlags::values);
- for (unsigned int i = 0; i < phi_m.static_n_q_points; ++i)
- deallog << static_cast<int>(phi_m.begin_values()[i][0]) << ' ';
+ for (const auto q : phi_p.quadrature_point_indices())
+ deallog << static_cast<int>(phi_m.begin_values()[q][0]) << " ";
deallog << std::endl;
phi_p.read_dof_values(src);
- for (unsigned int i = 0; i < phi_p.static_dofs_per_component; ++i)
+ for (const auto i : phi_p.dof_indices())
deallog << static_cast<int>(phi_p.begin_dof_values()[i][0])
<< ' ';
deallog << std::endl;
phi_p.gather_evaluate(src, EvaluationFlags::values);
- for (unsigned int i = 0; i < phi_p.static_n_q_points; ++i)
- deallog << static_cast<int>(phi_p.begin_values()[i][0]) << ' ';
+ for (const auto q : phi_p.quadrature_point_indices())
+ deallog << static_cast<int>(phi_p.begin_values()[q][0]) << " ";
deallog << std::endl << std::endl;
}
}