152 std::vector<std::string> names2 {
"bar",
"baz"};
153 mesh2.add_elem_integers(names2);
155 std::vector<std::string> names3 {
"bar",
"foo"};
156 mesh3.add_elem_integers(names3);
159 MeshTools::Generation::build_cube (mesh0, ps, ps, ps, -1, 0, 0, 1, 0, 1,
HEX27);
160 MeshTools::Generation::build_cube (mesh1, ps, ps, ps, 0, 1, 0, 1, 0, 1,
HEX27);
161 MeshTools::Generation::build_cube (mesh2, ps, ps, ps, -1, 0, -1, 0, 0, 1,
HEX27);
162 MeshTools::Generation::build_cube (mesh3, ps, ps, ps, 0, 1, -1, 0, 0, 1,
HEX27);
164 struct trivially_copyable_pair
169 mesh0.add_node_integer(
"baz");
170 unsigned int foo1e_idx = mesh1.add_elem_integer(
"foo");
171 mesh2.template add_elem_datum<trivially_copyable_pair>(
"qux");
172 unsigned int qux2n_idx = mesh2.template add_node_datum<trivially_copyable_pair>(
"qux");
173 mesh3.add_node_integers(names3);
175 for (
const auto & elem : mesh1.element_ptr_range())
176 elem->set_extra_integer(foo1e_idx, 2);
178 for (
const auto & node : mesh2.node_ptr_range())
179 node->template set_extra_datum<trivially_copyable_pair>
183 mesh0.stitch_meshes(mesh1, 2, 4,
TOLERANCE,
true,
true,
false,
false);
184 mesh2.stitch_meshes(mesh3, 2, 4,
TOLERANCE,
true,
true,
false,
false);
185 mesh0.stitch_meshes(mesh2, 1, 3,
TOLERANCE,
true,
true,
false,
false);
187 CPPUNIT_ASSERT_EQUAL(mesh0.n_elem(),
static_cast<dof_id_type>(32));
188 CPPUNIT_ASSERT_EQUAL(mesh0.n_nodes(),
static_cast<dof_id_type>(405));
189 CPPUNIT_ASSERT_EQUAL(mesh0.n_elem_integers(), 5u);
190 CPPUNIT_ASSERT_EQUAL(mesh0.n_node_integers(), 5u);
191 std::vector<std::string> all_names {
"foo",
"bar",
"baz",
"qux"};
192 std::vector<unsigned int> node_name_indices {4, 3, 0, 1};
193 for (
unsigned int i=0; i != 4; ++i)
195 CPPUNIT_ASSERT(mesh0.has_elem_integer(all_names[i]));
196 CPPUNIT_ASSERT_EQUAL(mesh0.get_elem_integer_index(all_names[i]), i);
197 CPPUNIT_ASSERT(mesh0.has_node_integer(all_names[i]));
198 CPPUNIT_ASSERT_EQUAL(mesh0.get_node_integer_index(all_names[i]), node_name_indices[i]);
201 unsigned int foo0e_idx = mesh0.get_elem_integer_index(
"foo");
202 for (
const auto & elem : mesh0.element_ptr_range())
204 CPPUNIT_ASSERT_EQUAL(elem->n_extra_integers(), 5u);
205 const Point c = elem->vertex_average();
206 if (c(0) > 0 && c(1) > 0)
207 CPPUNIT_ASSERT_EQUAL(elem->get_extra_integer(foo0e_idx),
static_cast<dof_id_type>(2));
209 CPPUNIT_ASSERT_EQUAL(elem->get_extra_integer(foo0e_idx), DofObject::invalid_id);
212 unsigned int qux0n_idx = mesh0.get_node_integer_index(
"qux");
213 for (
const auto & node : mesh0.node_ptr_range())
215 CPPUNIT_ASSERT_EQUAL(node->n_extra_integers(), 5u);
216 trivially_copyable_pair datum =
217 node->template get_extra_datum<trivially_copyable_pair>(qux0n_idx);
218 if ((*node)(0) <= 0 && (*node)(1) < 0)
220 CPPUNIT_ASSERT_EQUAL(datum.first, static_cast<dof_id_type>(3));
221 CPPUNIT_ASSERT_EQUAL(datum.second, static_cast<dof_id_type>(4));
225 CPPUNIT_ASSERT_EQUAL(datum.first, DofObject::invalid_id);
226 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.