41 {
43
44
46
48 5, 5,
49 -1., 1.,
50 -1., 1.,
52
53
55
56
57 std::vector<std::string> var_names;
58 std::vector<std::set<boundary_id_type>> side_ids;
59 std::vector<std::map<BoundaryInfo::BCTuple, Real>> bc_vals;
60
61 if (write_vars)
62 {
63
64 std::vector<BoundaryInfo::BCTuple> all_bc_tuples =
66
67
68 var_names = {"var1", "var2", "var3"};
69 side_ids =
70 {
71 {0, 2},
72 {1, 3},
73 {4}
74 };
75
76
77
78 bc_vals.resize(var_names.size());
79
80
81 for (unsigned int i=0; i<var_names.size(); ++i)
82 {
83
84 auto & vals = bc_vals[i];
85
86 for (const auto & t : all_bc_tuples)
87 {
88
89
91
92 if (side_ids[i].count(b_id))
93 {
94
95
97
98
99 vals.emplace(t, val);
100 }
101 }
102
103
104
107
108 }
109
110
111 {
112 IOClass writer(
mesh);
113 writer.write(filename);
114 writer.write_sideset_data (1, var_names, side_ids, bc_vals);
115 }
116 }
117
118
120
121
122 Mesh read_mesh(*TestCommWorld);
123 IOClass reader(read_mesh);
124 reader.read(filename);
125
126 if (write_vars)
127 {
128 std::vector<std::string> read_in_var_names;
129 std::vector<std::set<boundary_id_type>> read_in_side_ids;
130 std::vector<std::map<BoundaryInfo::BCTuple, Real>> read_in_bc_vals;
131 reader.read_sideset_data
132 (1, read_in_var_names, read_in_side_ids, read_in_bc_vals);
133
134
135 CPPUNIT_ASSERT(read_in_var_names == var_names);
136 CPPUNIT_ASSERT(read_in_side_ids == side_ids);
137 CPPUNIT_ASSERT(read_in_bc_vals == bc_vals);
138 }
139
140
141 std::map<BoundaryInfo::BCTuple, unsigned int> bc_array_indices;
142 reader.get_sideset_data_indices(bc_array_indices);
143
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
169
170
171
172
173
174
175
176
177
178
179
180
181 for (unsigned int i=0; i<5; ++i)
182 CPPUNIT_ASSERT_EQUAL
183 (static_cast<unsigned int>(i),
184 libmesh_map_find(bc_array_indices,
185 std::make_tuple(cast_int<dof_id_type>(i),
186 0,
187 0)));
188
189
190 for (unsigned int i=0; i<5; ++i)
191 CPPUNIT_ASSERT_EQUAL
192 (static_cast<unsigned int>(i),
193 libmesh_map_find(bc_array_indices,
194 std::make_tuple(cast_int<dof_id_type>(5*i + 4),
195 1,
196 1)));
197
198
199 for (unsigned int i=0; i<5; ++i)
200 CPPUNIT_ASSERT_EQUAL
201 (static_cast<unsigned int>(i),
202 libmesh_map_find(bc_array_indices,
203 std::make_tuple(cast_int<dof_id_type>(20+i),
204 2,
205 2)));
206
207
208 for (unsigned int i=0; i<5; ++i)
209 CPPUNIT_ASSERT_EQUAL
210 (static_cast<unsigned int>(i),
211 libmesh_map_find(bc_array_indices,
212 std::make_tuple(cast_int<dof_id_type>(5*i),
213 3,
214 3)));
215 }
std::string & sideset_name(boundary_id_type id)
std::vector< BCTuple > build_side_list(BCTupleSortBy sort_by=BCTupleSortBy::ELEM_ID) const
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