diff --git a/include/geom/cell_hex.h b/include/geom/cell_hex.h index af98d0e0258..86477d82374 100644 --- a/include/geom/cell_hex.h +++ b/include/geom/cell_hex.h @@ -77,6 +77,11 @@ class Hex : public Cell */ virtual unsigned int n_vertices() const override final { return 8; } + /** + * \returns 4. Every side has four vertices. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override final { return 4; } + /** * \returns 12. All hexahedra have 12 edges. */ diff --git a/include/geom/cell_inf_hex.h b/include/geom/cell_inf_hex.h index afceea8dff6..5272dec4a76 100644 --- a/include/geom/cell_inf_hex.h +++ b/include/geom/cell_inf_hex.h @@ -90,6 +90,11 @@ class InfHex : public InfCell */ virtual unsigned int n_vertices() const override final { return 8; } + /** + * \returns 4. Every side has four vertices. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override final { return 4; } + /** * \returns \p true if the specified (local) node number is a * "mid-edge" node on an infinite element edge. diff --git a/include/geom/cell_inf_prism.h b/include/geom/cell_inf_prism.h index b5db41e285b..1e627f7e089 100644 --- a/include/geom/cell_inf_prism.h +++ b/include/geom/cell_inf_prism.h @@ -86,6 +86,9 @@ class InfPrism : public InfCell */ virtual unsigned int n_vertices() const override final { return 6; } + virtual unsigned int n_vertices_on_side(const unsigned int side) const override final + { return 4 - (side == 0 || side == 4); } + /** * \returns 6. All infinite prisms have 6 edges, * 3 lying in the base, and 3 perpendicular to the base. diff --git a/include/geom/cell_prism.h b/include/geom/cell_prism.h index 78eb74efd88..b0cca8428dc 100644 --- a/include/geom/cell_prism.h +++ b/include/geom/cell_prism.h @@ -83,6 +83,9 @@ class Prism : public Cell */ virtual unsigned int n_vertices() const override final { return 6; } + virtual unsigned int n_vertices_on_side(const unsigned int side) const override final + { return 4 - (side == 0 || side == 4); } + /** * \returns 9. All prisms have 9 edges. */ diff --git a/include/geom/cell_pyramid.h b/include/geom/cell_pyramid.h index 96e6918f98a..ffb2cf03c8f 100644 --- a/include/geom/cell_pyramid.h +++ b/include/geom/cell_pyramid.h @@ -87,6 +87,9 @@ class Pyramid : public Cell */ virtual unsigned int n_vertices() const override { return 5; } + virtual unsigned int n_vertices_on_side(const unsigned int side) const override final + { return 4 - (side != 4); } + /** * \returns 8. All pyramids have 8 edges. */ diff --git a/include/geom/cell_tet.h b/include/geom/cell_tet.h index 6f310c6e9ce..6dd769a9793 100644 --- a/include/geom/cell_tet.h +++ b/include/geom/cell_tet.h @@ -78,6 +78,11 @@ class Tet : public Cell */ virtual unsigned int n_vertices() const override final { return 4; } + /** + * \returns 3. Every side has three vertices. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override final { return 3; } + /** * \returns 6. All tetrahedra have 6 edges. */ diff --git a/include/geom/edge.h b/include/geom/edge.h index 726e82e297c..d80dc9da8dd 100644 --- a/include/geom/edge.h +++ b/include/geom/edge.h @@ -78,6 +78,11 @@ class Edge : public Elem */ virtual unsigned int n_vertices() const override final { return 2; } + /** + * \returns 1. Every side has one vertex. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override final { return 1; } + /** * \returns 0. All 1D elements have no edges. */ diff --git a/include/geom/elem.h b/include/geom/elem.h index fd7a0fcc8b3..53de385efb5 100644 --- a/include/geom/elem.h +++ b/include/geom/elem.h @@ -659,6 +659,11 @@ class Elem : public ReferenceCountedObject, */ virtual unsigned int n_vertices () const = 0; + /** + * \returns The number of verticies on the side with index \p s. + */ + virtual unsigned int n_vertices_on_side (const unsigned int s) const = 0; + /** * \returns The number of edges the element that has been derived * from this class has. diff --git a/include/geom/face.h b/include/geom/face.h index d3a818bf217..9e77cbd75cd 100644 --- a/include/geom/face.h +++ b/include/geom/face.h @@ -66,6 +66,11 @@ class Face : public Elem */ virtual unsigned int n_faces() const override final { return 0; } + /** + * \returns 2. Every side has two vertices. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override final { return 2; } + /** * build_side and build_edge are identical for faces. */ diff --git a/include/geom/face_inf_quad.h b/include/geom/face_inf_quad.h index fba93f7c33f..09b951700db 100644 --- a/include/geom/face_inf_quad.h +++ b/include/geom/face_inf_quad.h @@ -106,6 +106,11 @@ class InfQuad : public Elem */ virtual unsigned int n_vertices() const override final { return 4; } + /** + * \returns 2. Every side has two vertices. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override final { return 2; } + /** * \returns 3. All infinite quads have 1 edge in the * base, and 2 perpendicular to the base. diff --git a/include/geom/node_elem.h b/include/geom/node_elem.h index 312921a4fd6..20403950920 100644 --- a/include/geom/node_elem.h +++ b/include/geom/node_elem.h @@ -87,6 +87,12 @@ class NodeElem : public Elem */ virtual unsigned int n_vertices() const override { return 1; } + /** + * The \p Elem::n_vertices_on_side makes no sense for nodes. + */ + virtual unsigned int n_vertices_on_side(const unsigned int) const override + { libmesh_not_implemented(); return 0; } + /** * \returns 0. */ diff --git a/include/geom/remote_elem.h b/include/geom/remote_elem.h index 49f1fa3a566..c891ab19c4b 100644 --- a/include/geom/remote_elem.h +++ b/include/geom/remote_elem.h @@ -125,6 +125,9 @@ class RemoteElem : public Elem, virtual unsigned int n_vertices () const override { libmesh_not_implemented(); return 0; } + virtual unsigned int n_vertices_on_side(const unsigned int) const override + { libmesh_not_implemented(); return 0; } + virtual unsigned int n_edges () const override { libmesh_not_implemented(); return 0; } diff --git a/tests/geom/elem_test.C b/tests/geom/elem_test.C index c4c5161a915..99bbf2cf1ab 100644 --- a/tests/geom/elem_test.C +++ b/tests/geom/elem_test.C @@ -301,6 +301,21 @@ public: CPPUNIT_ASSERT_EQUAL(elem->build_side_ptr(s)->type(), elem->side_type(s)); } + void test_n_vertices_on_side() + { + LOG_UNIT_TEST; + + for (const auto & elem : _mesh->active_local_element_ptr_range()) + for (const auto s : elem->side_index_range()) + { + unsigned int n_vertices_on_side = 0; + for (const auto entry : elem_type::side_nodes_map[s]) + if (entry >= elem->n_nodes()) + ++n_vertices_on_side; + CPPUNIT_ASSERT_EQUAL(n_vertices_on_side, elem->n_vertices_on_side(s)); + } + }; + void test_elem_side_builder() { LOG_UNIT_TEST; @@ -331,6 +346,7 @@ public: CPPUNIT_TEST( test_contains_point_node ); \ CPPUNIT_TEST( test_center_node_on_side ); \ CPPUNIT_TEST( test_side_type ); \ + CPPUNIT_TEST( test_n_vertices_on_side ); \ CPPUNIT_TEST( test_elem_side_builder ); #define INSTANTIATE_ELEMTEST(elemtype) \