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

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (DistortTest)
 The goal of this test is to make sure that boundary nodes are not restricted during distortion.
 
 CPPUNIT_TEST (testDistortQuad)
 
 CPPUNIT_TEST (testDistortHex)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testDistortQuad ()
 
void testDistortHex ()
 

Protected Member Functions

void test_helper_2D (ElemType elem_type)
 
void test_helper_3D (ElemType elem_type)
 
void perturb_and_check (ReplicatedMesh &mesh)
 

Detailed Description

Definition at line 18 of file distort.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/2]

DistortTest::CPPUNIT_TEST ( testDistortHex  )

◆ CPPUNIT_TEST() [2/2]

DistortTest::CPPUNIT_TEST ( testDistortQuad  )

◆ CPPUNIT_TEST_SUITE_END()

DistortTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

DistortTest::LIBMESH_CPPUNIT_TEST_SUITE ( DistortTest  )

The goal of this test is to make sure that boundary nodes are not restricted during distortion.

◆ perturb_and_check()

void DistortTest::perturb_and_check ( ReplicatedMesh mesh)
inlineprotected

Definition at line 69 of file distort.C.

70 {
71 // Record node positions ahead of time to make sure the correct
72 // ones are moved by distort.
73 std::unordered_map<dof_id_type, Point> pts_before;
74 for (const auto & node : mesh.node_ptr_range())
75 pts_before[node->id()] = *node;
76
77 std::unordered_set<dof_id_type> boundary_node_ids =
79
81 /*factor=*/0.1,
82 /*perturb_boundary=*/false);
83
84 // Make sure the boundary nodes are not perturbed, and the
85 // other nodes are.
86 for (const auto & node : mesh.node_ptr_range())
87 {
88 bool equal = node->absolute_fuzzy_equals(pts_before[node->id()]);
89 CPPUNIT_ASSERT(boundary_node_ids.count(node->id()) ? equal : !equal);
90 }
91 }
MeshBase & mesh
void distort(MeshBase &mesh, const Real factor, const bool perturb_boundary=false)
Randomly perturb the nodal locations.
std::unordered_set< dof_id_type > find_boundary_nodes(const MeshBase &mesh)
Returns a std::set containing Node IDs for all of the boundary nodes.
Definition mesh_tools.C:524

References libMesh::MeshTools::Modification::distort(), libMesh::MeshTools::find_boundary_nodes(), and mesh.

Referenced by test_helper_2D(), and test_helper_3D().

◆ setUp()

void DistortTest::setUp ( )
inline

Definition at line 94 of file distort.C.

94{}

◆ tearDown()

void DistortTest::tearDown ( )
inline

Definition at line 95 of file distort.C.

95{}

◆ test_helper_2D()

void DistortTest::test_helper_2D ( ElemType  elem_type)
inlineprotected

Definition at line 41 of file distort.C.

42 {
43 ReplicatedMesh mesh(*TestCommWorld, /*dim=*/2);
44
46 /*nx=*/2, /*ny=*/2,
47 /*xmin=*/0., /*xmax=*/1.,
48 /*ymin=*/0., /*ymax=*/1.,
49 elem_type);
50
52 }
void perturb_and_check(ReplicatedMesh &mesh)
Definition distort.C:69
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
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.

References libMesh::MeshTools::Generation::build_square(), mesh, perturb_and_check(), and TestCommWorld.

Referenced by testDistortQuad().

◆ test_helper_3D()

void DistortTest::test_helper_3D ( ElemType  elem_type)
inlineprotected

Definition at line 55 of file distort.C.

56 {
57 ReplicatedMesh mesh(*TestCommWorld, /*dim=*/3);
58
60 /*nx=*/2, /*ny=*/2, /*nz=*/2,
61 /*xmin=*/0., /*xmax=*/1.,
62 /*ymin=*/0., /*ymax=*/1.,
63 /*zmin=*/0., /*zmax=*/1.,
64 elem_type);
66 }
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.

References libMesh::MeshTools::Generation::build_cube(), mesh, perturb_and_check(), and TestCommWorld.

Referenced by testDistortHex().

◆ testDistortHex()

void DistortTest::testDistortHex ( )
inline

Definition at line 97 of file distort.C.

97{ LOG_UNIT_TEST; test_helper_3D(HEX8); }
void test_helper_3D(ElemType elem_type)
Definition distort.C:55

References libMesh::HEX8, and test_helper_3D().

◆ testDistortQuad()

void DistortTest::testDistortQuad ( )
inline

Definition at line 96 of file distort.C.

96{ LOG_UNIT_TEST; test_helper_2D(QUAD4); }
void test_helper_2D(ElemType elem_type)
Definition distort.C:41

References libMesh::QUAD4, and test_helper_2D().


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