141 {
142 LOG_UNIT_TEST;
143
144
145 MeshType mesh0(*TestCommWorld),
146 mesh1(*TestCommWorld),
147 mesh2(*TestCommWorld),
148 mesh3(*TestCommWorld);
149
150
151
152
153
154
155 std::vector<std::string> names2 {"bar", "baz"};
156 mesh2.add_elem_integers(names2);
157
158 std::vector<std::string> names3 {"bar", "foo"};
159 mesh3.add_elem_integers(names3);
160
161 int ps = 2;
162 MeshTools::Generation::build_cube (mesh0, ps, ps, ps, -1, 0, 0, 1, 0, 1,
HEX27);
163 MeshTools::Generation::build_cube (mesh1, ps, ps, ps, 0, 1, 0, 1, 0, 1,
HEX27);
164 MeshTools::Generation::build_cube (mesh2, ps, ps, ps, -1, 0, -1, 0, 0, 1,
HEX27);
165 MeshTools::Generation::build_cube (mesh3, ps, ps, ps, 0, 1, -1, 0, 0, 1,
HEX27);
166
167 struct trivially_copyable_pair
168 {
170 };
171
172 mesh0.add_node_integer("baz");
173 unsigned int foo1e_idx = mesh1.add_elem_integer("foo");
174 mesh2.template add_elem_datum<trivially_copyable_pair>("qux");
175 unsigned int qux2n_idx = mesh2.template add_node_datum<trivially_copyable_pair>("qux");
176 mesh3.add_node_integers(names3);
177
178 for (const auto & elem : mesh1.element_ptr_range())
179 elem->set_extra_integer(foo1e_idx, 2);
180
181 for (const auto & node : mesh2.node_ptr_range())
182 node->template set_extra_datum<trivially_copyable_pair>
183 (qux2n_idx, {3, 4});
184
185
186 mesh0.stitch_meshes(mesh1, 2, 4,
TOLERANCE,
true,
false,
false,
false);
187 mesh2.stitch_meshes(mesh3, 2, 4,
TOLERANCE,
true,
false,
false,
false);
188 mesh0.stitch_meshes(mesh2, 1, 3,
TOLERANCE,
true,
false,
false,
false);
189
190 CPPUNIT_ASSERT_EQUAL(mesh0.n_elem(),
static_cast<dof_id_type>(32));
191 CPPUNIT_ASSERT_EQUAL(mesh0.n_nodes(),
static_cast<dof_id_type>(405));
192 CPPUNIT_ASSERT_EQUAL(mesh0.n_elem_integers(), 5u);
193 CPPUNIT_ASSERT_EQUAL(mesh0.n_node_integers(), 5u);
194 std::vector<std::string> all_names {"foo", "bar", "baz", "qux"};
195 std::vector<unsigned int> node_name_indices {4, 3, 0, 1};
196 for (unsigned int i=0; i != 4; ++i)
197 {
198 CPPUNIT_ASSERT(mesh0.has_elem_integer(all_names[i]));
199 CPPUNIT_ASSERT_EQUAL(mesh0.get_elem_integer_index(all_names[i]), i);
200 CPPUNIT_ASSERT(mesh0.has_node_integer(all_names[i]));
201 CPPUNIT_ASSERT_EQUAL(mesh0.get_node_integer_index(all_names[i]), node_name_indices[i]);
202 }
203
204 unsigned int foo0e_idx = mesh0.get_elem_integer_index("foo");
205 for (const auto & elem : mesh0.element_ptr_range())
206 {
207 CPPUNIT_ASSERT_EQUAL(elem->n_extra_integers(), 5u);
208 const Point c = elem->vertex_average();
209 if (c(0) > 0 && c(1) > 0)
210 CPPUNIT_ASSERT_EQUAL(elem->get_extra_integer(foo0e_idx),
static_cast<dof_id_type>(2));
211 else
213 }
214
215 unsigned int qux0n_idx = mesh0.get_node_integer_index("qux");
216 for (const auto & node : mesh0.node_ptr_range())
217 {
218 CPPUNIT_ASSERT_EQUAL(node->n_extra_integers(), 5u);
219 trivially_copyable_pair datum =
220 node->template get_extra_datum<trivially_copyable_pair>(qux0n_idx);
221 if ((*node)(0) <= 0 && (*node)(1) < 0)
222 {
223 CPPUNIT_ASSERT_EQUAL(datum.first,
static_cast<dof_id_type>(3));
224 CPPUNIT_ASSERT_EQUAL(datum.second,
static_cast<dof_id_type>(4));
225 }
226 else
227 {
230 }
231 }
232 }
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
A Point defines a location in LIBMESH_DIM dimensional Real space.