From: Wolfgang Bangerth Date: Wed, 4 Mar 2020 22:29:17 +0000 (-0700) Subject: Add GeometryInfo::vertex_indices(). X-Git-Tag: v9.2.0-rc1~454^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7943dc1982e5013cb0552f07d5d96954801a1546;p=dealii.git Add GeometryInfo::vertex_indices(). --- 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)