]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Provide GeometryInfo::face_indices().
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 22 Jan 2020 02:59:54 +0000 (19:59 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 22 Jan 2020 02:59:54 +0000 (19:59 -0700)
include/deal.II/base/geometry_info.h

index 496149883ef468165196d0a85e271039dc39d7a6..76e752e8e2778e390297a92039955d2112ae5fed 100644 (file)
@@ -22,6 +22,8 @@
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/point.h>
 
+#include <boost/range/irange.hpp>
+
 #include <cstdint>
 
 
@@ -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<dim>::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<unsigned int>
+  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 <int dim>
+boost::integer_range<unsigned int>
+GeometryInfo<dim>::face_indices()
+{
+  return boost::irange(0U, faces_per_cell);
+}
+
+
 template <int dim>
 inline Point<dim>
 GeometryInfo<dim>::unit_cell_vertex(const unsigned int)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.