From 7e666260f9c13ae63ff7d8aef197a447029c2f8c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 24 Jan 2022 11:20:16 -0700 Subject: [PATCH] Introduce ReferenceCell::n_isotropic_children(). --- include/deal.II/grid/reference_cell.h | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 016476c862..28f8229f85 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -278,6 +278,27 @@ public: std_cxx20::ranges::iota_view 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 + 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 +ReferenceCell::isotropic_child_indices() const +{ + return {0U, n_isotropic_children()}; +} + + + inline std_cxx20::ranges::iota_view ReferenceCell::vertex_indices() const { -- 2.39.5