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

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MeshInputTest)
 
 CPPUNIT_TEST (testVTKPreserveElemIds)
 
 CPPUNIT_TEST (testVTKPreserveSubdomainIds)
 
 CPPUNIT_TEST (testVTKReadPolyhedra)
 
 CPPUNIT_TEST (testVTKReadPolyhedraSerial)
 
 CPPUNIT_TEST (testVTKReadNotAnXMLFile)
 
 CPPUNIT_TEST (testExodusCopyNodalSolutionDistributed)
 
 CPPUNIT_TEST (testExodusCopyElementSolutionDistributed)
 
 CPPUNIT_TEST (testExodusCopyNodalSolutionReplicated)
 
 CPPUNIT_TEST (testExodusCopyElementSolutionReplicated)
 
 CPPUNIT_TEST (testExodusCopyHighOrderElementSolution)
 
 CPPUNIT_TEST (testExodusReadHeader)
 
 CPPUNIT_TEST (testExodusSetNodeUniqueIdsFromMaps)
 
 CPPUNIT_TEST (testExodusSetElemUniqueIdsFromMaps)
 
 CPPUNIT_TEST (testExodusIGASidesets)
 
 CPPUNIT_TEST (testLowOrderEdgeBlocks)
 
 CPPUNIT_TEST (testExodusCopyElementVectorDistributed)
 
 CPPUNIT_TEST (testExodusCopyElementVectorReplicated)
 
 CPPUNIT_TEST (testExodusWriteElementDataFromDiscontinuousNodalData)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesEdgeC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesEdgeC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesMixedEdgeC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesMixedEdgeC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesTriC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesTriC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesMixedTriC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesMixedTriC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesQuadC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesQuadC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesMixedQuadC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesMixedQuadC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesHexC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesHexC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesMixedHexC0)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesMixedHexC0)
 
 CPPUNIT_TEST (testExodusWriteAddedSidesHexDisc)
 
 CPPUNIT_TEST (testExodusDiscWriteAddedSidesHexDisc)
 
 CPPUNIT_TEST (testExodusFileMappingsPlateWithHole)
 
 CPPUNIT_TEST (testExodusFileMappingsTwoBlocks)
 
 CPPUNIT_TEST (testExodusFileMappingsTwoElemIGA)
 
 CPPUNIT_TEST (testExodusFileMappingsCyl3d)
 
 CPPUNIT_TEST (testExodusDiscPlateWithHole)
 
 CPPUNIT_TEST (testExodusDiscTwoBlocks)
 
 CPPUNIT_TEST (testExodusDiscTwoElemIGA)
 
 CPPUNIT_TEST (testExodusDiscCyl3d)
 
 CPPUNIT_TEST (testNemesisReadReplicated)
 
 CPPUNIT_TEST (testNemesisReadDistributed)
 
 CPPUNIT_TEST (testNemesisCopyNodalSolutionDistributed)
 
 CPPUNIT_TEST (testNemesisCopyNodalSolutionReplicated)
 
 CPPUNIT_TEST (testNemesisCopyElementSolutionDistributed)
 
 CPPUNIT_TEST (testNemesisCopyElementSolutionReplicated)
 
 CPPUNIT_TEST (testNemesisSingleElementDistributed)
 
 CPPUNIT_TEST (testNemesisSingleElementReplicated)
 
 CPPUNIT_TEST (testNemesisCopyElementVectorDistributed)
 
 CPPUNIT_TEST (testNemesisCopyElementVectorReplicated)
 
 CPPUNIT_TEST (testAbaqusReadFirst)
 
 CPPUNIT_TEST (testAbaqusReadSecond)
 
 CPPUNIT_TEST (testDynaReadElem)
 
 CPPUNIT_TEST (testDynaNoSplines)
 
 CPPUNIT_TEST (testDynaReadPatch)
 
 CPPUNIT_TEST (testDynaFileMappingsFEMEx5)
 
 CPPUNIT_TEST (testDynaFileMappingsBlockWithHole)
 
 CPPUNIT_TEST (testDynaFileMappingsPlateWithHole)
 
 CPPUNIT_TEST (testDynaFileMappingsCyl3d)
 
 CPPUNIT_TEST (testBadGmsh)
 
 CPPUNIT_TEST (testGoodGmsh)
 
 CPPUNIT_TEST (testGoodSTL)
 
 CPPUNIT_TEST (testGoodSTLBinary)
 
 CPPUNIT_TEST (testGmshBCIDOverlap)
 
 CPPUNIT_TEST (testTetgenIO)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testVTKPreserveElemIds ()
 
void testVTKPreserveSubdomainIds ()
 
void checkHexPrismPolyhedron (MeshBase &mesh)
 
void testVTKReadPolyhedra ()
 
void testVTKReadPolyhedraSerial ()
 
void testVTKReadNotAnXMLFile ()
 
void testExodusSetNodeUniqueIdsFromMaps_implementation (bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
 
void testExodusSetNodeUniqueIdsFromMaps ()
 
void testExodusSetElemUniqueIdsFromMaps_implementation (bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
 
void testExodusSetElemUniqueIdsFromMaps ()
 
void testExodusReadHeader ()
 
void testLowOrderEdgeBlocks ()
 
void testExodusIGASidesets ()
 
template<typename MeshType , typename IOType >
void testCopyNodalSolutionImpl (const std::string &filename)
 
void testExodusCopyNodalSolutionReplicated ()
 
void testExodusCopyNodalSolutionDistributed ()
 
void testNemesisCopyNodalSolutionReplicated ()
 
void testNemesisCopyNodalSolutionDistributed ()
 
template<typename MeshType , typename IOType >
void testCopyElementSolutionImpl (const std::string &filename)
 
void testExodusCopyElementSolutionReplicated ()
 
void testExodusCopyElementSolutionDistributed ()
 
void testExodusCopyHighOrderElementSolution ()
 
void testNemesisCopyElementSolutionReplicated ()
 
void testNemesisCopyElementSolutionDistributed ()
 
template<typename MeshType , typename IOType >
void testSingleElementImpl (const std::string &filename)
 
void testNemesisSingleElementReplicated ()
 
void testNemesisSingleElementDistributed ()
 
template<typename MeshType , typename IOType >
void testCopyElementVectorImpl (const std::string &filename)
 
void testExodusCopyElementVectorReplicated ()
 
void testExodusCopyElementVectorDistributed ()
 
void testNemesisCopyElementVectorReplicated ()
 
void testNemesisCopyElementVectorDistributed ()
 
void testExodusWriteElementDataFromDiscontinuousNodalData ()
 
void testExodusWriteAddedSides (Number(*exact_sol)(const Point &, const Parameters &, const std::string &, const std::string &), const ElemType elem_type, const Order order, const bool write_discontinuous=false, const std::vector< FEType > earlier_vars={}, const std::vector< FEType > later_vars={})
 
void testExodusWriteAddedSidesEdgeC0 ()
 
void testExodusDiscWriteAddedSidesEdgeC0 ()
 
void testExodusWriteAddedSidesMixedEdgeC0 ()
 
void testExodusDiscWriteAddedSidesMixedEdgeC0 ()
 
void testExodusWriteAddedSidesEdgeDisc ()
 
void testExodusDiscWriteAddedSidesEdgeDisc ()
 
void testExodusWriteAddedSidesTriC0 ()
 
void testExodusDiscWriteAddedSidesTriC0 ()
 
void testExodusWriteAddedSidesMixedTriC0 ()
 
void testExodusDiscWriteAddedSidesMixedTriC0 ()
 
void testExodusWriteAddedSidesTriDisc ()
 
void testExodusDiscWriteAddedSidesTriDisc ()
 
void testExodusWriteAddedSidesQuadC0 ()
 
void testExodusDiscWriteAddedSidesQuadC0 ()
 
void testExodusWriteAddedSidesMixedQuadC0 ()
 
void testExodusDiscWriteAddedSidesMixedQuadC0 ()
 
void testExodusWriteAddedSidesQuadDisc ()
 
void testExodusDiscWriteAddedSidesQuadDisc ()
 
void testExodusWriteAddedSidesTetC0 ()
 
void testExodusDiscWriteAddedSidesTetC0 ()
 
void testExodusWriteAddedSidesTetDisc ()
 
void testExodusDiscWriteAddedSidesTetDisc ()
 
void testExodusWriteAddedSidesHexC0 ()
 
void testExodusDiscWriteAddedSidesHexC0 ()
 
void testExodusWriteAddedSidesMixedHexC0 ()
 
void testExodusDiscWriteAddedSidesMixedHexC0 ()
 
void testExodusWriteAddedSidesHexDisc ()
 
void testExodusDiscWriteAddedSidesHexDisc ()
 
template<typename MeshType >
void testNemesisReadImpl ()
 
void testNemesisReadReplicated ()
 
void testNemesisReadDistributed ()
 
void testMasterCenters (const MeshBase &mesh)
 
void helperTestingDynaQuad (const MeshBase &mesh)
 
void testAbaqusRead (const std::string &fname, dof_id_type n_elem, dof_id_type n_nodes)
 
void testAbaqusReadFirst ()
 
void testAbaqusReadSecond ()
 
void testDynaReadElem ()
 
void testBadGmsh ()
 
void testGoodGmsh ()
 
void testGmshBCIDOverlap ()
 
void testGoodSTL ()
 
void testGoodSTLBinary ()
 
void testTetgenIO ()
 
void testDynaNoSplines ()
 
void testDynaReadPatch ()
 
void testProjectionRegression (MeshBase &mesh, std::array< Real, 4 > expected_norms)
 
void testDynaFileMappings (const std::string &filename, std::array< Real, 4 > expected_norms)
 
void testDynaFileMappingsFEMEx5 ()
 
void testDynaFileMappingsBlockWithHole ()
 
void testDynaFileMappingsPlateWithHole ()
 
void testDynaFileMappingsCyl3d ()
 
void testExodusFileMappings (const std::string &filename, std::array< Real, 4 > expected_norms, bool use_disc_bex=false)
 
void testExodusFileMappingsPlateWithHole ()
 
void testExodusFileMappingsTwoBlocks ()
 
void testExodusFileMappingsTwoElemIGA ()
 
void testExodusFileMappingsCyl3d ()
 
void testExodusDiscPlateWithHole ()
 
void testExodusDiscTwoBlocks ()
 
void testExodusDiscTwoElemIGA ()
 
void testExodusDiscCyl3d ()
 

Detailed Description

Definition at line 100 of file mesh_input.C.

Member Function Documentation

◆ checkHexPrismPolyhedron()

void MeshInputTest::checkHexPrismPolyhedron ( MeshBase &  mesh)
inline

Definition at line 343 of file mesh_input.C.

344 {
345 CPPUNIT_ASSERT_EQUAL(dof_id_type(1), mesh.n_elem());
346
347 // The element may live on a single processor when the mesh is
348 // distributed, so guard the checks accordingly.
349 const Elem * elem = mesh.query_elem_ptr(0);
350 bool found_elem = elem;
351 mesh.comm().max(found_elem);
352 CPPUNIT_ASSERT(found_elem);
353
354 if (!elem)
355 return;
356
357 CPPUNIT_ASSERT_EQUAL(C0POLYHEDRON, elem->type());
358 CPPUNIT_ASSERT_EQUAL(12u, elem->n_vertices());
359 CPPUNIT_ASSERT_EQUAL(8u, elem->n_sides());
360
361 // The file has no libmesh_node_id array, so libMesh node ids match
362 // the VTK point ordering, i.e. the coordinates we wrote out.
363 LIBMESH_ASSERT_FP_EQUAL(6.0, elem->volume(), TOLERANCE);
364
365 // Collect the faces (as node-id sets) and compare against the faces
366 // that were written to the file, independent of any reordering the
367 // C0Polyhedron may do to its sides.
368 std::set<std::set<dof_id_type>> faces;
369 for (auto s : elem->side_index_range())
370 {
371 std::set<dof_id_type> face;
372 for (const auto n : elem->nodes_on_side(s))
373 face.insert(elem->node_id(n));
374 faces.insert(std::move(face));
375 }
376
377 const std::set<std::set<dof_id_type>> expected_faces =
378 { {0, 1, 2, 3, 4, 5},
379 {0, 1, 7, 6},
380 {1, 2, 8, 7},
381 {2, 3, 9, 8},
382 {3, 4, 10, 9},
383 {4, 5, 11, 10},
384 {5, 0, 6, 11},
385 {6, 7, 8, 9, 10, 11} };
386
387 CPPUNIT_ASSERT(faces == expected_faces);
388 }
void max(const T &r, T &o, Request &req) const
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual unsigned int n_vertices() const =0
virtual Real volume() const
Definition elem.C:3865
virtual ElemType type() const =0
virtual unsigned int n_sides() const =0
virtual dof_id_type n_elem() const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
const Parallel::Communicator & comm() const
MeshBase & mesh
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67

References libMesh::C0POLYHEDRON, libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::max(), mesh, libMesh::MeshBase::n_elem(), libMesh::Elem::n_sides(), libMesh::Elem::n_vertices(), libMesh::Elem::node_id(), libMesh::Elem::nodes_on_side(), libMesh::MeshBase::query_elem_ptr(), libMesh::Elem::side_index_range(), libMesh::TOLERANCE, libMesh::Elem::type(), and libMesh::Elem::volume().

Referenced by testVTKReadPolyhedra(), and testVTKReadPolyhedraSerial().

◆ CPPUNIT_TEST() [1/69]

MeshInputTest::CPPUNIT_TEST ( testAbaqusReadFirst  )

◆ CPPUNIT_TEST() [2/69]

MeshInputTest::CPPUNIT_TEST ( testAbaqusReadSecond  )

◆ CPPUNIT_TEST() [3/69]

MeshInputTest::CPPUNIT_TEST ( testBadGmsh  )

◆ CPPUNIT_TEST() [4/69]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsBlockWithHole  )

◆ CPPUNIT_TEST() [5/69]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsCyl3d  )

◆ CPPUNIT_TEST() [6/69]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsFEMEx5  )

◆ CPPUNIT_TEST() [7/69]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsPlateWithHole  )

◆ CPPUNIT_TEST() [8/69]

MeshInputTest::CPPUNIT_TEST ( testDynaNoSplines  )

◆ CPPUNIT_TEST() [9/69]

MeshInputTest::CPPUNIT_TEST ( testDynaReadElem  )

◆ CPPUNIT_TEST() [10/69]

MeshInputTest::CPPUNIT_TEST ( testDynaReadPatch  )

◆ CPPUNIT_TEST() [11/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementSolutionDistributed  )

◆ CPPUNIT_TEST() [12/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementSolutionReplicated  )

◆ CPPUNIT_TEST() [13/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementVectorDistributed  )

◆ CPPUNIT_TEST() [14/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementVectorReplicated  )

◆ CPPUNIT_TEST() [15/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyHighOrderElementSolution  )

◆ CPPUNIT_TEST() [16/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyNodalSolutionDistributed  )

◆ CPPUNIT_TEST() [17/69]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyNodalSolutionReplicated  )

◆ CPPUNIT_TEST() [18/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscCyl3d  )

◆ CPPUNIT_TEST() [19/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscPlateWithHole  )

◆ CPPUNIT_TEST() [20/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscTwoBlocks  )

◆ CPPUNIT_TEST() [21/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscTwoElemIGA  )

◆ CPPUNIT_TEST() [22/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesEdgeC0  )

◆ CPPUNIT_TEST() [23/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesHexC0  )

◆ CPPUNIT_TEST() [24/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesHexDisc  )

◆ CPPUNIT_TEST() [25/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedEdgeC0  )

◆ CPPUNIT_TEST() [26/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedHexC0  )

◆ CPPUNIT_TEST() [27/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedQuadC0  )

◆ CPPUNIT_TEST() [28/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedTriC0  )

◆ CPPUNIT_TEST() [29/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesQuadC0  )

◆ CPPUNIT_TEST() [30/69]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesTriC0  )

◆ CPPUNIT_TEST() [31/69]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsCyl3d  )

◆ CPPUNIT_TEST() [32/69]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsPlateWithHole  )

◆ CPPUNIT_TEST() [33/69]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsTwoBlocks  )

◆ CPPUNIT_TEST() [34/69]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsTwoElemIGA  )

◆ CPPUNIT_TEST() [35/69]

MeshInputTest::CPPUNIT_TEST ( testExodusIGASidesets  )

◆ CPPUNIT_TEST() [36/69]

MeshInputTest::CPPUNIT_TEST ( testExodusReadHeader  )

◆ CPPUNIT_TEST() [37/69]

MeshInputTest::CPPUNIT_TEST ( testExodusSetElemUniqueIdsFromMaps  )

◆ CPPUNIT_TEST() [38/69]

MeshInputTest::CPPUNIT_TEST ( testExodusSetNodeUniqueIdsFromMaps  )

◆ CPPUNIT_TEST() [39/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesEdgeC0  )

◆ CPPUNIT_TEST() [40/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesHexC0  )

◆ CPPUNIT_TEST() [41/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesHexDisc  )

◆ CPPUNIT_TEST() [42/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedEdgeC0  )

◆ CPPUNIT_TEST() [43/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedHexC0  )

◆ CPPUNIT_TEST() [44/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedQuadC0  )

◆ CPPUNIT_TEST() [45/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedTriC0  )

◆ CPPUNIT_TEST() [46/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesQuadC0  )

◆ CPPUNIT_TEST() [47/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesTriC0  )

◆ CPPUNIT_TEST() [48/69]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteElementDataFromDiscontinuousNodalData  )

◆ CPPUNIT_TEST() [49/69]

MeshInputTest::CPPUNIT_TEST ( testGmshBCIDOverlap  )

◆ CPPUNIT_TEST() [50/69]

MeshInputTest::CPPUNIT_TEST ( testGoodGmsh  )

◆ CPPUNIT_TEST() [51/69]

MeshInputTest::CPPUNIT_TEST ( testGoodSTL  )

◆ CPPUNIT_TEST() [52/69]

MeshInputTest::CPPUNIT_TEST ( testGoodSTLBinary  )

◆ CPPUNIT_TEST() [53/69]

MeshInputTest::CPPUNIT_TEST ( testLowOrderEdgeBlocks  )

◆ CPPUNIT_TEST() [54/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementSolutionDistributed  )

◆ CPPUNIT_TEST() [55/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementSolutionReplicated  )

◆ CPPUNIT_TEST() [56/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementVectorDistributed  )

◆ CPPUNIT_TEST() [57/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementVectorReplicated  )

◆ CPPUNIT_TEST() [58/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyNodalSolutionDistributed  )

◆ CPPUNIT_TEST() [59/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyNodalSolutionReplicated  )

◆ CPPUNIT_TEST() [60/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisReadDistributed  )

◆ CPPUNIT_TEST() [61/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisReadReplicated  )

◆ CPPUNIT_TEST() [62/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisSingleElementDistributed  )

◆ CPPUNIT_TEST() [63/69]

MeshInputTest::CPPUNIT_TEST ( testNemesisSingleElementReplicated  )

◆ CPPUNIT_TEST() [64/69]

MeshInputTest::CPPUNIT_TEST ( testTetgenIO  )

◆ CPPUNIT_TEST() [65/69]

MeshInputTest::CPPUNIT_TEST ( testVTKPreserveElemIds  )

◆ CPPUNIT_TEST() [66/69]

MeshInputTest::CPPUNIT_TEST ( testVTKPreserveSubdomainIds  )

◆ CPPUNIT_TEST() [67/69]

MeshInputTest::CPPUNIT_TEST ( testVTKReadNotAnXMLFile  )

◆ CPPUNIT_TEST() [68/69]

MeshInputTest::CPPUNIT_TEST ( testVTKReadPolyhedra  )

◆ CPPUNIT_TEST() [69/69]

MeshInputTest::CPPUNIT_TEST ( testVTKReadPolyhedraSerial  )

◆ CPPUNIT_TEST_SUITE_END()

MeshInputTest::CPPUNIT_TEST_SUITE_END ( )

◆ helperTestingDynaQuad()

void MeshInputTest::helperTestingDynaQuad ( const MeshBase &  mesh)
inline

Definition at line 1802 of file mesh_input.C.

1803 {
1804 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
1806
1807 unsigned char weight_index = mesh.default_mapping_data();
1808
1809 bool found_the_quad = false;
1810
1811 for (auto & elem : mesh.element_ptr_range())
1812 {
1813 if (elem->type() == NODEELEM)
1814 continue;
1815
1816 CPPUNIT_ASSERT_EQUAL(elem->type(), QUAD9);
1817 found_the_quad = true;
1818
1819 for (unsigned int n=0; n != 9; ++n)
1820 CPPUNIT_ASSERT_EQUAL
1821 (elem->node_ref(n).get_extra_datum<Real>(weight_index),
1822 Real(0.75));
1823
1824 CPPUNIT_ASSERT_EQUAL(elem->point(0)(0), Real(0.5));
1825 CPPUNIT_ASSERT_EQUAL(elem->point(0)(1), Real(0.5));
1826 CPPUNIT_ASSERT_EQUAL(elem->point(1)(0), Real(1.5));
1827 CPPUNIT_ASSERT_EQUAL(elem->point(1)(1), Real(0.5));
1828 CPPUNIT_ASSERT_EQUAL(elem->point(2)(0), Real(1.5));
1829 CPPUNIT_ASSERT_EQUAL(elem->point(2)(1), Real(1.5));
1830 CPPUNIT_ASSERT_EQUAL(elem->point(3)(0), Real(0.5));
1831 CPPUNIT_ASSERT_EQUAL(elem->point(3)(1), Real(1.5));
1832 CPPUNIT_ASSERT(elem->has_affine_map());
1833#if LIBMESH_DIM > 2
1834 for (unsigned int v=0; v != 4; ++v)
1835 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2), Real(0));
1836#endif
1837 }
1838
1839 TestCommWorld->max(found_the_quad);
1840 CPPUNIT_ASSERT(found_the_quad);
1841
1843 }
void testMasterCenters(const MeshBase &mesh)
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
Definition mesh_base.h:938
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition mesh_base.h:956
Communicator * TestCommWorld
@ RATIONAL_BERNSTEIN_MAP
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::MeshBase::default_mapping_data(), libMesh::MeshBase::default_mapping_type(), mesh, libMesh::NODEELEM, libMesh::QUAD9, libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::Real, TestCommWorld, and testMasterCenters().

Referenced by testDynaNoSplines(), and testDynaReadElem().

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MeshInputTest::LIBMESH_CPPUNIT_TEST_SUITE ( MeshInputTest  )

◆ setUp()

void MeshInputTest::setUp ( )
inline

Definition at line 225 of file mesh_input.C.

226 {}

◆ tearDown()

void MeshInputTest::tearDown ( )
inline

Definition at line 228 of file mesh_input.C.

229 {}

◆ testAbaqusRead()

void MeshInputTest::testAbaqusRead ( const std::string &  fname,
dof_id_type  n_elem,
dof_id_type  n_nodes 
)
inline

Definition at line 1846 of file mesh_input.C.

1849 {
1850 Mesh mesh(*TestCommWorld);
1851
1852 AbaqusIO abaqus(mesh);
1853
1854 if (mesh.processor_id() == 0)
1855 abaqus.read(fname);
1857
1859
1860 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_elem);
1861 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), n_nodes);
1862 }
The AbaqusIO class is a preliminary implementation for reading Abaqus mesh files in ASCII format.
Definition abaqus_io.h:42
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 dof_id_type n_nodes() const =0
This is the MeshCommunication class.
void broadcast(MeshBase &) const
This method takes a mesh (which is assumed to reside on processor 0) and broadcasts it to all the oth...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
processor_id_type processor_id() const
const dof_id_type n_nodes
Definition tecplot_io.C:67

References libMesh::MeshCommunication::broadcast(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::AbaqusIO::read(), and TestCommWorld.

Referenced by testAbaqusReadFirst(), and testAbaqusReadSecond().

◆ testAbaqusReadFirst()

void MeshInputTest::testAbaqusReadFirst ( )
inline

Definition at line 1865 of file mesh_input.C.

1866 {
1867 LOG_UNIT_TEST;
1868 testAbaqusRead("meshes/tensile_sample_test1.inp.gz", 728, 1166);
1869 }
void testAbaqusRead(const std::string &fname, dof_id_type n_elem, dof_id_type n_nodes)

References testAbaqusRead().

◆ testAbaqusReadSecond()

void MeshInputTest::testAbaqusReadSecond ( )
inline

Definition at line 1872 of file mesh_input.C.

1873 {
1874 LOG_UNIT_TEST;
1875 testAbaqusRead("meshes/poly_sample_test2.inp.gz", 1280, 1625);
1876 }

References testAbaqusRead().

◆ testBadGmsh()

void MeshInputTest::testBadGmsh ( )
inline

Definition at line 1901 of file mesh_input.C.

1902 {
1903 LOG_UNIT_TEST;
1904
1905 Mesh mesh(*TestCommWorld);
1906
1907 GmshIO gmsh_io(mesh);
1908
1909#ifdef LIBMESH_ENABLE_EXCEPTIONS
1910 std::string what = "";
1911 try
1912 {
1913 if (mesh.processor_id() == 0)
1914 gmsh_io.read("meshes/block.msh");
1915 }
1916 catch (libMesh::LogicError & e)
1917 {
1918 what = e.what();
1919 }
1920
1921 TestCommWorld->broadcast(what);
1922 std::regex msg_regex("outside entity physical bounding box");
1923 CPPUNIT_ASSERT(std::regex_search(what, msg_regex));
1924#endif
1925 }
Reading and writing meshes in the Gmsh format.
Definition gmsh_io.h:53
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...

References mesh, libMesh::ParallelObject::processor_id(), libMesh::GmshIO::read(), and TestCommWorld.

◆ testCopyElementSolutionImpl()

template<typename MeshType , typename IOType >
void MeshInputTest::testCopyElementSolutionImpl ( const std::string &  filename)
inline

Definition at line 841 of file mesh_input.C.

842 {
843 {
844 MeshType mesh(*TestCommWorld);
845
847 System &sys = es.add_system<System> ("SimpleSystem");
848 sys.add_variable("e", CONSTANT, MONOMIAL);
849 sys.add_variable("e_no_p", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
850 sys.add_variable("e_xyz", FEType(CONSTANT, XYZ));
851
853 3, 3,
854 0., 1., 0., 1.);
855
856 es.init();
857 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
858
859 IOType meshinput(mesh);
860
861 // Don't try to write element data as nodal data
862 std::set<std::string> sys_list;
863 meshinput.write_equation_systems(filename, es, &sys_list);
864
865 // Just write it as element data
866 meshinput.write_element_data(es);
867 }
868
869 {
870 MeshType mesh(*TestCommWorld);
871 mesh.allow_renumbering(false);
872 IOType meshinput(mesh);
873
874 // Avoid getting Nemesis solution values mixed up
875 if (meshinput.is_parallel_format())
876 {
878 }
879
881 System &sys = es.add_system<System> ("SimpleSystem");
882 sys.add_variable("teste", CONSTANT, MONOMIAL);
883 sys.add_variable("teste_no_p", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
884 sys.add_variable("teste_xyz", FEType(CONSTANT, XYZ));
885
886 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
887 meshinput.read(filename);
888 if (!meshinput.is_parallel_format())
891
892 es.init();
893
894 // Read the solution e into variable teste.
895 //
896 // With complex numbers, we'll only bother reading the real
897 // part.
898#ifdef LIBMESH_USE_COMPLEX_NUMBERS
899 meshinput.copy_elemental_solution(sys, "teste", "r_e");
900 meshinput.copy_elemental_solution(sys, "teste_no_p", "r_e_no_p");
901 meshinput.copy_elemental_solution(sys, "teste_xyz", "r_e_xyz");
902#else
903 meshinput.copy_elemental_solution(sys, "teste", "e");
904 meshinput.copy_elemental_solution(sys, "teste_no_p", "e_no_p");
905 meshinput.copy_elemental_solution(sys, "teste_xyz", "e_xyz");
906#endif
907
908 // Exodus only handles double precision
909 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
910
911 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
912 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
913 {
914 Point p(x,y);
915 LIBMESH_ASSERT_NUMBERS_EQUAL
916 (sys.point_value(0,p), 6*x+60*y, exotol);
917 LIBMESH_ASSERT_NUMBERS_EQUAL
918 (sys.point_value(1,p), 6*x+60*y, exotol);
919 LIBMESH_ASSERT_NUMBERS_EQUAL
920 (sys.point_value(2,p), 6*x+60*y, exotol);
921 }
922 }
923 }
This is the EquationSystems class.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
FEType set_p_refinement(bool p) &
"Fluent API" for constructing a non-default p_refinement, for easier compatibility between non-InfFE ...
Definition fe_type.h:298
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
void skip_noncritical_partitioning(bool skip)
If true is passed in then the elements on this mesh will no longer be (re)partitioned,...
Definition mesh_base.h:1415
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2219
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition system.C:1344
Number six_x_plus_sixty_y(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition mesh_input.C:31
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::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_square(), libMesh::CONSTANT, libMesh::EquationSystems::init(), mesh, libMesh::MONOMIAL, libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::System::project_solution(), libMesh::Real, libMesh::FEType::set_p_refinement(), six_x_plus_sixty_y(), libMesh::MeshBase::skip_noncritical_partitioning(), TestCommWorld, libMesh::TOLERANCE, and libMesh::XYZ.

◆ testCopyElementVectorImpl()

template<typename MeshType , typename IOType >
void MeshInputTest::testCopyElementVectorImpl ( const std::string &  filename)
inline

Definition at line 1082 of file mesh_input.C.

1083 {
1084 {
1085 MeshType mesh(*TestCommWorld);
1086
1088
1089 // We need a mesh.spatial_dimension() *before* adding a
1090 // vector-valued variable, so add_variable() can figure out how
1091 // many components it needs.
1093 3, 3,
1094 0., 1., 0., 1.);
1095
1096 System & sys = es.add_system<System> ("SimpleSystem");
1097 auto e_var = sys.add_variable("e", CONSTANT, MONOMIAL_VEC);
1098 auto e_no_p_var = sys.add_variable("e_no_p",
1100
1101 es.init();
1102
1103 // Here, we're going to manually set up the solution because the 'project_solution()' and
1104 // 'project_vector()' methods don't work so well with CONSTANT MONOMIAL_VEC variables. They
1105 // each lead to an error downstream asserting positive-definiteness when Cholesky decomposing.
1106 // Interestingly, the error is only invoked for CONSTANT MONOMIAL_VEC, and not, e.g.,
1107 // CONSTANT MONOMIAL nor FIRST LAGRANGE_VEC.
1108 //
1109 // Anyways, the important thing here is that we test the ExodusII and Nemesis writers, how
1110 // the solution is set is hardly important, and we're pretty much following the same
1111 // philosophy as the 'test2DProjectVectorFE()' unit tester in 'systems_test.C'
1112 Parameters params;
1113 for (const auto & elem : mesh.active_local_element_ptr_range())
1114 {
1115 const Point & p = elem->vertex_average();
1116
1117 // Set the x-component with the value from 'six_x_plus_sixty_y()' and the y-component
1118 // with that from 'sin_x_plus_cos_y()' at the element centroid (vertex average)
1119 sys.current_local_solution->set(
1120 elem->dof_number(sys.number(), e_var, 0), six_x_plus_sixty_y(p, params, "", ""));
1121 sys.current_local_solution->set(
1122 elem->dof_number(sys.number(), e_var, 1), sin_x_plus_cos_y(p, params, "", ""));
1123 sys.current_local_solution->set(
1124 elem->dof_number(sys.number(), e_no_p_var, 0), six_x_plus_sixty_y(p, params, "", ""));
1125 sys.current_local_solution->set(
1126 elem->dof_number(sys.number(), e_no_p_var, 1), sin_x_plus_cos_y(p, params, "", ""));
1127 }
1128
1129 // After setting values, we need to assemble
1130 sys.current_local_solution->close();
1131
1132 IOType meshinput(mesh);
1133
1134 // Don't try to write element data as nodal data
1135 std::set<std::string> sys_list;
1136 meshinput.write_equation_systems(filename, es, &sys_list);
1137
1138 // Just write it as element data
1139 meshinput.write_element_data(es);
1140 }
1141
1142 {
1143 MeshType mesh(*TestCommWorld);
1144 mesh.allow_renumbering(false);
1145 IOType meshinput(mesh);
1146
1147 // Avoid getting Nemesis solution values mixed up
1148 if (meshinput.is_parallel_format())
1149 {
1151 }
1152
1154 System & sys = es.add_system<System> ("SimpleSystem");
1155
1156 // We have to read the CONSTANT MONOMIAL_VEC var "e" into separate CONSTANT MONOMIAL vars
1157 // "e_x" and "e_y" because 'copy_elemental_solution()' currently doesn't support vectors.
1158 // Again, this isn't a test for reading/copying an elemental vector solution, only writing.
1159 sys.add_variable("teste_x", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1160 sys.add_variable("teste_y", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1161 sys.add_variable("teste_no_p_x", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1162 sys.add_variable("teste_no_p_y", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1163
1164 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
1165 meshinput.read(filename);
1166 if (!meshinput.is_parallel_format())
1169
1170 es.init();
1171
1172 // Read the solution e_x and e_y into variable teste_x and teste_y, respectively.
1173 meshinput.copy_elemental_solution(sys, "teste_x", "e_x");
1174 meshinput.copy_elemental_solution(sys, "teste_y", "e_y");
1175 meshinput.copy_elemental_solution(sys, "teste_no_p_x", "e_no_p_x");
1176 meshinput.copy_elemental_solution(sys, "teste_no_p_y", "e_no_p_y");
1177
1178 // Exodus only handles double precision
1179 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
1180
1181 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
1182 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
1183 {
1184 Point p(x,y);
1185 LIBMESH_ASSERT_NUMBERS_EQUAL
1186 (sys.point_value(0,p), 6*x+60*y, exotol);
1187 LIBMESH_ASSERT_NUMBERS_EQUAL
1188 (sys.point_value(1,p), sin(x)+cos(y), exotol);
1189 LIBMESH_ASSERT_NUMBERS_EQUAL
1190 (sys.point_value(2,p), 6*x+60*y, exotol);
1191 LIBMESH_ASSERT_NUMBERS_EQUAL
1192 (sys.point_value(3,p), sin(x)+cos(y), exotol);
1193 }
1194 }
1195 }
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition system.h:1667
unsigned int number() const
Definition system.h:2393
Number sin_x_plus_cos_y(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition mesh_input.C:43

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_square(), libMesh::CONSTANT, libMesh::System::current_local_solution, libMesh::EquationSystems::init(), mesh, libMesh::MONOMIAL, libMesh::MONOMIAL_VEC, libMesh::System::number(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::FEType::set_p_refinement(), sin_x_plus_cos_y(), six_x_plus_sixty_y(), libMesh::MeshBase::skip_noncritical_partitioning(), TestCommWorld, and libMesh::TOLERANCE.

◆ testCopyNodalSolutionImpl()

template<typename MeshType , typename IOType >
void MeshInputTest::testCopyNodalSolutionImpl ( const std::string &  filename)
inline

Definition at line 757 of file mesh_input.C.

758 {
759 {
760 MeshType mesh(*TestCommWorld);
761
763 System &sys = es.add_system<System> ("SimpleSystem");
764 sys.add_variable("n", FIRST, LAGRANGE);
765
767 3, 3,
768 0., 1., 0., 1.);
769
770 es.init();
771 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
772
773 IOType meshoutput(mesh);
774
775 meshoutput.write_equation_systems(filename, es);
776 }
777
778 {
779 MeshType mesh(*TestCommWorld);
780 mesh.allow_renumbering(false);
781 IOType meshinput(mesh);
782
783 // Avoid getting Nemesis solution values mixed up
784 if (meshinput.is_parallel_format())
785 {
787 }
788
790 System &sys = es.add_system<System> ("SimpleSystem");
791 sys.add_variable("testn", FIRST, LAGRANGE);
792
793 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
794 meshinput.read(filename);
795 if (!meshinput.is_parallel_format())
798
799 es.init();
800
801 // Read the solution e into variable teste.
802 //
803 // With complex numbers, we'll only bother reading the real
804 // part.
805#ifdef LIBMESH_USE_COMPLEX_NUMBERS
806 meshinput.copy_nodal_solution(sys, "testn", "r_n");
807#else
808 meshinput.copy_nodal_solution(sys, "testn", "n");
809#endif
810
811 // Exodus only handles double precision
812 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
813
814 for (Real x = 0; x < 1 + TOLERANCE; x += Real(1.L/3.L))
815 for (Real y = 0; y < 1 + TOLERANCE; y += Real(1.L/3.L))
816 {
817 Point p(x,y);
818 LIBMESH_ASSERT_NUMBERS_EQUAL
819 (sys.point_value(0,p), 6*x+60*y, exotol);
820 }
821 }
822 }

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_square(), libMesh::FIRST, libMesh::EquationSystems::init(), libMesh::LAGRANGE, mesh, libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::System::project_solution(), libMesh::Real, six_x_plus_sixty_y(), libMesh::MeshBase::skip_noncritical_partitioning(), TestCommWorld, and libMesh::TOLERANCE.

◆ testDynaFileMappings()

void MeshInputTest::testDynaFileMappings ( const std::string &  filename,
std::array< Real, 4 >  expected_norms 
)
inline

Definition at line 2172 of file mesh_input.C.

2173 {
2174 Mesh mesh(*TestCommWorld);
2175
2176 DynaIO dyna(mesh);
2177 if (mesh.processor_id() == 0)
2178 dyna.read(filename);
2180
2182
2183 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2185
2186 // Useful when trying out different projection functions
2187 // std::cout << filename << ":" << std::endl;
2188
2190
2191 testProjectionRegression(mesh, expected_norms);
2192 }
void testProjectionRegression(MeshBase &mesh, std::array< Real, 4 > expected_norms)
Reading and writing meshes in (a subset of) LS-DYNA format.
Definition dyna_io.h:53

References libMesh::MeshCommunication::broadcast(), libMesh::MeshBase::default_mapping_type(), mesh, libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::DynaIO::read(), TestCommWorld, testMasterCenters(), and testProjectionRegression().

Referenced by testDynaFileMappingsBlockWithHole(), testDynaFileMappingsCyl3d(), testDynaFileMappingsFEMEx5(), and testDynaFileMappingsPlateWithHole().

◆ testDynaFileMappingsBlockWithHole()

void MeshInputTest::testDynaFileMappingsBlockWithHole ( )
inline

Definition at line 2204 of file mesh_input.C.

2205 {
2206 LOG_UNIT_TEST;
2207
2208 testDynaFileMappings("meshes/BlockWithHole_Patch9.bxt.gz",
2209 // Regression values for sin_x_plus_cos_y
2210 {{3.22612556930183, 1.97405365384733,
2211 2.53376235803176, 1.41374070517223}});
2212 }
void testDynaFileMappings(const std::string &filename, std::array< Real, 4 > expected_norms)

References testDynaFileMappings().

◆ testDynaFileMappingsCyl3d()

void MeshInputTest::testDynaFileMappingsCyl3d ( )
inline

Definition at line 2224 of file mesh_input.C.

2225 {
2226 LOG_UNIT_TEST;
2227
2228 testDynaFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.bxt.gz",
2229 // Regression values for sin_x_plus_cos_y
2230 {{0.963612880188165, 1.82329452603503,
2231 0.707998701597943, 1.31399222566683}});
2232 }

References testDynaFileMappings().

◆ testDynaFileMappingsFEMEx5()

void MeshInputTest::testDynaFileMappingsFEMEx5 ( )
inline

Definition at line 2194 of file mesh_input.C.

2195 {
2196 LOG_UNIT_TEST;
2197
2198 testDynaFileMappings("meshes/PressurizedCyl_Patch6_256Elem.bxt.gz",
2199 // Regression values for sin_x_plus_cos_y
2200 {{0.9639857809698268, 1.839870171669186,
2201 0.7089812562241862, 1.306121188539059}});
2202 }

References testDynaFileMappings().

◆ testDynaFileMappingsPlateWithHole()

void MeshInputTest::testDynaFileMappingsPlateWithHole ( )
inline

Definition at line 2214 of file mesh_input.C.

2215 {
2216 LOG_UNIT_TEST;
2217
2218 testDynaFileMappings("meshes/PlateWithHole_Patch8.bxt.gz",
2219 // Regression values for sin_x_plus_cos_y
2220 {{2.2812154374012, 1.974049990211937,
2221 1.791640772215248, 1.413679237529376}});
2222 }

References testDynaFileMappings().

◆ testDynaNoSplines()

void MeshInputTest::testDynaNoSplines ( )
inline

Definition at line 2039 of file mesh_input.C.

2040 {
2041 LOG_UNIT_TEST;
2042
2043 Mesh mesh(*TestCommWorld);
2044
2045 DynaIO dyna(mesh, /* keep_spline_nodes = */ false);
2046
2047 if (mesh.processor_id() == 0)
2048 dyna.read("meshes/1_quad.bxt.gz");
2050
2052
2053 // We have 1 QUAD9 finite element
2054 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(1));
2055 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(9));
2056
2058 }
void helperTestingDynaQuad(const MeshBase &mesh)

References libMesh::MeshCommunication::broadcast(), helperTestingDynaQuad(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::DynaIO::read(), and TestCommWorld.

◆ testDynaReadElem()

void MeshInputTest::testDynaReadElem ( )
inline

Definition at line 1879 of file mesh_input.C.

1880 {
1881 LOG_UNIT_TEST;
1882
1883 Mesh mesh(*TestCommWorld);
1884
1885 DynaIO dyna(mesh);
1886
1887 if (mesh.processor_id() == 0)
1888 dyna.read("meshes/1_quad.bxt.gz");
1890
1892
1893 // We have 1 QUAD9 finite element, attached via a trivial map to 9
1894 // spline Node+NodeElem objects
1895 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(10));
1896 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(18));
1897
1899 }

References libMesh::MeshCommunication::broadcast(), helperTestingDynaQuad(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::DynaIO::read(), and TestCommWorld.

◆ testDynaReadPatch()

void MeshInputTest::testDynaReadPatch ( )
inline

Definition at line 2061 of file mesh_input.C.

2062 {
2063 LOG_UNIT_TEST;
2064
2065 Mesh mesh(*TestCommWorld);
2066
2067 DynaIO dyna(mesh);
2068 if (mesh.processor_id() == 0)
2069 dyna.read("meshes/25_quad.bxt.gz");
2071
2073
2074 // We have 5^2 QUAD9 elements, with 11^2 nodes,
2075 // tied to 49 Node/NodeElem spline nodes
2076 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(25+49));
2077 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(121+49));
2078
2079 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2081
2082 unsigned char weight_index = mesh.default_mapping_data();
2083
2084 for (const auto & elem : mesh.active_element_ptr_range())
2085 {
2086 if (elem->type() == NODEELEM)
2087 continue;
2088 LIBMESH_ASSERT_FP_EQUAL(Real(0.04), elem->volume(), TOLERANCE);
2089
2090 for (unsigned int n=0; n != 9; ++n)
2091 CPPUNIT_ASSERT_EQUAL
2092 (elem->node_ref(n).get_extra_datum<Real>(weight_index),
2093 Real(1.0));
2094
2095 unsigned int n_neighbors = 0, n_neighbors_expected = 2;
2096 for (unsigned int side=0; side != 4; ++side)
2097 if (elem->neighbor_ptr(side))
2098 n_neighbors++;
2099 Point c = elem->vertex_average();
2100
2101 if (c(0) > 0.2 && c(0) < 0.8)
2102 n_neighbors_expected++;
2103 if (c(1) > 0.2 && c(1) < 0.8)
2104 n_neighbors_expected++;
2105
2106 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
2107 }
2108
2110
2111#ifdef LIBMESH_HAVE_SOLVER
2112#ifdef LIBMESH_ENABLE_CONSTRAINTS
2113 // Now test whether we can assign the desired constraint equations
2115 System & sys = es.add_system<LinearImplicitSystem>("test");
2116 sys.add_variable("u", SECOND); // to match QUAD9
2117 es.init();
2118
2119 // We should have a constraint on every FE dof
2120 CPPUNIT_ASSERT_EQUAL(sys.get_dof_map().n_constrained_dofs(), static_cast<dof_id_type>(121));
2121#endif // LIBMESH_ENABLE_CONSTRAINTS
2122#endif // LIBMESH_HAVE_SOLVER
2123 }
dof_id_type n_constrained_dofs() const
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
const DofMap & get_dof_map() const
Definition system.h:2417

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshCommunication::broadcast(), libMesh::MeshBase::default_mapping_data(), libMesh::MeshBase::default_mapping_type(), libMesh::System::get_dof_map(), libMesh::EquationSystems::init(), mesh, libMesh::DofMap::n_constrained_dofs(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::NODEELEM, libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::DynaIO::read(), libMesh::Real, libMesh::SECOND, TestCommWorld, testMasterCenters(), and libMesh::TOLERANCE.

◆ testExodusCopyElementSolutionDistributed()

void MeshInputTest::testExodusCopyElementSolutionDistributed ( )
inline

Definition at line 929 of file mesh_input.C.

930 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,ExodusII_IO>("dist_with_elem_soln.e"); }

◆ testExodusCopyElementSolutionReplicated()

void MeshInputTest::testExodusCopyElementSolutionReplicated ( )
inline

Definition at line 926 of file mesh_input.C.

927 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,ExodusII_IO>("repl_with_elem_soln.e"); }

◆ testExodusCopyElementVectorDistributed()

void MeshInputTest::testExodusCopyElementVectorDistributed ( )
inline

Definition at line 1200 of file mesh_input.C.

1201 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,ExodusII_IO>("dist_with_elem_vec.e"); }

◆ testExodusCopyElementVectorReplicated()

void MeshInputTest::testExodusCopyElementVectorReplicated ( )
inline

Definition at line 1197 of file mesh_input.C.

1198 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh, ExodusII_IO>("repl_with_elem_vec.e"); }

◆ testExodusCopyHighOrderElementSolution()

void MeshInputTest::testExodusCopyHighOrderElementSolution ( )
inline

Definition at line 941 of file mesh_input.C.

942 {
943 LOG_UNIT_TEST;
944
945 const std::string filename("repl_with_high_order_elem_soln.e");
946
947 {
948 ReplicatedMesh mesh(*TestCommWorld);
949
951 System &sys = es.add_system<System> ("SimpleSystem");
952 sys.add_variable("e", FIRST, MONOMIAL);
953
955 3, 3,
956 0., 1., 0., 1.);
957
958 es.init();
959 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
960
961 ExodusII_IO meshinput(mesh);
962 meshinput.write_discontinuous_elemental_data(true);
963
964 std::set<std::string> sys_list;
965 meshinput.write_equation_systems(filename, es, &sys_list);
966 meshinput.write_element_data(es);
967 }
968
969 {
970 ReplicatedMesh mesh(*TestCommWorld);
971 mesh.allow_renumbering(false);
972 ExodusII_IO meshinput(mesh);
973
975 System &sys = es.add_system<System> ("SimpleSystem");
976 sys.add_variable("teste", CONSTANT, MONOMIAL);
977
978 if (mesh.processor_id() == 0)
979 meshinput.read(filename);
982
983 es.init();
984
985#ifdef LIBMESH_USE_COMPLEX_NUMBERS
986 meshinput.copy_elemental_solution(sys, "teste", "r_e");
987#else
988 meshinput.copy_elemental_solution(sys, "teste", "e");
989#endif
990
991 // Exodus only handles double precision
992 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
993
994 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
995 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
996 {
997 Point p(x,y);
998 LIBMESH_ASSERT_NUMBERS_EQUAL
999 (sys.point_value(0,p), 6*x+60*y, exotol);
1000 }
1001 }
1002 }
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition exodusII_io.h:53
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_square(), libMesh::CONSTANT, libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::FIRST, libMesh::EquationSystems::init(), mesh, libMesh::MONOMIAL, libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::System::project_solution(), libMesh::ExodusII_IO::read(), libMesh::Real, six_x_plus_sixty_y(), TestCommWorld, libMesh::TOLERANCE, libMesh::ExodusII_IO::write_discontinuous_elemental_data(), libMesh::ExodusII_IO::write_element_data(), and libMesh::ExodusII_IO::write_equation_systems().

◆ testExodusCopyNodalSolutionDistributed()

void MeshInputTest::testExodusCopyNodalSolutionDistributed ( )
inline

Definition at line 828 of file mesh_input.C.

829 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,ExodusII_IO>("dist_with_nodal_soln.e"); }

◆ testExodusCopyNodalSolutionReplicated()

void MeshInputTest::testExodusCopyNodalSolutionReplicated ( )
inline

Definition at line 825 of file mesh_input.C.

826 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,ExodusII_IO>("repl_with_nodal_soln.e"); }

◆ testExodusDiscCyl3d()

void MeshInputTest::testExodusDiscCyl3d ( )
inline

Definition at line 2356 of file mesh_input.C.

2357 {
2358 LOG_UNIT_TEST;
2359
2360 testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
2361 {{0.963855209590556, 1.8234396424318,
2362 0.708286572453382, 1.31468940958327}},
2363 true);
2364 }
void testExodusFileMappings(const std::string &filename, std::array< Real, 4 > expected_norms, bool use_disc_bex=false)

References testExodusFileMappings().

◆ testExodusDiscPlateWithHole()

void MeshInputTest::testExodusDiscPlateWithHole ( )
inline

Definition at line 2317 of file mesh_input.C.

2318 {
2319 LOG_UNIT_TEST;
2320
2321 testExodusFileMappings("meshes/PlateWithHole_Patch8.e",
2322 // Regression values for sin_x_plus_cos_y
2323 //
2324 // These are *not* the same as for the continuous plate, because
2325 // we do the C^TKCx=C^Tf trick to pull back projections to the
2326 // spline nodes, and the pseudoinverse here minimizes the error in
2327 // a discretization-dependent norm, not in a Sobolev norm. For
2328 // these coarse meshes, our Sobolev norms can end up being ~0.1%
2329 // different.
2330 {{2.28234312456534, 1.97439548757586,
2331 1.79290449809266, 1.41075128955985}},
2332 true);
2333 }

References testExodusFileMappings().

◆ testExodusDiscTwoBlocks()

void MeshInputTest::testExodusDiscTwoBlocks ( )
inline

Definition at line 2335 of file mesh_input.C.

2336 {
2337 LOG_UNIT_TEST;
2338
2339 testExodusFileMappings("meshes/two_quads_two_blocks.e",
2340 // Regression values for sin_x_plus_cos_y
2341 {{2.03496953073072, 1.97996853164955,
2342 1.18462134113435, 1.03085301158959}},
2343 true);
2344 }

References testExodusFileMappings().

◆ testExodusDiscTwoElemIGA()

void MeshInputTest::testExodusDiscTwoElemIGA ( )
inline

Definition at line 2345 of file mesh_input.C.

2346 {
2347 LOG_UNIT_TEST;
2348
2349 testExodusFileMappings("meshes/two_element_iga_in.e",
2350 // Regression values for sin_x_plus_cos_y
2351 {{1.26877626663365, 1.42553698909339,
2352 1.54810114917177, 1.29792704408979}},
2353 true);
2354 }

References testExodusFileMappings().

◆ testExodusDiscWriteAddedSidesEdgeC0()

void MeshInputTest::testExodusDiscWriteAddedSidesEdgeC0 ( )
inline

Definition at line 1572 of file mesh_input.C.

1573 {
1576 }
void testExodusWriteAddedSides(Number(*exact_sol)(const Point &, const Parameters &, const std::string &, const std::string &), const ElemType elem_type, const Order order, const bool write_discontinuous=false, const std::vector< FEType > earlier_vars={}, const std::vector< FEType > later_vars={})

References libMesh::EDGE3, libMesh::FIRST, libMesh::SECOND, six_x_plus_sixty_y(), and testExodusWriteAddedSides().

◆ testExodusDiscWriteAddedSidesEdgeDisc()

void MeshInputTest::testExodusDiscWriteAddedSidesEdgeDisc ( )
inline

Definition at line 1595 of file mesh_input.C.

1596 {
1598 }
Number designed_for_side_elems(const Point &p, const Parameters &param, const std::string &, const std::string &)
Definition mesh_input.C:56

References designed_for_side_elems(), libMesh::EDGE3, libMesh::SECOND, and testExodusWriteAddedSides().

◆ testExodusDiscWriteAddedSidesHexC0()

void MeshInputTest::testExodusDiscWriteAddedSidesHexC0 ( )
inline

◆ testExodusDiscWriteAddedSidesHexDisc()

void MeshInputTest::testExodusDiscWriteAddedSidesHexDisc ( )
inline

◆ testExodusDiscWriteAddedSidesMixedEdgeC0()

void MeshInputTest::testExodusDiscWriteAddedSidesMixedEdgeC0 ( )
inline

◆ testExodusDiscWriteAddedSidesMixedHexC0()

void MeshInputTest::testExodusDiscWriteAddedSidesMixedHexC0 ( )
inline

◆ testExodusDiscWriteAddedSidesMixedQuadC0()

void MeshInputTest::testExodusDiscWriteAddedSidesMixedQuadC0 ( )
inline

◆ testExodusDiscWriteAddedSidesMixedTriC0()

void MeshInputTest::testExodusDiscWriteAddedSidesMixedTriC0 ( )
inline

◆ testExodusDiscWriteAddedSidesQuadC0()

void MeshInputTest::testExodusDiscWriteAddedSidesQuadC0 ( )
inline

◆ testExodusDiscWriteAddedSidesQuadDisc()

void MeshInputTest::testExodusDiscWriteAddedSidesQuadDisc ( )
inline

◆ testExodusDiscWriteAddedSidesTetC0()

void MeshInputTest::testExodusDiscWriteAddedSidesTetC0 ( )
inline

◆ testExodusDiscWriteAddedSidesTetDisc()

void MeshInputTest::testExodusDiscWriteAddedSidesTetDisc ( )
inline

◆ testExodusDiscWriteAddedSidesTriC0()

void MeshInputTest::testExodusDiscWriteAddedSidesTriC0 ( )
inline

◆ testExodusDiscWriteAddedSidesTriDisc()

void MeshInputTest::testExodusDiscWriteAddedSidesTriDisc ( )
inline

◆ testExodusFileMappings()

void MeshInputTest::testExodusFileMappings ( const std::string &  filename,
std::array< Real, 4 >  expected_norms,
bool  use_disc_bex = false 
)
inline

Definition at line 2234 of file mesh_input.C.

2237 {
2238 Mesh mesh(*TestCommWorld);
2239
2240 ExodusII_IO exii(mesh);
2241 // IGA Exodus meshes require ExodusII 8 or higher
2242 if (exii.get_exodus_version() < 800)
2243 return;
2244
2245 // This should default to false
2246 if (use_disc_bex)
2247 exii.set_discontinuous_bex(true);
2248
2249 if (mesh.processor_id() == 0)
2250 exii.read(filename);
2252
2254
2255 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2257
2259
2260 testProjectionRegression(mesh, expected_norms);
2261
2262 // Test a write when we're done reading; I was getting weirdness
2263 // from NetCDF at this point in a Moose output test.
2264 {
2265 ExodusII_IO exii(mesh);
2266
2267 exii.write("exodus_file_mapping_out.e");
2268 }
2269
2270#ifdef LIBMESH_HAVE_VTK
2271 {
2272 VTKIO vtkout(mesh);
2273
2274 vtkout.write("vtk_file_mapping_out.pvtu");
2275 }
2276#endif
2277 }
This class implements reading and writing meshes in the VTK format.
Definition vtk_io.h:62

References libMesh::MeshCommunication::broadcast(), libMesh::MeshBase::default_mapping_type(), libMesh::ExodusII_IO::get_exodus_version(), mesh, libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::ExodusII_IO::read(), libMesh::ExodusII_IO::set_discontinuous_bex(), TestCommWorld, testMasterCenters(), testProjectionRegression(), libMesh::VTKIO::write(), and libMesh::ExodusII_IO::write().

Referenced by testExodusDiscCyl3d(), testExodusDiscPlateWithHole(), testExodusDiscTwoBlocks(), testExodusDiscTwoElemIGA(), testExodusFileMappingsCyl3d(), testExodusFileMappingsPlateWithHole(), testExodusFileMappingsTwoBlocks(), and testExodusFileMappingsTwoElemIGA().

◆ testExodusFileMappingsCyl3d()

void MeshInputTest::testExodusFileMappingsCyl3d ( )
inline

Definition at line 2308 of file mesh_input.C.

2309 {
2310 LOG_UNIT_TEST;
2311
2312 testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
2313 {{0.963612880188165, 1.82329452603503,
2314 0.707998701597943, 1.31399222566683}});
2315 }

References testExodusFileMappings().

◆ testExodusFileMappingsPlateWithHole()

void MeshInputTest::testExodusFileMappingsPlateWithHole ( )
inline

Definition at line 2279 of file mesh_input.C.

2280 {
2281 LOG_UNIT_TEST;
2282
2283 testExodusFileMappings("meshes/PlateWithHole_Patch8.e",
2284 // Regression values for sin_x_plus_cos_y
2285 {{2.2812154374012, 1.974049990211937,
2286 1.791640772215248, 1.413679237529376}});
2287 }

References testExodusFileMappings().

◆ testExodusFileMappingsTwoBlocks()

void MeshInputTest::testExodusFileMappingsTwoBlocks ( )
inline

Definition at line 2289 of file mesh_input.C.

2290 {
2291 LOG_UNIT_TEST;
2292
2293 testExodusFileMappings("meshes/two_quads_two_blocks.e",
2294 // Regression values for sin_x_plus_cos_y
2295 {{2.03496953073072, 1.97996853164955,
2296 1.18462134113435, 1.03085301158959}});
2297 }

References testExodusFileMappings().

◆ testExodusFileMappingsTwoElemIGA()

void MeshInputTest::testExodusFileMappingsTwoElemIGA ( )
inline

Definition at line 2298 of file mesh_input.C.

2299 {
2300 LOG_UNIT_TEST;
2301
2302 testExodusFileMappings("meshes/two_element_iga_in.e",
2303 // Regression values for sin_x_plus_cos_y
2304 {{1.26865962862531, 1.42562070158386,
2305 1.54905363492342, 1.29782906548366}});
2306 }

References testExodusFileMappings().

◆ testExodusIGASidesets()

void MeshInputTest::testExodusIGASidesets ( )
inline

Definition at line 666 of file mesh_input.C.

667 {
668 LOG_UNIT_TEST;
669
670 Mesh mesh(*TestCommWorld);
671
672 // Block here so we trigger exii destructor early; I thought I
673 // might have had a bug in there at one point
674 {
675 ExodusII_IO exii(mesh);
676 // IGA Exodus meshes require ExodusII 8 or higher
677 if (exii.get_exodus_version() < 800)
678 return;
679
680 if (mesh.processor_id() == 0)
681 exii.read("meshes/Cube_With_Sidesets.e");
682
683 }
684
687
688 // 5^3 spline nodes + 7^3 Rational Bezier nodes
689 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(468));
690 // 5^3 spline elements + 3^3 Rational Bezier elements
691 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(152));
692
693 // Check that we see the boundary ids we expect
695
696 // On a ReplicatedMesh, we should see all 6 boundary ids on each processor
697 if (mesh.is_serial())
698 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(6), bi.n_boundary_ids());
699
700 // On any mesh, we should see each id on *some* processor
701 {
702 const std::set<boundary_id_type> & bc_ids = bi.get_boundary_ids();
703 // CoreForm gave me a file with 1-based numbering! (faints)
704 for (boundary_id_type i = 1 ; i != 7; ++i)
705 {
706 bool has_bcid = bc_ids.count(i);
707 mesh.comm().max(has_bcid);
708 CPPUNIT_ASSERT(has_bcid);
709 }
710 }
711
712 // Indexed by bcid-1, because we count from 0, like God and
713 // Dijkstra intended!
714 std::vector<int> side_counts(6, 0);
715
716 // Map from our side numbers to the file's BCIDs
717 const boundary_id_type libmesh_side_to_bcid[] = {1, 4, 6, 3, 5, 2};
718
719 for (const auto & elem : mesh.active_local_element_ptr_range())
720 {
721 if (elem->type() == NODEELEM)
722 continue;
723
724 for (unsigned short side=0; side<elem->n_sides(); side++)
725 {
726 if (elem->neighbor_ptr(side))
727 CPPUNIT_ASSERT_EQUAL(bi.n_boundary_ids(elem, side), 0u);
728 else
729 {
730 CPPUNIT_ASSERT_EQUAL(bi.n_boundary_ids(elem, side), 1u);
731 std::vector<boundary_id_type> bids;
732 bi.boundary_ids(elem, side, bids);
733 side_counts[bids[0]-1]++;
734 CPPUNIT_ASSERT_EQUAL(libmesh_side_to_bcid[side], bids[0]);
735 }
736 }
737 }
738
739 for (auto bc_count : side_counts)
740 {
741 // We should have 3^2 sides with each id
742 mesh.comm().sum(bc_count);
743 CPPUNIT_ASSERT_EQUAL(bc_count, 9);
744 }
745
746 // Test a write when we're done reading; I was getting weirdness
747 // from NetCDF at this point in a Moose output test.
748 {
749 ExodusII_IO exii(mesh);
750
751 exii.write("Cube_With_Sidesets_out.e");
752 }
753 }
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
std::size_t n_boundary_ids() const
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
const std::set< boundary_id_type > & get_boundary_ids() const
virtual bool is_serial() const
Definition mesh_base.h:357
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
int8_t boundary_id_type
Definition id_types.h:51

References libMesh::BoundaryInfo::boundary_ids(), libMesh::MeshCommunication::broadcast(), libMesh::ParallelObject::comm(), libMesh::BoundaryInfo::get_boundary_ids(), libMesh::MeshBase::get_boundary_info(), libMesh::ExodusII_IO::get_exodus_version(), libMesh::MeshBase::is_serial(), libMesh::Parallel::Communicator::max(), mesh, libMesh::BoundaryInfo::n_boundary_ids(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::NODEELEM, libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO::read(), libMesh::Parallel::Communicator::sum(), TestCommWorld, and libMesh::ExodusII_IO::write().

◆ testExodusReadHeader()

void MeshInputTest::testExodusReadHeader ( )
inline

Definition at line 586 of file mesh_input.C.

587 {
588 LOG_UNIT_TEST;
589
590 // first scope: write file
591 {
592 ReplicatedMesh mesh(*TestCommWorld);
593 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
594 ExodusII_IO exii(mesh);
595 mesh.write("read_header_test.e");
596 }
597
598 // Make sure that the writing is done before the reading starts.
599 TestCommWorld->barrier();
600
601 // second scope: read header
602 // Note: The header information is read from file on processor 0
603 // and then broadcast to the other procs, so with this test we are
604 // checking both that the header information is read correctly and
605 // that it is correctly communicated to other procs.
606 {
607 ReplicatedMesh mesh(*TestCommWorld);
608 ExodusII_IO exii(mesh);
609 ExodusHeaderInfo header_info = exii.read_header("read_header_test.e");
610
611 // Make sure the header information is as expected.
612 CPPUNIT_ASSERT_EQUAL(std::string(header_info.title.data()), std::string("read_header_test.e"));
613 CPPUNIT_ASSERT_EQUAL(header_info.num_dim, 2);
614 CPPUNIT_ASSERT_EQUAL(header_info.num_elem, 9);
615 CPPUNIT_ASSERT_EQUAL(header_info.num_elem_blk, 1);
616 CPPUNIT_ASSERT_EQUAL(header_info.num_node_sets, 4);
617 CPPUNIT_ASSERT_EQUAL(header_info.num_side_sets, 4);
618 CPPUNIT_ASSERT_EQUAL(header_info.num_edge_blk, 0);
619 CPPUNIT_ASSERT_EQUAL(header_info.num_edge, 0);
620 }
621 }
This class is used as both an external data structure for passing around Exodus file header informati...
virtual void write(const std::string &name) const =0

References libMesh::MeshTools::Generation::build_square(), mesh, libMesh::ExodusHeaderInfo::num_dim, libMesh::ExodusHeaderInfo::num_edge, libMesh::ExodusHeaderInfo::num_edge_blk, libMesh::ExodusHeaderInfo::num_elem, libMesh::ExodusHeaderInfo::num_elem_blk, libMesh::ExodusHeaderInfo::num_node_sets, libMesh::ExodusHeaderInfo::num_side_sets, libMesh::ExodusII_IO::read_header(), TestCommWorld, libMesh::ExodusHeaderInfo::title, and libMesh::MeshBase::write().

◆ testExodusSetElemUniqueIdsFromMaps()

void MeshInputTest::testExodusSetElemUniqueIdsFromMaps ( )
inline

Definition at line 555 of file mesh_input.C.

556 {
557 LOG_UNIT_TEST;
558
559 // The mesh used in this test has a non-trivial elem_num_map with
560 // a non-contiguous numbering that has a "gap" at the beginning
561 // and is also missing "16":
562 // elem_num_map = 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
563 // 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
564 // 45, 46 ;
565 {
566 // When we assign (zero-based) elem_num_map entries as unique_ids, the
567 // unique_ids are just a zero-based version of the entries above.
568 std::vector<unique_id_type> expected_unique_ids = {
569 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
570 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
572 /*set_unique_ids=*/true, expected_unique_ids);
573 }
574
575 {
576 // When libmesh assigns unique_ids, all the Nodes (50) are
577 // numbered first, so the first Elem is assigned a unique_id of
578 // 50 and the rest are sequential from there.
579 std::vector<unique_id_type> expected_unique_ids(/*size=*/35);
580 std::iota(expected_unique_ids.begin(), expected_unique_ids.end(), /*start=*/50);
582 /*set_unique_ids=*/false, expected_unique_ids);
583 }
584 }
void testExodusSetElemUniqueIdsFromMaps_implementation(bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
Definition mesh_input.C:520

References testExodusSetElemUniqueIdsFromMaps_implementation().

◆ testExodusSetElemUniqueIdsFromMaps_implementation()

void MeshInputTest::testExodusSetElemUniqueIdsFromMaps_implementation ( bool  set_unique_ids,
const std::vector< unique_id_type > &  expected_unique_ids 
)
inline

Definition at line 520 of file mesh_input.C.

523 {
524 // This test requires that libmesh is compiled with unique_ids enabled
525#ifdef LIBMESH_ENABLE_UNIQUE_ID
526 {
527 ReplicatedMesh mesh(*TestCommWorld);
528 ExodusII_IO exii(mesh);
529
530 // Set Node/Elem unique ids based on the node/elem_num_map
531 exii.set_unique_ids_from_maps(set_unique_ids);
532
533 // Read the mesh
534 exii.read("meshes/nontrivial_elem_num_map.exo");
535
536 // Verify the results.
537 auto expected_it = expected_unique_ids.begin();
538 for (const auto & elem : mesh.element_ptr_range())
539 {
540 // Debugging:
541 // libMesh::out << "unique_id for Elem " << elem->id()
542 // << " = " << elem->unique_id()
543 // << std::endl;
544
545 CPPUNIT_ASSERT_EQUAL(elem->unique_id(), *expected_it++);
546 }
547 }
548#else
549 // Prevent compiler warnings about unused variables when
550 // unique_ids are not enabled.
551 libmesh_ignore(set_unique_ids, expected_unique_ids);
552#endif // LIBMESH_ENABLE_UNIQUE_ID
553 }
void libmesh_ignore(const Args &...)

References libMesh::libmesh_ignore(), mesh, libMesh::ExodusII_IO::read(), libMesh::ExodusII_IO::set_unique_ids_from_maps(), and TestCommWorld.

Referenced by testExodusSetElemUniqueIdsFromMaps().

◆ testExodusSetNodeUniqueIdsFromMaps()

void MeshInputTest::testExodusSetNodeUniqueIdsFromMaps ( )
inline

Definition at line 499 of file mesh_input.C.

500 {
501 LOG_UNIT_TEST;
502
503 // node_num_map = 1, 3, 9, 8, 2, 5, 7, 6, 4
504 // The input is a (zero-based) version of the node_num_map as it
505 // exists in the file.
507 /*set_unique_ids=*/true,
508 /*expected_unique_ids=*/{0, 2, 8, 7, 1, 4, 6, 5, 3});
509
510 // The input is the (zero-based) _position_ of the (one-based) id
511 // "i" in the node_num_map, as it exists in the file. For example,
512 // zero-based Node id 3 corresponds to one-based Node id 4, which
513 // appears in (zero-based) position 8 in the node_num_map, hence:
514 // 3 -> 8, etc.
516 /*set_unique_ids=*/false,
517 /*expected_unique_ids=*/{0, 4, 1, 8, 5, 7, 6, 3, 2});
518 }
void testExodusSetNodeUniqueIdsFromMaps_implementation(bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
Definition mesh_input.C:463

References testExodusSetNodeUniqueIdsFromMaps_implementation().

◆ testExodusSetNodeUniqueIdsFromMaps_implementation()

void MeshInputTest::testExodusSetNodeUniqueIdsFromMaps_implementation ( bool  set_unique_ids,
const std::vector< unique_id_type > &  expected_unique_ids 
)
inline

Definition at line 463 of file mesh_input.C.

466 {
467 // This test requires that libmesh is compiled with unique_ids enabled
468#ifdef LIBMESH_ENABLE_UNIQUE_ID
469 {
470 ReplicatedMesh mesh(*TestCommWorld);
471 ExodusII_IO exii(mesh);
472
473 // Set Node/Elem unique ids based on the node/elem_num_map
474 exii.set_unique_ids_from_maps(set_unique_ids);
475
476 // Read the mesh
477 exii.read("meshes/nontrivial_node_num_map.exo");
478
479 // Verify the results.
480 for (auto i : index_range(expected_unique_ids))
481 {
482 // Debugging:
483 // libMesh::out << "unique_id for node " << i
484 // << " = " << mesh.node_ptr(i)->unique_id()
485 // << std::endl;
486
487 CPPUNIT_ASSERT_EQUAL(mesh.node_ptr(i)->unique_id(), expected_unique_ids[i]);
488 }
489 }
490#else
491 // Prevent compiler warnings about unused variables when
492 // unique_ids are not enabled.
493 libmesh_ignore(set_unique_ids, expected_unique_ids);
494#endif // LIBMESH_ENABLE_UNIQUE_ID
495 } // end testExodusSetNodeUniqueIdsFromMaps_implementation()
unique_id_type unique_id() const
Definition dof_object.h:849
virtual const Node * node_ptr(const dof_id_type i) const =0
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153

References libMesh::index_range(), libMesh::libmesh_ignore(), mesh, libMesh::MeshBase::node_ptr(), libMesh::ExodusII_IO::read(), libMesh::ExodusII_IO::set_unique_ids_from_maps(), TestCommWorld, and libMesh::DofObject::unique_id().

Referenced by testExodusSetNodeUniqueIdsFromMaps().

◆ testExodusWriteAddedSides()

void MeshInputTest::testExodusWriteAddedSides ( Number(*)(const Point &, const Parameters &, const std::string &, const std::string &)  exact_sol,
const ElemType  elem_type,
const Order  order,
const bool  write_discontinuous = false,
const std::vector< FEType >  earlier_vars = {},
const std::vector< FEType >  later_vars = {} 
)
inline

Definition at line 1324 of file mesh_input.C.

1330 {},
1331 const std::vector<FEType> later_vars = {})
1332 {
1333 constexpr unsigned int nx = added_sides_nxyz[0],
1334 ny = added_sides_nxyz[1],
1335 nz = added_sides_nxyz[2];
1336
1337 const unsigned int dim = Elem::type_to_dim_map[elem_type];
1338 const bool is_tensor = (Elem::build(elem_type)->n_sides() == dim * 2);
1339
1340 // Figure out how many fake and true elements to expect
1341 dof_id_type n_fake_elem = 0;
1342 dof_id_type n_true_elem = 0;
1343
1344 dof_id_type n_fake_nodes = 0;
1345 dof_id_type n_true_nodes = 0;
1346
1347 const std::string filename =
1348 "side_discontinuous_"+Utility::enum_to_string<ElemType>(elem_type)+(write_discontinuous?"_disc":"")+".e";
1349
1350 // first scope: write file
1351 {
1352 Mesh mesh(*TestCommWorld);
1353
1355 System & sys = es.add_system<System> ("SimpleSystem");
1356 int varnum = 1;
1357 for (auto vartype : earlier_vars)
1358 sys.add_variable("earlier_"+std::to_string(varnum++), vartype);
1359
1360 sys.add_variable("u", order, SIDE_HIERARCHIC);
1361
1362 varnum = 1;
1363 for (auto vartype : later_vars)
1364 sys.add_variable("later_"+std::to_string(varnum++), vartype);
1365
1366 if (dim == 3)
1368 (mesh, nx, ny, nz, 0., 1., 0., 1., 0., 1., elem_type);
1369 else if (dim == 2)
1371 (mesh, nx, ny, 0., 1., 0., 1., elem_type);
1372 else
1374 (mesh, nx, 0., 1., elem_type);
1375
1376 n_true_elem = mesh.n_elem();
1377 n_true_nodes = mesh.n_nodes();
1378 CPPUNIT_ASSERT_LESS(n_true_nodes, n_true_elem); // Ne < Nn
1379
1380 const unsigned int our_ny = dim>1 ? ny : 1;
1381 const unsigned int our_nz = dim>2 ? nz : 1;
1382
1383 dof_id_type min_n_elem = nx * our_ny * our_nz;
1384 CPPUNIT_ASSERT_LESSEQUAL(n_true_elem, min_n_elem); // "backwards" API...
1385
1386 for (const auto & elem : mesh.active_local_element_ptr_range())
1387 {
1388 for (auto s : make_range(elem->n_sides()))
1389 if (!elem->neighbor_ptr(s) || elem->neighbor_ptr(s)->id() < elem->id())
1390 {
1391 ++n_fake_elem;
1392 auto side = elem->build_side_ptr(s);
1393 n_fake_nodes += side->n_nodes();
1394 }
1395 }
1396 mesh.comm().sum(n_fake_elem);
1397 mesh.comm().sum(n_fake_nodes);
1398
1399 const dof_id_type expected_fakes = [elem_type]() {
1400 switch (elem_type)
1401 {
1402 case EDGE3:
1403 return nx+1;
1404 case TRI6:
1405 return 3*nx*ny + nx + ny;
1406 case QUAD8:
1407 case QUAD9:
1408 return 2*nx*ny + nx + ny;
1409 case TET14:
1410 return 48*nx*ny*nz + 4*(nx*ny+nx*nz+ny*nz);
1411 case HEX27:
1412 return 3*nx*ny*nz + nx*ny + nx*nz + ny*nz;
1413 default:
1414 libmesh_error();
1415 }
1416 } (); // Invoke anonymous lambda
1417
1418 CPPUNIT_ASSERT_EQUAL(n_fake_elem, expected_fakes); // "backwards" API...
1419
1420 es.init();
1421 sys.project_solution(exact_sol, nullptr,
1422 es.parameters);
1423
1424 // Set solution u^e_i = i, for the ith vertex of a given element e.
1425
1426 // Now write to file.
1427 ExodusII_IO exii(mesh);
1428 exii.write_added_sides(true);
1429
1430 if (write_discontinuous)
1431 exii.write_discontinuous_equation_systems(filename, es);
1432 else
1433 exii.write_equation_systems(filename, es);
1434 } // end first scope
1435
1436 // second scope: read file, verify extra elements exist
1437 {
1438 Mesh mesh(*TestCommWorld);
1439 mesh.allow_renumbering(false);
1440 ExodusII_IO exii(mesh);
1441
1442 if (mesh.processor_id() == 0)
1443 exii.read(filename);
1446
1447 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_true_elem + n_fake_elem);
1448 if (write_discontinuous)
1449 {
1450 const dof_id_type nodes_per_elem = Elem::build(elem_type)->n_nodes();
1451 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
1452 n_true_elem*nodes_per_elem + n_fake_nodes);
1453 }
1454 else
1455 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), n_true_nodes + n_fake_nodes);
1456
1458 System & sys = es.add_system<System> ("SimpleSystem");
1459 // Read back into a LAGRANGE variable for testing; we still
1460 // can't use Exodus for a proper restart.
1461 sys.add_variable("ul", SECOND);
1462 es.init();
1463
1464 const DofMap & dof_map = sys.get_dof_map();
1465
1466#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1467 exii.copy_nodal_solution(sys, "ul", "r_u");
1468#else
1469 exii.copy_nodal_solution(sys, "ul", "u");
1470#endif
1471
1472 dof_id_type n_side_nodes = 0;
1473 const std::string nullstr;
1474 const std::string facestr = "face";
1475
1476 // Debugging this in parallel is tricky. Let's make sure that
1477 // if we have a failure on one rank we see it on all the others
1478 // and we can go on to other tests.
1479#ifdef LIBMESH_ENABLE_EXCEPTIONS
1480 bool threw_exception = false;
1481 try
1482#endif // LIBMESH_ENABLE_EXCEPTIONS
1483 {
1484 for (const auto & elem : mesh.active_local_element_ptr_range())
1485 {
1486 // Just look at side elements, not interiors
1487 if (elem->dim() == dim)
1488 continue;
1489
1490 std::vector<dof_id_type> dof_indices;
1491 dof_map.dof_indices(elem, dof_indices, 0);
1492
1493 // Find what face direction we're looking at, to
1494 // disambiguate when testing against a discontinuous
1495 // function, since we're evaluating on nodes that overlap
1496 // multiple faces
1497 const Point normal = [elem](){
1498 if (elem->dim() == 2)
1499 return Point((elem->point(1) - elem->point(0)).cross
1500 (elem->point(2) - elem->point(0)));
1501 else if (elem->dim() == 1)
1502 return Point
1503 (elem->point(1)(1)-elem->point(0)(1),
1504 elem->point(0)(0)-elem->point(1)(0));
1505 else
1506 return Point(1);
1507 } (); // Invoke anonymous lambda
1508
1509 short faceval = -1;
1510 if (is_tensor)
1511 {
1512 if (std::abs(normal(0)) > TOLERANCE)
1513 {
1514 faceval = 0;
1515 libmesh_assert_less(std::abs(normal(1)), TOLERANCE);
1516 libmesh_assert_less(std::abs(normal(2)), TOLERANCE);
1517 }
1518 else if (std::abs(normal(1)) > TOLERANCE)
1519 {
1520 faceval = 1;
1521 libmesh_assert_less(std::abs(normal(2)), TOLERANCE);
1522 }
1523 else
1524 {
1525 faceval = 2;
1526 libmesh_assert_greater(std::abs(normal(2)), TOLERANCE);
1527 }
1528 libmesh_assert_greater_equal(faceval, 0);
1529 es.parameters.set<short>(facestr) = faceval;
1530 }
1531
1532 for (auto i : index_range(dof_indices))
1533 {
1534 const Point node_pt = elem->point(i);
1535 const Real nodal_coef =
1536 libmesh_real((*sys.current_local_solution)(dof_indices[i]));
1537 const Real exact_val =
1538 libmesh_real(exact_sol
1539 (node_pt, es.parameters, nullstr,
1540 nullstr));
1541 LIBMESH_ASSERT_FP_EQUAL
1542 (nodal_coef, exact_val,
1543 std::max(Real(2),nodal_coef+exact_val)*
1544 TOLERANCE*std::sqrt(TOLERANCE));
1545 ++n_side_nodes;
1546 }
1547 }
1548 }
1549#ifdef LIBMESH_ENABLE_EXCEPTIONS
1550 catch (...)
1551 {
1552 threw_exception = true;
1553 TestCommWorld->max(threw_exception);
1554 throw;
1555 }
1556 if (!threw_exception)
1557 TestCommWorld->max(threw_exception);
1558 CPPUNIT_ASSERT(!threw_exception);
1559#endif // LIBMESH_ENABLE_EXCEPTIONS
1560
1561 TestCommWorld->sum(n_side_nodes);
1562 CPPUNIT_ASSERT_EQUAL(n_side_nodes, n_fake_nodes);
1563 } // end second scope
1564 } // end testExodusWriteAddedSides
unsigned int dim
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2203
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:382
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
Definition elem.h:649
constexpr int added_sides_nxyz[]
Definition mesh_input.C:54
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.
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.
LIBMESH_DEVICE_INLINE T libmesh_real(T a)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

Referenced by testExodusDiscWriteAddedSidesEdgeC0(), testExodusDiscWriteAddedSidesEdgeDisc(), testExodusDiscWriteAddedSidesHexC0(), testExodusDiscWriteAddedSidesHexDisc(), testExodusDiscWriteAddedSidesMixedEdgeC0(), testExodusDiscWriteAddedSidesMixedHexC0(), testExodusDiscWriteAddedSidesMixedQuadC0(), testExodusDiscWriteAddedSidesMixedTriC0(), testExodusDiscWriteAddedSidesQuadC0(), testExodusDiscWriteAddedSidesQuadDisc(), testExodusDiscWriteAddedSidesTetC0(), testExodusDiscWriteAddedSidesTetDisc(), testExodusDiscWriteAddedSidesTriC0(), testExodusDiscWriteAddedSidesTriDisc(), testExodusWriteAddedSidesEdgeC0(), testExodusWriteAddedSidesEdgeDisc(), testExodusWriteAddedSidesHexC0(), testExodusWriteAddedSidesHexDisc(), testExodusWriteAddedSidesMixedEdgeC0(), testExodusWriteAddedSidesMixedHexC0(), testExodusWriteAddedSidesMixedQuadC0(), testExodusWriteAddedSidesMixedTriC0(), testExodusWriteAddedSidesQuadC0(), testExodusWriteAddedSidesQuadDisc(), testExodusWriteAddedSidesTetC0(), testExodusWriteAddedSidesTetDisc(), testExodusWriteAddedSidesTriC0(), and testExodusWriteAddedSidesTriDisc().

◆ testExodusWriteAddedSidesEdgeC0()

void MeshInputTest::testExodusWriteAddedSidesEdgeC0 ( )
inline

◆ testExodusWriteAddedSidesEdgeDisc()

void MeshInputTest::testExodusWriteAddedSidesEdgeDisc ( )
inline

◆ testExodusWriteAddedSidesHexC0()

void MeshInputTest::testExodusWriteAddedSidesHexC0 ( )
inline

◆ testExodusWriteAddedSidesHexDisc()

void MeshInputTest::testExodusWriteAddedSidesHexDisc ( )
inline

◆ testExodusWriteAddedSidesMixedEdgeC0()

void MeshInputTest::testExodusWriteAddedSidesMixedEdgeC0 ( )
inline

◆ testExodusWriteAddedSidesMixedHexC0()

void MeshInputTest::testExodusWriteAddedSidesMixedHexC0 ( )
inline

◆ testExodusWriteAddedSidesMixedQuadC0()

void MeshInputTest::testExodusWriteAddedSidesMixedQuadC0 ( )
inline

◆ testExodusWriteAddedSidesMixedTriC0()

void MeshInputTest::testExodusWriteAddedSidesMixedTriC0 ( )
inline

◆ testExodusWriteAddedSidesQuadC0()

void MeshInputTest::testExodusWriteAddedSidesQuadC0 ( )
inline

◆ testExodusWriteAddedSidesQuadDisc()

void MeshInputTest::testExodusWriteAddedSidesQuadDisc ( )
inline

◆ testExodusWriteAddedSidesTetC0()

void MeshInputTest::testExodusWriteAddedSidesTetC0 ( )
inline

◆ testExodusWriteAddedSidesTetDisc()

void MeshInputTest::testExodusWriteAddedSidesTetDisc ( )
inline

◆ testExodusWriteAddedSidesTriC0()

void MeshInputTest::testExodusWriteAddedSidesTriC0 ( )
inline

◆ testExodusWriteAddedSidesTriDisc()

void MeshInputTest::testExodusWriteAddedSidesTriDisc ( )
inline

◆ testExodusWriteElementDataFromDiscontinuousNodalData()

void MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData ( )
inline

Definition at line 1212 of file mesh_input.C.

1213 {
1214 LOG_UNIT_TEST;
1215
1216 const Real scalar_value = 42.;
1217 const Real xyz_value = 84.;
1218 const std::vector<Real> vector_values = {10., 20., 30.};
1219
1220 // first scope: write file
1221 {
1222 Mesh mesh(*TestCommWorld);
1223
1225 System & sys = es.add_system<System> ("SimpleSystem");
1226 sys.add_variable("u", FIRST, L2_LAGRANGE);
1227 const auto c_var =
1229 const auto xyz_var =
1230 sys.add_variable("xyz", FEType(CONSTANT, XYZ));
1231 const auto vec_var =
1233
1235 (mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1., HEX8);
1236
1237 es.init();
1238
1239 // Set solution u^e_i = i, for the ith vertex of a given element e.
1240 const DofMap & dof_map = sys.get_dof_map();
1241 std::vector<dof_id_type> dof_indices;
1242 for (const auto & elem : mesh.element_ptr_range())
1243 {
1244 dof_map.dof_indices(elem, dof_indices, /*var_id=*/0);
1245 for (unsigned int i=0; i<dof_indices.size(); ++i)
1246 sys.solution->set(dof_indices[i], i);
1247
1248 sys.solution->set(elem->dof_number(sys.number(), c_var, 0), scalar_value);
1249 sys.solution->set(elem->dof_number(sys.number(), xyz_var, 0), xyz_value);
1250 for (auto comp : index_range(vector_values))
1251 sys.solution->set(elem->dof_number(sys.number(),
1252 vec_var,
1253 cast_int<unsigned int>(comp)),
1254 vector_values[comp]);
1255 }
1256 sys.solution->close();
1257
1258 // Now write to file.
1259 ExodusII_IO exii(mesh);
1260
1261 // Don't try to write element data as averaged nodal data.
1262 std::set<std::string> sys_list;
1263 exii.write_equation_systems("elemental_from_nodal.e", es, &sys_list);
1264
1265 // Write one elemental data field per vertex value.
1266 sys_list = {"SimpleSystem"};
1267
1268 exii.write_element_data_from_discontinuous_nodal_data
1269 (es, &sys_list, /*var_suffix=*/"_elem_corner_");
1270 } // end first scope
1271
1272 // second scope: read values back in, verify they are correct.
1273 {
1274 std::vector<std::string> file_var_names =
1275 {"u_elem_corner_0",
1276 "u_elem_corner_1",
1277 "u_elem_corner_2",
1278 "u_elem_corner_3",
1279 "c",
1280 "xyz",
1281 "vec_x",
1282 "vec_y",
1283 "vec_z"};
1284 std::vector<Real> expected_values =
1285 {0., 1., 2., 3.,
1286 scalar_value, xyz_value, vector_values[0], vector_values[1], vector_values[2]};
1287
1288 // copy_elemental_solution currently requires ReplicatedMesh
1289 ReplicatedMesh mesh(*TestCommWorld);
1290 mesh.allow_renumbering(false);
1291
1293 System & sys = es.add_system<System> ("SimpleSystem");
1294 for (auto i : index_range(file_var_names))
1295 sys.add_variable(file_var_names[i], FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1296
1297 ExodusII_IO exii(mesh);
1298
1299 if (mesh.processor_id() == 0)
1300 exii.read("elemental_from_nodal.e");
1303
1304 es.init();
1305
1306 for (auto i : index_range(file_var_names))
1307 exii.copy_elemental_solution
1308 (sys, sys.variable_name(i), file_var_names[i]);
1309
1310 // Check that the values we read back in are as expected.
1311 for (const auto & elem : mesh.active_element_ptr_range())
1312 for (auto i : index_range(file_var_names))
1313 {
1314 Real read_val = sys.point_value(i, elem->vertex_average());
1315 LIBMESH_ASSERT_FP_EQUAL
1316 (expected_values[i], read_val, TOLERANCE*TOLERANCE);
1317 }
1318 } // end second scope
1319 } // end testExodusWriteElementDataFromDiscontinuousNodalData
void ErrorVector unsigned int
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1655
Tnew cast_int(Told oldvar)

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshCommunication::broadcast(), libMesh::MeshTools::Generation::build_cube(), libMesh::CONSTANT, libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::DofMap::dof_indices(), libMesh::FIRST, libMesh::System::get_dof_map(), libMesh::HEX8, libMesh::index_range(), libMesh::EquationSystems::init(), libMesh::L2_LAGRANGE, mesh, libMesh::MONOMIAL, libMesh::MONOMIAL_VEC, libMesh::System::number(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO::read(), libMesh::Real, libMesh::FEType::set_p_refinement(), libMesh::System::solution, TestCommWorld, libMesh::TOLERANCE, libMesh::System::variable_name(), libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data(), libMesh::ExodusII_IO::write_equation_systems(), and libMesh::XYZ.

◆ testGmshBCIDOverlap()

void MeshInputTest::testGmshBCIDOverlap ( )
inline

Definition at line 1942 of file mesh_input.C.

1943 {
1944 LOG_UNIT_TEST;
1945
1946 Mesh mesh(*TestCommWorld);
1947
1948 GmshIO gmsh_io(mesh);
1949
1950 if (mesh.processor_id() == 0)
1951 gmsh_io.read("meshes/bcid_overlap.msh");
1953
1954 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().get_sideset_name_map().size(),
1955 std::size_t(2));
1956 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(1),
1957 std::string("srfBC4A"));
1958 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(2),
1959 std::string("srfBC4B"));
1960 CPPUNIT_ASSERT_EQUAL(mesh.get_subdomain_name_map().size(),
1961 std::size_t(2));
1962 CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(1),
1963 std::string("volBC3A"));
1964 CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(2),
1965 std::string("volBC3B"));
1966 }
std::string & sideset_name(boundary_id_type id)
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1930
std::string & subdomain_name(subdomain_id_type id)
Definition mesh_base.C:1902

References libMesh::MeshCommunication::broadcast(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_sideset_name_map(), libMesh::MeshBase::get_subdomain_name_map(), mesh, libMesh::ParallelObject::processor_id(), libMesh::GmshIO::read(), libMesh::BoundaryInfo::sideset_name(), libMesh::MeshBase::subdomain_name(), and TestCommWorld.

◆ testGoodGmsh()

void MeshInputTest::testGoodGmsh ( )
inline

Definition at line 1927 of file mesh_input.C.

1928 {
1929 LOG_UNIT_TEST;
1930
1931 Mesh mesh(*TestCommWorld);
1932
1933 GmshIO gmsh_io(mesh);
1934
1935 if (mesh.processor_id() == 0)
1936 gmsh_io.read("meshes/circle.msh");
1938
1939 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(14));
1940 }

References libMesh::MeshCommunication::broadcast(), mesh, libMesh::MeshBase::n_elem(), libMesh::ParallelObject::processor_id(), libMesh::GmshIO::read(), and TestCommWorld.

◆ testGoodSTL()

void MeshInputTest::testGoodSTL ( )
inline

Definition at line 1968 of file mesh_input.C.

1969 {
1970 LOG_UNIT_TEST;
1971
1972 Mesh mesh(*TestCommWorld);
1973
1974 STLIO stl_io(mesh);
1975
1976 if (mesh.processor_id() == 0)
1977 stl_io.read("meshes/Cluster_34.stl");
1979
1980 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(40));
1981 }
This class implements reading and writing triangle meshes in the STL format.
Definition stl_io.h:47

References libMesh::MeshCommunication::broadcast(), mesh, libMesh::MeshBase::n_elem(), libMesh::ParallelObject::processor_id(), libMesh::STLIO::read(), and TestCommWorld.

◆ testGoodSTLBinary()

void MeshInputTest::testGoodSTLBinary ( )
inline

Definition at line 1983 of file mesh_input.C.

1984 {
1985 LOG_UNIT_TEST;
1986
1987 Mesh mesh(*TestCommWorld);
1988
1989 STLIO stl_io(mesh);
1990
1991 if (mesh.processor_id() == 0)
1992 stl_io.read("meshes/engraving.stl");
1994
1995 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(426));
1996 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(215));
1997 }

References libMesh::MeshCommunication::broadcast(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::processor_id(), libMesh::STLIO::read(), and TestCommWorld.

◆ testLowOrderEdgeBlocks()

void MeshInputTest::testLowOrderEdgeBlocks ( )
inline

Definition at line 623 of file mesh_input.C.

624 {
625 LOG_UNIT_TEST;
626
627 Mesh mesh(*TestCommWorld);
628 ExodusII_IO exii(mesh);
629
630 if (mesh.processor_id() == 0)
631 exii.read("meshes/mesh_with_low_order_edge_blocks.e");
632
635
636 // Check that we see the boundary ids we expect
638
639 // On a ReplicatedMesh, check that the number of edge boundary
640 // conditions is as expected. The real test is that we can read
641 // this file in at all. Prior to the changes in #3491, the Exodus
642 // reader threw an exception while trying to read this mesh.
643 if (mesh.is_serial())
644 {
645 // Mesh has 26 boundary ids total (including edge and side ids).
646 // ss_prop1 = 200, 201 ;
647 // ed_prop1 = 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010,
648 // 8011, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 9008, 9009, 9010,
649 // 9011, 9012 ;
650 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(26), bi.n_boundary_ids());
651
652 // We can binary_search() the build_edge_list() which is sorted
653 // in lexicographical order before it's returned.
654 auto edge_list = bi.build_edge_list();
655
656 // Search for some tuples we expect to be present
657 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(4, 1, 8007)));
658 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(10, 6, 8001)));
659
660 // And make sure we don't have entries we shouldn't have
661 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(1, 8, 8009)));
662 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(2, 10, 9011)));
663 }
664 }
std::vector< BCTuple > build_edge_list() const
Create a list of (element_id, edge_id, boundary_id) tuples for all relevant edges.

References libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_edge_list(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::is_serial(), mesh, libMesh::BoundaryInfo::n_boundary_ids(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO::read(), and TestCommWorld.

◆ testMasterCenters()

void MeshInputTest::testMasterCenters ( const MeshBase &  mesh)
inline

Definition at line 1761 of file mesh_input.C.

1762 {
1763 auto locator = mesh.sub_point_locator();
1764
1765 for (auto & elem : mesh.element_ptr_range())
1766 {
1767 Point master_pt = {}; // center, for tensor product elements
1768
1769 // But perturb it to try and trigger any mapping weirdness
1770 if (elem->dim() > 0)
1771 master_pt(0) = 0.25;
1772
1773 if (elem->dim() > 1)
1774 master_pt(1) = -0.25;
1775
1776 if (elem->dim() > 2)
1777 master_pt(2) = 0.75;
1778
1779 Point physical_pt = FEMap::map(elem->dim(), elem, master_pt);
1780
1781 Point inverse_pt = FEMap::inverse_map(elem->dim(), elem,
1782 physical_pt);
1783
1784 CPPUNIT_ASSERT((inverse_pt-master_pt).norm() < TOLERANCE);
1785
1786 CPPUNIT_ASSERT(elem->contains_point(physical_pt));
1787
1788 // We only want to find elements in the same block
1789 std::set<subdomain_id_type> my_subdomain { elem->subdomain_id() };
1790
1791 // We can *still* have overlapping NodeElem from a slit mesh
1792 // input file; better check them all
1793 std::set<const Elem * > located_elems;
1794 (*locator)(physical_pt, located_elems, &my_subdomain);
1795
1796 CPPUNIT_ASSERT(located_elems.count(elem));
1797 }
1798 }
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
Definition fe_map.C:1954
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition fe_map.C:1512
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1848
LIBMESH_DEVICE_INLINE auto norm(const T &a)

References libMesh::FEMap::inverse_map(), libMesh::FEMap::map(), mesh, libMesh::MeshBase::sub_point_locator(), and libMesh::TOLERANCE.

Referenced by helperTestingDynaQuad(), testDynaFileMappings(), testDynaReadPatch(), and testExodusFileMappings().

◆ testNemesisCopyElementSolutionDistributed()

void MeshInputTest::testNemesisCopyElementSolutionDistributed ( )
inline

Definition at line 1009 of file mesh_input.C.

1010 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,Nemesis_IO>("dist_with_elem_soln.nem"); }

◆ testNemesisCopyElementSolutionReplicated()

void MeshInputTest::testNemesisCopyElementSolutionReplicated ( )
inline

Definition at line 1006 of file mesh_input.C.

1007 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,Nemesis_IO>("repl_with_elem_soln.nem"); }

◆ testNemesisCopyElementVectorDistributed()

void MeshInputTest::testNemesisCopyElementVectorDistributed ( )
inline

Definition at line 1207 of file mesh_input.C.

1208 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,Nemesis_IO>("dist_with_elem_vec.nem"); }

◆ testNemesisCopyElementVectorReplicated()

void MeshInputTest::testNemesisCopyElementVectorReplicated ( )
inline

Definition at line 1204 of file mesh_input.C.

1205 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh,Nemesis_IO>("repl_with_elem_vec.nem"); }

◆ testNemesisCopyNodalSolutionDistributed()

void MeshInputTest::testNemesisCopyNodalSolutionDistributed ( )
inline

Definition at line 835 of file mesh_input.C.

836 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,Nemesis_IO>("dist_with_nodal_soln.nem"); }

◆ testNemesisCopyNodalSolutionReplicated()

void MeshInputTest::testNemesisCopyNodalSolutionReplicated ( )
inline

Definition at line 832 of file mesh_input.C.

833 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,Nemesis_IO>("repl_with_nodal_soln.nem"); }

◆ testNemesisReadDistributed()

void MeshInputTest::testNemesisReadDistributed ( )
inline

Definition at line 1756 of file mesh_input.C.

1757 { LOG_UNIT_TEST; testNemesisReadImpl<DistributedMesh>(); }

◆ testNemesisReadImpl()

template<typename MeshType >
void MeshInputTest::testNemesisReadImpl ( )
inline

Definition at line 1729 of file mesh_input.C.

1730 {
1731 // first scope: write file
1732 {
1733 MeshType mesh(*TestCommWorld);
1734 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
1735 mesh.write("test_nemesis_read.nem");
1736 }
1737
1738 // Make sure that the writing is done before the reading starts.
1739 TestCommWorld->barrier();
1740
1741 // second scope: read file
1742 {
1743 MeshType mesh(*TestCommWorld);
1744 Nemesis_IO nem(mesh);
1745
1746 nem.read("test_nemesis_read.nem");
1748 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(9));
1749 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(16));
1750 }
1751 }
The Nemesis_IO class implements reading parallel meshes in the Nemesis file format from Sandia Nation...
Definition nemesis_io.h:54

References libMesh::MeshTools::Generation::build_square(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), TestCommWorld, and libMesh::MeshBase::write().

◆ testNemesisReadReplicated()

void MeshInputTest::testNemesisReadReplicated ( )
inline

Definition at line 1753 of file mesh_input.C.

1754 { LOG_UNIT_TEST; testNemesisReadImpl<ReplicatedMesh>(); }

◆ testNemesisSingleElementDistributed()

void MeshInputTest::testNemesisSingleElementDistributed ( )
inline

Definition at line 1071 of file mesh_input.C.

1072 { LOG_UNIT_TEST; testSingleElementImpl<DistributedMesh,Nemesis_IO>("dist_with_single_elem.nem"); }

◆ testNemesisSingleElementReplicated()

void MeshInputTest::testNemesisSingleElementReplicated ( )
inline

Definition at line 1068 of file mesh_input.C.

1069 { LOG_UNIT_TEST; testSingleElementImpl<ReplicatedMesh,Nemesis_IO>("repl_with_single_elem.nem"); }

◆ testProjectionRegression()

void MeshInputTest::testProjectionRegression ( MeshBase &  mesh,
std::array< Real, 4 >  expected_norms 
)
inline

Definition at line 2125 of file mesh_input.C.

2126 {
2127 int order = 0;
2128 for (const auto elem : mesh.element_ptr_range())
2129 order = std::max(order, int(elem->default_order()));
2130 TestCommWorld->max(order);
2131 CPPUNIT_ASSERT (order > 0);
2132
2133 // Let's test that IGA constraints are preserved (in a relative
2134 // sense) when we clone a mesh.
2135 std::unique_ptr<MeshBase> mesh_clone = mesh.clone();
2136 CPPUNIT_ASSERT(*mesh_clone == mesh);
2137
2139 System &sys = es.add_system<System> ("SimpleSystem");
2140 sys.add_variable("n", Order(order), RATIONAL_BERNSTEIN);
2141
2142 es.init();
2143
2144 sys.project_solution(sin_x_plus_cos_y, nullptr, es.parameters);
2145
2146 // Make this easy to tweak in the future
2147 const Real my_tolerance = TOLERANCE;
2148
2149 // Calculate some norms, skipping the spline points, and compare
2150 // to regression standard values
2151 std::set<unsigned int> skip_dimensions {0};
2152 const Real L2_norm =
2153 sys.calculate_norm(*sys.solution, 0, L2, &skip_dimensions);
2154// std::cout.precision(16);
2155// std::cout << "L2_norm = " << L2_norm << std::endl;
2156 LIBMESH_ASSERT_FP_EQUAL(L2_norm, expected_norms[0], my_tolerance);
2157 const Real Linf_norm =
2158 sys.calculate_norm(*sys.solution, 0, L_INF, &skip_dimensions);
2159// std::cout << "Linf_norm = " << Linf_norm << std::endl;
2160 LIBMESH_ASSERT_FP_EQUAL(Linf_norm, expected_norms[1], my_tolerance);
2161 const Real H1_norm =
2162 sys.calculate_norm(*sys.solution, 0, H1_SEMINORM, &skip_dimensions);
2163// std::cout << "H1_norm = " << H1_norm << std::endl;
2164 LIBMESH_ASSERT_FP_EQUAL(H1_norm, expected_norms[2], my_tolerance);
2165 const Real W1inf_norm =
2166 sys.calculate_norm(*sys.solution, 0, W1_INF_SEMINORM, &skip_dimensions);
2167// std::cout << "W1inf_norm = " << W1inf_norm << std::endl;
2168 // W1_inf seems more sensitive to FP error...
2169 LIBMESH_ASSERT_FP_EQUAL(W1inf_norm, expected_norms[3], 10*my_tolerance);
2170 }
virtual std::unique_ptr< MeshBase > clone() const =0
Virtual "copy constructor".
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition system.C:1511
@ RATIONAL_BERNSTEIN

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::System::calculate_norm(), libMesh::MeshBase::clone(), libMesh::H1_SEMINORM, libMesh::EquationSystems::init(), libMesh::L2, libMesh::L_INF, mesh, libMesh::EquationSystems::parameters, libMesh::System::project_solution(), libMesh::RATIONAL_BERNSTEIN, libMesh::Real, sin_x_plus_cos_y(), libMesh::System::solution, TestCommWorld, libMesh::TOLERANCE, and libMesh::W1_INF_SEMINORM.

Referenced by testDynaFileMappings(), and testExodusFileMappings().

◆ testSingleElementImpl()

template<typename MeshType , typename IOType >
void MeshInputTest::testSingleElementImpl ( const std::string &  filename)
inline

Definition at line 1017 of file mesh_input.C.

1018 {
1019 {
1020 // Generate a single 1x1 square element mesh
1021 MeshType mesh(*TestCommWorld);
1023
1025 auto & sys = es.add_system<System>("SimpleSystem");
1026 sys.add_variable("e", CONSTANT, MONOMIAL);
1027
1028 // Set an arbitrary solution for the single element DOF
1029 es.init();
1030 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
1031
1032 // Write the solution to Nemesis file(s) - only proc 0 should have anything to write!
1033 Nemesis_IO nem_io(mesh);
1034 std::set<std::string> sys_list;
1035 nem_io.write_equation_systems(filename, es, &sys_list);
1036 nem_io.write_element_data(es);
1037 }
1038
1039 // If we can read and copy the correct element value back into the mesh, we know the Nemesis
1040 // file(s) were written properly.
1041 {
1042 MeshType mesh(*TestCommWorld);
1043 mesh.allow_renumbering(false);
1045 auto & sys = es.add_system<System>("SimpleSystem");
1046 sys.add_variable("teste", CONSTANT, MONOMIAL);
1047
1048 Nemesis_IO nem_io(mesh);
1049 if (mesh.processor_id() == 0 || nem_io.is_parallel_format())
1050 nem_io.read(filename);
1051
1053 es.init();
1054
1055#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1056 nem_io.copy_elemental_solution(sys, "teste", "r_e");
1057#else
1058 nem_io.copy_elemental_solution(sys, "teste", "e");
1059#endif
1060
1061 // The result should be '\frac{6 + 60}{2} = 33' at all points in the element domain
1062 CPPUNIT_ASSERT_EQUAL(int(sys.solution->size()), 1);
1063 CPPUNIT_ASSERT_EQUAL(libmesh_real(sys.point_value(0, Point(0.5, 0.5))), Real(33));
1064 }
1065 }

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshTools::Generation::build_square(), libMesh::CONSTANT, libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::EquationSystems::init(), libMesh::MeshInput< MT >::is_parallel_format(), libMesh::libmesh_real(), mesh, libMesh::MONOMIAL, libMesh::EquationSystems::parameters, libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::Nemesis_IO::read(), libMesh::Real, six_x_plus_sixty_y(), TestCommWorld, libMesh::Nemesis_IO::write_element_data(), and libMesh::MeshOutput< MT >::write_equation_systems().

◆ testTetgenIO()

void MeshInputTest::testTetgenIO ( )
inline

Definition at line 1999 of file mesh_input.C.

2000 {
2001#ifdef LIBMESH_HAVE_TETGEN
2002 LOG_UNIT_TEST;
2003
2004 Mesh mesh(*TestCommWorld);
2005
2006 TetGenIO tetgen_io(mesh);
2007
2008 if (mesh.processor_id() == 0)
2009 tetgen_io.read("meshes/tetgen_one_tet10.ele");
2011
2013
2014 // Mesh should contain 1 TET10 finite element
2015 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(1));
2016 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(10));
2017
2018 // Element should have TET10 reference element volume
2019 const Elem * const elem = mesh.query_elem_ptr(0);
2020
2021 // On a serial mesh we have every element everywhere
2022 if (mesh.is_serial())
2023 CPPUNIT_ASSERT(elem);
2024 else
2025 {
2026 bool have_elem = elem;
2027 mesh.comm().max(have_elem);
2028 CPPUNIT_ASSERT(have_elem);
2029 }
2030
2031 if (elem)
2032 {
2033 const Real vol = elem->volume();
2034 LIBMESH_ASSERT_FP_EQUAL(vol, 1./6, TOLERANCE*TOLERANCE);
2035 }
2036#endif
2037 }
This class implements reading and writing meshes in the TetGen format.
Definition tetgen_io.h:49

References libMesh::MeshCommunication::broadcast(), libMesh::ParallelObject::comm(), libMesh::MeshBase::is_serial(), libMesh::Parallel::Communicator::max(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::query_elem_ptr(), libMesh::TetGenIO::read(), libMesh::Real, TestCommWorld, libMesh::TOLERANCE, and libMesh::Elem::volume().

◆ testVTKPreserveElemIds()

void MeshInputTest::testVTKPreserveElemIds ( )
inline

Definition at line 232 of file mesh_input.C.

233 {
234 LOG_UNIT_TEST;
235
236 // Come up with some crazy numbering. Make all the new ids higher
237 // than the existing ids so we don't have to worry about conflicts
238 // while renumbering.
239 dof_id_type start_id;
240
241 // first scope: write file
242 {
243 Mesh mesh(*TestCommWorld);
244 mesh.allow_renumbering(false);
245 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
246
247 start_id = mesh.max_elem_id();
248
249 // Use a separate container that won't invalidate iterators when
250 // we renumber
251 std::set<Elem *> elements {mesh.elements_begin(), mesh.elements_end()};
252 for (Elem * elem : elements)
253 {
254 const Point center = elem->vertex_average();
255 const int xn = int(center(0)*3);
256 const int yn = int(center(1)*3);
257 const dof_id_type new_id = start_id + yn*5 + xn;
258 mesh.renumber_elem(elem->id(), new_id);
259 }
260
261 // Explicit writer object here to be absolutely sure we get VTK
262 VTKIO vtk(mesh);
263 vtk.write("read_elem_ids_test.pvtu");
264 }
265
266 // Make sure that the writing is done before the reading starts.
267 TestCommWorld->barrier();
268
269 // second scope: read file
270 {
271 Mesh mesh(*TestCommWorld);
272 mesh.allow_renumbering(false);
273
274 mesh.read("read_elem_ids_test.pvtu");
276
277 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(16));
278 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(9));
279
280 for (const auto & elem : mesh.element_ptr_range())
281 {
282 const Point center = elem->vertex_average();
283 const int xn = int(center(0)*3);
284 const int yn = int(center(1)*3);
285 const dof_id_type expected_id = start_id + yn*5 + xn;
286 CPPUNIT_ASSERT_EQUAL(elem->id(), expected_id);
287 }
288 }
289 }
virtual void renumber_elem(dof_id_type old_id, dof_id_type new_id)=0
Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in t...
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
virtual dof_id_type max_elem_id() const =0

References libMesh::MeshBase::allow_renumbering(), libMesh::MeshTools::Generation::build_square(), int, libMesh::MeshBase::max_elem_id(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::read(), libMesh::MeshBase::renumber_elem(), TestCommWorld, and libMesh::VTKIO::write().

◆ testVTKPreserveSubdomainIds()

void MeshInputTest::testVTKPreserveSubdomainIds ( )
inline

Definition at line 291 of file mesh_input.C.

292 {
293 LOG_UNIT_TEST;
294
295 // first scope: write file
296 {
297 Mesh mesh(*TestCommWorld);
298 mesh.allow_renumbering(false);
299 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
300
301 for (const auto & elem : mesh.element_ptr_range())
302 {
303 const Point center = elem->vertex_average();
304 const int xn = int(center(0)*3);
305 const int yn = int(center(1)*3);
306 const subdomain_id_type new_id = yn*4 + xn;
307 elem->subdomain_id() = new_id;
308 }
309
310 // Explicit writer object here to be absolutely sure we get VTK
311 VTKIO vtk(mesh);
312 vtk.write("read_sbd_ids_test.pvtu");
313 }
314
315 // Make sure that the writing is done before the reading starts.
316 TestCommWorld->barrier();
317
318 // second scope: read file
319 {
320 Mesh mesh(*TestCommWorld);
321 mesh.allow_renumbering(false);
322
323 mesh.read("read_sbd_ids_test.pvtu");
325
326 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(16));
327 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(9));
328
329 for (const auto & elem : mesh.element_ptr_range())
330 {
331 const Point center = elem->vertex_average();
332 const int xn = int(center(0)*3);
333 const int yn = int(center(1)*3);
334 const subdomain_id_type expected_id = yn*4 + xn;
335 CPPUNIT_ASSERT_EQUAL(elem->subdomain_id(), expected_id);
336 }
337 }
338 }

References libMesh::MeshBase::allow_renumbering(), libMesh::MeshTools::Generation::build_square(), int, mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::read(), TestCommWorld, and libMesh::VTKIO::write().

◆ testVTKReadNotAnXMLFile()

void MeshInputTest::testVTKReadNotAnXMLFile ( )
inline

Definition at line 445 of file mesh_input.C.

446 {
447 LOG_UNIT_TEST;
448
449#ifdef LIBMESH_ENABLE_EXCEPTIONS
450 Mesh mesh(*TestCommWorld);
451 VTKIO vtk(mesh);
452 CPPUNIT_ASSERT_THROW_MESSAGE
453 ("Non-VTK-XML file not detected",
454 vtk.read("meshes/circle.msh"),
456#endif
457 }

References mesh, libMesh::VTKIO::read(), and TestCommWorld.

◆ testVTKReadPolyhedra()

void MeshInputTest::testVTKReadPolyhedra ( )
inline

Definition at line 390 of file mesh_input.C.

391 {
392 LOG_UNIT_TEST;
393
394 // This .pvtu (+ piece) file contains a single VTK_POLYHEDRON cell.
395 // VTKIO::read() sniffs the file's actual root element to tell a
396 // parallel PUnstructuredGrid (.pvtu) descriptor from a plain serial
397 // UnstructuredGrid (.vtu) file and uses the matching reader class --
398 // see testVTKReadPolyhedraSerial below for the latter.
399 Mesh mesh(*TestCommWorld);
400 // Without this, prepare_for_use()'s default renumbering can reassign
401 // node ids (by local element-traversal order rather than preserving
402 // the ids we read), which would invalidate the "ids match VTK point
403 // ordering" assumption checkHexPrismPolyhedron() relies on.
404 mesh.allow_renumbering(false);
405 mesh.read("meshes/hex_prism_polyhedron.pvtu");
407
409 }
void checkHexPrismPolyhedron(MeshBase &mesh)
Definition mesh_input.C:343

References libMesh::MeshBase::allow_renumbering(), checkHexPrismPolyhedron(), mesh, libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::read(), and TestCommWorld.

◆ testVTKReadPolyhedraSerial()

void MeshInputTest::testVTKReadPolyhedraSerial ( )
inline

Definition at line 420 of file mesh_input.C.

421 {
422 LOG_UNIT_TEST;
423
424 Mesh mesh(*TestCommWorld);
425 mesh.allow_renumbering(false);
426 mesh.read("meshes/hex_prism_polyhedron_0.vtu");
428
430 }

References libMesh::MeshBase::allow_renumbering(), checkHexPrismPolyhedron(), mesh, libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::read(), and TestCommWorld.


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