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

Classes

class  QueryElemSubdomainID
 

Public Member Functions

 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 26 of file mesh_extruder.C.

Member Function Documentation

MeshExtruderTest::CPPUNIT_TEST ( testExtruder  )
MeshExtruderTest::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.

MeshExtruderTest::CPPUNIT_TEST_SUITE_END ( )
void MeshExtruderTest::setUp ( )

Definition at line 54 of file mesh_extruder.C.

54 {}
void MeshExtruderTest::tearDown ( )

Definition at line 56 of file mesh_extruder.C.

56 {}
void MeshExtruderTest::testExtruder ( )

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 58 of file mesh_extruder.C.

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

59  {
60  ReplicatedMesh src_mesh(*TestCommWorld, /*dim=*/2);
61 
62  const unsigned int n_elems_per_side = 4;
63  const unsigned int num_layers = 4;
64  const unsigned int n_elems_per_layer = n_elems_per_side * n_elems_per_side;
65 
66 
67  MeshTools::Generation::build_square(src_mesh, n_elems_per_side, n_elems_per_side);
68  for (unsigned int i=0; i<n_elems_per_layer; ++i)
69  {
70  // Retrieve the element from the mesh by ID to guarantee proper ordering instead of with iterators
71  Elem & elem = src_mesh.elem_ref(i);
72  elem.subdomain_id() = i;
73  }
74 
75  ReplicatedMesh dest_mesh(*TestCommWorld, /*dim=*/3);
76 
77  RealVectorValue extrusion_vector(0, 0, 1);
78 
79  QueryElemSubdomainID new_elem_subdomain_id;
80 
85  MeshTools::Generation::build_extrusion(dest_mesh, src_mesh, num_layers, extrusion_vector, &new_elem_subdomain_id);
86 
87  for (unsigned int i=0; i<n_elems_per_layer * num_layers; ++i)
88  {
89  // Retrieve the element from the mesh by ID to guarantee proper ordering instead of with iterators
90  Elem & elem = dest_mesh.elem_ref(i);
91 
92  CPPUNIT_ASSERT_EQUAL((unsigned int)elem.subdomain_id(), i%n_elems_per_layer + i/n_elems_per_layer /* integer division */);
93  }
94  }
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
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:1951
void build_extrusion(UnstructuredMesh &mesh, const MeshBase &cross_section, const unsigned int nz, RealVectorValue extrusion_vector, QueryElemSubdomainIDBase *elem_subdomain=libmesh_nullptr)
Meshes the tensor product of a 1D and a 1D-or-2D domain.

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