libMesh
Public Member Functions | List of all members
WriteEdgesetData Class Reference
Inheritance diagram for WriteEdgesetData:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (WriteEdgesetData)
 This test ensures you can write both vector and scalar variables. More...
 
 CPPUNIT_TEST (testWriteExodus)
 
 CPPUNIT_TEST_SUITE_END ()
 
template<typename IOClass >
void testWriteImpl (const std::string &filename)
 
void testWriteExodus ()
 
void testWriteNemesis ()
 

Detailed Description

Definition at line 18 of file write_edgeset_data.C.

Member Function Documentation

◆ CPPUNIT_TEST()

WriteEdgesetData::CPPUNIT_TEST ( testWriteExodus  )

◆ CPPUNIT_TEST_SUITE_END()

WriteEdgesetData::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

WriteEdgesetData::LIBMESH_CPPUNIT_TEST_SUITE ( WriteEdgesetData  )

This test ensures you can write both vector and scalar variables.

◆ testWriteExodus()

void WriteEdgesetData::testWriteExodus ( )
inline

Definition at line 107 of file write_edgeset_data.C.

108  {
109  LOG_UNIT_TEST;
110 
111  testWriteImpl<ExodusII_IO>("write_edgeset_data.e");
112  }

◆ testWriteImpl()

template<typename IOClass >
void WriteEdgesetData::testWriteImpl ( const std::string &  filename)
inline

Definition at line 38 of file write_edgeset_data.C.

References libMesh::BoundaryInfo::add_edge(), TIMPI::Communicator::barrier(), libMesh::MeshTools::Generation::build_cube(), libMesh::BoundaryInfo::build_edge_list(), libMesh::BoundaryInfo::build_side_list(), libMesh::BoundaryInfo::edgeset_name(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_edge_boundary_ids(), libMesh::HEX8, mesh, libMesh::BoundaryInfo::n_edge_conds(), and TestCommWorld.

39  {
41 
43  5, 5, 5,
44  0., 1.,
45  0., 1.,
46  0., 1.,
47  HEX8);
48 
49  // Add named edgesets containing the "front" and "back" edges of
50  // the cube.
52 
53  std::vector<BoundaryInfo::BCTuple> bc_tuples =
54  bi.build_side_list();
55 
56  for (const auto & t : bc_tuples)
57  {
58  dof_id_type elem_id = std::get<0>(t);
59  boundary_id_type b_id = std::get<2>(t);
60 
61  // Side 0 corresponds to the "back" sideset, with edges {0,1,2,3}
62  // Side 5 corresponds to the "front" sideset, with edges {4,5,6,7}
63  // If we are on either of those sides, add all the corresponding edges.
64  if (b_id == 0)
65  for (unsigned short edge=0; edge<4; ++edge)
66  bi.add_edge(elem_id, edge, b_id);
67 
68  if (b_id == 5)
69  for (unsigned short edge=8; edge<12; ++edge)
70  bi.add_edge(elem_id, edge, b_id);
71  }
72 
73  // Name the edgesets
74  bi.edgeset_name(0) = "back_edgeset";
75  bi.edgeset_name(5) = "front_edgeset";
76 
77  // We write the file in the requested format.
78  {
79  IOClass writer(mesh);
80  writer.write(filename);
81  }
82 
83  // Make sure that the writing is done before the reading starts.
85 
86  // Now read it back in
87  ReplicatedMesh read_mesh(*TestCommWorld);
88  IOClass reader(read_mesh);
89  reader.read(filename);
90 
91  // Assert that we got back out what we put in.
92  BoundaryInfo & read_bi = read_mesh.get_boundary_info();
93  CPPUNIT_ASSERT(read_bi.edgeset_name(0) == "back_edgeset");
94  CPPUNIT_ASSERT(read_bi.edgeset_name(5) == "front_edgeset");
95  CPPUNIT_ASSERT(read_bi.n_edge_conds() == 200);
96  CPPUNIT_ASSERT(read_bi.get_edge_boundary_ids().size() == 2);
97 
98  // Make sure that we have the expected amount of edges in each edgeset.
99  std::map<boundary_id_type, unsigned int> counts;
100  std::vector<BoundaryInfo::BCTuple> edge_tuples = bi.build_edge_list();
101  for (const auto & t : edge_tuples)
102  counts[std::get<2>(t)]++;
103  CPPUNIT_ASSERT(counts[0] == 100);
104  CPPUNIT_ASSERT(counts[5] == 100);
105  }
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
std::size_t n_edge_conds() const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void barrier() const
MeshBase & mesh
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
int8_t boundary_id_type
Definition: id_types.h:51
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
void build_edge_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &edge_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, edges, and boundary ids for those edges.
const std::set< boundary_id_type > & get_edge_boundary_ids() const
std::string & edgeset_name(boundary_id_type id)
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.
uint8_t dof_id_type
Definition: id_types.h:67
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
Add edge edge of element number elem with boundary id id to the boundary information data structure...

◆ testWriteNemesis()

void WriteEdgesetData::testWriteNemesis ( )
inline

Definition at line 114 of file write_edgeset_data.C.

115  {
116  // LOG_UNIT_TEST;
117 
118  // FIXME: Not yet implemented
119  // testWriteImpl<Nemesis_IO>("write_edgeset_data.n");
120  }

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