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

Member Function Documentation

◆ CPPUNIT_TEST()

MeshExtruderTest::CPPUNIT_TEST ( testExtruder  )

◆ CPPUNIT_TEST_SUITE()

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.

◆ CPPUNIT_TEST_SUITE_END()

MeshExtruderTest::CPPUNIT_TEST_SUITE_END ( )

◆ 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.

47  {
48  ReplicatedMesh src_mesh(*TestCommWorld, /*dim=*/2);
49 
50  const unsigned int n_elems_per_side = 4;
51  const unsigned int num_layers = 4;
52  const unsigned int n_elems_per_layer = n_elems_per_side * n_elems_per_side;
53 
54 
55  MeshTools::Generation::build_square(src_mesh, n_elems_per_side, n_elems_per_side);
56  for (unsigned int i=0; i<n_elems_per_layer; ++i)
57  {
58  // Retrieve the element from the mesh by ID to guarantee proper ordering instead of with iterators
59  Elem & elem = src_mesh.elem_ref(i);
60  elem.subdomain_id() = i;
61  }
62 
63  ReplicatedMesh dest_mesh(*TestCommWorld, /*dim=*/3);
64 
65  RealVectorValue extrusion_vector(0, 0, 1);
66 
67  QueryElemSubdomainID new_elem_subdomain_id;
68 
73  MeshTools::Generation::build_extrusion(dest_mesh, src_mesh, num_layers, extrusion_vector, &new_elem_subdomain_id);
74 
75  for (unsigned int i=0; i<n_elems_per_layer * num_layers; ++i)
76  {
77  // Retrieve the element from the mesh by ID to guarantee proper ordering instead of with iterators
78  Elem & elem = dest_mesh.elem_ref(i);
79 
80  CPPUNIT_ASSERT_EQUAL((unsigned int)elem.subdomain_id(), i%n_elems_per_layer + i/n_elems_per_layer /* integer division */);
81  }
82  }

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


The documentation for this class was generated from the following file:
libMesh::VectorValue< Real >
libMesh::ReplicatedMesh
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Definition: replicated_mesh.h:47
libMesh::MeshTools::Generation::build_square
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.
Definition: mesh_generation.C:1501
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::Elem::subdomain_id
subdomain_id_type subdomain_id() const
Definition: elem.h:2069
libMesh::MeshTools::Generation::build_extrusion
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.
Definition: mesh_generation.C:1994
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100