445 #ifdef LIBMESH_ENABLE_AMR 447 if (elem_type ==
EDGE4 ||
455 auto refining_mesh = this->
_mesh->clone();
458 mr.uniformly_refine(n);
460 std::set<std::pair<dof_id_type, unsigned int>> parent_node_was_touched;
461 std::set<std::pair<dof_id_type, unsigned int>> parent_child_was_touched;
463 for (
const Elem * elem : refining_mesh->active_element_ptr_range())
465 CPPUNIT_ASSERT_EQUAL(elem->level(), n);
466 CPPUNIT_ASSERT(!elem->ancestor());
467 CPPUNIT_ASSERT(elem->active());
468 CPPUNIT_ASSERT(!elem->subactive());
469 CPPUNIT_ASSERT(!elem->has_children());
470 CPPUNIT_ASSERT(!elem->has_ancestor_children());
471 CPPUNIT_ASSERT(!elem->interior_parent());
474 CPPUNIT_ASSERT(parent);
475 CPPUNIT_ASSERT(parent->ancestor());
476 CPPUNIT_ASSERT(!parent->active());
477 CPPUNIT_ASSERT(!parent->subactive());
478 CPPUNIT_ASSERT(parent->has_children());
479 CPPUNIT_ASSERT(!parent->has_ancestor_children());
480 CPPUNIT_ASSERT(!parent->interior_parent());
483 CPPUNIT_ASSERT_EQUAL(parent, elem->top_parent());
484 CPPUNIT_ASSERT_EQUAL(parent, parent->top_parent());
488 CPPUNIT_ASSERT(parent != elem->top_parent());
489 CPPUNIT_ASSERT(parent != parent->top_parent());
490 CPPUNIT_ASSERT_EQUAL(elem->top_parent(), parent->top_parent());
493 CPPUNIT_ASSERT(parent->is_ancestor_of(elem));
494 const unsigned int c = parent->which_child_am_i(elem);
495 CPPUNIT_ASSERT(c < parent->n_children());
496 CPPUNIT_ASSERT_EQUAL(elem, parent->child_ptr(c));
497 parent_child_was_touched.emplace(parent->id(), c);
499 CPPUNIT_ASSERT_EQUAL(parent->n_nodes_in_child(c), elem->n_nodes());
502 CPPUNIT_ASSERT_EQUAL(parent->is_vertex_on_child(c, n), elem->is_vertex(n));
504 auto pn = parent->as_parent_node(c, n);
505 CPPUNIT_ASSERT_EQUAL(pn, parent->get_node_index(elem->node_ptr(n)));
508 CPPUNIT_ASSERT_EQUAL(parent->is_vertex_on_parent(c, n), parent->is_vertex(pn));
509 parent_node_was_touched.emplace(parent->id(), pn);
514 if (parent->is_child_on_side(c,s))
516 auto parent_side = parent->build_side_ptr(s);
521 auto child_side = elem->build_side_ptr(s);
524 if (!parent_side->infinite())
525 for (
const Node & node : child_side->node_ref_range())
526 CPPUNIT_ASSERT(parent_side->contains_point(node));
528 if (elem->neighbor_ptr(s) && !elem->neighbor_ptr(s)->is_remote())
529 CPPUNIT_ASSERT_EQUAL(parent->child_neighbor(elem->neighbor_ptr(s)), elem);
535 if (parent->is_child_on_edge(c,e))
537 auto parent_edge = parent->build_edge_ptr(e);
542 auto child_edge = elem->build_edge_ptr(e);
545 if (!parent_edge->infinite())
546 for (
const Node & node : child_edge->node_ref_range())
547 CPPUNIT_ASSERT(parent_edge->contains_point(node));
551 if (parent->has_affine_map())
552 CPPUNIT_ASSERT(elem->has_affine_map());
560 for (
const Elem * elem : refining_mesh->local_element_ptr_range())
570 std::vector<const Elem *> family;
571 elem->family_tree(family);
572 CPPUNIT_ASSERT_EQUAL(family.size(),
573 std::size_t(elem->n_children() + 1));
576 elem->total_family_tree(family);
577 CPPUNIT_ASSERT_EQUAL(family.size(),
578 std::size_t(elem->n_children() + 1));
581 elem->active_family_tree(family);
582 CPPUNIT_ASSERT_EQUAL(family.size(),
583 std::size_t(elem->n_children()));
588 elem->active_family_tree_by_side(family,s);
589 if (!elem->build_side_ptr(s)->infinite())
590 CPPUNIT_ASSERT_EQUAL(
double(family.size()),
593 CPPUNIT_ASSERT_EQUAL(
double(family.size()),
595 for (
const Elem * child : family)
597 if (child->is_remote())
600 unsigned int c = elem->which_child_am_i(child);
601 CPPUNIT_ASSERT(elem->is_child_on_side(c, s));
606 if (elem->level() + 1 == n)
610 auto it = parent_child_was_touched.find(std::make_pair(elem->id(), c));
611 CPPUNIT_ASSERT(it != parent_child_was_touched.end());
616 auto it = parent_node_was_touched.find(std::make_pair(elem->id(), n));
617 CPPUNIT_ASSERT(it != parent_node_was_touched.end());
const Elem * parent() const
A Node is like a Point, but with more information.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
libMesh::Parallel::Communicator * TestCommWorld
std::unique_ptr< Mesh > _mesh
This is the base class from which all geometric element types are derived.
Implements (adaptive) mesh refinement algorithms for a MeshBase.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
void set_union(T &data, const unsigned int root_id) const