libMesh
Loading...
Searching...
No Matches
Public Member Functions | List of all members
MeshSubdomainIDTest Class Reference
Inheritance diagram for MeshSubdomainIDTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MeshSubdomainIDTest)
 The goal of this test is to verify proper operation of the MeshBase::subdomain_ids() method.
 
 CPPUNIT_TEST (testUnpartitioned)
 
 CPPUNIT_TEST (testMultiple)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testUnpartitioned ()
 
void testMultiple ()
 

Detailed Description

Definition at line 12 of file mesh_subdomain_id.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/2]

MeshSubdomainIDTest::CPPUNIT_TEST ( testMultiple  )

◆ CPPUNIT_TEST() [2/2]

MeshSubdomainIDTest::CPPUNIT_TEST ( testUnpartitioned  )

◆ CPPUNIT_TEST_SUITE_END()

MeshSubdomainIDTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MeshSubdomainIDTest::LIBMESH_CPPUNIT_TEST_SUITE ( MeshSubdomainIDTest  )

The goal of this test is to verify proper operation of the MeshBase::subdomain_ids() method.

◆ setUp()

void MeshSubdomainIDTest::setUp ( )
inline

Definition at line 27 of file mesh_subdomain_id.C.

27{}

◆ tearDown()

void MeshSubdomainIDTest::tearDown ( )
inline

Definition at line 29 of file mesh_subdomain_id.C.

29{}

◆ testMultiple()

void MeshSubdomainIDTest::testMultiple ( )
inline

Definition at line 52 of file mesh_subdomain_id.C.

53 {
54 LOG_UNIT_TEST;
55
56 std::unique_ptr<UnstructuredMesh> mesh = std::make_unique<Mesh>(*TestCommWorld);
57
59
60 std::set<subdomain_id_type> actual_ids;
61 for (auto & elem : mesh->active_element_ptr_range())
62 {
63 CPPUNIT_ASSERT(elem->id() < static_cast<dof_id_type>(Elem::invalid_subdomain_id));
64 actual_ids.insert((subdomain_id_type)elem->id());
65 elem->subdomain_id() = (subdomain_id_type)elem->id();
66 }
67
68 std::set<subdomain_id_type> ids;
69 mesh->subdomain_ids(ids);
70
71 CPPUNIT_ASSERT_EQUAL(ids.size(), actual_ids.size());
72 for (auto id : ids)
73 CPPUNIT_ASSERT(actual_ids.count(id));
74 }
static constexpr subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition elem.h:246
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false,...
Definition mesh_base.C:1126
MeshBase & mesh
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition id_types.h:43
uint8_t dof_id_type
Definition id_types.h:67

References libMesh::MeshTools::Generation::build_line(), libMesh::EDGE2, libMesh::Elem::invalid_subdomain_id, mesh, libMesh::MeshBase::subdomain_ids(), and TestCommWorld.

◆ testUnpartitioned()

void MeshSubdomainIDTest::testUnpartitioned ( )
inline

Definition at line 31 of file mesh_subdomain_id.C.

32 {
33 LOG_UNIT_TEST;
34
35 std::unique_ptr<UnstructuredMesh> mesh = std::make_unique<Mesh>(*TestCommWorld);
36
37 mesh->add_point(Point(0, 0, 0), 0);
38 mesh->add_point(Point(1, 0, 0), 1);
39
41 elem->set_node(0, mesh.node_ptr(0));
42 elem->set_node(1, mesh.node_ptr(1));
43
44 std::set<subdomain_id_type> ids;
45 mesh->subdomain_ids(ids);
46
47 CPPUNIT_ASSERT_EQUAL(mesh->n_subdomains(), (subdomain_id_type)1);
48 CPPUNIT_ASSERT_EQUAL(ids.size(), (std::size_t)1);
49 CPPUNIT_ASSERT_EQUAL(*ids.begin(), (subdomain_id_type)0);
50 }
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual Node *& set_node(const unsigned int i)
Definition elem.h:2567
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:442
virtual const Node * node_ptr(const dof_id_type i) const =0
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.
subdomain_id_type n_subdomains() const
Definition mesh_base.C:1190
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::Elem::build(), libMesh::EDGE2, mesh, libMesh::MeshBase::n_subdomains(), libMesh::MeshBase::node_ptr(), libMesh::Elem::set_node(), libMesh::MeshBase::subdomain_ids(), and TestCommWorld.


The documentation for this class was generated from the following file: