Skip to content

Commit

Permalink
Add Elem::nodes_on_edge_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Nov 9, 2022
1 parent 718c60a commit a5f54c8
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/geom/cell_hex20.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Hex20 final : public Hex

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Hex20>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_hex27.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Hex27 final : public Hex

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Hex27>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_hex8.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class Hex8 final : public Hex

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Hex8>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_inf_hex16.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class InfHex16 final : public InfHex

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<InfHex16>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_inf_hex18.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class InfHex18 final : public InfHex

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<InfHex18>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_inf_hex8.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class InfHex8 final : public InfHex

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<InfHex8>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_inf_prism12.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class InfPrism12 final : public InfPrism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<InfPrism12>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_inf_prism6.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ class InfPrism6 final : public InfPrism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<InfPrism6>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_prism15.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class Prism15 final : public Prism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Prism15>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_prism18.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class Prism18 final : public Prism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Prism18>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_prism20.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class Prism20 final : public Prism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Prism20>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_prism21.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class Prism21 final : public Prism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Prism21>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_prism6.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class Prism6 final : public Prism

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Prism6>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_pyramid13.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class Pyramid13 final : public Pyramid

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Pyramid13>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_pyramid14.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class Pyramid14 final : public Pyramid

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Pyramid14>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_pyramid5.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class Pyramid5 final : public Pyramid

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Pyramid5>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_tet10.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class Tet10 final : public Tet

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Tet10>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_tet14.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Tet14 final : public Tet

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Tet14>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/cell_tet4.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class Tet4 final : public Tet

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return this->_nodes_on_edge_ptr<Tet4>(e); }

/**
* \returns \p true if the specified (local) node number is on the
* specified edge.
Expand Down
3 changes: 3 additions & 0 deletions include/geom/edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ class Edge : public Elem

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

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const override final
{ return nodes_on_side_ptr(e); }

virtual std::vector<unsigned int> sides_on_edge(const unsigned int) const override final
{ return {}; }

Expand Down
24 changes: 22 additions & 2 deletions include/geom/elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -751,18 +751,27 @@ class Elem : public ReferenceCountedObject<Elem>,

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

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

/**
* \returns A pointer to the beginning of the array that contains the
* (local) node numbers on the edge \p e
*
* This does not create temproraries, unlike \p nodes_on_edge.
* Use n_nodes_on_edge for indexing.
*/
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short e) const = 0;

/**
* \returns the (local) side numbers that touch the specified edge
*/
Expand Down Expand Up @@ -2015,6 +2024,17 @@ class Elem : public ReferenceCountedObject<Elem>,
return ElemClass::side_nodes_map[s];
}

/**
* Helper for overriding nodes_on_side in derived classes.
*/
template <class ElemClass>
const unsigned int * _nodes_on_edge_ptr(const unsigned short s) const
{
static_assert(std::is_base_of<Elem, ElemClass>::value, "Not an Elem");
libmesh_assert_less(s, std::extent<decltype(ElemClass::edge_nodes_map)>::value);
return ElemClass::edge_nodes_map[s];
}

#ifdef LIBMESH_ENABLE_AMR

/**
Expand Down
3 changes: 3 additions & 0 deletions include/geom/face.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class Face : public Elem
*/
virtual unsigned int n_faces() const override final { return 0; }

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short s) const override final
{ return nodes_on_side_ptr(s); }

/**
* \returns 2. Every side has two vertices.
*/
Expand Down
3 changes: 3 additions & 0 deletions include/geom/face_inf_quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ class InfQuad : public Elem
virtual unsigned int n_nodes_on_edge(const unsigned short e) const override final
{ return this->n_nodes_on_side(e); }

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short s) const override final
{ return nodes_on_side_ptr(s); }

protected:

/**
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 @@ -95,6 +95,12 @@ class NodeElem : public Elem
virtual const unsigned int * nodes_on_side_ptr(const unsigned short) const override final
{ libmesh_not_implemented(); return nullptr; }

/**
* The \p Elem::nodes_on_edge_ptr makes no sense for nodes.
*/
virtual const unsigned int * nodes_on_edge_ptr(const unsigned short) const override final
{ libmesh_not_implemented(); return nullptr; }

/**
* \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 @@ -171,6 +171,9 @@ class RemoteElem : public Elem,
return {0};
}

virtual const unsigned int * nodes_on_edge_ptr(const unsigned short) const override
{ libmesh_not_implemented(); return nullptr; }

virtual std::vector<unsigned int> sides_on_edge(const unsigned int) const override
{
libmesh_not_implemented();
Expand Down
15 changes: 15 additions & 0 deletions tests/geom/elem_test.C
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,20 @@ public:
}
};

void test_nodes_on_edge_ptr()
{
LOG_UNIT_TEST;

for (const auto & elem : _mesh->active_local_element_ptr_range())
for (const auto s : elem->side_index_range())
{
const auto nodes_on_edge = elem->nodes_on_edge(s);
const auto nodes_on_edge_ptr = elem->nodes_on_edge_ptr(s);
for (const auto i : index_range(nodes_on_edge))
CPPUNIT_ASSERT_EQUAL(nodes_on_edge_ptr[i], nodes_on_edge_ptr[i]);
}
};

void test_elem_side_builder()
{
LOG_UNIT_TEST;
Expand Down Expand Up @@ -394,6 +408,7 @@ public:
CPPUNIT_TEST( test_n_nodes_on_edge ); \
CPPUNIT_TEST( test_n_vertices_on_side ); \
CPPUNIT_TEST( test_nodes_on_side_ptr ); \
CPPUNIT_TEST( test_nodes_on_edge_ptr ); \
CPPUNIT_TEST( test_elem_side_builder );

#define INSTANTIATE_ELEMTEST(elemtype) \
Expand Down

0 comments on commit a5f54c8

Please sign in to comment.