1 #include <libmesh/distributed_mesh.h> 2 #include <libmesh/mesh.h> 3 #include <libmesh/mesh_generation.h> 4 #include <libmesh/mesh_refinement.h> 5 #include <libmesh/mesh_serializer.h> 6 #include <libmesh/remote_elem.h> 7 #include <libmesh/replicated_mesh.h> 8 #include <libmesh/boundary_info.h> 24 const unsigned int parent_side_index_tag =
27 for (
const auto & belem : boundary_mesh.element_ptr_range())
30 belem->get_extra_integer(parent_side_index_tag);
34 (static_cast<dof_id_type>(belem->interior_parent()->which_side_am_i(belem)),
46 for (
const auto & elem :
mesh.active_element_ptr_range())
48 const Elem * pip = elem->
dim() < interior_dim ?
49 elem->interior_parent() :
nullptr;
64 CPPUNIT_ASSERT_EQUAL(elem->type(), boundary_type);
65 CPPUNIT_ASSERT_EQUAL(pip->
type(), interior_type);
66 CPPUNIT_ASSERT_EQUAL(pip->
level(), elem->level());
72 CPPUNIT_ASSERT(is_mixed);
73 CPPUNIT_ASSERT_EQUAL(elem->type(), interior_type);
90 CPPUNIT_TEST( testMesh );
93 CPPUNIT_TEST_SUITE_END();
97 std::unique_ptr<UnstructuredMesh>
_mesh;
104 _mesh = std::make_unique<Mesh>(*TestCommWorld);
105 _replicated_boundary_mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
106 _distributed_boundary_mesh = std::make_unique<DistributedMesh>(*TestCommWorld);
107 _interior_node_mesh = std::make_unique<Mesh>(*TestCommWorld);
116 for (
auto & elem : _mesh->active_element_ptr_range())
118 const Point c = elem->vertex_average();
126 if (!_mesh->is_serial())
128 _mesh->skip_noncritical_partitioning(
true);
129 _replicated_boundary_mesh->skip_noncritical_partitioning(
true);
130 _distributed_boundary_mesh->skip_noncritical_partitioning(
true);
137 const std::set<boundary_id_type> exterior_boundaries {0, 1};
139 _mesh->get_boundary_info().sync(exterior_boundaries,
140 *_replicated_boundary_mesh);
141 check_parent_side_index_tag(*_replicated_boundary_mesh);
143 _mesh->get_boundary_info().sync(exterior_boundaries,
144 *_distributed_boundary_mesh);
145 check_parent_side_index_tag(*_distributed_boundary_mesh);
147 const std::set<boundary_id_type> interior_boundaries {2};
148 _mesh->get_boundary_info().sync(interior_boundaries,
149 *_interior_node_mesh);
150 check_parent_side_index_tag(*_interior_node_mesh);
156 std::set<boundary_id_type> right_id;
159 _mesh->get_boundary_info().add_elements
160 (right_id, *_mesh,
false);
161 _mesh->prepare_for_use();
169 this->sync_and_test_meshes();
179 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(4),
183 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(7),
187 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
188 _replicated_boundary_mesh->n_elem());
189 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
190 _distributed_boundary_mesh->n_elem());
193 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
194 _replicated_boundary_mesh->n_nodes());
195 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
196 _distributed_boundary_mesh->n_nodes());
199 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(1),
200 _interior_node_mesh->n_elem());
201 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(1),
202 _interior_node_mesh->n_nodes());
214 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
215 _replicated_boundary_mesh->n_elem());
216 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
217 _distributed_boundary_mesh->n_elem());
220 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
221 _replicated_boundary_mesh->n_nodes());
222 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
223 _distributed_boundary_mesh->n_nodes());
232 sanity_check_mesh(*_replicated_boundary_mesh,
NODEELEM,
EDGE3,
false);
233 sanity_check_mesh(*_distributed_boundary_mesh,
NODEELEM,
EDGE3,
false);
234 sanity_check_mesh(*_interior_node_mesh,
NODEELEM,
EDGE3,
false);
250 CPPUNIT_TEST( testMesh );
251 CPPUNIT_TEST( testBoundarySerialization );
254 CPPUNIT_TEST_SUITE_END();
258 std::unique_ptr<UnstructuredMesh>
_mesh;
271 _mesh = std::make_unique<Mesh>(*TestCommWorld);
272 _multi_boundary_mesh = std::make_unique<Mesh>(*TestCommWorld);
273 _exterior_boundary_mesh = std::make_unique<Mesh>(*TestCommWorld);
277 _left_boundary_mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
281 _internal_boundary_mesh = std::make_unique<DistributedMesh>(*TestCommWorld);
284 0.2, 0.8, 0.2, 0.7,
QUAD9);
289 if (!_mesh->is_serial())
291 _mesh->skip_noncritical_partitioning(
true);
292 _left_boundary_mesh->skip_noncritical_partitioning(
true);
293 _multi_boundary_mesh->skip_noncritical_partitioning(
true);
294 _exterior_boundary_mesh->skip_noncritical_partitioning(
true);
295 _internal_boundary_mesh->skip_noncritical_partitioning(
true);
316 for (
auto & elem : _mesh->active_element_ptr_range())
318 const Point c = elem->vertex_average();
319 if (c(0) < 0.6 && c(1) < 0.4)
320 elem->subdomain_id() = 1;
322 elem->subdomain_id() = 2;
331 for (
auto & elem : _mesh->active_element_ptr_range())
333 const Point c = elem->vertex_average();
334 if (c(0) < 0.6 && c(1) < 0.4)
343 if (c(0) < 0.75 && c(1) < 0.4)
345 if (c(0) < 0.6 && c(1) < 0.5)
354 const std::set<boundary_id_type> exterior_boundaries {0, 1, 2, 3};
355 _mesh->get_boundary_info().sync(exterior_boundaries,
356 *_exterior_boundary_mesh);
357 check_parent_side_index_tag(*_exterior_boundary_mesh);
370 const std::set<boundary_id_type> multi_boundaries {1, 2, 5};
371 _mesh->get_boundary_info().sync(multi_boundaries,
372 *_multi_boundary_mesh);
373 check_parent_side_index_tag(*_multi_boundary_mesh);
375 std::set<boundary_id_type> left_id, right_id;
383 _mesh->get_boundary_info().add_elements
384 (right_id, *_mesh,
false);
385 _mesh->prepare_for_use();
388 _mesh->get_boundary_info().sync(left_id, *_left_boundary_mesh);
389 check_parent_side_index_tag(*_left_boundary_mesh);
393 std::set<boundary_id_type> requested_boundary_ids {bid1, bid2};
394 std::set<subdomain_id_type> subdomains_relative_to;
395 subdomains_relative_to.insert(1);
396 _mesh->get_boundary_info().sync(requested_boundary_ids,
397 *_internal_boundary_mesh,
398 subdomains_relative_to);
399 check_parent_side_index_tag(*_internal_boundary_mesh);
408 this->sync_and_test_meshes();
418 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(20),
422 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(77),
426 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(16),
427 _exterior_boundary_mesh->n_elem());
430 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(32),
431 _exterior_boundary_mesh->n_nodes());
434 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(5),
435 _left_boundary_mesh->n_elem());
438 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(11),
439 _left_boundary_mesh->n_nodes());
442 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(4),
443 _internal_boundary_mesh->n_elem());
446 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(9),
447 _internal_boundary_mesh->n_nodes());
450 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(12),
451 _multi_boundary_mesh->n_elem());
454 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(26),
455 _multi_boundary_mesh->n_nodes());
467 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(4),
468 _internal_boundary_mesh->n_elem());
471 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(9),
472 _internal_boundary_mesh->n_nodes());
479 sanity_check_mesh(*_mesh,
EDGE3,
QUAD9,
true);
480 sanity_check_mesh(*_multi_boundary_mesh,
EDGE3,
QUAD9,
false);
481 sanity_check_mesh(*_exterior_boundary_mesh,
EDGE3,
QUAD9,
false);
482 sanity_check_mesh(*_left_boundary_mesh,
EDGE3,
QUAD9,
false);
483 sanity_check_mesh(*_internal_boundary_mesh,
EDGE3,
QUAD9,
false);
485 for (
const auto & elem : _left_boundary_mesh->active_element_ptr_range())
488 LIBMESH_ASSERT_FP_EQUAL(0.2, elem->vertex_average()(0),
493 for (
const auto & elem : _internal_boundary_mesh->active_element_ptr_range())
498 CPPUNIT_ASSERT_EQUAL(static_cast<subdomain_id_type>(1),
499 elem->subdomain_id());
507 #ifdef LIBMESH_ENABLE_AMR 520 CPPUNIT_TEST( testMesh );
521 CPPUNIT_TEST( testBoundarySerialization );
524 CPPUNIT_TEST_SUITE_END();
533 this->sync_and_test_meshes();
552 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(70),
553 _mesh->n_active_elem());
556 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(90),
560 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(273),
564 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(32),
565 _exterior_boundary_mesh->n_active_elem());
568 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(48),
569 _exterior_boundary_mesh->n_elem());
572 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(64),
573 _exterior_boundary_mesh->n_nodes());
576 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(10),
577 _left_boundary_mesh->n_active_elem());
580 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(15),
581 _left_boundary_mesh->n_elem());
584 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(21),
585 _left_boundary_mesh->n_nodes());
589 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(8),
590 _internal_boundary_mesh->n_active_elem());
593 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(12),
594 _internal_boundary_mesh->n_elem());
597 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(17),
598 _internal_boundary_mesh->n_nodes());
602 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(24),
603 _multi_boundary_mesh->n_active_elem());
606 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(36),
607 _multi_boundary_mesh->n_elem());
611 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(50),
612 _multi_boundary_mesh->n_nodes());
627 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(8),
628 _internal_boundary_mesh->n_active_elem());
631 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(12),
632 _internal_boundary_mesh->n_elem());
635 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(17),
636 _internal_boundary_mesh->n_nodes());
656 CPPUNIT_TEST( testMesh );
657 CPPUNIT_TEST( testBoundarySerialization );
660 CPPUNIT_TEST_SUITE_END();
673 this->sync_and_test_meshes();
683 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(70),
684 _mesh->n_active_elem());
687 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(90),
691 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(273),
695 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(32),
696 _exterior_boundary_mesh->n_active_elem());
699 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(48),
700 _exterior_boundary_mesh->n_elem());
703 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(64),
704 _exterior_boundary_mesh->n_nodes());
707 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(10),
708 _left_boundary_mesh->n_active_elem());
711 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(15),
712 _left_boundary_mesh->n_elem());
715 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(21),
716 _left_boundary_mesh->n_nodes());
720 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(8),
721 _internal_boundary_mesh->n_active_elem());
724 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(12),
725 _internal_boundary_mesh->n_elem());
728 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(17),
729 _internal_boundary_mesh->n_nodes());
733 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(24),
734 _multi_boundary_mesh->n_active_elem());
737 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(36),
738 _multi_boundary_mesh->n_elem());
741 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(50),
742 _multi_boundary_mesh->n_nodes());
755 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(8),
756 _internal_boundary_mesh->n_active_elem());
759 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(12),
760 _internal_boundary_mesh->n_elem());
763 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(17),
764 _internal_boundary_mesh->n_nodes());
ElemType
Defines an enum for geometric element types.
std::unique_ptr< UnstructuredMesh > _internal_boundary_mesh
void sync_and_test_meshes()
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
std::unique_ptr< UnstructuredMesh > _replicated_boundary_mesh
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
std::unique_ptr< UnstructuredMesh > _exterior_boundary_mesh
void testBoundarySerialization()
This is the base class from which all geometric element types are derived.
std::unique_ptr< UnstructuredMesh > _distributed_boundary_mesh
processor_id_type rank() const
The libMesh namespace provides an interface to certain functionality in the library.
std::unique_ptr< UnstructuredMesh > _mesh
void testBoundarySerialization()
unsigned int get_elem_integer_index(std::string_view name) const
Implements (adaptive) mesh refinement algorithms for a MeshBase.
The UnstructuredMesh class is derived from the MeshBase class.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
CPPUNIT_TEST_SUITE_REGISTRATION(BoundaryMesh0DTest)
void testBoundarySerialization()
std::unique_ptr< UnstructuredMesh > _left_boundary_mesh
void sync_and_test_meshes()
std::unique_ptr< UnstructuredMesh > _interior_node_mesh
unsigned int level() const
std::unique_ptr< UnstructuredMesh > _multi_boundary_mesh
virtual unsigned short dim() const =0
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
std::unique_ptr< UnstructuredMesh > _mesh
virtual ElemType type() const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.
void testBoundarySerialization()
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
const RemoteElem * remote_elem