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 (testGoodSTLGzipped)
 
 CPPUNIT_TEST (testUCDWriteNodalData)
 
 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 testSTLGzipped (const std::string &basename, dof_id_type n_elem, dof_id_type n_nodes)
 
void testGoodSTLGzipped ()
 
void testUCDWriteNodalData ()
 
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 105 of file mesh_input.C.

Member Function Documentation

◆ checkHexPrismPolyhedron()

void MeshInputTest::checkHexPrismPolyhedron ( MeshBase &  mesh)
inline

Definition at line 353 of file mesh_input.C.

354 {
355 CPPUNIT_ASSERT_EQUAL(dof_id_type(1), mesh.n_elem());
356
357 // The element may live on a single processor when the mesh is
358 // distributed, so guard the checks accordingly.
359 const Elem * elem = mesh.query_elem_ptr(0);
360 bool found_elem = elem;
361 mesh.comm().max(found_elem);
362 CPPUNIT_ASSERT(found_elem);
363
364 if (!elem)
365 return;
366
367 CPPUNIT_ASSERT_EQUAL(C0POLYHEDRON, elem->type());
368 CPPUNIT_ASSERT_EQUAL(12u, elem->n_vertices());
369 CPPUNIT_ASSERT_EQUAL(8u, elem->n_sides());
370
371 // The file has no libmesh_node_id array, so libMesh node ids match
372 // the VTK point ordering, i.e. the coordinates we wrote out.
373 LIBMESH_ASSERT_FP_EQUAL(6.0, elem->volume(), TOLERANCE);
374
375 // Collect the faces (as node-id sets) and compare against the faces
376 // that were written to the file, independent of any reordering the
377 // C0Polyhedron may do to its sides.
378 std::set<std::set<dof_id_type>> faces;
379 for (auto s : elem->side_index_range())
380 {
381 std::set<dof_id_type> face;
382 for (const auto n : elem->nodes_on_side(s))
383 face.insert(elem->node_id(n));
384 faces.insert(std::move(face));
385 }
386
387 const std::set<std::set<dof_id_type>> expected_faces =
388 { {0, 1, 2, 3, 4, 5},
389 {0, 1, 7, 6},
390 {1, 2, 8, 7},
391 {2, 3, 9, 8},
392 {3, 4, 10, 9},
393 {4, 5, 11, 10},
394 {5, 0, 6, 11},
395 {6, 7, 8, 9, 10, 11} };
396
397 CPPUNIT_ASSERT(faces == expected_faces);
398 }
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/71]

MeshInputTest::CPPUNIT_TEST ( testAbaqusReadFirst  )

◆ CPPUNIT_TEST() [2/71]

MeshInputTest::CPPUNIT_TEST ( testAbaqusReadSecond  )

◆ CPPUNIT_TEST() [3/71]

MeshInputTest::CPPUNIT_TEST ( testBadGmsh  )

◆ CPPUNIT_TEST() [4/71]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsBlockWithHole  )

◆ CPPUNIT_TEST() [5/71]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsCyl3d  )

◆ CPPUNIT_TEST() [6/71]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsFEMEx5  )

◆ CPPUNIT_TEST() [7/71]

MeshInputTest::CPPUNIT_TEST ( testDynaFileMappingsPlateWithHole  )

◆ CPPUNIT_TEST() [8/71]

MeshInputTest::CPPUNIT_TEST ( testDynaNoSplines  )

◆ CPPUNIT_TEST() [9/71]

MeshInputTest::CPPUNIT_TEST ( testDynaReadElem  )

◆ CPPUNIT_TEST() [10/71]

MeshInputTest::CPPUNIT_TEST ( testDynaReadPatch  )

◆ CPPUNIT_TEST() [11/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementSolutionDistributed  )

◆ CPPUNIT_TEST() [12/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementSolutionReplicated  )

◆ CPPUNIT_TEST() [13/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementVectorDistributed  )

◆ CPPUNIT_TEST() [14/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyElementVectorReplicated  )

◆ CPPUNIT_TEST() [15/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyHighOrderElementSolution  )

◆ CPPUNIT_TEST() [16/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyNodalSolutionDistributed  )

◆ CPPUNIT_TEST() [17/71]

MeshInputTest::CPPUNIT_TEST ( testExodusCopyNodalSolutionReplicated  )

◆ CPPUNIT_TEST() [18/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscCyl3d  )

◆ CPPUNIT_TEST() [19/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscPlateWithHole  )

◆ CPPUNIT_TEST() [20/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscTwoBlocks  )

◆ CPPUNIT_TEST() [21/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscTwoElemIGA  )

◆ CPPUNIT_TEST() [22/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesEdgeC0  )

◆ CPPUNIT_TEST() [23/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesHexC0  )

◆ CPPUNIT_TEST() [24/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesHexDisc  )

◆ CPPUNIT_TEST() [25/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedEdgeC0  )

◆ CPPUNIT_TEST() [26/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedHexC0  )

◆ CPPUNIT_TEST() [27/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedQuadC0  )

◆ CPPUNIT_TEST() [28/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesMixedTriC0  )

◆ CPPUNIT_TEST() [29/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesQuadC0  )

◆ CPPUNIT_TEST() [30/71]

MeshInputTest::CPPUNIT_TEST ( testExodusDiscWriteAddedSidesTriC0  )

◆ CPPUNIT_TEST() [31/71]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsCyl3d  )

◆ CPPUNIT_TEST() [32/71]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsPlateWithHole  )

◆ CPPUNIT_TEST() [33/71]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsTwoBlocks  )

◆ CPPUNIT_TEST() [34/71]

MeshInputTest::CPPUNIT_TEST ( testExodusFileMappingsTwoElemIGA  )

◆ CPPUNIT_TEST() [35/71]

MeshInputTest::CPPUNIT_TEST ( testExodusIGASidesets  )

◆ CPPUNIT_TEST() [36/71]

MeshInputTest::CPPUNIT_TEST ( testExodusReadHeader  )

◆ CPPUNIT_TEST() [37/71]

MeshInputTest::CPPUNIT_TEST ( testExodusSetElemUniqueIdsFromMaps  )

◆ CPPUNIT_TEST() [38/71]

MeshInputTest::CPPUNIT_TEST ( testExodusSetNodeUniqueIdsFromMaps  )

◆ CPPUNIT_TEST() [39/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesEdgeC0  )

◆ CPPUNIT_TEST() [40/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesHexC0  )

◆ CPPUNIT_TEST() [41/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesHexDisc  )

◆ CPPUNIT_TEST() [42/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedEdgeC0  )

◆ CPPUNIT_TEST() [43/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedHexC0  )

◆ CPPUNIT_TEST() [44/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedQuadC0  )

◆ CPPUNIT_TEST() [45/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesMixedTriC0  )

◆ CPPUNIT_TEST() [46/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesQuadC0  )

◆ CPPUNIT_TEST() [47/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteAddedSidesTriC0  )

◆ CPPUNIT_TEST() [48/71]

MeshInputTest::CPPUNIT_TEST ( testExodusWriteElementDataFromDiscontinuousNodalData  )

◆ CPPUNIT_TEST() [49/71]

MeshInputTest::CPPUNIT_TEST ( testGmshBCIDOverlap  )

◆ CPPUNIT_TEST() [50/71]

MeshInputTest::CPPUNIT_TEST ( testGoodGmsh  )

◆ CPPUNIT_TEST() [51/71]

MeshInputTest::CPPUNIT_TEST ( testGoodSTL  )

◆ CPPUNIT_TEST() [52/71]

MeshInputTest::CPPUNIT_TEST ( testGoodSTLBinary  )

◆ CPPUNIT_TEST() [53/71]

MeshInputTest::CPPUNIT_TEST ( testGoodSTLGzipped  )

◆ CPPUNIT_TEST() [54/71]

MeshInputTest::CPPUNIT_TEST ( testLowOrderEdgeBlocks  )

◆ CPPUNIT_TEST() [55/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementSolutionDistributed  )

◆ CPPUNIT_TEST() [56/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementSolutionReplicated  )

◆ CPPUNIT_TEST() [57/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementVectorDistributed  )

◆ CPPUNIT_TEST() [58/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyElementVectorReplicated  )

◆ CPPUNIT_TEST() [59/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyNodalSolutionDistributed  )

◆ CPPUNIT_TEST() [60/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisCopyNodalSolutionReplicated  )

◆ CPPUNIT_TEST() [61/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisReadDistributed  )

◆ CPPUNIT_TEST() [62/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisReadReplicated  )

◆ CPPUNIT_TEST() [63/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisSingleElementDistributed  )

◆ CPPUNIT_TEST() [64/71]

MeshInputTest::CPPUNIT_TEST ( testNemesisSingleElementReplicated  )

◆ CPPUNIT_TEST() [65/71]

MeshInputTest::CPPUNIT_TEST ( testTetgenIO  )

◆ CPPUNIT_TEST() [66/71]

MeshInputTest::CPPUNIT_TEST ( testUCDWriteNodalData  )

◆ CPPUNIT_TEST() [67/71]

MeshInputTest::CPPUNIT_TEST ( testVTKPreserveElemIds  )

◆ CPPUNIT_TEST() [68/71]

MeshInputTest::CPPUNIT_TEST ( testVTKPreserveSubdomainIds  )

◆ CPPUNIT_TEST() [69/71]

MeshInputTest::CPPUNIT_TEST ( testVTKReadNotAnXMLFile  )

◆ CPPUNIT_TEST() [70/71]

MeshInputTest::CPPUNIT_TEST ( testVTKReadPolyhedra  )

◆ CPPUNIT_TEST() [71/71]

MeshInputTest::CPPUNIT_TEST ( testVTKReadPolyhedraSerial  )

◆ CPPUNIT_TEST_SUITE_END()

MeshInputTest::CPPUNIT_TEST_SUITE_END ( )

◆ helperTestingDynaQuad()

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

Definition at line 1812 of file mesh_input.C.

1813 {
1814 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
1816
1817 unsigned char weight_index = mesh.default_mapping_data();
1818
1819 bool found_the_quad = false;
1820
1821 for (auto & elem : mesh.element_ptr_range())
1822 {
1823 if (elem->type() == NODEELEM)
1824 continue;
1825
1826 CPPUNIT_ASSERT_EQUAL(elem->type(), QUAD9);
1827 found_the_quad = true;
1828
1829 for (unsigned int n=0; n != 9; ++n)
1830 CPPUNIT_ASSERT_EQUAL
1831 (elem->node_ref(n).get_extra_datum<Real>(weight_index),
1832 Real(0.75));
1833
1834 CPPUNIT_ASSERT_EQUAL(elem->point(0)(0), Real(0.5));
1835 CPPUNIT_ASSERT_EQUAL(elem->point(0)(1), Real(0.5));
1836 CPPUNIT_ASSERT_EQUAL(elem->point(1)(0), Real(1.5));
1837 CPPUNIT_ASSERT_EQUAL(elem->point(1)(1), Real(0.5));
1838 CPPUNIT_ASSERT_EQUAL(elem->point(2)(0), Real(1.5));
1839 CPPUNIT_ASSERT_EQUAL(elem->point(2)(1), Real(1.5));
1840 CPPUNIT_ASSERT_EQUAL(elem->point(3)(0), Real(0.5));
1841 CPPUNIT_ASSERT_EQUAL(elem->point(3)(1), Real(1.5));
1842 CPPUNIT_ASSERT(elem->has_affine_map());
1843#if LIBMESH_DIM > 2
1844 for (unsigned int v=0; v != 4; ++v)
1845 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2), Real(0));
1846#endif
1847 }
1848
1849 TestCommWorld->max(found_the_quad);
1850 CPPUNIT_ASSERT(found_the_quad);
1851
1853 }
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:946
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition mesh_base.h:964
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 235 of file mesh_input.C.

236 {}

◆ tearDown()

void MeshInputTest::tearDown ( )
inline

Definition at line 238 of file mesh_input.C.

239 {}

◆ testAbaqusRead()

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

Definition at line 1856 of file mesh_input.C.

1859 {
1860 Mesh mesh(*TestCommWorld);
1861
1862 AbaqusIO abaqus(mesh);
1863
1864 if (mesh.processor_id() == 0)
1865 abaqus.read(fname);
1867
1869
1870 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_elem);
1871 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), n_nodes);
1872 }
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:901
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 1875 of file mesh_input.C.

1876 {
1877 LOG_UNIT_TEST;
1878 testAbaqusRead("meshes/tensile_sample_test1.inp.gz", 728, 1166);
1879 }
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 1882 of file mesh_input.C.

1883 {
1884 LOG_UNIT_TEST;
1885 testAbaqusRead("meshes/poly_sample_test2.inp.gz", 1280, 1625);
1886 }

References testAbaqusRead().

◆ testBadGmsh()

void MeshInputTest::testBadGmsh ( )
inline

Definition at line 1911 of file mesh_input.C.

1912 {
1913 LOG_UNIT_TEST;
1914
1915 Mesh mesh(*TestCommWorld);
1916
1917 GmshIO gmsh_io(mesh);
1918
1919#ifdef LIBMESH_ENABLE_EXCEPTIONS
1920 std::string what = "";
1921 try
1922 {
1923 if (mesh.processor_id() == 0)
1924 gmsh_io.read("meshes/block.msh");
1925 }
1926 catch (libMesh::LogicError & e)
1927 {
1928 what = e.what();
1929 }
1930
1931 TestCommWorld->broadcast(what);
1932 std::regex msg_regex("outside entity physical bounding box");
1933 CPPUNIT_ASSERT(std::regex_search(what, msg_regex));
1934#endif
1935 }
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 851 of file mesh_input.C.

852 {
853 {
854 MeshType mesh(*TestCommWorld);
855
857 System &sys = es.add_system<System> ("SimpleSystem");
858 sys.add_variable("e", CONSTANT, MONOMIAL);
859 sys.add_variable("e_no_p", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
860 sys.add_variable("e_xyz", FEType(CONSTANT, XYZ));
861
863 3, 3,
864 0., 1., 0., 1.);
865
866 es.init();
867 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
868
869 IOType meshinput(mesh);
870
871 // Don't try to write element data as nodal data
872 std::set<std::string> sys_list;
873 meshinput.write_equation_systems(filename, es, &sys_list);
874
875 // Just write it as element data
876 meshinput.write_element_data(es);
877 }
878
879 {
880 MeshType mesh(*TestCommWorld);
881 mesh.allow_renumbering(false);
882 IOType meshinput(mesh);
883
884 // Avoid getting Nemesis solution values mixed up
885 if (meshinput.is_parallel_format())
886 {
888 }
889
891 System &sys = es.add_system<System> ("SimpleSystem");
892 sys.add_variable("teste", CONSTANT, MONOMIAL);
893 sys.add_variable("teste_no_p", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
894 sys.add_variable("teste_xyz", FEType(CONSTANT, XYZ));
895
896 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
897 meshinput.read(filename);
898 if (!meshinput.is_parallel_format())
901
902 es.init();
903
904 // Read the solution e into variable teste.
905 //
906 // With complex numbers, we'll only bother reading the real
907 // part.
908#ifdef LIBMESH_USE_COMPLEX_NUMBERS
909 meshinput.copy_elemental_solution(sys, "teste", "r_e");
910 meshinput.copy_elemental_solution(sys, "teste_no_p", "r_e_no_p");
911 meshinput.copy_elemental_solution(sys, "teste_xyz", "r_e_xyz");
912#else
913 meshinput.copy_elemental_solution(sys, "teste", "e");
914 meshinput.copy_elemental_solution(sys, "teste_no_p", "e_no_p");
915 meshinput.copy_elemental_solution(sys, "teste_xyz", "e_xyz");
916#endif
917
918 // Exodus only handles double precision
919 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
920
921 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
922 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
923 {
924 Point p(x,y);
925 LIBMESH_ASSERT_NUMBERS_EQUAL
926 (sys.point_value(0,p), 6*x+60*y, exotol);
927 LIBMESH_ASSERT_NUMBERS_EQUAL
928 (sys.point_value(1,p), 6*x+60*y, exotol);
929 LIBMESH_ASSERT_NUMBERS_EQUAL
930 (sys.point_value(2,p), 6*x+60*y, exotol);
931 }
932 }
933 }
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:1367
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:1430
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:2274
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:1400
Number six_x_plus_sixty_y(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition mesh_input.C:36
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 1092 of file mesh_input.C.

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

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 767 of file mesh_input.C.

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

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 2253 of file mesh_input.C.

2254 {
2255 Mesh mesh(*TestCommWorld);
2256
2257 DynaIO dyna(mesh);
2258 if (mesh.processor_id() == 0)
2259 dyna.read(filename);
2261
2263
2264 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2266
2267 // Useful when trying out different projection functions
2268 // std::cout << filename << ":" << std::endl;
2269
2271
2272 testProjectionRegression(mesh, expected_norms);
2273 }
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 2285 of file mesh_input.C.

2286 {
2287 LOG_UNIT_TEST;
2288
2289 testDynaFileMappings("meshes/BlockWithHole_Patch9.bxt.gz",
2290 // Regression values for sin_x_plus_cos_y
2291 {{3.22612556930183, 1.97405365384733,
2292 2.53376235803176, 1.41374070517223}});
2293 }
void testDynaFileMappings(const std::string &filename, std::array< Real, 4 > expected_norms)

References testDynaFileMappings().

◆ testDynaFileMappingsCyl3d()

void MeshInputTest::testDynaFileMappingsCyl3d ( )
inline

Definition at line 2305 of file mesh_input.C.

2306 {
2307 LOG_UNIT_TEST;
2308
2309 testDynaFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.bxt.gz",
2310 // Regression values for sin_x_plus_cos_y
2311 {{0.963612880188165, 1.82329452603503,
2312 0.707998701597943, 1.31399222566683}});
2313 }

References testDynaFileMappings().

◆ testDynaFileMappingsFEMEx5()

void MeshInputTest::testDynaFileMappingsFEMEx5 ( )
inline

Definition at line 2275 of file mesh_input.C.

2276 {
2277 LOG_UNIT_TEST;
2278
2279 testDynaFileMappings("meshes/PressurizedCyl_Patch6_256Elem.bxt.gz",
2280 // Regression values for sin_x_plus_cos_y
2281 {{0.9639857809698268, 1.839870171669186,
2282 0.7089812562241862, 1.306121188539059}});
2283 }

References testDynaFileMappings().

◆ testDynaFileMappingsPlateWithHole()

void MeshInputTest::testDynaFileMappingsPlateWithHole ( )
inline

Definition at line 2295 of file mesh_input.C.

2296 {
2297 LOG_UNIT_TEST;
2298
2299 testDynaFileMappings("meshes/PlateWithHole_Patch8.bxt.gz",
2300 // Regression values for sin_x_plus_cos_y
2301 {{2.2812154374012, 1.974049990211937,
2302 1.791640772215248, 1.413679237529376}});
2303 }

References testDynaFileMappings().

◆ testDynaNoSplines()

void MeshInputTest::testDynaNoSplines ( )
inline

Definition at line 2120 of file mesh_input.C.

2121 {
2122 LOG_UNIT_TEST;
2123
2124 Mesh mesh(*TestCommWorld);
2125
2126 DynaIO dyna(mesh, /* keep_spline_nodes = */ false);
2127
2128 if (mesh.processor_id() == 0)
2129 dyna.read("meshes/1_quad.bxt.gz");
2131
2133
2134 // We have 1 QUAD9 finite element
2135 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(1));
2136 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(9));
2137
2139 }
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 1889 of file mesh_input.C.

1890 {
1891 LOG_UNIT_TEST;
1892
1893 Mesh mesh(*TestCommWorld);
1894
1895 DynaIO dyna(mesh);
1896
1897 if (mesh.processor_id() == 0)
1898 dyna.read("meshes/1_quad.bxt.gz");
1900
1902
1903 // We have 1 QUAD9 finite element, attached via a trivial map to 9
1904 // spline Node+NodeElem objects
1905 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(10));
1906 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(18));
1907
1909 }

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 2142 of file mesh_input.C.

2143 {
2144 LOG_UNIT_TEST;
2145
2146 Mesh mesh(*TestCommWorld);
2147
2148 DynaIO dyna(mesh);
2149 if (mesh.processor_id() == 0)
2150 dyna.read("meshes/25_quad.bxt.gz");
2152
2154
2155 // We have 5^2 QUAD9 elements, with 11^2 nodes,
2156 // tied to 49 Node/NodeElem spline nodes
2157 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(25+49));
2158 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(121+49));
2159
2160 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2162
2163 unsigned char weight_index = mesh.default_mapping_data();
2164
2165 for (const auto & elem : mesh.active_element_ptr_range())
2166 {
2167 if (elem->type() == NODEELEM)
2168 continue;
2169 LIBMESH_ASSERT_FP_EQUAL(Real(0.04), elem->volume(), TOLERANCE);
2170
2171 for (unsigned int n=0; n != 9; ++n)
2172 CPPUNIT_ASSERT_EQUAL
2173 (elem->node_ref(n).get_extra_datum<Real>(weight_index),
2174 Real(1.0));
2175
2176 unsigned int n_neighbors = 0, n_neighbors_expected = 2;
2177 for (unsigned int side=0; side != 4; ++side)
2178 if (elem->neighbor_ptr(side))
2179 n_neighbors++;
2180 Point c = elem->vertex_average();
2181
2182 if (c(0) > 0.2 && c(0) < 0.8)
2183 n_neighbors_expected++;
2184 if (c(1) > 0.2 && c(1) < 0.8)
2185 n_neighbors_expected++;
2186
2187 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
2188 }
2189
2191
2192#ifdef LIBMESH_HAVE_SOLVER
2193#ifdef LIBMESH_ENABLE_CONSTRAINTS
2194 // Now test whether we can assign the desired constraint equations
2196 System & sys = es.add_system<LinearImplicitSystem>("test");
2197 sys.add_variable("u", SECOND); // to match QUAD9
2198 es.init();
2199
2200 // We should have a constraint on every FE dof
2201 CPPUNIT_ASSERT_EQUAL(sys.get_dof_map().n_constrained_dofs(), static_cast<dof_id_type>(121));
2202#endif // LIBMESH_ENABLE_CONSTRAINTS
2203#endif // LIBMESH_HAVE_SOLVER
2204 }
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:2448

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 939 of file mesh_input.C.

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

◆ testExodusCopyElementSolutionReplicated()

void MeshInputTest::testExodusCopyElementSolutionReplicated ( )
inline

Definition at line 936 of file mesh_input.C.

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

◆ testExodusCopyElementVectorDistributed()

void MeshInputTest::testExodusCopyElementVectorDistributed ( )
inline

Definition at line 1210 of file mesh_input.C.

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

◆ testExodusCopyElementVectorReplicated()

void MeshInputTest::testExodusCopyElementVectorReplicated ( )
inline

Definition at line 1207 of file mesh_input.C.

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

◆ testExodusCopyHighOrderElementSolution()

void MeshInputTest::testExodusCopyHighOrderElementSolution ( )
inline

Definition at line 951 of file mesh_input.C.

952 {
953 LOG_UNIT_TEST;
954
955 const std::string filename("repl_with_high_order_elem_soln.e");
956
957 {
958 ReplicatedMesh mesh(*TestCommWorld);
959
961 System &sys = es.add_system<System> ("SimpleSystem");
962 sys.add_variable("e", FIRST, MONOMIAL);
963
965 3, 3,
966 0., 1., 0., 1.);
967
968 es.init();
969 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
970
971 ExodusII_IO meshinput(mesh);
972 meshinput.write_discontinuous_elemental_data(true);
973
974 std::set<std::string> sys_list;
975 meshinput.write_equation_systems(filename, es, &sys_list);
976 meshinput.write_element_data(es);
977 }
978
979 {
980 ReplicatedMesh mesh(*TestCommWorld);
981 mesh.allow_renumbering(false);
982 ExodusII_IO meshinput(mesh);
983
985 System &sys = es.add_system<System> ("SimpleSystem");
986 sys.add_variable("teste", CONSTANT, MONOMIAL);
987
988 if (mesh.processor_id() == 0)
989 meshinput.read(filename);
992
993 es.init();
994
995#ifdef LIBMESH_USE_COMPLEX_NUMBERS
996 meshinput.copy_elemental_solution(sys, "teste", "r_e");
997#else
998 meshinput.copy_elemental_solution(sys, "teste", "e");
999#endif
1000
1001 // Exodus only handles double precision
1002 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
1003
1004 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
1005 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
1006 {
1007 Point p(x,y);
1008 LIBMESH_ASSERT_NUMBERS_EQUAL
1009 (sys.point_value(0,p), 6*x+60*y, exotol);
1010 }
1011 }
1012 }
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 838 of file mesh_input.C.

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

◆ testExodusCopyNodalSolutionReplicated()

void MeshInputTest::testExodusCopyNodalSolutionReplicated ( )
inline

Definition at line 835 of file mesh_input.C.

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

◆ testExodusDiscCyl3d()

void MeshInputTest::testExodusDiscCyl3d ( )
inline

Definition at line 2437 of file mesh_input.C.

2438 {
2439 LOG_UNIT_TEST;
2440
2441 testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
2442 {{0.963855209590556, 1.8234396424318,
2443 0.708286572453382, 1.31468940958327}},
2444 true);
2445 }
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 2398 of file mesh_input.C.

2399 {
2400 LOG_UNIT_TEST;
2401
2402 testExodusFileMappings("meshes/PlateWithHole_Patch8.e",
2403 // Regression values for sin_x_plus_cos_y
2404 //
2405 // These are *not* the same as for the continuous plate, because
2406 // we do the C^TKCx=C^Tf trick to pull back projections to the
2407 // spline nodes, and the pseudoinverse here minimizes the error in
2408 // a discretization-dependent norm, not in a Sobolev norm. For
2409 // these coarse meshes, our Sobolev norms can end up being ~0.1%
2410 // different.
2411 {{2.28234312456534, 1.97439548757586,
2412 1.79290449809266, 1.41075128955985}},
2413 true);
2414 }

References testExodusFileMappings().

◆ testExodusDiscTwoBlocks()

void MeshInputTest::testExodusDiscTwoBlocks ( )
inline

Definition at line 2416 of file mesh_input.C.

2417 {
2418 LOG_UNIT_TEST;
2419
2420 testExodusFileMappings("meshes/two_quads_two_blocks.e",
2421 // Regression values for sin_x_plus_cos_y
2422 {{2.03496953073072, 1.97996853164955,
2423 1.18462134113435, 1.03085301158959}},
2424 true);
2425 }

References testExodusFileMappings().

◆ testExodusDiscTwoElemIGA()

void MeshInputTest::testExodusDiscTwoElemIGA ( )
inline

Definition at line 2426 of file mesh_input.C.

2427 {
2428 LOG_UNIT_TEST;
2429
2430 testExodusFileMappings("meshes/two_element_iga_in.e",
2431 // Regression values for sin_x_plus_cos_y
2432 {{1.26877626663365, 1.42553698909339,
2433 1.54810114917177, 1.29792704408979}},
2434 true);
2435 }

References testExodusFileMappings().

◆ testExodusDiscWriteAddedSidesEdgeC0()

void MeshInputTest::testExodusDiscWriteAddedSidesEdgeC0 ( )
inline

Definition at line 1582 of file mesh_input.C.

1583 {
1586 }
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 1605 of file mesh_input.C.

1606 {
1608 }
Number designed_for_side_elems(const Point &p, const Parameters &param, const std::string &, const std::string &)
Definition mesh_input.C:61

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 2315 of file mesh_input.C.

2318 {
2319 Mesh mesh(*TestCommWorld);
2320
2321 ExodusII_IO exii(mesh);
2322 // IGA Exodus meshes require ExodusII 8 or higher
2323 if (exii.get_exodus_version() < 800)
2324 return;
2325
2326 // This should default to false
2327 if (use_disc_bex)
2328 exii.set_discontinuous_bex(true);
2329
2330 if (mesh.processor_id() == 0)
2331 exii.read(filename);
2333
2335
2336 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2338
2340
2341 testProjectionRegression(mesh, expected_norms);
2342
2343 // Test a write when we're done reading; I was getting weirdness
2344 // from NetCDF at this point in a Moose output test.
2345 {
2346 ExodusII_IO exii(mesh);
2347
2348 exii.write("exodus_file_mapping_out.e");
2349 }
2350
2351#ifdef LIBMESH_HAVE_VTK
2352 {
2353 VTKIO vtkout(mesh);
2354
2355 vtkout.write("vtk_file_mapping_out.pvtu");
2356 }
2357#endif
2358 }
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 2389 of file mesh_input.C.

2390 {
2391 LOG_UNIT_TEST;
2392
2393 testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
2394 {{0.963612880188165, 1.82329452603503,
2395 0.707998701597943, 1.31399222566683}});
2396 }

References testExodusFileMappings().

◆ testExodusFileMappingsPlateWithHole()

void MeshInputTest::testExodusFileMappingsPlateWithHole ( )
inline

Definition at line 2360 of file mesh_input.C.

2361 {
2362 LOG_UNIT_TEST;
2363
2364 testExodusFileMappings("meshes/PlateWithHole_Patch8.e",
2365 // Regression values for sin_x_plus_cos_y
2366 {{2.2812154374012, 1.974049990211937,
2367 1.791640772215248, 1.413679237529376}});
2368 }

References testExodusFileMappings().

◆ testExodusFileMappingsTwoBlocks()

void MeshInputTest::testExodusFileMappingsTwoBlocks ( )
inline

Definition at line 2370 of file mesh_input.C.

2371 {
2372 LOG_UNIT_TEST;
2373
2374 testExodusFileMappings("meshes/two_quads_two_blocks.e",
2375 // Regression values for sin_x_plus_cos_y
2376 {{2.03496953073072, 1.97996853164955,
2377 1.18462134113435, 1.03085301158959}});
2378 }

References testExodusFileMappings().

◆ testExodusFileMappingsTwoElemIGA()

void MeshInputTest::testExodusFileMappingsTwoElemIGA ( )
inline

Definition at line 2379 of file mesh_input.C.

2380 {
2381 LOG_UNIT_TEST;
2382
2383 testExodusFileMappings("meshes/two_element_iga_in.e",
2384 // Regression values for sin_x_plus_cos_y
2385 {{1.26865962862531, 1.42562070158386,
2386 1.54905363492342, 1.29782906548366}});
2387 }

References testExodusFileMappings().

◆ testExodusIGASidesets()

void MeshInputTest::testExodusIGASidesets ( )
inline

Definition at line 676 of file mesh_input.C.

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

597 {
598 LOG_UNIT_TEST;
599
600 // first scope: write file
601 {
602 ReplicatedMesh mesh(*TestCommWorld);
603 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
604 ExodusII_IO exii(mesh);
605 mesh.write("read_header_test.e");
606 }
607
608 // Make sure that the writing is done before the reading starts.
609 TestCommWorld->barrier();
610
611 // second scope: read header
612 // Note: The header information is read from file on processor 0
613 // and then broadcast to the other procs, so with this test we are
614 // checking both that the header information is read correctly and
615 // that it is correctly communicated to other procs.
616 {
617 ReplicatedMesh mesh(*TestCommWorld);
618 ExodusII_IO exii(mesh);
619 ExodusHeaderInfo header_info = exii.read_header("read_header_test.e");
620
621 // Make sure the header information is as expected.
622 CPPUNIT_ASSERT_EQUAL(std::string(header_info.title.data()), std::string("read_header_test.e"));
623 CPPUNIT_ASSERT_EQUAL(header_info.num_dim, 2);
624 CPPUNIT_ASSERT_EQUAL(header_info.num_elem, 9);
625 CPPUNIT_ASSERT_EQUAL(header_info.num_elem_blk, 1);
626 CPPUNIT_ASSERT_EQUAL(header_info.num_node_sets, 4);
627 CPPUNIT_ASSERT_EQUAL(header_info.num_side_sets, 4);
628 CPPUNIT_ASSERT_EQUAL(header_info.num_edge_blk, 0);
629 CPPUNIT_ASSERT_EQUAL(header_info.num_edge, 0);
630 }
631 }
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 565 of file mesh_input.C.

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

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 530 of file mesh_input.C.

533 {
534 // This test requires that libmesh is compiled with unique_ids enabled
535#ifdef LIBMESH_ENABLE_UNIQUE_ID
536 {
537 ReplicatedMesh mesh(*TestCommWorld);
538 ExodusII_IO exii(mesh);
539
540 // Set Node/Elem unique ids based on the node/elem_num_map
541 exii.set_unique_ids_from_maps(set_unique_ids);
542
543 // Read the mesh
544 exii.read("meshes/nontrivial_elem_num_map.exo");
545
546 // Verify the results.
547 auto expected_it = expected_unique_ids.begin();
548 for (const auto & elem : mesh.element_ptr_range())
549 {
550 // Debugging:
551 // libMesh::out << "unique_id for Elem " << elem->id()
552 // << " = " << elem->unique_id()
553 // << std::endl;
554
555 CPPUNIT_ASSERT_EQUAL(elem->unique_id(), *expected_it++);
556 }
557 }
558#else
559 // Prevent compiler warnings about unused variables when
560 // unique_ids are not enabled.
561 libmesh_ignore(set_unique_ids, expected_unique_ids);
562#endif // LIBMESH_ENABLE_UNIQUE_ID
563 }
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 509 of file mesh_input.C.

510 {
511 LOG_UNIT_TEST;
512
513 // node_num_map = 1, 3, 9, 8, 2, 5, 7, 6, 4
514 // The input is a (zero-based) version of the node_num_map as it
515 // exists in the file.
517 /*set_unique_ids=*/true,
518 /*expected_unique_ids=*/{0, 2, 8, 7, 1, 4, 6, 5, 3});
519
520 // The input is the (zero-based) _position_ of the (one-based) id
521 // "i" in the node_num_map, as it exists in the file. For example,
522 // zero-based Node id 3 corresponds to one-based Node id 4, which
523 // appears in (zero-based) position 8 in the node_num_map, hence:
524 // 3 -> 8, etc.
526 /*set_unique_ids=*/false,
527 /*expected_unique_ids=*/{0, 4, 1, 8, 5, 7, 6, 3, 2});
528 }
void testExodusSetNodeUniqueIdsFromMaps_implementation(bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
Definition mesh_input.C:473

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 473 of file mesh_input.C.

476 {
477 // This test requires that libmesh is compiled with unique_ids enabled
478#ifdef LIBMESH_ENABLE_UNIQUE_ID
479 {
480 ReplicatedMesh mesh(*TestCommWorld);
481 ExodusII_IO exii(mesh);
482
483 // Set Node/Elem unique ids based on the node/elem_num_map
484 exii.set_unique_ids_from_maps(set_unique_ids);
485
486 // Read the mesh
487 exii.read("meshes/nontrivial_node_num_map.exo");
488
489 // Verify the results.
490 for (auto i : index_range(expected_unique_ids))
491 {
492 // Debugging:
493 // libMesh::out << "unique_id for node " << i
494 // << " = " << mesh.node_ptr(i)->unique_id()
495 // << std::endl;
496
497 CPPUNIT_ASSERT_EQUAL(mesh.node_ptr(i)->unique_id(), expected_unique_ids[i]);
498 }
499 }
500#else
501 // Prevent compiler warnings about unused variables when
502 // unique_ids are not enabled.
503 libmesh_ignore(set_unique_ids, expected_unique_ids);
504#endif // LIBMESH_ENABLE_UNIQUE_ID
505 } // 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 1334 of file mesh_input.C.

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

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

1953 {
1954 LOG_UNIT_TEST;
1955
1956 Mesh mesh(*TestCommWorld);
1957
1958 GmshIO gmsh_io(mesh);
1959
1960 if (mesh.processor_id() == 0)
1961 gmsh_io.read("meshes/bcid_overlap.msh");
1963
1964 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().get_sideset_name_map().size(),
1965 std::size_t(2));
1966 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(1),
1967 std::string("srfBC4A"));
1968 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(2),
1969 std::string("srfBC4B"));
1970 CPPUNIT_ASSERT_EQUAL(mesh.get_subdomain_name_map().size(),
1971 std::size_t(2));
1972 CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(1),
1973 std::string("volBC3A"));
1974 CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(2),
1975 std::string("volBC3B"));
1976 }
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:1984
std::string & subdomain_name(subdomain_id_type id)
Definition mesh_base.C:2006

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 1937 of file mesh_input.C.

1938 {
1939 LOG_UNIT_TEST;
1940
1941 Mesh mesh(*TestCommWorld);
1942
1943 GmshIO gmsh_io(mesh);
1944
1945 if (mesh.processor_id() == 0)
1946 gmsh_io.read("meshes/circle.msh");
1948
1949 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(14));
1950 }

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 1978 of file mesh_input.C.

1979 {
1980 LOG_UNIT_TEST;
1981
1982 Mesh mesh(*TestCommWorld);
1983
1984 STLIO stl_io(mesh);
1985
1986 if (mesh.processor_id() == 0)
1987 stl_io.read("meshes/Cluster_34.stl");
1989
1990 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(40));
1991 }
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 1993 of file mesh_input.C.

1994 {
1995 LOG_UNIT_TEST;
1996
1997 Mesh mesh(*TestCommWorld);
1998
1999 STLIO stl_io(mesh);
2000
2001 if (mesh.processor_id() == 0)
2002 stl_io.read("meshes/engraving.stl");
2004
2005 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(426));
2006 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(215));
2007 }

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

◆ testGoodSTLGzipped()

void MeshInputTest::testGoodSTLGzipped ( )
inline

Definition at line 2034 of file mesh_input.C.

2035 {
2036 LOG_UNIT_TEST;
2037
2038 // Gzipped copies of the ASCII and the binary test files
2039 testSTLGzipped("Cluster_34", 40, 60);
2040 testSTLGzipped("engraving", 426, 215);
2041 }
void testSTLGzipped(const std::string &basename, dof_id_type n_elem, dof_id_type n_nodes)

References testSTLGzipped().

◆ testLowOrderEdgeBlocks()

void MeshInputTest::testLowOrderEdgeBlocks ( )
inline

Definition at line 633 of file mesh_input.C.

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

1772 {
1773 auto locator = mesh.sub_point_locator();
1774
1775 for (auto & elem : mesh.element_ptr_range())
1776 {
1777 Point master_pt = {}; // center, for tensor product elements
1778
1779 // But perturb it to try and trigger any mapping weirdness
1780 if (elem->dim() > 0)
1781 master_pt(0) = 0.25;
1782
1783 if (elem->dim() > 1)
1784 master_pt(1) = -0.25;
1785
1786 if (elem->dim() > 2)
1787 master_pt(2) = 0.75;
1788
1789 Point physical_pt = FEMap::map(elem->dim(), elem, master_pt);
1790
1791 Point inverse_pt = FEMap::inverse_map(elem->dim(), elem,
1792 physical_pt);
1793
1794 CPPUNIT_ASSERT((inverse_pt-master_pt).norm() < TOLERANCE);
1795
1796 CPPUNIT_ASSERT(elem->contains_point(physical_pt));
1797
1798 // We only want to find elements in the same block
1799 std::set<subdomain_id_type> my_subdomain { elem->subdomain_id() };
1800
1801 // We can *still* have overlapping NodeElem from a slit mesh
1802 // input file; better check them all
1803 std::set<const Elem * > located_elems;
1804 (*locator)(physical_pt, located_elems, &my_subdomain);
1805
1806 CPPUNIT_ASSERT(located_elems.count(elem));
1807 }
1808 }
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:1952
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 1019 of file mesh_input.C.

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

◆ testNemesisCopyElementSolutionReplicated()

void MeshInputTest::testNemesisCopyElementSolutionReplicated ( )
inline

Definition at line 1016 of file mesh_input.C.

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

◆ testNemesisCopyElementVectorDistributed()

void MeshInputTest::testNemesisCopyElementVectorDistributed ( )
inline

Definition at line 1217 of file mesh_input.C.

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

◆ testNemesisCopyElementVectorReplicated()

void MeshInputTest::testNemesisCopyElementVectorReplicated ( )
inline

Definition at line 1214 of file mesh_input.C.

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

◆ testNemesisCopyNodalSolutionDistributed()

void MeshInputTest::testNemesisCopyNodalSolutionDistributed ( )
inline

Definition at line 845 of file mesh_input.C.

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

◆ testNemesisCopyNodalSolutionReplicated()

void MeshInputTest::testNemesisCopyNodalSolutionReplicated ( )
inline

Definition at line 842 of file mesh_input.C.

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

◆ testNemesisReadDistributed()

void MeshInputTest::testNemesisReadDistributed ( )
inline

Definition at line 1766 of file mesh_input.C.

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

◆ testNemesisReadImpl()

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

Definition at line 1739 of file mesh_input.C.

1740 {
1741 // first scope: write file
1742 {
1743 MeshType mesh(*TestCommWorld);
1744 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
1745 mesh.write("test_nemesis_read.nem");
1746 }
1747
1748 // Make sure that the writing is done before the reading starts.
1749 TestCommWorld->barrier();
1750
1751 // second scope: read file
1752 {
1753 MeshType mesh(*TestCommWorld);
1754 Nemesis_IO nem(mesh);
1755
1756 nem.read("test_nemesis_read.nem");
1758 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(9));
1759 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(16));
1760 }
1761 }
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 1763 of file mesh_input.C.

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

◆ testNemesisSingleElementDistributed()

void MeshInputTest::testNemesisSingleElementDistributed ( )
inline

Definition at line 1081 of file mesh_input.C.

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

◆ testNemesisSingleElementReplicated()

void MeshInputTest::testNemesisSingleElementReplicated ( )
inline

Definition at line 1078 of file mesh_input.C.

1079 { 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 2206 of file mesh_input.C.

2207 {
2208 int order = 0;
2209 for (const auto elem : mesh.element_ptr_range())
2210 order = std::max(order, int(elem->default_order()));
2211 TestCommWorld->max(order);
2212 CPPUNIT_ASSERT (order > 0);
2213
2214 // Let's test that IGA constraints are preserved (in a relative
2215 // sense) when we clone a mesh.
2216 std::unique_ptr<MeshBase> mesh_clone = mesh.clone();
2217 CPPUNIT_ASSERT(*mesh_clone == mesh);
2218
2220 System &sys = es.add_system<System> ("SimpleSystem");
2221 sys.add_variable("n", Order(order), RATIONAL_BERNSTEIN);
2222
2223 es.init();
2224
2225 sys.project_solution(sin_x_plus_cos_y, nullptr, es.parameters);
2226
2227 // Make this easy to tweak in the future
2228 const Real my_tolerance = TOLERANCE;
2229
2230 // Calculate some norms, skipping the spline points, and compare
2231 // to regression standard values
2232 std::set<unsigned int> skip_dimensions {0};
2233 const Real L2_norm =
2234 sys.calculate_norm(*sys.solution, 0, L2, &skip_dimensions);
2235// std::cout.precision(16);
2236// std::cout << "L2_norm = " << L2_norm << std::endl;
2237 LIBMESH_ASSERT_FP_EQUAL(L2_norm, expected_norms[0], my_tolerance);
2238 const Real Linf_norm =
2239 sys.calculate_norm(*sys.solution, 0, L_INF, &skip_dimensions);
2240// std::cout << "Linf_norm = " << Linf_norm << std::endl;
2241 LIBMESH_ASSERT_FP_EQUAL(Linf_norm, expected_norms[1], my_tolerance);
2242 const Real H1_norm =
2243 sys.calculate_norm(*sys.solution, 0, H1_SEMINORM, &skip_dimensions);
2244// std::cout << "H1_norm = " << H1_norm << std::endl;
2245 LIBMESH_ASSERT_FP_EQUAL(H1_norm, expected_norms[2], my_tolerance);
2246 const Real W1inf_norm =
2247 sys.calculate_norm(*sys.solution, 0, W1_INF_SEMINORM, &skip_dimensions);
2248// std::cout << "W1inf_norm = " << W1inf_norm << std::endl;
2249 // W1_inf seems more sensitive to FP error...
2250 LIBMESH_ASSERT_FP_EQUAL(W1inf_norm, expected_norms[3], 10*my_tolerance);
2251 }
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:1566
@ 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 1027 of file mesh_input.C.

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

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().

◆ testSTLGzipped()

void MeshInputTest::testSTLGzipped ( const std::string &  basename,
dof_id_type  n_elem,
dof_id_type  n_nodes 
)
inline

Definition at line 2010 of file mesh_input.C.

2013 {
2014 Mesh mesh(*TestCommWorld);
2015
2016 STLIO stl_io(mesh);
2017
2018 if (mesh.processor_id() == 0)
2019 {
2020 const std::string gz_name = basename + "_test.stl.gz";
2021 {
2022 std::ifstream in("meshes/" + basename + ".stl", std::ios::binary);
2023 ogzstream out(gz_name.c_str());
2024 out << in.rdbuf();
2025 }
2026 stl_io.read(gz_name);
2027 }
2029
2030 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_elem);
2031 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), n_nodes);
2032 }
streambufT * rdbuf() const
Get the associated stream buffer.
OStreamProxy out

References libMesh::MeshCommunication::broadcast(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::BasicOStreamProxy< charT, traits >::rdbuf(), libMesh::STLIO::read(), and TestCommWorld.

Referenced by testGoodSTLGzipped().

◆ testTetgenIO()

void MeshInputTest::testTetgenIO ( )
inline

Definition at line 2080 of file mesh_input.C.

2081 {
2082#ifdef LIBMESH_HAVE_TETGEN
2083 LOG_UNIT_TEST;
2084
2085 Mesh mesh(*TestCommWorld);
2086
2087 TetGenIO tetgen_io(mesh);
2088
2089 if (mesh.processor_id() == 0)
2090 tetgen_io.read("meshes/tetgen_one_tet10.ele");
2092
2094
2095 // Mesh should contain 1 TET10 finite element
2096 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(1));
2097 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(10));
2098
2099 // Element should have TET10 reference element volume
2100 const Elem * const elem = mesh.query_elem_ptr(0);
2101
2102 // On a serial mesh we have every element everywhere
2103 if (mesh.is_serial())
2104 CPPUNIT_ASSERT(elem);
2105 else
2106 {
2107 bool have_elem = elem;
2108 mesh.comm().max(have_elem);
2109 CPPUNIT_ASSERT(have_elem);
2110 }
2111
2112 if (elem)
2113 {
2114 const Real vol = elem->volume();
2115 LIBMESH_ASSERT_FP_EQUAL(vol, 1./6, TOLERANCE*TOLERANCE);
2116 }
2117#endif
2118 }
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().

◆ testUCDWriteNodalData()

void MeshInputTest::testUCDWriteNodalData ( )
inline

Definition at line 2044 of file mesh_input.C.

2045 {
2046 LOG_UNIT_TEST;
2047
2048 ReplicatedMesh mesh(*TestCommWorld);
2049 MeshTools::Generation::build_cube(mesh, 1, 1, 1, 0., 1., 0., 1., 0., 1., HEX8);
2050
2051 std::vector<Number> soln(mesh.n_nodes());
2052 for (auto i : index_range(soln))
2053 soln[i] = i;
2054
2055 UCDIO(mesh).write_nodal_data("ucd_nodal_data.inp", soln, {"u"});
2056
2057 if (mesh.processor_id() != 0)
2058 return;
2059
2060 // After the comments come a header line, one line per node, one
2061 // line per element, two lines describing the variable, and then
2062 // one line of nodal data per node.
2063 std::ifstream in("ucd_nodal_data.inp");
2064 std::vector<std::string> lines;
2065 for (std::string line; std::getline(in, line);)
2066 if (!line.empty() && line[0] != '#')
2067 lines.push_back(line);
2068
2069 const std::size_t n_nodes = mesh.n_nodes();
2070 const std::size_t first_data_line = 1 + n_nodes + mesh.n_elem() + 2;
2071 CPPUNIT_ASSERT_EQUAL(first_data_line + n_nodes, lines.size());
2072
2073 // UCD node numbers are 1-based, so the last line is for node n_nodes
2074 std::istringstream last_line(lines.back());
2075 std::size_t node_num = 0;
2076 last_line >> node_num;
2077 CPPUNIT_ASSERT_EQUAL(n_nodes, node_num);
2078 }
This class implements reading & writing meshes in the AVS's UCD format.
Definition ucd_io.h:46
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
This method implements writing a mesh and solution to a specified file in UCD format.
Definition ucd_io.C:331

References libMesh::MeshTools::Generation::build_cube(), libMesh::HEX8, libMesh::index_range(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::ParallelObject::processor_id(), TestCommWorld, and libMesh::UCDIO::write_nodal_data().

◆ testVTKPreserveElemIds()

void MeshInputTest::testVTKPreserveElemIds ( )
inline

Definition at line 242 of file mesh_input.C.

243 {
244 LOG_UNIT_TEST;
245
246 // Come up with some crazy numbering. Make all the new ids higher
247 // than the existing ids so we don't have to worry about conflicts
248 // while renumbering.
249 dof_id_type start_id;
250
251 // first scope: write file
252 {
253 Mesh mesh(*TestCommWorld);
254 mesh.allow_renumbering(false);
255 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
256
257 start_id = mesh.max_elem_id();
258
259 // Use a separate container that won't invalidate iterators when
260 // we renumber
261 std::set<Elem *> elements {mesh.elements_begin(), mesh.elements_end()};
262 for (Elem * elem : elements)
263 {
264 const Point center = elem->vertex_average();
265 const int xn = int(center(0)*3);
266 const int yn = int(center(1)*3);
267 const dof_id_type new_id = start_id + yn*5 + xn;
268 mesh.renumber_elem(elem->id(), new_id);
269 }
270
271 // Explicit writer object here to be absolutely sure we get VTK
272 VTKIO vtk(mesh);
273 vtk.write("read_elem_ids_test.pvtu");
274 }
275
276 // Make sure that the writing is done before the reading starts.
277 TestCommWorld->barrier();
278
279 // second scope: read file
280 {
281 Mesh mesh(*TestCommWorld);
282 mesh.allow_renumbering(false);
283
284 mesh.read("read_elem_ids_test.pvtu");
286
287 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(16));
288 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(9));
289
290 for (const auto & elem : mesh.element_ptr_range())
291 {
292 const Point center = elem->vertex_average();
293 const int xn = int(center(0)*3);
294 const int yn = int(center(1)*3);
295 const dof_id_type expected_id = start_id + yn*5 + xn;
296 CPPUNIT_ASSERT_EQUAL(elem->id(), expected_id);
297 }
298 }
299 }
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 301 of file mesh_input.C.

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

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 455 of file mesh_input.C.

456 {
457 LOG_UNIT_TEST;
458
459#ifdef LIBMESH_ENABLE_EXCEPTIONS
460 Mesh mesh(*TestCommWorld);
461 VTKIO vtk(mesh);
462 CPPUNIT_ASSERT_THROW_MESSAGE
463 ("Non-VTK-XML file not detected",
464 vtk.read("meshes/circle.msh"),
466#endif
467 }

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

◆ testVTKReadPolyhedra()

void MeshInputTest::testVTKReadPolyhedra ( )
inline

Definition at line 400 of file mesh_input.C.

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

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 430 of file mesh_input.C.

431 {
432 LOG_UNIT_TEST;
433
434 Mesh mesh(*TestCommWorld);
435 mesh.allow_renumbering(false);
436 mesh.read("meshes/hex_prism_polyhedron_0.vtu");
438
440 }

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: