From b6f96d099622b366d20ce32473b0752bf12e88bf Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 21 Jan 2020 19:59:54 -0700 Subject: [PATCH] Provide GeometryInfo::face_indices(). --- include/deal.II/base/geometry_info.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/deal.II/base/geometry_info.h b/include/deal.II/base/geometry_info.h index 496149883e..76e752e8e2 100644 --- a/include/deal.II/base/geometry_info.h +++ b/include/deal.II/base/geometry_info.h @@ -22,6 +22,8 @@ #include #include +#include + #include @@ -1835,6 +1837,23 @@ struct GeometryInfo */ static constexpr unsigned int faces_per_cell = 2 * dim; + /** + * Return an object that can be thought of as an array containing all + * indices from zero to `faces_per_cell`. This allows to write code + * using range-based for loops of the following kind: + * @code + * for (auto &cell : triangulation.active_cell_iterators()) + * for (auto face_index : GeometryInfo::face_indices) + * if (cell->face(face_index)->at_boundary()) + * ... do something ... + * @endcode + * Here, we are looping over all faces of all cells, with `face_index` + * taking on all valid indices for faces (zero and one in 1d, zero + * through three in 2d, and zero through 5 in 3d). + */ + static boost::integer_range + face_indices(); + /** * Maximum number of children of a refined face, i.e. the number of children * of an isotropically refined face. @@ -2667,6 +2686,14 @@ GeometryInfo<3>::unit_cell_vertex(const unsigned int vertex) +template +boost::integer_range +GeometryInfo::face_indices() +{ + return boost::irange(0U, faces_per_cell); +} + + template inline Point GeometryInfo::unit_cell_vertex(const unsigned int) -- 2.39.5