libMesh
Public Member Functions | List of all members
MeshStitchTest Class Reference
Inheritance diagram for MeshStitchTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MeshStitchTest)
 
 CPPUNIT_TEST (testReplicatedMeshStitch)
 
 CPPUNIT_TEST (testDistributedMeshStitch)
 
 CPPUNIT_TEST (testReplicatedBoundaryInfo)
 
 CPPUNIT_TEST (testDistributedBoundaryInfo)
 
 CPPUNIT_TEST (testReplicatedMeshStitchElemsets)
 
 CPPUNIT_TEST (testRemappingStitch)
 
 CPPUNIT_TEST (testAmbiguousRemappingStitch)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void renameAndShift (UnstructuredMesh &mesh, const boundary_id_type boundary_id_offset, const std::string &boundary_name_prefix)
 
template<typename MeshType >
void testBoundaryInfo ()
 
void testReplicatedBoundaryInfo ()
 
void testDistributedBoundaryInfo ()
 
template<typename MeshType >
void testMeshStitch ()
 
void testReplicatedMeshStitch ()
 
void testDistributedMeshStitch ()
 
template<typename MeshType >
void testMeshStitchElemsets (unsigned int ps)
 
void testReplicatedMeshStitchElemsets ()
 
void testRemappingStitch ()
 
void testAmbiguousRemappingStitch ()
 

Detailed Description

Definition at line 22 of file mesh_stitch.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/7]

MeshStitchTest::CPPUNIT_TEST ( testReplicatedMeshStitch  )

◆ CPPUNIT_TEST() [2/7]

MeshStitchTest::CPPUNIT_TEST ( testDistributedMeshStitch  )

◆ CPPUNIT_TEST() [3/7]

MeshStitchTest::CPPUNIT_TEST ( testReplicatedBoundaryInfo  )

◆ CPPUNIT_TEST() [4/7]

MeshStitchTest::CPPUNIT_TEST ( testDistributedBoundaryInfo  )

◆ CPPUNIT_TEST() [5/7]

MeshStitchTest::CPPUNIT_TEST ( testReplicatedMeshStitchElemsets  )

◆ CPPUNIT_TEST() [6/7]

MeshStitchTest::CPPUNIT_TEST ( testRemappingStitch  )

◆ CPPUNIT_TEST() [7/7]

MeshStitchTest::CPPUNIT_TEST ( testAmbiguousRemappingStitch  )

◆ CPPUNIT_TEST_SUITE_END()

MeshStitchTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MeshStitchTest::LIBMESH_CPPUNIT_TEST_SUITE ( MeshStitchTest  )

◆ renameAndShift()

void MeshStitchTest::renameAndShift ( UnstructuredMesh mesh,
const boundary_id_type  boundary_id_offset,
const std::string &  boundary_name_prefix 
)
inline

Definition at line 47 of file mesh_stitch.C.

References libMesh::MeshTools::Modification::change_boundary_id(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_global_boundary_ids(), mesh, libMesh::BoundaryInfo::nodeset_name(), and libMesh::BoundaryInfo::sideset_name().

50  {
51  BoundaryInfo & boundary_info = mesh.get_boundary_info();
52  const auto mesh_boundary_ids = boundary_info.get_global_boundary_ids();
53  for (auto rit = mesh_boundary_ids.rbegin(); rit != mesh_boundary_ids.rend(); ++rit)
54  {
55  const auto old_sideset_name = boundary_info.sideset_name(*rit);
56  const auto old_nodeset_name = boundary_info.nodeset_name(*rit);
57 
58  MeshTools::Modification::change_boundary_id(mesh, *rit, *rit + boundary_id_offset);
59 
60  boundary_info.sideset_name(*rit + boundary_id_offset) =
61  boundary_name_prefix + old_sideset_name;
62  boundary_info.nodeset_name(*rit + boundary_id_offset) =
63  boundary_name_prefix + old_nodeset_name;
64  }
65  }
std::string & nodeset_name(boundary_id_type id)
MeshBase & mesh
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
void change_boundary_id(MeshBase &mesh, const boundary_id_type old_id, const boundary_id_type new_id)
Finds any boundary ids that are currently old_id, changes them to new_id.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
std::string & sideset_name(boundary_id_type id)
const std::set< boundary_id_type > & get_global_boundary_ids() const

◆ setUp()

void MeshStitchTest::setUp ( )
inline

Definition at line 41 of file mesh_stitch.C.

42  {}

◆ tearDown()

void MeshStitchTest::tearDown ( )
inline

Definition at line 44 of file mesh_stitch.C.

45  {}

◆ testAmbiguousRemappingStitch()

void MeshStitchTest::testAmbiguousRemappingStitch ( )
inline

Definition at line 407 of file mesh_stitch.C.

References libMesh::MeshTools::Generation::build_cube(), libMesh::HEX8, libMesh::MeshBase::subdomain_name(), TestCommWorld, and libMesh::TOLERANCE.

408  {
409  LOG_UNIT_TEST;
410 
411  Mesh mesh0(*TestCommWorld), mesh1(*TestCommWorld);
412 
413  int ps = 2;
414  MeshTools::Generation::build_cube(mesh0, ps, ps, ps, -1, 0, 0, 1, 0, 1, HEX8);
415  MeshTools::Generation::build_cube(mesh1, ps, ps, ps, 0, 1, 0, 1, 0, 1, HEX8);
416 
417  // rename and shift boundaries
418  renameAndShift(mesh0, 0, "zero_");
419  renameAndShift(mesh1, 6, "one_");
420 
421  // Create matching subdomain ids
422  for (const auto & elem : mesh0.element_ptr_range())
423  elem->subdomain_id() = 123;
424 
425  for (const auto & elem : mesh1.element_ptr_range())
426  elem->subdomain_id() = 123;
427 
428  // Create a conflict when only one is named
429  mesh1.subdomain_name(123) = "OneTwoThree";
430 
431 #ifdef LIBMESH_ENABLE_EXCEPTIONS
432  bool threw_error = false;
433  try
434  {
435  mesh0.stitch_meshes(mesh1, 2, 10, TOLERANCE, true, false, false,
436  false, false, /* remap_subdomain_ids = */ true);
437  }
438  catch (libMesh::LogicError & e)
439  {
440  std::regex msg_regex("safely stitch with a mesh");
441  CPPUNIT_ASSERT(std::regex_search(e.what(), msg_regex));
442  threw_error = true;
443  }
444 
445  CPPUNIT_ASSERT(threw_error);
446 #endif // LIBMESH_ENABLE_EXCEPTIONS
447  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
static constexpr Real TOLERANCE
void renameAndShift(UnstructuredMesh &mesh, const boundary_id_type boundary_id_offset, const std::string &boundary_name_prefix)
Definition: mesh_stitch.C:47
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.

◆ testBoundaryInfo()

template<typename MeshType >
void MeshStitchTest::testBoundaryInfo ( )
inline

Definition at line 69 of file mesh_stitch.C.

References libMesh::MeshTools::Generation::build_cube(), libMesh::BoundaryInfo::get_node_boundary_ids(), libMesh::BoundaryInfo::get_nodeset_name_map(), libMesh::BoundaryInfo::get_side_boundary_ids(), libMesh::BoundaryInfo::get_sideset_name_map(), libMesh::HEX8, TestCommWorld, and libMesh::TOLERANCE.

70  {
71  LOG_UNIT_TEST;
72 
73  MeshType mesh0(*TestCommWorld), mesh1(*TestCommWorld);
74 
75  int ps = 2;
76  MeshTools::Generation::build_cube(mesh0, ps, ps, ps, -1, 0, 0, 1, 0, 1, HEX8);
77  MeshTools::Generation::build_cube(mesh1, ps, ps, ps, 0, 1, 0, 1, 0, 1, HEX8);
78 
79  // rename and shift boundaries
80  renameAndShift(mesh0, 0, "zero_");
81  renameAndShift(mesh1, 6, "one_");
82 
83  mesh0.stitch_meshes(mesh1, 2, 10, TOLERANCE, true, true, false, false);
84 
85  CPPUNIT_ASSERT_EQUAL(mesh0.n_elem(), static_cast<dof_id_type>(16));
86  CPPUNIT_ASSERT_EQUAL(mesh0.n_nodes(), static_cast<dof_id_type>(45));
87 
88  const BoundaryInfo & bi = mesh0.get_boundary_info();
89  const auto & sbi = bi.get_side_boundary_ids();
90  typename std::decay<decltype(sbi.size())>::type expected_size = 10;
91  CPPUNIT_ASSERT_EQUAL(expected_size, sbi.size());
92 
93  const auto & nbi = bi.get_node_boundary_ids();
94  CPPUNIT_ASSERT_EQUAL(expected_size, nbi.size());
95 
96  // We expect that the "zero_right" and "one_left" boundaries have
97  // disappeared after being stitched together.
98  std::set<std::string> expected_names = {{"zero_left",
99  "zero_top",
100  "zero_front",
101  "zero_back",
102  "zero_bottom",
103  "one_right",
104  "one_top",
105  "one_front",
106  "one_back",
107  "one_bottom"}};
108  std::set<std::string> ss_names;
109  for (const auto & pr : bi.get_sideset_name_map())
110  ss_names.insert(pr.second);
111  CPPUNIT_ASSERT(ss_names == expected_names);
112 
113  std::set<std::string> ns_names;
114  for (const auto & pr : bi.get_nodeset_name_map())
115  ns_names.insert(pr.second);
116  CPPUNIT_ASSERT(ns_names == expected_names);
117  }
const std::set< boundary_id_type > & get_side_boundary_ids() const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
static constexpr Real TOLERANCE
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
void renameAndShift(UnstructuredMesh &mesh, const boundary_id_type boundary_id_offset, const std::string &boundary_name_prefix)
Definition: mesh_stitch.C:47
const std::set< boundary_id_type > & get_node_boundary_ids() const
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
uint8_t dof_id_type
Definition: id_types.h:67

◆ testDistributedBoundaryInfo()

void MeshStitchTest::testDistributedBoundaryInfo ( )
inline

Definition at line 126 of file mesh_stitch.C.

127  {
128  testBoundaryInfo<DistributedMesh>();
129  }

◆ testDistributedMeshStitch()

void MeshStitchTest::testDistributedMeshStitch ( )
inline

Definition at line 232 of file mesh_stitch.C.

233  {
234  testMeshStitch<DistributedMesh>();
235  }

◆ testMeshStitch()

template<typename MeshType >
void MeshStitchTest::testMeshStitch ( )
inline

Definition at line 133 of file mesh_stitch.C.

References libMesh::MeshTools::Generation::build_cube(), libMesh::HEX27, and TestCommWorld.

134  {
135  LOG_UNIT_TEST;
136 
137  // Generate four meshes to be stitched together
138  MeshType mesh0(*TestCommWorld),
139  mesh1(*TestCommWorld),
140  mesh2(*TestCommWorld),
141  mesh3(*TestCommWorld);
142 
143  // Give the meshes different extra integers to make sure those
144  // merge. Reuse names between nodes and elements to make sure
145  // those don't mix. Add some integers before and others after
146  // generation to test flexibility there.
147 
148  std::vector<std::string> names2 {"bar", "baz"};
149  mesh2.add_elem_integers(names2);
150 
151  std::vector<std::string> names3 {"bar", "foo"};
152  mesh3.add_elem_integers(names3);
153 
154  int ps = 2;
155  MeshTools::Generation::build_cube (mesh0, ps, ps, ps, -1, 0, 0, 1, 0, 1, HEX27);
156  MeshTools::Generation::build_cube (mesh1, ps, ps, ps, 0, 1, 0, 1, 0, 1, HEX27);
157  MeshTools::Generation::build_cube (mesh2, ps, ps, ps, -1, 0, -1, 0, 0, 1, HEX27);
158  MeshTools::Generation::build_cube (mesh3, ps, ps, ps, 0, 1, -1, 0, 0, 1, HEX27);
159 
160  struct trivially_copyable_pair // std::pair triggers -Wclass-memaccess
161  {
162  dof_id_type first, second;
163  };
164 
165  mesh0.add_node_integer("baz");
166  unsigned int foo1e_idx = mesh1.add_elem_integer("foo");
167  mesh2.template add_elem_datum<trivially_copyable_pair>("qux");
168  unsigned int qux2n_idx = mesh2.template add_node_datum<trivially_copyable_pair>("qux");
169  mesh3.add_node_integers(names3);
170 
171  for (const auto & elem : mesh1.element_ptr_range())
172  elem->set_extra_integer(foo1e_idx, 2);
173 
174  for (const auto & node : mesh2.node_ptr_range())
175  node->template set_extra_datum<trivially_copyable_pair>
176  (qux2n_idx, {3, 4});
177 
178  // We stitch the meshes in a hierarchical way.
179  mesh0.stitch_meshes(mesh1, 2, 4, TOLERANCE, true, true, false, false);
180  mesh2.stitch_meshes(mesh3, 2, 4, TOLERANCE, true, true, false, false);
181  mesh0.stitch_meshes(mesh2, 1, 3, TOLERANCE, true, true, false, false);
182 
183  CPPUNIT_ASSERT_EQUAL(mesh0.n_elem(), static_cast<dof_id_type>(32));
184  CPPUNIT_ASSERT_EQUAL(mesh0.n_nodes(), static_cast<dof_id_type>(405));
185  CPPUNIT_ASSERT_EQUAL(mesh0.n_elem_integers(), 5u); // that pair counts 2x
186  CPPUNIT_ASSERT_EQUAL(mesh0.n_node_integers(), 5u);
187  std::vector<std::string> all_names {"foo", "bar", "baz", "qux"};
188  std::vector<unsigned int> node_name_indices {4, 3, 0, 1};
189  for (unsigned int i=0; i != 4; ++i)
190  {
191  CPPUNIT_ASSERT(mesh0.has_elem_integer(all_names[i]));
192  CPPUNIT_ASSERT_EQUAL(mesh0.get_elem_integer_index(all_names[i]), i);
193  CPPUNIT_ASSERT(mesh0.has_node_integer(all_names[i]));
194  CPPUNIT_ASSERT_EQUAL(mesh0.get_node_integer_index(all_names[i]), node_name_indices[i]);
195  }
196 
197  unsigned int foo0e_idx = mesh0.get_elem_integer_index("foo");
198  for (const auto & elem : mesh0.element_ptr_range())
199  {
200  CPPUNIT_ASSERT_EQUAL(elem->n_extra_integers(), 5u);
201  const Point c = elem->vertex_average();
202  if (c(0) > 0 && c(1) > 0) // this came from mesh1
203  CPPUNIT_ASSERT_EQUAL(elem->get_extra_integer(foo0e_idx), static_cast<dof_id_type>(2));
204  else
205  CPPUNIT_ASSERT_EQUAL(elem->get_extra_integer(foo0e_idx), DofObject::invalid_id);
206  }
207 
208  unsigned int qux0n_idx = mesh0.get_node_integer_index("qux");
209  for (const auto & node : mesh0.node_ptr_range())
210  {
211  CPPUNIT_ASSERT_EQUAL(node->n_extra_integers(), 5u);
212  trivially_copyable_pair datum =
213  node->template get_extra_datum<trivially_copyable_pair>(qux0n_idx);
214  if ((*node)(0) <= 0 && (*node)(1) < 0) // this came from mesh2
215  {
216  CPPUNIT_ASSERT_EQUAL(datum.first, static_cast<dof_id_type>(3));
217  CPPUNIT_ASSERT_EQUAL(datum.second, static_cast<dof_id_type>(4));
218  }
219  else
220  {
221  CPPUNIT_ASSERT_EQUAL(datum.first, DofObject::invalid_id);
222  CPPUNIT_ASSERT_EQUAL(datum.second, DofObject::invalid_id);
223  }
224  }
225  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
static constexpr Real TOLERANCE
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
uint8_t dof_id_type
Definition: id_types.h:67

◆ testMeshStitchElemsets()

template<typename MeshType >
void MeshStitchTest::testMeshStitchElemsets ( unsigned int  ps)
inline

Definition at line 238 of file mesh_stitch.C.

References libMesh::MeshBase::add_elem_integer(), libMesh::MeshBase::add_elemset_code(), libMesh::MeshTools::Generation::build_cube(), libMesh::HEX27, mesh, libMesh::TOLERANCE, and libMesh::MeshTools::Modification::translate().

239  {
240  LOG_UNIT_TEST;
241 
242  // Generate meshes to be stitched together. We are going to clone
243  // these so work with unique_ptrs directly.
244  auto mesh0 = std::make_unique<MeshType>(*TestCommWorld);
245 
246  // If the user tries to stitch meshes with overlapping codes, we
247  // allow this as long as the codes refer to the same underlying
248  // set ids.
249 
250  // Build a mesh on the unit cube
251  MeshTools::Generation::build_cube (*mesh0, ps, ps, ps,
252  /*xmin=*/0., /*xmax=*/1.,
253  /*ymin=*/0., /*ymax=*/1.,
254  /*zmin=*/0., /*zmax=*/1.,
255  HEX27);
256 
257  // Make a copy
258  auto mesh1 = mesh0->clone();
259 
260  // Shift copy one unit to the right
261  MeshTools::Modification::translate(*mesh1, /*x-dir*/1.0);
262 
263  // For both meshes:
264  // .) Put odd-numbered Elems in elmset 1
265  // .) Put even-numbered Elems in elemset 2
266  // We use the trivial encoding: elemset id == elemset code for simplicity
267  auto place_elems = [](MeshBase & mesh)
268  {
269  unsigned int elemset_index =
270  mesh.add_elem_integer("elemset_code", /*allocate_data=*/true);
271 
272  mesh.add_elemset_code(/*code=*/1, /*set_ids*/{1});
273  mesh.add_elemset_code(/*code=*/2, /*set_ids*/{2});
274 
275  for (const auto & elem : mesh.element_ptr_range())
276  {
277  if (elem->id() % 2) // id odd
278  elem->set_extra_integer(elemset_index, 1);
279  else // id even
280  elem->set_extra_integer(elemset_index, 2);
281  }
282  };
283 
284  place_elems(*mesh0);
285  place_elems(*mesh1);
286 
287  // Before stitching, change the elemset codes on mesh1 so they
288  // don't overlap with the codes on mesh0.
289  mesh1->change_elemset_code(/*old*/1, /*new*/3); // 1 -> 3
290  mesh1->change_elemset_code(/*old*/2, /*new*/4); // 2 -> 4
291 
292  // Before stitching, change the elemset ids on mesh1 so they
293  // don't overlap with the elemset ids on mesh0.
294  mesh1->change_elemset_id(/*old*/1, /*new*/100); // 1 -> 100
295  mesh1->change_elemset_id(/*old*/2, /*new*/200); // 2 -> 200
296 
297  // Stitch the meshes together at the indicated boundary ids
298  mesh0->stitch_meshes(dynamic_cast<UnstructuredMesh &>(*mesh1),
299  /*this boundary=*/2,
300  /*other boundary=*/4,
301  TOLERANCE,
302  /*clear_stitched_boundary_ids=*/true,
303  /*verbose=*/true,
304  /*use_binary_search=*/false,
305  /*enforce_all_nodes_match_on_boundaries=*/false);
306 
307  // Number of elements in each mesh pre-stitch
308  dof_id_type n_elem_prestitch = Utility::pow<3>(ps);
309 
310  // mesh0 should contain 2 * ps**3 total elements after stitching
311  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2 * n_elem_prestitch), mesh0->n_elem());
312 
313  // Check that the stitched mesh still stores "elemset_code" in the
314  // same index (0) as it was before the meshes were stitched.
315  unsigned int elemset_index = mesh0->get_elem_integer_index("elemset_code");
316  CPPUNIT_ASSERT_EQUAL(0u, elemset_index);
317 
318  // Check that the stitched mesh has merged elemset codes and ids as expected
319  MeshBase::elemset_type id_set_to_fill;
320  const elemset_id_type code_to_type[] = {0,1,2,100,200};
321  for (dof_id_type elemset_code=1; elemset_code<5; ++elemset_code)
322  {
323  mesh0->get_elemsets(elemset_code, id_set_to_fill);
324 
325  // Assert one elemset id in each set, and that set contains the correct id
326  CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), id_set_to_fill.size());
327  CPPUNIT_ASSERT(id_set_to_fill.count(code_to_type[elemset_code]));
328  }
329 
330  bool ps_odd = ps % 2;
331 
332  for (const auto & elem : mesh0->element_ptr_range())
333  {
334  dof_id_type elemset_code = elem->get_extra_integer(elemset_index);
335  bool elem_id_odd = elem->id() % 2;
336 
337  // Debugging
338  // libMesh::out << "Elem " << elem->id() << " in stitched mesh has elemset_code = " << elemset_code << std::endl;
339 
340  // Verify that the stitched mesh elemset codes match their pre-stitched values
341  if (elem->id() < n_elem_prestitch) // lower half id
342  {
343  if (elem_id_odd)
344  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(1), elemset_code);
345  else
346  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2), elemset_code);
347  }
348  else // upper half id
349  {
350  // i.) If ps == odd, then n_elem_prestitch == odd, and even mesh1
351  // elem ids will become odd, and odd mesh1 elem ids will become
352  // even..
353  // ii.) If ps == even, then n_elem_prestitch == even, and even mesh1
354  // elem ids will remain even, odd mesh1 elem ids will remain odd.
355  if (elem_id_odd)
356  CPPUNIT_ASSERT_EQUAL(ps_odd ? static_cast<dof_id_type>(4) : static_cast<dof_id_type>(3), elemset_code);
357  else
358  CPPUNIT_ASSERT_EQUAL(ps_odd ? static_cast<dof_id_type>(3) : static_cast<dof_id_type>(4), elemset_code);
359  }
360  }
361  }
static constexpr Real TOLERANCE
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh...
Definition: mesh_base.C:512
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set...
Definition: mesh_base.C:350
MeshBase & mesh
This is the MeshBase class.
Definition: mesh_base.h:74
void translate(MeshBase &mesh, const Real xt=0., const Real yt=0., const Real zt=0.)
Translates the mesh.
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:297
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
uint8_t dof_id_type
Definition: id_types.h:67

◆ testRemappingStitch()

void MeshStitchTest::testRemappingStitch ( )
inline

Definition at line 370 of file mesh_stitch.C.

References libMesh::MeshTools::Generation::build_cube(), libMesh::HEX8, libMesh::MeshBase::subdomain_name(), TestCommWorld, and libMesh::TOLERANCE.

371  {
372  LOG_UNIT_TEST;
373 
374  Mesh mesh0(*TestCommWorld), mesh1(*TestCommWorld);
375 
376  int ps = 2;
377  MeshTools::Generation::build_cube(mesh0, ps, ps, ps, -1, 0, 0, 1, 0, 1, HEX8);
378  MeshTools::Generation::build_cube(mesh1, ps, ps, ps, 0, 1, 0, 1, 0, 1, HEX8);
379 
380  // rename and shift boundaries
381  renameAndShift(mesh0, 0, "zero_");
382  renameAndShift(mesh1, 6, "one_");
383 
384  // Create "auto" generated subdomain ids
385  for (const auto & elem : mesh0.element_ptr_range())
386  elem->subdomain_id() = 123;
387 
388  for (const auto & elem : mesh1.element_ptr_range())
389  elem->subdomain_id() = 456;
390 
391  // Resolve them to the same name
392  mesh0.subdomain_name(123) = "OneTwoThree";
393  mesh1.subdomain_name(456) = "OneTwoThree"; // silly autogen
394 
395  mesh0.stitch_meshes(mesh1, 2, 10, TOLERANCE, true, false, false,
396  false, false, /* remap_subdomain_ids = */ true);
397 
398  CPPUNIT_ASSERT_EQUAL(mesh0.n_elem(), static_cast<dof_id_type>(16));
399  CPPUNIT_ASSERT_EQUAL(mesh0.n_nodes(), static_cast<dof_id_type>(45));
400 
401  // Ensure they still map to the same name but now with the same id
402  for (const auto & elem : mesh0.element_ptr_range())
403  CPPUNIT_ASSERT_EQUAL(elem->subdomain_id(), subdomain_id_type(123));
404  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
static constexpr Real TOLERANCE
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
void renameAndShift(UnstructuredMesh &mesh, const boundary_id_type boundary_id_offset, const std::string &boundary_name_prefix)
Definition: mesh_stitch.C:47
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
uint8_t dof_id_type
Definition: id_types.h:67

◆ testReplicatedBoundaryInfo()

void MeshStitchTest::testReplicatedBoundaryInfo ( )
inline

Definition at line 120 of file mesh_stitch.C.

121  {
122  testBoundaryInfo<ReplicatedMesh>();
123  }

◆ testReplicatedMeshStitch()

void MeshStitchTest::testReplicatedMeshStitch ( )
inline

Definition at line 227 of file mesh_stitch.C.

228  {
229  testMeshStitch<ReplicatedMesh>();
230  }

◆ testReplicatedMeshStitchElemsets()

void MeshStitchTest::testReplicatedMeshStitchElemsets ( )
inline

Definition at line 363 of file mesh_stitch.C.

364  {
365  testMeshStitchElemsets<ReplicatedMesh>(/*ps=*/2);
366  testMeshStitchElemsets<ReplicatedMesh>(/*ps=*/3);
367  }

The documentation for this class was generated from the following file: