Skip to content

Commit a5f54c8

Browse files
committed
Add Elem::nodes_on_edge_ptr
1 parent 718c60a commit a5f54c8

26 files changed

+112
-2
lines changed

include/geom/cell_hex20.h

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class Hex20 final : public Hex
129129

130130
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
131131

132+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
133+
{ return this->_nodes_on_edge_ptr<Hex20>(e); }
134+
132135
/**
133136
* \returns \p true if the specified (local) node number is on the
134137
* specified edge.

include/geom/cell_hex27.h

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class Hex27 final : public Hex
129129

130130
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
131131

132+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
133+
{ return this->_nodes_on_edge_ptr<Hex27>(e); }
134+
132135
/**
133136
* \returns \p true if the specified (local) node number is on the
134137
* specified edge.

include/geom/cell_hex8.h

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class Hex8 final : public Hex
114114

115115
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
116116

117+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
118+
{ return this->_nodes_on_edge_ptr<Hex8>(e); }
119+
117120
/**
118121
* \returns \p true if the specified (local) node number is on the
119122
* specified edge.

include/geom/cell_inf_hex16.h

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class InfHex16 final : public InfHex
129129

130130
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
131131

132+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
133+
{ return this->_nodes_on_edge_ptr<InfHex16>(e); }
134+
132135
/**
133136
* \returns \p true if the specified (local) node number is on the
134137
* specified edge.

include/geom/cell_inf_hex18.h

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class InfHex18 final : public InfHex
134134

135135
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
136136

137+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
138+
{ return this->_nodes_on_edge_ptr<InfHex18>(e); }
139+
137140
/**
138141
* \returns \p true if the specified (local) node number is on the
139142
* specified edge.

include/geom/cell_inf_hex8.h

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class InfHex8 final : public InfHex
114114

115115
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
116116

117+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
118+
{ return this->_nodes_on_edge_ptr<InfHex8>(e); }
119+
117120
/**
118121
* \returns \p true if the specified (local) node number is on the
119122
* specified edge.

include/geom/cell_inf_prism12.h

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ class InfPrism12 final : public InfPrism
120120

121121
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
122122

123+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
124+
{ return this->_nodes_on_edge_ptr<InfPrism12>(e); }
125+
123126
/**
124127
* \returns \p true if the specified (local) node number is on the
125128
* specified edge.

include/geom/cell_inf_prism6.h

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ class InfPrism6 final : public InfPrism
116116

117117
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
118118

119+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
120+
{ return this->_nodes_on_edge_ptr<InfPrism6>(e); }
121+
119122
/**
120123
* \returns \p true if the specified (local) node number is on the
121124
* specified edge.

include/geom/cell_prism15.h

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class Prism15 final : public Prism
134134

135135
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
136136

137+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
138+
{ return this->_nodes_on_edge_ptr<Prism15>(e); }
139+
137140
/**
138141
* \returns \p true if the specified (local) node number is on the
139142
* specified edge.

include/geom/cell_prism18.h

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class Prism18 final : public Prism
134134

135135
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
136136

137+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
138+
{ return this->_nodes_on_edge_ptr<Prism18>(e); }
139+
137140
/**
138141
* \returns \p true if the specified (local) node number is on the
139142
* specified edge.

include/geom/cell_prism20.h

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ class Prism20 final : public Prism
138138

139139
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
140140

141+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
142+
{ return this->_nodes_on_edge_ptr<Prism20>(e); }
143+
141144
/**
142145
* \returns \p true if the specified (local) node number is on the
143146
* specified edge.

include/geom/cell_prism21.h

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class Prism21 final : public Prism
141141

142142
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
143143

144+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
145+
{ return this->_nodes_on_edge_ptr<Prism21>(e); }
146+
144147
/**
145148
* \returns \p true if the specified (local) node number is on the
146149
* specified edge.

include/geom/cell_prism6.h

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ class Prism6 final : public Prism
112112

113113
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
114114

115+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
116+
{ return this->_nodes_on_edge_ptr<Prism6>(e); }
117+
115118
/**
116119
* \returns \p true if the specified (local) node number is on the
117120
* specified edge.

include/geom/cell_pyramid13.h

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ class Pyramid13 final : public Pyramid
133133

134134
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
135135

136+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
137+
{ return this->_nodes_on_edge_ptr<Pyramid13>(e); }
138+
136139
/**
137140
* \returns \p true if the specified (local) node number is on the
138141
* specified edge.

include/geom/cell_pyramid14.h

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ class Pyramid14 final : public Pyramid
136136

137137
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
138138

139+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
140+
{ return this->_nodes_on_edge_ptr<Pyramid14>(e); }
141+
139142
/**
140143
* \returns \p true if the specified (local) node number is on the
141144
* specified edge.

include/geom/cell_pyramid5.h

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class Pyramid5 final : public Pyramid
111111

112112
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
113113

114+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
115+
{ return this->_nodes_on_edge_ptr<Pyramid5>(e); }
116+
114117
/**
115118
* \returns \p true if the specified (local) node number is on the
116119
* specified edge.

include/geom/cell_tet10.h

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class Tet10 final : public Tet
123123

124124
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
125125

126+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
127+
{ return this->_nodes_on_edge_ptr<Tet10>(e); }
128+
126129
/**
127130
* \returns \p true if the specified (local) node number is on the
128131
* specified edge.

include/geom/cell_tet14.h

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class Tet14 final : public Tet
129129

130130
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
131131

132+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
133+
{ return this->_nodes_on_edge_ptr<Tet14>(e); }
134+
132135
/**
133136
* \returns \p true if the specified (local) node number is on the
134137
* specified edge.

include/geom/cell_tet4.h

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class Tet4 final : public Tet
118118

119119
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
120120

121+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
122+
{ return this->_nodes_on_edge_ptr<Tet4>(e); }
123+
121124
/**
122125
* \returns \p true if the specified (local) node number is on the
123126
* specified edge.

include/geom/edge.h

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ class Edge : public Elem
201201

202202
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
203203

204+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
205+
{ return nodes_on_side_ptr(e); }
206+
204207
virtual std::vector<unsigned int> sides_on_edge(const unsigned int) const override final
205208
{ return {}; }
206209

include/geom/elem.h

+22-2
Original file line numberDiff line numberDiff line change
@@ -751,18 +751,27 @@ class Elem : public ReferenceCountedObject<Elem>,
751751

752752
/**
753753
* \returns A pointer to the beginning of the array that contains the
754-
* (local) node numbers on the specified side
754+
* (local) node numbers on the side \p s
755755
*
756756
* This does not create temproraries, unlike \p nodes_on_side.
757757
* Use n_nodes_on_side for indexing.
758758
*/
759-
virtual const unsigned int * nodes_on_side_ptr(const unsigned short) const = 0;
759+
virtual const unsigned int * nodes_on_side_ptr(const unsigned short s) const = 0;
760760

761761
/**
762762
* \returns the (local) node numbers on the specified edge
763763
*/
764764
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int /*e*/) const = 0;
765765

766+
/**
767+
* \returns A pointer to the beginning of the array that contains the
768+
* (local) node numbers on the edge \p e
769+
*
770+
* This does not create temproraries, unlike \p nodes_on_edge.
771+
* Use n_nodes_on_edge for indexing.
772+
*/
773+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const = 0;
774+
766775
/**
767776
* \returns the (local) side numbers that touch the specified edge
768777
*/
@@ -2015,6 +2024,17 @@ class Elem : public ReferenceCountedObject<Elem>,
20152024
return ElemClass::side_nodes_map[s];
20162025
}
20172026

2027+
/**
2028+
* Helper for overriding nodes_on_side in derived classes.
2029+
*/
2030+
template <class ElemClass>
2031+
const unsigned int * _nodes_on_edge_ptr(const unsigned short s) const
2032+
{
2033+
static_assert(std::is_base_of<Elem, ElemClass>::value, "Not an Elem");
2034+
libmesh_assert_less(s, std::extent<decltype(ElemClass::edge_nodes_map)>::value);
2035+
return ElemClass::edge_nodes_map[s];
2036+
}
2037+
20182038
#ifdef LIBMESH_ENABLE_AMR
20192039

20202040
/**

include/geom/face.h

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

69+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short s) const override final
70+
{ return nodes_on_side_ptr(s); }
71+
6972
/**
7073
* \returns 2. Every side has two vertices.
7174
*/

include/geom/face_inf_quad.h

+3
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ class InfQuad : public Elem
240240
virtual unsigned int n_nodes_on_edge(const unsigned short e) const override final
241241
{ return this->n_nodes_on_side(e); }
242242

243+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short s) const override final
244+
{ return nodes_on_side_ptr(s); }
245+
243246
protected:
244247

245248
/**

include/geom/node_elem.h

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ class NodeElem : public Elem
9595
virtual const unsigned int * nodes_on_side_ptr(const unsigned short) const override final
9696
{ libmesh_not_implemented(); return nullptr; }
9797

98+
/**
99+
* The \p Elem::nodes_on_edge_ptr makes no sense for nodes.
100+
*/
101+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short) const override final
102+
{ libmesh_not_implemented(); return nullptr; }
103+
98104
/**
99105
* \returns 0.
100106
*/

include/geom/remote_elem.h

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class RemoteElem : public Elem,
171171
return {0};
172172
}
173173

174+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short) const override
175+
{ libmesh_not_implemented(); return nullptr; }
176+
174177
virtual std::vector<unsigned int> sides_on_edge(const unsigned int) const override
175178
{
176179
libmesh_not_implemented();

tests/geom/elem_test.C

+15
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,20 @@ public:
360360
}
361361
};
362362

363+
void test_nodes_on_edge_ptr()
364+
{
365+
LOG_UNIT_TEST;
366+
367+
for (const auto & elem : _mesh->active_local_element_ptr_range())
368+
for (const auto s : elem->side_index_range())
369+
{
370+
const auto nodes_on_edge = elem->nodes_on_edge(s);
371+
const auto nodes_on_edge_ptr = elem->nodes_on_edge_ptr(s);
372+
for (const auto i : index_range(nodes_on_edge))
373+
CPPUNIT_ASSERT_EQUAL(nodes_on_edge_ptr[i], nodes_on_edge_ptr[i]);
374+
}
375+
};
376+
363377
void test_elem_side_builder()
364378
{
365379
LOG_UNIT_TEST;
@@ -394,6 +408,7 @@ public:
394408
CPPUNIT_TEST( test_n_nodes_on_edge ); \
395409
CPPUNIT_TEST( test_n_vertices_on_side ); \
396410
CPPUNIT_TEST( test_nodes_on_side_ptr ); \
411+
CPPUNIT_TEST( test_nodes_on_edge_ptr ); \
397412
CPPUNIT_TEST( test_elem_side_builder );
398413

399414
#define INSTANTIATE_ELEMTEST(elemtype) \

0 commit comments

Comments
 (0)