]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce ReferenceCell::n_isotropic_children().
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 24 Jan 2022 18:20:16 +0000 (11:20 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 26 Jan 2022 18:34:00 +0000 (11:34 -0700)
include/deal.II/grid/reference_cell.h

index 016476c862a09442f9c9bc6685c8fb906004ffd2..28f8229f8596a5f1ebb566fc1143004283a1a85b 100644 (file)
@@ -278,6 +278,27 @@ public:
   std_cxx20::ranges::iota_view<unsigned int, unsigned int>
   face_indices() const;
 
+  /**
+   * Return the number of cells one would get by isotropically
+   * refining the current cell. Here, "isotropic refinement"
+   * means that we subdivide in each "direction" of a cell.
+   * For example, a square would be refined into four children
+   * by introducing new vertices along each edge and a new
+   * vertex in the cell center. For triangles, one would introduce
+   * new vertices at the center of each edge, and connect them to
+   * obtain four children. Similar constructions can be done for
+   * the other reference cell types.
+   */
+  unsigned int
+  n_isotropic_children() const;
+
+  /**
+   * Return an object that can be thought of as an array containing all
+   * indices from zero to n_isotropic_children().
+   */
+  std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+  isotropic_child_indices() const;
+
   /**
    * Return the reference-cell type of face @p face_no of the current
    * object. For example, if the current object is
@@ -1026,6 +1047,45 @@ ReferenceCell::face_indices() const
 
 
 
+inline unsigned int
+ReferenceCell::n_isotropic_children() const
+{
+  if (*this == ReferenceCells::Vertex)
+    return 0;
+  else if (*this == ReferenceCells::Line)
+    return 2;
+  else if (*this == ReferenceCells::Triangle)
+    return 4;
+  else if (*this == ReferenceCells::Quadrilateral)
+    return 4;
+  else if (*this == ReferenceCells::Tetrahedron)
+    return 8;
+  else if (*this == ReferenceCells::Pyramid)
+    {
+      // We haven't yet decided how to refine pyramids. Update
+      // this when we have
+      Assert(false, ExcNotImplemented());
+      return numbers::invalid_unsigned_int;
+    }
+  else if (*this == ReferenceCells::Wedge)
+    return 8;
+  else if (*this == ReferenceCells::Hexahedron)
+    return 8;
+
+  Assert(false, ExcNotImplemented());
+  return numbers::invalid_unsigned_int;
+}
+
+
+
+inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
+ReferenceCell::isotropic_child_indices() const
+{
+  return {0U, n_isotropic_children()};
+}
+
+
+
 inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
 ReferenceCell::vertex_indices() const
 {

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.