1 #include <libmesh/libmesh.h> 2 #include <libmesh/node.h> 3 #include <libmesh/mesh_generation.h> 4 #include <libmesh/mesh_tools.h> 5 #include <libmesh/replicated_mesh.h> 6 #include <libmesh/elem.h> 36 CPPUNIT_TEST( testEdge2 );
37 CPPUNIT_TEST( testEdge3 );
38 CPPUNIT_TEST( testEdge4 );
39 CPPUNIT_TEST( testOrientation );
41 CPPUNIT_TEST_SUITE_END();
59 std::vector<std::vector<const Elem *>> nodes_to_elem_map;
64 std::vector<const Node*> neighbor_nodes;
67 for (
const auto & node :
mesh.node_ptr_range())
74 std::vector<dof_id_type> neighbor_node_ids(neighbor_nodes.size());
75 for (std::size_t i=0; i<neighbor_nodes.size(); ++i)
76 neighbor_node_ids[i] = neighbor_nodes[i]->
id();
77 std::sort(neighbor_node_ids.begin(), neighbor_node_ids.end());
80 for (std::size_t j=0; j<neighbor_node_ids.size(); ++j)
82 CPPUNIT_ASSERT_EQUAL( validation_data[2*ctr + j], neighbor_node_ids[j] );
115 do_test(10,
EDGE2, validation_data);
139 do_test(5,
EDGE3, validation_data);
162 do_test(3,
EDGE4, validation_data);
195 std::vector<unsigned int> conn =
207 for (
unsigned int e=0; e<7; ++e)
217 for (
const auto & elem :
mesh.element_ptr_range())
219 auto elem_id = elem->id();
222 if (elem_id == 1 || elem_id == 2)
224 CPPUNIT_ASSERT(elem->neighbor_ptr(0) ==
nullptr);
225 CPPUNIT_ASSERT(elem->neighbor_ptr(1) !=
nullptr);
230 CPPUNIT_ASSERT(elem->neighbor_ptr(0) !=
nullptr);
231 CPPUNIT_ASSERT(elem->neighbor_ptr(1) !=
nullptr);
ElemType
Defines an enum for geometric element types.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual Node *& set_node(const unsigned int i)
libMesh::Parallel::Communicator * TestCommWorld
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
This is the base class from which all geometric element types are derived.
The libMesh namespace provides an interface to certain functionality in the library.
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
void do_test(unsigned n_elem, ElemType elem_type, dof_id_type *validation_data)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
static std::unique_ptr< Elem > build_with_id(const ElemType type, dof_id_type id)
Calls the build() method above with a nullptr parent, and additionally sets the newly-created Elem's ...
CPPUNIT_TEST_SUITE_REGISTRATION(NodalNeighborsTest)
virtual const Node * node_ptr(const dof_id_type i) const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.