Skip to content

Commit

Permalink
Add Elem::n_vertices_per_side()
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Nov 8, 2022
1 parent e61fa8e commit 888b673
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/geom/cell_hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/geom/cell_inf_hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_inf_prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_pyramid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/geom/cell_tet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/geom/edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/geom/elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ class Elem : public ReferenceCountedObject<Elem>,
*/
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.
Expand Down
5 changes: 5 additions & 0 deletions include/geom/face.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/geom/face_inf_quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions include/geom/node_elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 3 additions & 0 deletions include/geom/remote_elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
16 changes: 16 additions & 0 deletions tests/geom/elem_test.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) \
Expand Down

0 comments on commit 888b673

Please sign in to comment.