2 #include "libmesh/equation_systems.h" 3 #include "libmesh/exodusII_io.h" 4 #include "libmesh/nemesis_io.h" 5 #include "libmesh/mesh.h" 6 #include "libmesh/mesh_generation.h" 7 #include "libmesh/parallel.h" 8 #include "libmesh/string_to_enum.h" 9 #include "libmesh/boundary_info.h" 10 #include "libmesh/utility.h" 25 #ifdef LIBMESH_HAVE_EXODUS_API 26 CPPUNIT_TEST(testWriteExodus);
27 #endif // #ifdef LIBMESH_HAVE_EXODUS_API 28 #ifdef LIBMESH_HAVE_NEMESIS_API 33 CPPUNIT_TEST_SUITE_END();
35 template <
typename IOClass>
51 std::vector<std::string> var_names;
52 std::vector<std::set<boundary_id_type>> node_boundary_ids;
53 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> bc_vals;
66 std::vector<BoundaryInfo::NodeBCTuple> all_bc_tuples = bi.
build_node_list();
69 var_names = {
"var1",
"var2",
"var3"};
79 bc_vals.resize(var_names.size());
82 for (
unsigned int i=0; i<var_names.size(); ++i)
85 auto & vals = bc_vals[i];
87 for (
const auto & t : all_bc_tuples)
91 if (node_boundary_ids[i].count(b_id))
113 IOClass writer(
mesh);
114 writer.write(filename);
115 writer.write_nodeset_data (1, var_names, node_boundary_ids, bc_vals);
124 IOClass reader(read_mesh);
125 reader.read(filename);
129 std::vector<std::string> read_in_var_names;
130 std::vector<std::set<boundary_id_type>> read_in_node_boundary_ids;
131 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> read_in_bc_vals;
132 reader.read_nodeset_data
133 (1, read_in_var_names, read_in_node_boundary_ids, read_in_bc_vals);
136 CPPUNIT_ASSERT(read_in_var_names == var_names);
137 CPPUNIT_ASSERT(read_in_node_boundary_ids == node_boundary_ids);
138 CPPUNIT_ASSERT(read_in_bc_vals == bc_vals);
142 std::map<BoundaryInfo::NodeBCTuple, unsigned int> bc_array_indices;
143 reader.get_nodeset_data_indices(bc_array_indices);
168 for (
unsigned int i=0; i<6; ++i)
170 (static_cast<unsigned int>(i),
171 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(i), 0)));
175 for (
unsigned int i=0; i<6; ++i)
177 (static_cast<unsigned int>(i),
178 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(6*i + 5), 1)));
182 for (
unsigned int i=0; i<6; ++i)
184 (static_cast<unsigned int>(i),
185 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(30 + i), 2)));
189 for (
unsigned int i=0; i<6; ++i)
191 (static_cast<unsigned int>(i),
192 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(6*i), 3)));
199 testWriteImpl<ExodusII_IO>(
"write_nodeset_data.e",
true);
200 testWriteImpl<ExodusII_IO>(
"write_nodeset_data.e",
false);
std::string & nodeset_name(boundary_id_type id)
void build_node_list_from_side_list()
Adds nodes with boundary ids based on the side's boundary ids they are connected to.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
libMesh::Parallel::Communicator * TestCommWorld
The libMesh namespace provides an interface to certain functionality in the library.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual bool is_serial() const
void build_node_list(std::vector< dof_id_type > &node_id_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of nodes and ids for those nodes.
void testWriteImpl(const std::string &filename, bool write_vars)
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
CPPUNIT_TEST_SUITE_REGISTRATION(WriteNodesetData)
void set_union(T &data, const unsigned int root_id) const