155 std::vector<std::string> names2 {
"bar",
"baz"};
156 mesh2.add_elem_integers(names2);
158 std::vector<std::string> names3 {
"bar",
"foo"};
159 mesh3.add_elem_integers(names3);
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);
167 struct trivially_copyable_pair
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);
178 for (
const auto & elem : mesh1.element_ptr_range())
179 elem->set_extra_integer(foo1e_idx, 2);
181 for (
const auto & node : mesh2.node_ptr_range())
182 node->template set_extra_datum<trivially_copyable_pair>
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);
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)
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]);
204 unsigned int foo0e_idx = mesh0.get_elem_integer_index(
"foo");
205 for (
const auto & elem : mesh0.element_ptr_range())
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));
212 CPPUNIT_ASSERT_EQUAL(elem->get_extra_integer(foo0e_idx), DofObject::invalid_id);
215 unsigned int qux0n_idx = mesh0.get_node_integer_index(
"qux");
216 for (
const auto & node : mesh0.node_ptr_range())
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)
223 CPPUNIT_ASSERT_EQUAL(datum.first, static_cast<dof_id_type>(3));
224 CPPUNIT_ASSERT_EQUAL(datum.second, static_cast<dof_id_type>(4));
228 CPPUNIT_ASSERT_EQUAL(datum.first, DofObject::invalid_id);
229 CPPUNIT_ASSERT_EQUAL(datum.second, DofObject::invalid_id);
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
A Point defines a location in LIBMESH_DIM dimensional Real space.