From: Jean-Paul Pelteret Date: Tue, 28 Apr 2020 18:16:19 +0000 (+0200) Subject: Add range based loop for QPoints to FEValuesBase X-Git-Tag: v9.2.0-rc1~155^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82304bbbbff0c6db96f761a34b829fff8b330779;p=dealii.git Add range based loop for QPoints to FEValuesBase --- diff --git a/doc/news/changes/minor/20200429Jean-PaulPelteret b/doc/news/changes/minor/20200429Jean-PaulPelteret new file mode 100644 index 0000000000..c1fe3efbec --- /dev/null +++ b/doc/news/changes/minor/20200429Jean-PaulPelteret @@ -0,0 +1,5 @@ +New: There is a new function FEValuesBase::quadrature_point_indices() +that makes writing range-based for loops over all quadrature points of a +cell or face much simpler. +
+(Jean-Paul Pelteret, 2020/04/29) diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 9488af2116..5ddb4ca914 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -39,6 +39,8 @@ #include +#include + #include #include #include @@ -2912,6 +2914,27 @@ public: /// @name Geometry of the cell //@{ + /** + * 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 of the following kind: + * @code + * FEValues fe_values (...); + * + * for (auto &cell : dof_handler.active_cell_iterators()) + * { + * fe_values.reinit(cell); + * for (const auto q_point : fe_values.quadrature_point_indices()) + * ... do something at the quadrature point ... + * } + * @endcode + * Here, we are looping over all quadrature points on all cells, with + * `q_point` taking on all valid indices for quadrature points, as defined + * by the quadrature rule passed to `fe_values`. + */ + boost::integer_range + quadrature_point_indices() const; + /** * Position of the qth quadrature point in real space. * @@ -5406,6 +5429,15 @@ FEValuesBase::get_inverse_jacobians() const +template +inline boost::integer_range +FEValuesBase::quadrature_point_indices() const +{ + return boost::irange(0U, n_quadrature_points); +} + + + template inline const Point & FEValuesBase::quadrature_point(const unsigned int i) const