1 #include <libmesh/mesh.h>
2 #include <libmesh/mesh_generation.h>
3 #include <libmesh/mesh_refinement.h>
4 #include <libmesh/remote_elem.h>
5 #include <libmesh/replicated_mesh.h>
6 #include <libmesh/auto_ptr.h>
23 CPPUNIT_TEST( testMesh );
26 CPPUNIT_TEST_SUITE_END();
38 _all_boundary_mesh = libmesh_make_unique<Mesh>(*
TestCommWorld);
39 _left_boundary_mesh = libmesh_make_unique<Mesh>(*
TestCommWorld);
40 _internal_boundary_mesh = libmesh_make_unique<Mesh>(*
TestCommWorld);
43 0.2, 0.8, 0.2, 0.7,
QUAD9);
48 if (!_mesh->is_serial())
50 _mesh->skip_noncritical_partitioning(
true);
51 _left_boundary_mesh->skip_noncritical_partitioning(
true);
52 _all_boundary_mesh->skip_noncritical_partitioning(
true);
53 _internal_boundary_mesh->skip_noncritical_partitioning(
true);
74 for (
auto & elem : _mesh->active_element_ptr_range())
76 const Point c = elem->centroid();
77 if (c(0) < 0.6 && c(1) < 0.4)
78 elem->subdomain_id() = 1;
80 elem->subdomain_id() = 2;
84 _mesh->get_boundary_info().sync(*_all_boundary_mesh);
86 std::set<boundary_id_type> left_id, right_id;
92 _mesh->get_boundary_info().add_elements(right_id, *_mesh);
93 _mesh->prepare_for_use();
96 _mesh->get_boundary_info().sync(left_id, *_left_boundary_mesh);
108 for (
auto & elem : _mesh->active_element_ptr_range())
110 const Point c = elem->centroid();
111 if (c(0) < 0.6 && c(1) < 0.4)
120 if (c(0) < 0.75 && c(1) < 0.4)
122 if (c(0) < 0.6 && c(1) < 0.5)
130 std::set<boundary_id_type> requested_boundary_ids;
131 requested_boundary_ids.insert(bid);
132 std::set<subdomain_id_type> subdomains_relative_to;
133 subdomains_relative_to.insert(1);
134 _mesh->get_boundary_info().sync(requested_boundary_ids,
135 *_internal_boundary_mesh,
136 subdomains_relative_to);
152 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(20),
156 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(77),
160 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(16),
161 _all_boundary_mesh->n_elem());
164 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(32),
165 _all_boundary_mesh->n_nodes());
168 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(5),
169 _left_boundary_mesh->n_elem());
172 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(11),
173 _left_boundary_mesh->n_nodes());
176 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(4),
177 _internal_boundary_mesh->n_elem());
180 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(9),
181 _internal_boundary_mesh->n_nodes());
189 for (
const auto & elem : _mesh->active_element_ptr_range())
191 const Elem * pip = elem->
dim() < 2 ? elem->interior_parent() :
nullptr;
197 CPPUNIT_ASSERT(elem->processor_id() !=
TestCommWorld->rank());
205 CPPUNIT_ASSERT_EQUAL(elem->type(),
EDGE3);
206 CPPUNIT_ASSERT_EQUAL(pip->
type(),
QUAD9);
207 CPPUNIT_ASSERT_EQUAL(pip->
level(), elem->level());
210 LIBMESH_ASSERT_FP_EQUAL(elem->centroid()(0), 0.8,
215 CPPUNIT_ASSERT_EQUAL(elem->type(),
QUAD9);
219 for (
const auto & elem : _left_boundary_mesh->active_element_ptr_range())
221 CPPUNIT_ASSERT_EQUAL(elem->type(),
EDGE3);
229 CPPUNIT_ASSERT(elem->processor_id() !=
TestCommWorld->rank());
235 CPPUNIT_ASSERT_EQUAL(pip->type(),
QUAD9);
236 CPPUNIT_ASSERT_EQUAL(pip->level(), elem->level());
239 LIBMESH_ASSERT_FP_EQUAL(elem->centroid()(0), 0.2,
243 for (
const auto & elem : _left_boundary_mesh->active_element_ptr_range())
245 CPPUNIT_ASSERT_EQUAL(elem->type(),
EDGE3);
253 CPPUNIT_ASSERT(elem->processor_id() !=
TestCommWorld->rank());
259 CPPUNIT_ASSERT_EQUAL(pip->type(),
QUAD9);
260 CPPUNIT_ASSERT_EQUAL(pip->level(), elem->level());
264 for (
const auto & elem : _internal_boundary_mesh->active_element_ptr_range())
266 CPPUNIT_ASSERT_EQUAL(elem->type(),
EDGE3);
271 CPPUNIT_ASSERT_EQUAL(static_cast<subdomain_id_type>(1),
272 elem->subdomain_id());
280 #ifdef LIBMESH_ENABLE_AMR
293 CPPUNIT_TEST( testMesh );
296 CPPUNIT_TEST_SUITE_END();
318 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(70),
319 _mesh->n_active_elem());
322 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(90),
326 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(273),
330 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(32),
331 _all_boundary_mesh->n_active_elem());
334 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(48),
335 _all_boundary_mesh->n_elem());
338 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(64),
339 _all_boundary_mesh->n_nodes());
342 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(10),
343 _left_boundary_mesh->n_active_elem());
346 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(15),
347 _left_boundary_mesh->n_elem());
350 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(21),
351 _left_boundary_mesh->n_nodes());