Skip to content

Commit f33c96c

Browse files
committed
Add Elem::nodes_on_edge_ptr
1 parent 956b42c commit f33c96c

26 files changed

+112
-2
lines changed

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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.

Diff for: 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

Diff for: include/geom/elem.h

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

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

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

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

2065+
/**
2066+
* Helper for overriding nodes_on_side in derived classes.
2067+
*/
2068+
template <class ElemClass>
2069+
const unsigned int * _nodes_on_edge_ptr(const unsigned short s) const
2070+
{
2071+
static_assert(std::is_base_of<Elem, ElemClass>::value, "Not an Elem");
2072+
libmesh_assert_less(s, std::extent<decltype(ElemClass::edge_nodes_map)>::value);
2073+
return ElemClass::edge_nodes_map[s];
2074+
}
2075+
20562076
#ifdef LIBMESH_ENABLE_AMR
20572077

20582078
/**

Diff for: 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
*/

Diff for: include/geom/face_inf_quad.h

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

245+
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short s) const override final
246+
{ return nodes_on_side_ptr(s); }
247+
245248
protected:
246249

247250
/**

Diff for: 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
*/

Diff for: 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();

Diff for: tests/geom/elem_test.C

+15
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,20 @@ public:
547547
}
548548
};
549549

550+
void test_nodes_on_edge_ptr()
551+
{
552+
LOG_UNIT_TEST;
553+
554+
for (const auto & elem : _mesh->active_local_element_ptr_range())
555+
for (const auto s : elem->side_index_range())
556+
{
557+
const auto nodes_on_edge = elem->nodes_on_edge(s);
558+
const auto nodes_on_edge_ptr = elem->nodes_on_edge_ptr(s);
559+
for (const auto i : index_range(nodes_on_edge))
560+
CPPUNIT_ASSERT_EQUAL(nodes_on_edge_ptr[i], nodes_on_edge_ptr[i]);
561+
}
562+
};
563+
550564
void test_elem_side_builder()
551565
{
552566
LOG_UNIT_TEST;
@@ -584,6 +598,7 @@ public:
584598
CPPUNIT_TEST( test_n_nodes_on_edge ); \
585599
CPPUNIT_TEST( test_n_vertices_on_side ); \
586600
CPPUNIT_TEST( test_nodes_on_side_ptr ); \
601+
CPPUNIT_TEST( test_nodes_on_edge_ptr ); \
587602
CPPUNIT_TEST( test_elem_side_builder );
588603

589604
#define INSTANTIATE_ELEMTEST(elemtype) \

0 commit comments

Comments
 (0)