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 (polyhedronTetNeighbor)
 
 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 polyhedronTetNeighbor ()
 
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< UnstructuredMesh > new_mesh (bool is_replicated)
 

Detailed Description

Definition at line 23 of file mesh_generation_test.C.

Member Typedef Documentation

◆ Builder

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

Definition at line 383 of file mesh_generation_test.C.

Member Function Documentation

◆ buildCubeC0Polyhedron()

void MeshGenerationTest::buildCubeC0Polyhedron ( )
inline

Definition at line 425 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 423 of file mesh_generation_test.C.

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

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

◆ buildCubeHex27()

void MeshGenerationTest::buildCubeHex27 ( )
inline

Definition at line 424 of file mesh_generation_test.C.

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

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

◆ buildCubeHex8()

void MeshGenerationTest::buildCubeHex8 ( )
inline

Definition at line 422 of file mesh_generation_test.C.

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

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

◆ buildCubePrism15()

void MeshGenerationTest::buildCubePrism15 ( )
inline

Definition at line 528 of file mesh_generation_test.C.

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

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

◆ buildCubePrism18()

void MeshGenerationTest::buildCubePrism18 ( )
inline

Definition at line 529 of file mesh_generation_test.C.

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

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

◆ buildCubePrism20()

void MeshGenerationTest::buildCubePrism20 ( )
inline

Definition at line 530 of file mesh_generation_test.C.

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

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

◆ buildCubePrism21()

void MeshGenerationTest::buildCubePrism21 ( )
inline

Definition at line 531 of file mesh_generation_test.C.

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

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

◆ buildCubePrism6()

void MeshGenerationTest::buildCubePrism6 ( )
inline

Definition at line 527 of file mesh_generation_test.C.

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

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

◆ buildCubePyramid13()

void MeshGenerationTest::buildCubePyramid13 ( )
inline

Definition at line 537 of file mesh_generation_test.C.

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

◆ buildCubePyramid14()

void MeshGenerationTest::buildCubePyramid14 ( )
inline

Definition at line 538 of file mesh_generation_test.C.

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

◆ buildCubePyramid5()

void MeshGenerationTest::buildCubePyramid5 ( )
inline

Definition at line 536 of file mesh_generation_test.C.

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

◆ buildCubeTet10()

void MeshGenerationTest::buildCubeTet10 ( )
inline

Definition at line 420 of file mesh_generation_test.C.

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

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

◆ buildCubeTet14()

void MeshGenerationTest::buildCubeTet14 ( )
inline

Definition at line 421 of file mesh_generation_test.C.

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

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

◆ buildCubeTet4()

void MeshGenerationTest::buildCubeTet4 ( )
inline

Definition at line 419 of file mesh_generation_test.C.

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

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

◆ buildLineEdge2()

void MeshGenerationTest::buildLineEdge2 ( )
inline

Definition at line 399 of file mesh_generation_test.C.

399{ 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 400 of file mesh_generation_test.C.

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

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

◆ buildLineEdge4()

void MeshGenerationTest::buildLineEdge4 ( )
inline

Definition at line 401 of file mesh_generation_test.C.

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

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

◆ buildSphereEdge2()

void MeshGenerationTest::buildSphereEdge2 ( )
inline

Definition at line 403 of file mesh_generation_test.C.

403{ 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 404 of file mesh_generation_test.C.

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

References libMesh::EDGE3, and testBuildSphere().

◆ buildSphereEdge4()

void MeshGenerationTest::buildSphereEdge4 ( )
inline

Definition at line 405 of file mesh_generation_test.C.

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

References libMesh::EDGE4, and testBuildSphere().

◆ buildSphereHex27()

void MeshGenerationTest::buildSphereHex27 ( )
inline

Definition at line 542 of file mesh_generation_test.C.

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

References libMesh::HEX27, and testBuildSphere().

◆ buildSphereHex8()

void MeshGenerationTest::buildSphereHex8 ( )
inline

Definition at line 541 of file mesh_generation_test.C.

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

References libMesh::HEX8, and testBuildSphere().

◆ buildSphereQuad4()

void MeshGenerationTest::buildSphereQuad4 ( )
inline

Definition at line 417 of file mesh_generation_test.C.

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

References libMesh::QUAD4, and testBuildSphere().

◆ buildSphereTri3()

void MeshGenerationTest::buildSphereTri3 ( )
inline

Definition at line 416 of file mesh_generation_test.C.

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

References testBuildSphere(), and libMesh::TRI3.

◆ buildSquareC0PolygonEven()

void MeshGenerationTest::buildSquareC0PolygonEven ( )
inline

Definition at line 414 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 413 of file mesh_generation_test.C.

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

◆ buildSquareQuad4()

void MeshGenerationTest::buildSquareQuad4 ( )
inline

Definition at line 410 of file mesh_generation_test.C.

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

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

◆ buildSquareQuad8()

void MeshGenerationTest::buildSquareQuad8 ( )
inline

Definition at line 411 of file mesh_generation_test.C.

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

◆ buildSquareQuad9()

void MeshGenerationTest::buildSquareQuad9 ( )
inline

Definition at line 412 of file mesh_generation_test.C.

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

◆ buildSquareTri3()

void MeshGenerationTest::buildSquareTri3 ( )
inline

Definition at line 407 of file mesh_generation_test.C.

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

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

◆ buildSquareTri6()

void MeshGenerationTest::buildSquareTri6 ( )
inline

Definition at line 408 of file mesh_generation_test.C.

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

◆ buildSquareTri7()

void MeshGenerationTest::buildSquareTri7 ( )
inline

Definition at line 409 of file mesh_generation_test.C.

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

◆ CPPUNIT_TEST() [1/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeC0Polyhedron  )

◆ CPPUNIT_TEST() [2/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeHex20  )

◆ CPPUNIT_TEST() [3/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeHex27  )

◆ CPPUNIT_TEST() [4/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeHex8  )

◆ CPPUNIT_TEST() [5/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism15  )

◆ CPPUNIT_TEST() [6/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism18  )

◆ CPPUNIT_TEST() [7/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism20  )

◆ CPPUNIT_TEST() [8/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism21  )

◆ CPPUNIT_TEST() [9/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePrism6  )

◆ CPPUNIT_TEST() [10/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePyramid13  )

◆ CPPUNIT_TEST() [11/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePyramid14  )

◆ CPPUNIT_TEST() [12/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubePyramid5  )

◆ CPPUNIT_TEST() [13/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeTet10  )

◆ CPPUNIT_TEST() [14/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeTet14  )

◆ CPPUNIT_TEST() [15/33]

MeshGenerationTest::CPPUNIT_TEST ( buildCubeTet4  )

◆ CPPUNIT_TEST() [16/33]

MeshGenerationTest::CPPUNIT_TEST ( buildLineEdge2  )

◆ CPPUNIT_TEST() [17/33]

MeshGenerationTest::CPPUNIT_TEST ( buildLineEdge3  )

◆ CPPUNIT_TEST() [18/33]

MeshGenerationTest::CPPUNIT_TEST ( buildLineEdge4  )

◆ CPPUNIT_TEST() [19/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereEdge2  )

◆ CPPUNIT_TEST() [20/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereEdge3  )

◆ CPPUNIT_TEST() [21/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereHex27  )

◆ CPPUNIT_TEST() [22/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereHex8  )

◆ CPPUNIT_TEST() [23/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereQuad4  )

◆ CPPUNIT_TEST() [24/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSphereTri3  )

◆ CPPUNIT_TEST() [25/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareC0PolygonEven  )

◆ CPPUNIT_TEST() [26/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareC0PolygonOdd  )

◆ CPPUNIT_TEST() [27/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareQuad4  )

◆ CPPUNIT_TEST() [28/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareQuad8  )

◆ CPPUNIT_TEST() [29/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareQuad9  )

◆ CPPUNIT_TEST() [30/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareTri3  )

◆ CPPUNIT_TEST() [31/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareTri6  )

◆ CPPUNIT_TEST() [32/33]

MeshGenerationTest::CPPUNIT_TEST ( buildSquareTri7  )

◆ CPPUNIT_TEST() [33/33]

MeshGenerationTest::CPPUNIT_TEST ( polyhedronTetNeighbor  )

◆ 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 91 of file mesh_generation_test.C.

92 {
93 if (is_replicated)
94 return std::make_unique<ReplicatedMesh>(*TestCommWorld);
95 return std::make_unique<DistributedMesh>(*TestCommWorld);
96 }

References TestCommWorld.

Referenced by polyhedronTetNeighbor(), and tester().

◆ polyhedronTetNeighbor()

void MeshGenerationTest::polyhedronTetNeighbor ( )
inline

Definition at line 434 of file mesh_generation_test.C.

435 {
436 LOG_UNIT_TEST;
437
438 // Exercise both a replicated and a (genuinely) distributed mesh; on
439 // a DistributedMesh with more ranks than elements this used to be
440 // built in a way that dereferenced elements deleted by
441 // delete_remote_elements(), so we must not hold element pointers
442 // across prepare_for_use() and must reduce counts across ranks.
443 for (int is_replicated = 0; is_replicated != 2; ++is_replicated)
444 {
445 std::unique_ptr<UnstructuredMesh> mesh_ptr = new_mesh(is_replicated);
446 UnstructuredMesh & mesh = *mesh_ptr;
447
448 // Five nodes: {0,1,2,3} form a tet-shaped polyhedron, and the
449 // TET4 is {1,2,3,4} on the far side of the shared face {1,2,3}.
450 mesh.add_point(Point(0,0,0), 0);
451 mesh.add_point(Point(1,0,0), 1);
452 mesh.add_point(Point(0,1,0), 2);
453 mesh.add_point(Point(0,0,1), 3);
454 mesh.add_point(Point(1,1,1), 4);
455
456 auto tri = [&mesh](dof_id_type a, dof_id_type b, dof_id_type c)
457 {
458 auto p = std::make_shared<C0Polygon>(3);
459 p->set_node(0, mesh.node_ptr(a));
460 p->set_node(1, mesh.node_ptr(b));
461 p->set_node(2, mesh.node_ptr(c));
462 return std::shared_ptr<Polygon>(std::move(p));
463 };
464
465 std::vector<std::shared_ptr<Polygon>> faces =
466 { tri(0,1,2), tri(0,1,3), tri(1,2,3), tri(0,2,3) };
467
468 std::unique_ptr<Node> mid_elem_node;
469 std::unique_ptr<Elem> poly =
470 std::make_unique<C0Polyhedron>(faces, mid_elem_node);
471 if (mid_elem_node)
472 mesh.add_node(std::move(mid_elem_node));
473 poly->set_id() = 0;
474 mesh.add_elem(std::move(poly));
475
476 std::unique_ptr<Elem> tet = Elem::build(TET4);
477 tet->set_id() = 1;
478 tet->set_node(0, mesh.node_ptr(1));
479 tet->set_node(1, mesh.node_ptr(2));
480 tet->set_node(2, mesh.node_ptr(3));
481 tet->set_node(3, mesh.node_ptr(4));
482 mesh.add_elem(std::move(tet));
483
485
486 // find_neighbors() must link the polyhedron's C0POLYGON face to
487 // the tet's TRI3 face. Count the interface from each owned
488 // element's side and reduce, so the check is valid however the
489 // two elements are partitioned.
490 int poly_to_tet = 0, tet_to_poly = 0;
491 for (const Elem * elem : mesh.active_local_element_ptr_range())
492 for (auto s : elem->side_index_range())
493 {
494 const Elem * neigh = elem->neighbor_ptr(s);
495 if (!neigh)
496 continue;
497
498 if (elem->type() == C0POLYHEDRON)
499 {
500 ++poly_to_tet;
501 if (!neigh->is_remote())
502 {
503 CPPUNIT_ASSERT_EQUAL(neigh->type(), TET4);
504 CPPUNIT_ASSERT(neigh->neighbor_ptr
505 (neigh->which_neighbor_am_i(elem)) == elem);
506 }
507 }
508 else if (elem->type() == TET4)
509 {
510 ++tet_to_poly;
511 if (!neigh->is_remote())
512 {
513 CPPUNIT_ASSERT_EQUAL(neigh->type(), C0POLYHEDRON);
514 CPPUNIT_ASSERT(neigh->neighbor_ptr
515 (neigh->which_neighbor_am_i(elem)) == elem);
516 }
517 }
518 }
519 mesh.comm().sum(poly_to_tet);
520 mesh.comm().sum(tet_to_poly);
521
522 CPPUNIT_ASSERT_EQUAL(1, poly_to_tet);
523 CPPUNIT_ASSERT_EQUAL(1, tet_to_poly);
524 }
525 }
std::unique_ptr< UnstructuredMesh > new_mesh(bool is_replicated)
dof_id_type & set_id()
Definition dof_object.h:841
This is the base class from which all geometric element types are derived.
Definition elem.h:96
unsigned int which_neighbor_am_i(const Elem *e) const
This function tells you which neighbor e is.
Definition elem.h:3057
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:382
virtual bool is_remote() const
Definition elem.h:617
virtual ElemType type() const =0
const Elem * neighbor_ptr(unsigned int i) const
Definition elem.h:2736
virtual const Node * node_ptr(const dof_id_type i) const =0
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
Definition mesh_base.C:824
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
The UnstructuredMesh class is derived from the MeshBase class.
static const Real b
MeshBase & mesh
uint8_t dof_id_type
Definition id_types.h:67

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_node(), libMesh::MeshBase::add_point(), b, libMesh::Elem::build(), libMesh::C0POLYHEDRON, libMesh::ParallelObject::comm(), libMesh::Elem::is_remote(), mesh, libMesh::Elem::neighbor_ptr(), new_mesh(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::set_id(), libMesh::Parallel::Communicator::sum(), libMesh::TET4, libMesh::Elem::type(), and libMesh::Elem::which_neighbor_am_i().

◆ setUp()

void MeshGenerationTest::setUp ( )
inline

Definition at line 99 of file mesh_generation_test.C.

99{}

◆ tearDown()

void MeshGenerationTest::tearDown ( )
inline

Definition at line 101 of file mesh_generation_test.C.

101{}

◆ testBuildCube()

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

Definition at line 190 of file mesh_generation_test.C.

191 {
192 MeshTools::Generation::build_cube (mesh, n, n, n, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, type);
193 if (type == C0POLYHEDRON)
194 {
195 const dof_id_type grid_nodes = cast_int<dof_id_type>((n+1)*(n+1)*(n+1));
196
197 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n));
198 CPPUNIT_ASSERT(mesh.n_nodes() >= grid_nodes);
199 CPPUNIT_ASSERT(mesh.n_nodes() <= grid_nodes + cast_int<dof_id_type>(n*n*n));
200 }
201 else
202 {
203 switch (Elem::type_to_n_sides_map[type])
204 {
205 case 4: // tets
206 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n*24));
207 break;
208 case 5: // prisms, pyramids
209 if (type == PRISM6 || type == PRISM15 || type == PRISM18 ||
210 type == PRISM20 || type == PRISM21)
211 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n*2));
212 else
213 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n*6));
214 break;
215 case 6: // hexes
216 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n*n*n));
217 break;
218 default:
219 libmesh_error();
220 }
221
222
223 switch (Elem::type_to_n_nodes_map[type])
224 {
225 case 4: // First-order tets
226 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
227 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n + 3*(n+1)*n*n));
228 break;
229 case 6: // First-order prisms and hexes use the same nodes
230 case 8:
231 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
232 cast_int<dof_id_type>((n+1)*(n+1)*(n+1)));
233 break;
234 case 10: // Second-order tets
235 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
236 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n));
237 break;
238 case 18:
239 case 27: // Second-order prisms and hexes use the same nodes
240 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
241 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1)));
242 break;
243 case 20:
244 if (type == HEX20)
245 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
246 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 3*(n+1)*n*n));
247 if (type == PRISM20)
248 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
249 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(n+1)*n*n));
250 break;
251 case 21: // Prisms based on full Tri7 cross sections
252 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
253 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 2*(2*n+1)*n*n));
254 break;
255 case 15: // weird partial order prism
256 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
257 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) - n*n*n - 2*(n+1)*n*n));
258 break;
259 case 5: // pyramids
260 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
261 cast_int<dof_id_type>((n+1)*(n+1)*(n+1) + n*n*n));
262 break;
263 case 13:
264 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
265 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n - 3*(n+1)*n*n));
266 break;
267 case 14: // pyramids, tets
268 if (type == PYRAMID14)
269 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
270 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 8*n*n*n));
271 else // TET14
272 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
273 cast_int<dof_id_type>((2*n+1)*(2*n+1)*(2*n+1) + 14*n*n*n + 4*3*(n+1)*n*n +
274 36*n*n*n + 4*3*(n+1)*n*n));
275 break;
276 default:
277 libmesh_error();
278 }
279 }
280
281 // Our bounding boxes can be loose on higher order elements, but
282 // we can at least assert that they're not too tight
284 CPPUNIT_ASSERT(bbox.min()(0) <= Real(-2.0));
285 CPPUNIT_ASSERT(bbox.max()(0) >= Real(3.0));
286 CPPUNIT_ASSERT(bbox.min()(1) <= Real(-4.0));
287 CPPUNIT_ASSERT(bbox.max()(1) >= Real(5.0));
288 CPPUNIT_ASSERT(bbox.min()(2) <= Real(-6.0));
289 CPPUNIT_ASSERT(bbox.max()(2) >= Real(7.0));
290
291 if (type == C0POLYHEDRON)
292 {
294 const Real expected_volume = Real(5) * Real(9) * Real(13);
295
296 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(0),
297 Real(-2.0),
299 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(0),
300 Real(3.0),
302 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(1),
303 Real(-4.0),
305 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(1),
306 Real(5.0),
308 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.min()(2),
309 Real(-6.0),
311 LIBMESH_ASSERT_FP_EQUAL(nodal_bbox.max()(2),
312 Real(7.0),
314 LIBMESH_ASSERT_FP_EQUAL(MeshTools::volume(mesh),
315 expected_volume,
317
318 for (auto & elem : mesh.element_ptr_range())
319 {
320 CPPUNIT_ASSERT_EQUAL(elem->type(), C0POLYHEDRON);
321 CPPUNIT_ASSERT_EQUAL(elem->n_sides(), 6u);
322 CPPUNIT_ASSERT(elem->n_sub_elem() > 0);
323 CPPUNIT_ASSERT(elem->volume() > 0);
324 }
325
326 // Verify that find_neighbors() actually linked the polyhedra to
327 // one another. This is a regression test for a bug where
328 // Polyhedron::low_order_key() hashed a face's nodes in their
329 // stored (winding) order rather than sorted; since two adjacent
330 // cells wind their shared face in opposite orders, the keys
331 // never matched and every interior face was left looking like a
332 // boundary face with no neighbor. For an n x n x n cube there
333 // are 3*(n-1)*n*n interior faces, each shared by two elements,
334 // so 2*3*(n-1)*n*n sides should carry a neighbor link.
335 int n_neighbor_links = 0;
336 for (auto & elem : mesh.active_local_element_ptr_range())
337 for (auto s : elem->side_index_range())
338 {
339 const Elem * neigh = elem->neighbor_ptr(s);
340 if (!neigh)
341 continue;
342 ++n_neighbor_links;
343
344 // Links to a non-remote neighbor must be reciprocal.
345 if (!neigh->is_remote())
346 {
347 const unsigned int ns = neigh->which_neighbor_am_i(elem);
348 CPPUNIT_ASSERT(ns < neigh->n_sides());
349 CPPUNIT_ASSERT(neigh->neighbor_ptr(ns) == elem);
350 }
351 }
352 mesh.comm().sum(n_neighbor_links);
353
354 CPPUNIT_ASSERT_EQUAL(n_neighbor_links,
355 static_cast<int>(2 * 3 * (n-1) * n * n));
356
357 return;
358 }
359
360 // We don't yet try to do affine map optimizations on pyramids
361 if (type == PYRAMID5 ||
362 type == PYRAMID13 ||
363 type == PYRAMID14)
364 return;
365
366 // Do serial assertions *after* all parallel assertions, so we
367 // stay in sync after failure on only some processor(s)
368 for (auto & elem : mesh.element_ptr_range())
369 CPPUNIT_ASSERT(elem->has_affine_map());
370 }
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_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:759
static constexpr 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:664
virtual dof_id_type n_elem() const =0
virtual dof_id_type n_nodes() const =0
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
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

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

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 103 of file mesh_generation_test.C.

104 {
105 MeshTools::Generation::build_line (mesh, n, -1.0, 2.0, type);
106 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), cast_int<dof_id_type>(n));
107 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
108 cast_int<dof_id_type>((Elem::type_to_n_nodes_map[type]-1)*n + 1));
109
111 CPPUNIT_ASSERT_EQUAL(bbox.min()(0), Real(-1.0));
112 CPPUNIT_ASSERT_EQUAL(bbox.max()(0), Real(2.0));
113
114 // Do serial assertions *after* all parallel assertions, so we
115 // stay in sync after failure on only some processor(s)
116 for (auto & elem : mesh.element_ptr_range())
117 CPPUNIT_ASSERT(elem->has_affine_map());
118 }
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 372 of file mesh_generation_test.C.

373 {
374 ReplicatedMesh rmesh(*TestCommWorld);
375 MeshTools::Generation::build_sphere (rmesh, 2.0, n_ref, type);
376
377 DistributedMesh dmesh(*TestCommWorld);
378 dmesh.allow_renumbering(false);
379 MeshTools::Generation::build_sphere (dmesh, 2.0, n_ref, type);
380 }
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 120 of file mesh_generation_test.C.

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

386 {
387 for (int is_replicated = 0; is_replicated != 2; ++is_replicated)
388 {
389 for (int skip_renumber = 0 ; skip_renumber != 2; ++skip_renumber)
390 {
391 std::unique_ptr<UnstructuredMesh> mesh =
392 new_mesh(is_replicated);
393 mesh->allow_renumbering(!skip_renumber);
394 (this->*f)(*mesh, n, type);
395 }
396 }
397 }
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:1359

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: