libMesh
Classes | Public Member Functions | List of all members
MeshExtruderTest Class Reference
Inheritance diagram for MeshExtruderTest:
[legend]

Classes

class  QueryElemSubdomainID
 

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MeshExtruderTest)
 The goal of this test is to verify proper operation of the Mesh Extruder with the optional object callback for setting custom subdomain IDs. More...
 
 CPPUNIT_TEST (testExtruder)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testExtruder ()
 

Detailed Description

Definition at line 12 of file mesh_extruder.C.

Member Function Documentation

◆ CPPUNIT_TEST()

MeshExtruderTest::CPPUNIT_TEST ( testExtruder  )

◆ CPPUNIT_TEST_SUITE_END()

MeshExtruderTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MeshExtruderTest::LIBMESH_CPPUNIT_TEST_SUITE ( MeshExtruderTest  )

The goal of this test is to verify proper operation of the Mesh Extruder with the optional object callback for setting custom subdomain IDs.

We pass a custom object for generating subdomains based on the old element ID and the current layer and assert the proper values.

◆ setUp()

void MeshExtruderTest::setUp ( )
inline

Definition at line 42 of file mesh_extruder.C.

42 {}

◆ tearDown()

void MeshExtruderTest::tearDown ( )
inline

Definition at line 44 of file mesh_extruder.C.

44 {}

◆ testExtruder()

void MeshExtruderTest::testExtruder ( )
inline

The test mesh is designed to be square with the subdomain corresponding to the element number. We will use this to assert the correct pattern from the custom extruder.

Definition at line 46 of file mesh_extruder.C.

References libMesh::MeshTools::Generation::build_extrusion(), libMesh::MeshTools::Generation::build_square(), libMesh::MeshBase::elem_ref(), libMesh::Elem::subdomain_id(), and TestCommWorld.

47  {
48  LOG_UNIT_TEST;
49 
50  ReplicatedMesh src_mesh(*TestCommWorld, /*dim=*/2);
51 
52  const unsigned int n_elems_per_side = 4;
53  const unsigned int num_layers = 4;
54  const unsigned int n_elems_per_layer = n_elems_per_side * n_elems_per_side;
55 
56 
57  MeshTools::Generation::build_square(src_mesh, n_elems_per_side, n_elems_per_side);
58  for (unsigned int i=0; i<n_elems_per_layer; ++i)
59  {
60  // Retrieve the element from the mesh by ID to guarantee proper ordering instead of with iterators
61  Elem & elem = src_mesh.elem_ref(i);
62  elem.subdomain_id() = i;
63  }
64 
65  ReplicatedMesh dest_mesh(*TestCommWorld, /*dim=*/3);
66 
67  RealVectorValue extrusion_vector(0, 0, 1);
68 
69  QueryElemSubdomainID new_elem_subdomain_id;
70 
75  MeshTools::Generation::build_extrusion(dest_mesh, src_mesh, num_layers, extrusion_vector, &new_elem_subdomain_id);
76 
77  for (unsigned int i=0; i<n_elems_per_layer * num_layers; ++i)
78  {
79  // Retrieve the element from the mesh by ID to guarantee proper ordering instead of with iterators
80  Elem & elem = dest_mesh.elem_ref(i);
81 
82  CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(elem.subdomain_id()), i%n_elems_per_layer + i/n_elems_per_layer /* integer division */);
83  }
84  }
void build_extrusion(UnstructuredMesh &mesh, const MeshBase &cross_section, const unsigned int nz, RealVectorValue extrusion_vector, QueryElemSubdomainIDBase *elem_subdomain=nullptr)
Meshes the tensor product of a 1D and a 1D-or-2D domain.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
subdomain_id_type subdomain_id() const
Definition: elem.h:2391

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