Go to the documentation of this file.
2 #include "libmesh/equation_systems.h"
3 #include "libmesh/exodusII_io.h"
4 #include "libmesh/mesh.h"
5 #include "libmesh/mesh_generation.h"
6 #include "libmesh/parallel.h"
7 #include "libmesh/string_to_enum.h"
8 #include "libmesh/boundary_info.h"
26 CPPUNIT_TEST(testWrite);
29 CPPUNIT_TEST_SUITE_END();
45 std::vector<BoundaryInfo::BCTuple> all_bc_tuples =
49 std::vector<std::string> var_names = {
"var1",
"var2"};
50 std::vector<std::set<boundary_id_type>> side_ids =
58 std::vector<std::map<BoundaryInfo::BCTuple, Real>> bc_vals(var_names.size());
61 for (
unsigned int i=0; i<var_names.size(); ++i)
64 auto & vals = bc_vals[i];
66 for (
const auto & t : all_bc_tuples)
72 if (side_ids[i].count(b_id))
76 Real val = static_cast<Real>(b_id);
79 vals.insert(std::make_pair(t, val));
90 #ifdef LIBMESH_HAVE_EXODUS_API
95 writer.
write(
"write_sideset_data.e");
105 reader.
read(
"write_sideset_data.e");
107 std::vector<std::string> read_in_var_names;
108 std::vector<std::set<boundary_id_type>> read_in_side_ids;
109 std::vector<std::map<BoundaryInfo::BCTuple, Real>> read_in_bc_vals;
111 (1, read_in_var_names, read_in_side_ids, read_in_bc_vals);
114 CPPUNIT_ASSERT(read_in_var_names == var_names);
115 CPPUNIT_ASSERT(read_in_side_ids == side_ids);
116 CPPUNIT_ASSERT(read_in_bc_vals == bc_vals);
118 #endif // #ifdef LIBMESH_HAVE_EXODUS_API
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual bool is_serial() const
void write_sideset_data(int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type >> &side_ids, const std::vector< std::map< BoundaryInfo::BCTuple, Real >> &bc_vals)
The Exodus format can also store values on sidesets.
The libMesh namespace provides an interface to certain functionality in the library.
CPPUNIT_TEST_SUITE_REGISTRATION(WriteSidesetData)
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
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.
void read_sideset_data(int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type >> &side_ids, std::vector< std::map< BoundaryInfo::BCTuple, Real >> &bc_vals)
Similar to write_sideset_data(), this function is used to read the data at a particular timestep.
libMesh::Parallel::Communicator * TestCommWorld
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.