Skip to content

Commit 954baa6

Browse files
committed
Add Elem::n_vertices_per_side()
1 parent bb0d86d commit 954baa6

File tree

13 files changed

+88
-0
lines changed

13 files changed

+88
-0
lines changed

include/geom/cell_hex.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ class Hex : public Cell
7777
*/
7878
virtual unsigned int n_vertices() const override final { return 8; }
7979

80+
/**
81+
* \returns 4. Every side has four vertices.
82+
*/
83+
virtual unsigned int n_vertices_on_side(const unsigned short libmesh_dbg_var(s)) const override final
84+
{ libmesh_assert_less(s, this->n_sides()); return 4; }
85+
8086
/**
8187
* \returns 12. All hexahedra have 12 edges.
8288
*/

include/geom/cell_inf_hex.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ class InfHex : public InfCell
9090
*/
9191
virtual unsigned int n_vertices() const override final { return 8; }
9292

93+
/**
94+
* \returns 4. Every side has four vertices.
95+
*/
96+
virtual unsigned int n_vertices_on_side(const unsigned short libmesh_dbg_var(s)) const override final
97+
{ libmesh_assert_less(s, this->n_sides()); return 4; }
98+
9399
/**
94100
* \returns \p true if the specified (local) node number is a
95101
* "mid-edge" node on an infinite element edge.

include/geom/cell_inf_prism.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class InfPrism : public InfCell
8686
*/
8787
virtual unsigned int n_vertices() const override final { return 6; }
8888

89+
virtual unsigned int n_vertices_on_side(const unsigned short s) const override final
90+
{ libmesh_assert_less(s, this->n_sides()); return 4 - (s == 0 || s == 4); }
91+
8992
/**
9093
* \returns 6. All infinite prisms have 6 edges,
9194
* 3 lying in the base, and 3 perpendicular to the base.

include/geom/cell_prism.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class Prism : public Cell
8383
*/
8484
virtual unsigned int n_vertices() const override final { return 6; }
8585

86+
virtual unsigned int n_vertices_on_side(const unsigned short s) const override final
87+
{ libmesh_assert_less(s, this->n_sides()); return 4 - (s == 0 || s == 4); }
88+
8689
/**
8790
* \returns 9. All prisms have 9 edges.
8891
*/

include/geom/cell_pyramid.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ class Pyramid : public Cell
8787
*/
8888
virtual unsigned int n_vertices() const override { return 5; }
8989

90+
virtual unsigned int n_vertices_on_side(const unsigned short s) const override final
91+
{ libmesh_assert_less(s, this->n_sides()); return 4 - (s != 4); }
92+
9093
/**
9194
* \returns 8. All pyramids have 8 edges.
9295
*/

include/geom/cell_tet.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class Tet : public Cell
7878
*/
7979
virtual unsigned int n_vertices() const override final { return 4; }
8080

81+
/**
82+
* \returns 3. Every side has three vertices.
83+
*/
84+
virtual unsigned int n_vertices_on_side(const unsigned short libmesh_dbg_var(s)) const override final
85+
{ libmesh_assert_less(s, this->n_sides()); return 3; }
86+
8187
/**
8288
* \returns 6. All tetrahedra have 6 edges.
8389
*/

include/geom/edge.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class Edge : public Elem
7878
*/
7979
virtual unsigned int n_vertices() const override final { return 2; }
8080

81+
/**
82+
* \returns 1. Every side has one vertex.
83+
*/
84+
virtual unsigned int n_vertices_on_side(const unsigned short libmesh_dbg_var(s)) const override final
85+
{ libmesh_assert_less(s, this->n_sides()); return 1; }
86+
8187
/**
8288
* \returns 0. All 1D elements have no edges.
8389
*/

include/geom/elem.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ class Elem : public ReferenceCountedObject<Elem>,
641641
*/
642642
IntRange<unsigned short> side_index_range () const;
643643

644+
/**
645+
* \returns An integer range from 0 up to (but not including)
646+
* the number of vertices this element has.
647+
*/
648+
IntRange<unsigned short> vertex_index_range () const;
649+
644650
/**
645651
* \returns The number of neighbors the element that has been derived
646652
* from this class has.
@@ -659,6 +665,11 @@ class Elem : public ReferenceCountedObject<Elem>,
659665
*/
660666
virtual unsigned int n_vertices () const = 0;
661667

668+
/**
669+
* \returns The number of verticies on the side with index \p s.
670+
*/
671+
virtual unsigned int n_vertices_on_side (const unsigned short s) const = 0;
672+
662673
/**
663674
* \returns The number of edges the element that has been derived
664675
* from this class has.
@@ -2427,6 +2438,13 @@ Elem::side_index_range() const
24272438

24282439

24292440

2441+
inline
2442+
IntRange<unsigned short>
2443+
Elem::vertex_index_range() const
2444+
{
2445+
return {0, cast_int<unsigned short>(this->n_vertices())};
2446+
}
2447+
24302448

24312449
inline
24322450
std::unique_ptr<const Elem> Elem::side_ptr (unsigned int i) const

include/geom/face.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class Face : public Elem
6666
*/
6767
virtual unsigned int n_faces() const override final { return 0; }
6868

69+
/**
70+
* \returns 2. Every side has two vertices.
71+
*/
72+
virtual unsigned int n_vertices_on_side(const unsigned short libmesh_dbg_var(s)) const override final
73+
{ libmesh_assert_less(s, this->n_sides()); return 2; }
74+
6975
/**
7076
* build_side and build_edge are identical for faces.
7177
*/

include/geom/face_inf_quad.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ class InfQuad : public Elem
106106
*/
107107
virtual unsigned int n_vertices() const override final { return 4; }
108108

109+
/**
110+
* \returns 2. Every side has two vertices.
111+
*/
112+
virtual unsigned int n_vertices_on_side(const unsigned short libmesh_dbg_var(s)) const override final
113+
{ libmesh_assert_less(s, this->n_sides()); return 2; }
114+
109115
/**
110116
* \returns 3. All infinite quads have 1 edge in the
111117
* base, and 2 perpendicular to the base.

0 commit comments

Comments
 (0)