From 7943dc1982e5013cb0552f07d5d96954801a1546 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 4 Mar 2020 15:29:17 -0700 Subject: [PATCH] Add GeometryInfo::vertex_indices(). --- include/deal.II/base/geometry_info.h | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/include/deal.II/base/geometry_info.h b/include/deal.II/base/geometry_info.h index 966b584b7b..1f15383965 100644 --- a/include/deal.II/base/geometry_info.h +++ b/include/deal.II/base/geometry_info.h @@ -1301,6 +1301,27 @@ struct GeometryInfo<0> */ static constexpr unsigned int vertices_per_cell = 1; + /** + * Return an object that can be thought of as an array containing all + * indices from zero to `vertices_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 vertex_index : GeometryInfo::vertex_indices()) + * if (cell->vertex(vertex_index) satisfies some condition) + * ... do something ... + * @endcode + * Here, we are looping over all vertices of all cells, with `vertex_index` + * taking on all valid indices. + * + * Of course, since this class is for the case `dim==0`, the + * returned object is a array with just one entry: zero. That's + * because an of dimension zero is really just a single point, + * corresponding to a vertex itself. + */ + static std::array + vertex_indices(); + /** * Number of vertices each face has. Since this is not useful in one * dimension, we provide a useless number (in the hope that a compiler may @@ -1944,6 +1965,22 @@ struct GeometryInfo */ static constexpr unsigned int vertices_per_cell = 1 << dim; + /** + * Return an object that can be thought of as an array containing all + * indices from zero to `vertices_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 vertex_index : GeometryInfo::vertex_indices()) + * if (cell->vertex(vertex_index) satisfies some condition) + * ... do something ... + * @endcode + * Here, we are looping over all vertices of all cells, with `vertex_index` + * taking on all valid indices. + */ + static boost::integer_range + vertex_indices(); + /** * Number of vertices on each face. */ @@ -2787,6 +2824,14 @@ GeometryInfo<0>::face_indices() +inline std::array +GeometryInfo<0>::vertex_indices() +{ + return {{0}}; +} + + + template inline boost::integer_range GeometryInfo::face_indices() @@ -2796,6 +2841,15 @@ GeometryInfo::face_indices() +template +inline boost::integer_range +GeometryInfo::vertex_indices() +{ + return boost::irange(0U, vertices_per_cell); +} + + + template inline Point GeometryInfo::unit_cell_vertex(const unsigned int) -- 2.39.5