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

Public Types

typedef void(MeshGenerationTest::* Builder) (UnstructuredMesh &, unsigned int, ElemType)
 

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MeshGenerationTest)
 The goal of this test is to verify proper operation of MeshGeneration functions, as well as to indirectly verify the MeshBase functions they rely on.
 
 CPPUNIT_TEST (buildLineEdge2)
 
 CPPUNIT_TEST (buildLineEdge3)
 
 CPPUNIT_TEST (buildLineEdge4)
 
 CPPUNIT_TEST (buildSphereEdge2)
 
 CPPUNIT_TEST (buildSphereEdge3)
 
 CPPUNIT_TEST (buildSquareTri3)
 
 CPPUNIT_TEST (buildSquareTri6)
 
 CPPUNIT_TEST (buildSquareTri7)
 
 CPPUNIT_TEST (buildSquareQuad4)
 
 CPPUNIT_TEST (buildSquareQuad8)
 
 CPPUNIT_TEST (buildSquareQuad9)
 
 CPPUNIT_TEST (buildSquareC0PolygonEven)
 
 CPPUNIT_TEST (buildSquareC0PolygonOdd)
 
 CPPUNIT_TEST (buildSphereTri3)
 
 CPPUNIT_TEST (buildSphereQuad4)
 
 CPPUNIT_TEST (buildCubeTet4)
 
 CPPUNIT_TEST (buildCubeTet10)
 
 CPPUNIT_TEST (buildCubeTet14)
 
 CPPUNIT_TEST (buildCubeHex8)
 
 CPPUNIT_TEST (buildCubeHex20)
 
 CPPUNIT_TEST (buildCubeHex27)
 
 CPPUNIT_TEST (buildCubeC0Polyhedron)
 
 CPPUNIT_TEST (buildCubePrism6)
 
 CPPUNIT_TEST (buildCubePrism15)
 
 CPPUNIT_TEST (buildCubePrism18)
 
 CPPUNIT_TEST (buildCubePrism20)
 
 CPPUNIT_TEST (buildCubePrism21)
 
 CPPUNIT_TEST (buildCubePyramid5)
 
 CPPUNIT_TEST (buildCubePyramid13)
 
 CPPUNIT_TEST (buildCubePyramid14)
 
 CPPUNIT_TEST (buildSphereHex27)
 
 CPPUNIT_TEST (buildSphereHex8)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testBuildLine (UnstructuredMesh &mesh, unsigned int n, ElemType type)
 
void testBuildSquare (UnstructuredMesh &mesh, unsigned int n, ElemType type)
 
void testBuildCube (UnstructuredMesh &mesh, unsigned int n, ElemType type)
 
void testBuildSphere (unsigned int n_ref, ElemType type)
 
void tester (Builder f, unsigned int n, ElemType type)
 
void buildLineEdge2 ()
 
void buildLineEdge3 ()
 
void buildLineEdge4 ()
 
void buildSphereEdge2 ()
 
void buildSphereEdge3 ()
 
void buildSphereEdge4 ()
 
void buildSquareTri3 ()
 
void buildSquareTri6 ()
 
void buildSquareTri7 ()
 
void buildSquareQuad4 ()
 
void buildSquareQuad8 ()
 
void buildSquareQuad9 ()
 
void buildSquareC0PolygonOdd ()
 
void buildSquareC0PolygonEven ()
 
void buildSphereTri3 ()
 
void buildSphereQuad4 ()
 
void buildCubeTet4 ()
 
void buildCubeTet10 ()
 
void buildCubeTet14 ()
 
void buildCubeHex8 ()
 
void buildCubeHex20 ()
 
void buildCubeHex27 ()
 
void buildCubeC0Polyhedron ()
 
void buildCubePrism6 ()
 
void buildCubePrism15 ()
 
void buildCubePrism18 ()
 
void buildCubePrism20 ()
 
void buildCubePrism21 ()
 
void buildCubePyramid5 ()
 
void buildCubePyramid13 ()
 
void buildCubePyramid14 ()
 
void buildSphereHex8 ()
 
void buildSphereHex27 ()
 

Protected Member Functions

std::unique_ptr< UnstructuredMeshnew_mesh (bool is_replicated)
 

Detailed Description

Definition at line 14 of file mesh_generation_test.C.

Member Typedef Documentation

◆ Builder

typedef void(MeshGenerationTest::* MeshGenerationTest::Builder) (UnstructuredMesh &, unsigned int, ElemType)

Definition at line 342 of file mesh_generation_test.C.

Member Function Documentation

◆ buildCubeC0Polyhedron()

void MeshGenerationTest::buildCubeC0Polyhedron ( )
inline

Definition at line 384 of file mesh_generation_test.C.

void testBuildCube(UnstructuredMesh &mesh, unsigned int n, ElemType type)
void tester(Builder f, unsigned int n, ElemType type)

References libMesh::C0POLYHEDRON, testBuildCube(), and tester().

◆ buildCubeHex20()

void MeshGenerationTest::buildCubeHex20 ( )
inline

Definition at line 382 of file mesh_generation_test.C.

382{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, HEX20); }

References libMesh::HEX20, testBuildCube(), and tester().

◆ buildCubeHex27()

void MeshGenerationTest::buildCubeHex27 ( )
inline

Definition at line 383 of file mesh_generation_test.C.

383{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, HEX27); }

References libMesh::HEX27, testBuildCube(), and tester().

◆ buildCubeHex8()

void MeshGenerationTest::buildCubeHex8 ( )
inline

Definition at line 381 of file mesh_generation_test.C.

381{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, HEX8); }

References libMesh::HEX8, testBuildCube(), and tester().

◆ buildCubePrism15()

void MeshGenerationTest::buildCubePrism15 ( )
inline

Definition at line 387 of file mesh_generation_test.C.

387{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, PRISM15); }

References libMesh::PRISM15, testBuildCube(), and tester().

◆ buildCubePrism18()

void MeshGenerationTest::buildCubePrism18 ( )
inline

Definition at line 388 of file mesh_generation_test.C.

388{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, PRISM18); }

References libMesh::PRISM18, testBuildCube(), and tester().

◆ buildCubePrism20()

void MeshGenerationTest::buildCubePrism20 ( )
inline

Definition at line 389 of file mesh_generation_test.C.

389{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, PRISM20); }

References libMesh::PRISM20, testBuildCube(), and tester().

◆ buildCubePrism21()

void MeshGenerationTest::buildCubePrism21 ( )
inline

Definition at line 390 of file mesh_generation_test.C.

390{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, PRISM21); }

References libMesh::PRISM21, testBuildCube(), and tester().

◆ buildCubePrism6()

void MeshGenerationTest::buildCubePrism6 ( )
inline

Definition at line 386 of file mesh_generation_test.C.

386{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, PRISM6); }

References libMesh::PRISM6, testBuildCube(), and tester().

◆ buildCubePyramid13()

void MeshGenerationTest::buildCubePyramid13 ( )
inline

Definition at line 396 of file mesh_generation_test.C.

References libMesh::PYRAMID13, testBuildCube(), and tester().

◆ buildCubePyramid14()

void MeshGenerationTest::buildCubePyramid14 ( )
inline

Definition at line 397 of file mesh_generation_test.C.

References libMesh::PYRAMID14, testBuildCube(), and tester().

◆ buildCubePyramid5()

void MeshGenerationTest::buildCubePyramid5 ( )
inline

Definition at line 395 of file mesh_generation_test.C.

References libMesh::PYRAMID5, testBuildCube(), and tester().

◆ buildCubeTet10()

void MeshGenerationTest::buildCubeTet10 ( )
inline

Definition at line 379 of file mesh_generation_test.C.

379{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, TET10); }

References testBuildCube(), tester(), and libMesh::TET10.

◆ buildCubeTet14()

void MeshGenerationTest::buildCubeTet14 ( )
inline

Definition at line 380 of file mesh_generation_test.C.

380{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, TET14); }

References testBuildCube(), tester(), and libMesh::TET14.

◆ buildCubeTet4()

void MeshGenerationTest::buildCubeTet4 ( )
inline

Definition at line 378 of file mesh_generation_test.C.

378{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildCube, 2, TET4); }

References testBuildCube(), tester(), and libMesh::TET4.

◆ buildLineEdge2()

void MeshGenerationTest::buildLineEdge2 ( )
inline

Definition at line 358 of file mesh_generation_test.C.

358{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildLine, 5, EDGE2); }
void testBuildLine(UnstructuredMesh &mesh, unsigned int n, ElemType type)

References libMesh::EDGE2, testBuildLine(), and tester().

◆ buildLineEdge3()

void MeshGenerationTest::buildLineEdge3 ( )
inline

Definition at line 359 of file mesh_generation_test.C.

359{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildLine, 5, EDGE3); }

References libMesh::EDGE3, testBuildLine(), and tester().

◆ buildLineEdge4()

void MeshGenerationTest::buildLineEdge4 ( )
inline

Definition at line 360 of file mesh_generation_test.C.

360{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildLine, 5, EDGE4); }

References libMesh::EDGE4, testBuildLine(), and tester().

◆ buildSphereEdge2()

void MeshGenerationTest::buildSphereEdge2 ( )
inline

Definition at line 362 of file mesh_generation_test.C.

362{ LOG_UNIT_TEST; testBuildSphere(2, EDGE2); }
void testBuildSphere(unsigned int n_ref, ElemType type)

References libMesh::EDGE2, and testBuildSphere().

◆ buildSphereEdge3()

void MeshGenerationTest::buildSphereEdge3 ( )
inline

Definition at line 363 of file mesh_generation_test.C.

363{ LOG_UNIT_TEST; testBuildSphere(2, EDGE3); }

References libMesh::EDGE3, and testBuildSphere().

◆ buildSphereEdge4()

void MeshGenerationTest::buildSphereEdge4 ( )
inline

Definition at line 364 of file mesh_generation_test.C.

364{ LOG_UNIT_TEST; testBuildSphere(2, EDGE4); }

References libMesh::EDGE4, and testBuildSphere().

◆ buildSphereHex27()

void MeshGenerationTest::buildSphereHex27 ( )
inline

Definition at line 401 of file mesh_generation_test.C.

401{ LOG_UNIT_TEST; testBuildSphere(2, HEX27); }

References libMesh::HEX27, and testBuildSphere().

◆ buildSphereHex8()

void MeshGenerationTest::buildSphereHex8 ( )
inline

Definition at line 400 of file mesh_generation_test.C.

400{ LOG_UNIT_TEST; testBuildSphere(2, HEX8); }

References libMesh::HEX8, and testBuildSphere().

◆ buildSphereQuad4()

void MeshGenerationTest::buildSphereQuad4 ( )
inline

Definition at line 376 of file mesh_generation_test.C.

376{ LOG_UNIT_TEST; testBuildSphere(2, QUAD4); }

References libMesh::QUAD4, and testBuildSphere().

◆ buildSphereTri3()

void MeshGenerationTest::buildSphereTri3 ( )
inline

Definition at line 375 of file mesh_generation_test.C.

375{ LOG_UNIT_TEST; testBuildSphere(2, TRI3); }

References testBuildSphere(), and libMesh::TRI3.

◆ buildSquareC0PolygonEven()

void MeshGenerationTest::buildSquareC0PolygonEven ( )
inline

Definition at line 373 of file mesh_generation_test.C.

void testBuildSquare(UnstructuredMesh &mesh, unsigned int n, ElemType type)

References libMesh::C0POLYGON, testBuildSquare(), and tester().

◆ buildSquareC0PolygonOdd()

void MeshGenerationTest::buildSquareC0PolygonOdd ( )
inline

Definition at line 372 of file mesh_generation_test.C.

References libMesh::C0POLYGON, testBuildSquare(), and tester().

◆ buildSquareQuad4()

void MeshGenerationTest::buildSquareQuad4 ( )
inline

Definition at line 369 of file mesh_generation_test.C.

369{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 4, QUAD4); }

References libMesh::QUAD4, testBuildSquare(), and tester().

◆ buildSquareQuad8()

void MeshGenerationTest::buildSquareQuad8 ( )
inline

Definition at line 370 of file mesh_generation_test.C.

References libMesh::QUAD8, testBuildSquare(), and tester().

◆ buildSquareQuad9()

void MeshGenerationTest::buildSquareQuad9 ( )
inline

Definition at line 371 of file mesh_generation_test.C.

References libMesh::QUAD9, testBuildSquare(), and tester().

◆ buildSquareTri3()

void MeshGenerationTest::buildSquareTri3 ( )
inline

Definition at line 366 of file mesh_generation_test.C.

366{ LOG_UNIT_TEST; tester(&MeshGenerationTest::testBuildSquare, 3, TRI3); }

References testBuildSquare(), tester(), and libMesh::TRI3.

◆ buildSquareTri6()

void MeshGenerationTest::buildSquareTri6 ( )
inline

Definition at line 367 of file mesh_generation_test.C.

References testBuildSquare(), tester(), and libMesh::TRI6.

◆ buildSquareTri7()

void MeshGenerationTest::buildSquareTri7 ( )
inline

Definition at line 368 of file mesh_generation_test.C.

References testBuildSquare(), tester(), and libMesh::TRI7.

◆ CPPUNIT_TEST() [1/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeC0Polyhedron  )

◆ CPPUNIT_TEST() [2/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeHex20  )

◆ CPPUNIT_TEST() [3/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeHex27  )

◆ CPPUNIT_TEST() [4/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeHex8  )

◆ CPPUNIT_TEST() [5/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism15  )

◆ CPPUNIT_TEST() [6/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism18  )

◆ CPPUNIT_TEST() [7/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism20  )

◆ CPPUNIT_TEST() [8/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism21  )

◆ CPPUNIT_TEST() [9/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism6  )

◆ CPPUNIT_TEST() [10/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePyramid13  )

◆ CPPUNIT_TEST() [11/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePyramid14  )

◆ CPPUNIT_TEST() [12/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePyramid5  )

◆ CPPUNIT_TEST() [13/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeTet10  )

◆ CPPUNIT_TEST() [14/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeTet14  )

◆ CPPUNIT_TEST() [15/32]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeTet4  )

◆ CPPUNIT_TEST() [16/32]

MeshGenerationTest::CPPUNIT_TEST ( buildLineEdge2  )

◆ CPPUNIT_TEST() [17/32]

MeshGenerationTest::CPPUNIT_TEST ( buildLineEdge3  )

◆ CPPUNIT_TEST() [18/32]

MeshGenerationTest::CPPUNIT_TEST ( buildLineEdge4  )

◆ CPPUNIT_TEST() [19/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereEdge2  )

◆ CPPUNIT_TEST() [20/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereEdge3  )

◆ CPPUNIT_TEST() [21/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereHex27  )

◆ CPPUNIT_TEST() [22/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereHex8  )

◆ CPPUNIT_TEST() [23/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereQuad4  )

◆ CPPUNIT_TEST() [24/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereTri3  )

◆ CPPUNIT_TEST() [25/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareC0PolygonEven  )

◆ CPPUNIT_TEST() [26/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareC0PolygonOdd  )

◆ CPPUNIT_TEST() [27/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareQuad4  )

◆ CPPUNIT_TEST() [28/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareQuad8  )

◆ CPPUNIT_TEST() [29/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareQuad9  )

◆ CPPUNIT_TEST() [30/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareTri3  )

◆ CPPUNIT_TEST() [31/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareTri6  )

◆ CPPUNIT_TEST() [32/32]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareTri7  )

◆ CPPUNIT_TEST_SUITE_END()

MeshGenerationTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MeshGenerationTest::LIBMESH_CPPUNIT_TEST_SUITE ( MeshGenerationTest  )

The goal of this test is to verify proper operation of MeshGeneration functions, as well as to indirectly verify the MeshBase functions they rely on.

◆ new_mesh()

std::unique_ptr< UnstructuredMesh > MeshGenerationTest::new_mesh ( bool  is_replicated)
inlineprotected

Definition at line 81 of file mesh_generation_test.C.

82 {
83 if (is_replicated)
84 return std::make_unique<ReplicatedMesh>(*TestCommWorld);
85 return std::make_unique<DistributedMesh>(*TestCommWorld);
86 }

References TestCommWorld.

Referenced by tester().

◆ setUp()

void MeshGenerationTest::setUp ( )
inline

Definition at line 89 of file mesh_generation_test.C.

89{}

◆ tearDown()

void MeshGenerationTest::tearDown ( )
inline

Definition at line 91 of file mesh_generation_test.C.

91{}

◆ testBuildCube()

void MeshGenerationTest::testBuildCube ( UnstructuredMesh mesh,
unsigned int  n,
ElemType  type 
)
inline

Definition at line 180 of file mesh_generation_test.C.

181 {
182 MeshTools::Generation::build_cube (mesh, n, n, n, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, type);
183 if (type == C0POLYHEDRON)
184 {
185 const dof_id_type grid_nodes = cast_int<dof_id_type>((n+1)*(n+1)*(n+1));
186
187 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n));
188 CPPUNIT_ASSERT(mesh.n_nodes() >= grid_nodes);
189 CPPUNIT_ASSERT(mesh.n_nodes() <= grid_nodes + cast_int<dof_id_type>(n*n*n));
190 }
191 else
192 {
193 switch (Elem::type_to_n_sides_map[type])
194 {
195 case 4: // tets
196 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n*24));
197 break;
198 case 5: // prisms, pyramids
199 if (type == PRISM6 || type == PRISM15 || type == PRISM18 ||
200 type == PRISM20 || type == PRISM21)
201 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n*2));
202 else
203 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n*6));
204 break;
205 case 6: // hexes
206 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n));
207 break;
208 default:
209 libmesh_error();
210 }
211
212
213 switch (Elem::type_to_n_nodes_map[type])
214 {
215 case 4: // First-order tets
216 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
217 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n + 3*(n+1)*n*n));
218 break;
219 case 6: // First-order prisms and hexes use the same nodes
220 case 8:
221 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
222 cast_int<dof_id_type>((n+1)*(n+1)*(n+1)));
223 break;
224 case 10: // Second-order tets
225 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
226 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n));
227 break;
228 case 18:
229 case 27: // Second-order prisms and hexes use the same nodes
230 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
231 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1)));
232 break;
233 case 20:
234 if (type == HEX20)
235 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
236 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 3*(n+1)*n*n));
237 if (type == PRISM20)
238 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
239 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(n+1)*n*n));
240 break;
241 case 21: // Prisms based on full Tri7 cross sections
242 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
243 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(2*n+1)*n*n));
244 break;
245 case 15: // weird partial order prism
246 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
247 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 2*(n+1)*n*n));
248 break;
249 case 5: // pyramids
250 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
251 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n));
252 break;
253 case 13:
254 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
255 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n - 3*(n+1)*n*n));
256 break;
257 case 14: // pyramids, tets
258 if (type == PYRAMID14)
259 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
260 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n));
261 else // TET14
262 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
263 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n +
264 36*n*n*n + 4*3*(n+1)*n*n));
265 break;
266 default:
267 libmesh_error();
268 }
269 }
270
271 // Our bounding boxes can be loose on higher order elements, but
272 // we can at least assert that they're not too tight
274 CPPUNIT_ASSERT(bbox.min()(0) <= Real(-2.0));
275 CPPUNIT_ASSERT(bbox.max()(0) >= Real(3.0));
276 CPPUNIT_ASSERT(bbox.min()(1) <= Real(-4.0));
277 CPPUNIT_ASSERT(bbox.max()(1) >= Real(5.0));
278 CPPUNIT_ASSERT(bbox.min()(2) <= Real(-6.0));
279 CPPUNIT_ASSERT(bbox.max()(2) >= Real(7.0));
280
281 if (type == C0POLYHEDRON)
282 {
284 const Real expected_volume = Real(5) * Real(9) * Real(13);
285
286 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(0),
287 Real(-2.0),
289 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(0),
290 Real(3.0),
292 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(1),
293 Real(-4.0),
295 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(1),
296 Real(5.0),
298 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(2),
299 Real(-6.0),
301 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(2),
302 Real(7.0),
304 LIBMESH_ASSERT_FP_EQUAL(MeshTools::volume(mesh),
305 expected_volume,
307
308 for (auto & elem : mesh.element_ptr_range())
309 {
310 CPPUNIT_ASSERT_EQUAL(elem->type(), C0POLYHEDRON);
311 CPPUNIT_ASSERT_EQUAL(elem->n_sides(), 6u);
312 CPPUNIT_ASSERT(elem->n_sub_elem() > 0);
313 CPPUNIT_ASSERT(elem->volume() > 0);
314 }
315
316 return;
317 }
318
319 // We don't yet try to do affine map optimizations on pyramids
320 if (type == PYRAMID5 ||
321 type == PYRAMID13 ||
322 type == PYRAMID14)
323 return;
324
325 // Do serial assertions *after* all parallel assertions, so we
326 // stay in sync after failure on only some processor(s)
327 for (auto & elem : mesh.element_ptr_range())
328 CPPUNIT_ASSERT(elem->has_affine_map());
329 }
Defines a Cartesian bounding box by the two corner extremum.
const Point & max() const
const Point & min() const
static const unsigned int type_to_n_nodes_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of nodes in the element...
Definition elem.h:643
static const unsigned int type_to_n_sides_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of sides on the element...
Definition elem.h:678
virtual dof_id_type n_elem() const =0
virtual dof_id_type n_nodes() const =0
MeshBase & mesh
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.
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
Find the total volume of a mesh (interpreting that as area for dim = 2, or total arc length for dim =...
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition mesh_tools.C:566
libMesh::BoundingBox create_nodal_bounding_box(const MeshBase &mesh)
Definition mesh_tools.C:591
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::MeshTools::Generation::build_cube(), libMesh::C0POLYHEDRON, libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::HEX20, libMesh::BoundingBox::max(), mesh, libMesh::BoundingBox::min(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::PRISM15, libMesh::PRISM18, libMesh::PRISM20, libMesh::PRISM21, libMesh::PRISM6, libMesh::PYRAMID13, libMesh::PYRAMID14, libMesh::PYRAMID5, libMesh::Real, libMesh::TOLERANCE, libMesh::Elem::type_to_n_nodes_map, libMesh::Elem::type_to_n_sides_map, and libMesh::MeshTools::volume().

Referenced by buildCubeC0Polyhedron(), buildCubeHex20(), buildCubeHex27(), buildCubeHex8(), buildCubePrism15(), buildCubePrism18(), buildCubePrism20(), buildCubePrism21(), buildCubePrism6(), buildCubePyramid13(), buildCubePyramid14(), buildCubePyramid5(), buildCubeTet10(), buildCubeTet14(), and buildCubeTet4().

◆ testBuildLine()

void MeshGenerationTest::testBuildLine ( UnstructuredMesh mesh,
unsigned int  n,
ElemType  type 
)
inline

Definition at line 93 of file mesh_generation_test.C.

94 {
95 MeshTools::Generation::build_line (mesh, n, -1.0, 2.0, type);
96 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n));
97 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
98 cast_int<dof_id_type>((Elem::type_to_n_nodes_map[type]-1)*n + 1));
99
101 CPPUNIT_ASSERT_EQUAL(bbox.min()(0), Real(-1.0));
102 CPPUNIT_ASSERT_EQUAL(bbox.max()(0), Real(2.0));
103
104 // Do serial assertions *after* all parallel assertions, so we
105 // stay in sync after failure on only some processor(s)
106 for (auto & elem : mesh.element_ptr_range())
107 CPPUNIT_ASSERT(elem->has_affine_map());
108 }
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.

References libMesh::MeshTools::Generation::build_line(), libMesh::MeshTools::create_bounding_box(), libMesh::BoundingBox::max(), mesh, libMesh::BoundingBox::min(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Real, and libMesh::Elem::type_to_n_nodes_map.

Referenced by buildLineEdge2(), buildLineEdge3(), and buildLineEdge4().

◆ testBuildSphere()

void MeshGenerationTest::testBuildSphere ( unsigned int  n_ref,
ElemType  type 
)
inline

Definition at line 331 of file mesh_generation_test.C.

332 {
333 ReplicatedMesh rmesh(*TestCommWorld);
334 MeshTools::Generation::build_sphere (rmesh, 2.0, n_ref, type);
335
336 DistributedMesh dmesh(*TestCommWorld);
337 dmesh.allow_renumbering(false);
338 MeshTools::Generation::build_sphere (dmesh, 2.0, n_ref, type);
339 }
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
void build_sphere(UnstructuredMesh &mesh, const Real radius=1, const unsigned int n_refinements=2, const ElemType type=INVALID_ELEM, const unsigned int n_smooth=2, const bool flat=true)
Fills mesh with a mesh discretizing a ball (||x||<= radius) or sphere (||x|| = radius) domain.

References libMesh::MeshBase::allow_renumbering(), libMesh::MeshTools::Generation::build_sphere(), and TestCommWorld.

Referenced by buildSphereEdge2(), buildSphereEdge3(), buildSphereEdge4(), buildSphereHex27(), buildSphereHex8(), buildSphereQuad4(), and buildSphereTri3().

◆ testBuildSquare()

void MeshGenerationTest::testBuildSquare ( UnstructuredMesh mesh,
unsigned int  n,
ElemType  type 
)
inline

Definition at line 110 of file mesh_generation_test.C.

111 {
112 MeshTools::Generation::build_square (mesh, n, n, -2.0, 3.0, -4.0, 5.0, type);
113 if (type == C0POLYGON)
114 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n + 4 + 2 * (n - 1) + ((n - 1) / 2)));
115 else if (Elem::type_to_n_sides_map[type] == 4)
116 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n));
117 else
118 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*2));
119
120 switch (type)
121 {
122 case TRI3: // First-order elements
123 case QUAD4:
124 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
125 cast_int<dof_id_type>((n+1)*(n+1)));
126 break;
127 case TRI6: // Second-order elements
128 case QUAD9:
129 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
130 cast_int<dof_id_type>((2*n+1)*(2*n+1)));
131 break;
132 case QUAD8: // Not-really-second-order element missing center nodes
133 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
134 cast_int<dof_id_type>((2*n+1)*(2*n+1) - n*n));
135 break;
136 case TRI7: // Not-really-second-order element with extra center nodes
137 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
138 cast_int<dof_id_type>((2*n+1)*(2*n+1) + 2*n*n));
139 break;
140 case C0POLYGON:
141 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
142 cast_int<dof_id_type>(4 + 2*n*n + (n - 1) + 2*n + 2 * (n%2)));
143 break;
144 default: // Wait, what did we try to build?
145 CPPUNIT_ASSERT(false);
146 }
147
148 // Our bounding boxes can be loose on higher order elements, but
149 // we can at least assert that they're not too tight
151 CPPUNIT_ASSERT(bbox.min()(0) <= Real(-2.0));
152 CPPUNIT_ASSERT(bbox.max()(0) >= Real(3.0));
153 CPPUNIT_ASSERT(bbox.min()(1) <= Real(-4.0));
154 CPPUNIT_ASSERT(bbox.max()(1) >= Real(5.0));
155
156 if (type == C0POLYGON)
157 {
159 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(0),
160 Real(-2.0),
162 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(0),
163 Real(3.0),
165 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(1),
166 Real(-4.0),
168 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(1),
169 Real(5.0),
171 }
172
173 // Do serial assertions *after* all parallel assertions, so we
174 // stay in sync after failure on only some processor(s)
175 if (type != C0POLYGON)
176 for (auto & elem : mesh.element_ptr_range())
177 CPPUNIT_ASSERT(elem->has_affine_map());
178 }
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(), libMesh::C0POLYGON, libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::BoundingBox::max(), mesh, libMesh::BoundingBox::min(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::Real, libMesh::TOLERANCE, libMesh::TRI3, libMesh::TRI6, libMesh::TRI7, and libMesh::Elem::type_to_n_sides_map.

Referenced by buildSquareC0PolygonEven(), buildSquareC0PolygonOdd(), buildSquareQuad4(), buildSquareQuad8(), buildSquareQuad9(), buildSquareTri3(), buildSquareTri6(), and buildSquareTri7().

◆ tester()

void MeshGenerationTest::tester ( Builder  f,
unsigned int  n,
ElemType  type 
)
inline

Definition at line 344 of file mesh_generation_test.C.

345 {
346 for (int is_replicated = 0; is_replicated != 2; ++is_replicated)
347 {
348 for (int skip_renumber = 0 ; skip_renumber != 2; ++skip_renumber)
349 {
350 std::unique_ptr<UnstructuredMesh> mesh =
351 new_mesh(is_replicated);
352 mesh->allow_renumbering(!skip_renumber);
353 (this->*f)(*mesh, n, type);
354 }
355 }
356 }
std::unique_ptr< UnstructuredMesh > new_mesh(bool is_replicated)
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
Definition mesh_base.h:1355

References libMesh::MeshBase::allow_renumbering(), mesh, and new_mesh().

Referenced by buildCubeC0Polyhedron(), buildCubeHex20(), buildCubeHex27(), buildCubeHex8(), buildCubePrism15(), buildCubePrism18(), buildCubePrism20(), buildCubePrism21(), buildCubePrism6(), buildCubePyramid13(), buildCubePyramid14(), buildCubePyramid5(), buildCubeTet10(), buildCubeTet14(), buildCubeTet4(), buildLineEdge2(), buildLineEdge3(), buildLineEdge4(), buildSquareC0PolygonEven(), buildSquareC0PolygonOdd(), buildSquareQuad4(), buildSquareQuad8(), buildSquareQuad9(), buildSquareTri3(), buildSquareTri6(), and buildSquareTri7().


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