38 {
42 5, 5,
43 -1., 1.,
44 -1., 1.,
46
47
49
50
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;
54
55 if (write_vars)
56 {
58
59
60
61
62
64
65
66 std::vector<BoundaryInfo::NodeBCTuple> all_bc_tuples = bi.
build_node_list();
67
68
69 var_names = {"var1", "var2", "var3"};
70 node_boundary_ids =
71 {
72 {0, 2},
73 {1, 3},
74 {4}
75 };
76
77
78
79 bc_vals.resize(var_names.size());
80
81
82 for (unsigned int i=0; i<var_names.size(); ++i)
83 {
84
85 auto & vals = bc_vals[i];
86
87 for (const auto & t : all_bc_tuples)
88 {
90
91 if (node_boundary_ids[i].count(b_id))
92 {
93
94
96
97
98 vals.emplace(t, val);
99 }
100 }
101
102
103
104
105
108
109 }
110
111
112 {
113 IOClass writer(
mesh);
114 writer.write(filename);
115 writer.write_nodeset_data (1, var_names, node_boundary_ids, bc_vals);
116 }
117 }
118
119
121
122
123 Mesh read_mesh(*TestCommWorld);
124 IOClass reader(read_mesh);
125 reader.read(filename);
126
127 if (write_vars)
128 {
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);
134
135
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);
139 }
140
141
142 std::map<BoundaryInfo::NodeBCTuple, unsigned int> bc_array_indices;
143 reader.get_nodeset_data_indices(bc_array_indices);
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 for (unsigned int i=0; i<6; ++i)
169 CPPUNIT_ASSERT_EQUAL
170 (static_cast<unsigned int>(i),
171 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(i), 0)));
172
173
174
175 for (unsigned int i=0; i<6; ++i)
176 CPPUNIT_ASSERT_EQUAL
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)));
179
180
181
182 for (unsigned int i=0; i<6; ++i)
183 CPPUNIT_ASSERT_EQUAL
184 (static_cast<unsigned int>(i),
185 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(30 + i), 2)));
186
187
188
189 for (unsigned int i=0; i<6; ++i)
190 CPPUNIT_ASSERT_EQUAL
191 (static_cast<unsigned int>(i),
192 libmesh_map_find(bc_array_indices, std::make_tuple(cast_int<dof_id_type>(6*i), 3)));
193 }
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
std::vector< NodeBCTuple > build_node_list(NodeBCTupleSortBy sort_by=NodeBCTupleSortBy::NODE_ID) const
std::string & nodeset_name(boundary_id_type id)
void build_node_list_from_side_list(const std::set< boundary_id_type > &sideset_list={})
Adds nodes with boundary ids based on the side's boundary ids they are connected to.
virtual bool is_serial() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Communicator * TestCommWorld
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real