43 #include <unordered_map> 44 #include <unordered_set> 74 for (
const auto & elem : range)
75 _weight += elem->n_nodes();
83 #if LIBMESH_USING_THREADS 84 void join (
const SumElemWeight & other)
85 { _weight += other.weight(); }
102 FindBBox () : _bbox()
111 for (
const auto & node : range)
113 libmesh_assert(node);
114 _bbox.union_with(*node);
120 for (
const auto & elem : range)
122 libmesh_assert(elem);
123 _bbox.union_with(elem->loose_bounding_box());
127 Point &
min() {
return _bbox.min(); }
129 Point &
max() {
return _bbox.max(); }
133 #if LIBMESH_USING_THREADS 134 void join (
const FindBBox & other)
136 _bbox.union_with(other._bbox);
156 const unsigned int n_sys = d->
n_systems();
158 std::vector<unsigned int>
n_vars (n_sys, 0);
159 for (
unsigned int s = 0; s != n_sys; ++s)
164 const unsigned int tot_n_vars =
167 std::vector<unsigned int> n_comp (tot_n_vars, 0);
168 std::vector<dof_id_type> first_dof (tot_n_vars, 0);
170 for (
unsigned int s = 0, i=0; s != n_sys; ++s)
176 for (
unsigned int v = 0; v !=
n_vars[s]; ++v, ++i)
178 n_comp[i] = d->
n_comp(s,v);
190 const unsigned int * p_ui =
nullptr;
191 const std::vector<unsigned int> * p_vui =
nullptr;
192 const std::vector<dof_id_type> * p_vdid =
nullptr;
219 return weight + unpartitioned_weight;
246 std::vector<std::vector<dof_id_type>> & nodes_to_elem_map)
251 for (
auto & node : elem->node_ref_range())
253 libmesh_assert_less (node.id(), nodes_to_elem_map.size());
254 libmesh_assert_less (elem->id(),
mesh.
n_elem());
256 nodes_to_elem_map[node.id()].push_back(elem->id());
263 std::vector<std::vector<const Elem *>> & nodes_to_elem_map)
268 for (
auto & node : elem->node_ref_range())
270 libmesh_assert_less (node.id(), nodes_to_elem_map.size());
272 nodes_to_elem_map[node.id()].push_back(elem);
279 std::unordered_map<
dof_id_type, std::vector<dof_id_type>> & nodes_to_elem_map)
281 nodes_to_elem_map.clear();
284 for (
auto & node : elem->node_ref_range())
285 nodes_to_elem_map[node.id()].push_back(elem->id());
291 std::unordered_map<
dof_id_type, std::vector<const Elem *>> & nodes_to_elem_map)
293 nodes_to_elem_map.clear();
296 for (
auto & node : elem->node_ref_range())
297 nodes_to_elem_map[node.id()].push_back(elem);
302 #ifdef LIBMESH_ENABLE_DEPRECATED 304 std::vector<bool> & on_boundary)
306 libmesh_deprecated();
310 std::fill(on_boundary.begin(),
317 for (
auto s : elem->side_index_range())
318 if (elem->neighbor_ptr(s) ==
nullptr)
320 std::unique_ptr<const Elem>
side = elem->build_side_ptr(s);
322 auto nodes_on_side = elem->nodes_on_side(s);
324 for (
auto & node_id : nodes_on_side)
325 on_boundary[node_id] =
true;
330 std::unordered_set<dof_id_type>
333 std::unordered_set<dof_id_type> boundary_nodes;
338 for (
auto s : elem->side_index_range())
339 if (elem->neighbor_ptr(s) ==
nullptr)
341 auto nodes_on_side = elem->nodes_on_side(s);
343 for (
auto & local_id : nodes_on_side)
344 boundary_nodes.insert(elem->node_ptr(local_id)->id());
347 return boundary_nodes;
350 std::unordered_set<dof_id_type>
353 std::unordered_set<dof_id_type> block_boundary_nodes;
358 for (
auto s : elem->side_index_range())
359 if (elem->neighbor_ptr(s) && (elem->neighbor_ptr(s)->subdomain_id() != elem->subdomain_id()))
361 auto nodes_on_side = elem->nodes_on_side(s);
363 for (
auto & local_id : nodes_on_side)
364 block_boundary_nodes.insert(elem->node_ptr(local_id)->id());
367 return block_boundary_nodes;
371 #ifdef LIBMESH_ENABLE_DEPRECATED 378 libmesh_deprecated();
405 return find_bbox.bbox();
432 return find_bbox.bbox();
442 const Real diag = (bbox.second - bbox.first).norm();
443 const Point cent = (bbox.second + bbox.first)/2;
445 return Sphere (cent, .5*diag);
459 return find_bbox.bbox();
464 #ifdef LIBMESH_ENABLE_DEPRECATED 469 libmesh_deprecated();
496 return find_bbox.bbox();
508 const Real diag = (bbox.second - bbox.first).norm();
509 const Point cent = (bbox.second + bbox.first)/2;
511 return Sphere (cent, .5*diag);
516 #ifdef LIBMESH_ENABLE_DEPRECATED 521 libmesh_deprecated();
547 return find_bbox.bbox();
559 const Real diag = (bbox.second - bbox.first).norm();
560 const Point cent = (bbox.second + bbox.first)/2;
562 return Sphere (cent, .5*diag);
568 std::vector<ElemType> & et)
573 if (!std::count(et.begin(), et.end(), elem->type()))
574 et.push_back(elem->type());
597 const unsigned int level)
604 if ((elem->level() == level) && !elem->subactive())
616 nl =
std::max(elem->level() + 1, nl);
632 nl =
std::max(elem->level() + 1, nl);
646 nl =
std::max(elem->level() + 1, nl);
661 nl =
std::max(elem->level() + 1, nl);
670 libmesh_assert_equal_to(nl, paranoid_nl);
683 nl =
std::max(elem->level() + 1, nl);
692 std::set<dof_id_type> & not_subactive_node_ids)
695 if (!elem->subactive())
696 for (
auto & n : elem->node_ref_range())
697 not_subactive_node_ids.insert(n.id());
705 return cast_int<dof_id_type>(std::distance(begin,
end));
713 return cast_int<dof_id_type>(std::distance(begin,
end));
722 unsigned int max_p_level = 0;
727 max_p_level =
std::max(elem->p_level(), max_p_level);
732 max_p_level =
std::max(elem->p_level(), max_p_level);
735 return max_p_level + 1;
742 const std::vector<std::vector<const Elem *>> & nodes_to_elem_map,
743 std::vector<const Node *> & neighbors)
751 std::set<const Node *> neighbor_set;
758 for (
const auto & elem : nodes_to_elem_map[global_id])
764 unsigned local_node_number = elem->local_node(global_id);
769 const unsigned short n_edges = elem->n_edges();
774 switch (elem->type())
778 switch (local_node_number)
782 neighbor_set.insert(elem->node_ptr(1));
787 neighbor_set.insert(elem->node_ptr(0));
791 libmesh_error_msg(
"Invalid local node number: " << local_node_number <<
" found." << std::endl);
798 switch (local_node_number)
803 neighbor_set.insert(elem->node_ptr(2));
808 neighbor_set.insert(elem->node_ptr(0));
809 neighbor_set.insert(elem->node_ptr(1));
813 libmesh_error_msg(
"Invalid local node number: " << local_node_number <<
" found." << std::endl);
820 switch (local_node_number)
824 neighbor_set.insert(elem->node_ptr(2));
829 neighbor_set.insert(elem->node_ptr(3));
834 neighbor_set.insert(elem->node_ptr(0));
835 neighbor_set.insert(elem->node_ptr(3));
840 neighbor_set.insert(elem->node_ptr(1));
841 neighbor_set.insert(elem->node_ptr(2));
845 libmesh_error_msg(
"Invalid local node number: " << local_node_number <<
" found." << std::endl);
856 unsigned current_edge = 0;
858 const unsigned short n_nodes = elem->n_nodes();
860 while (current_edge < n_edges)
863 bool found_edge =
false;
864 for (; current_edge<n_edges; ++current_edge)
865 if (elem->is_node_on_edge(local_node_number, current_edge))
874 const Node * node_to_save =
nullptr;
877 for (
unsigned other_node_this_edge = 0; other_node_this_edge !=
n_nodes; other_node_this_edge++)
878 if ( (elem->is_node_on_edge(other_node_this_edge, current_edge)) &&
879 (elem->node_id(other_node_this_edge) != global_id))
882 node_to_save = elem->node_ptr(other_node_this_edge);
887 libmesh_assert(node_to_save !=
nullptr);
889 neighbor_set.insert(node_to_save);
901 neighbors.assign(neighbor_set.begin(), neighbor_set.end());
908 const std::unordered_map<
dof_id_type, std::vector<const Elem *>> & nodes_to_elem_map,
909 std::vector<const Node *> & neighbors)
917 std::set<const Node *> neighbor_set;
920 auto my_elems_it = nodes_to_elem_map.find(global_id);
921 libmesh_assert(my_elems_it != nodes_to_elem_map.end());
923 std::vector<const Elem *>::const_iterator
924 el = my_elems_it->second.begin(),
925 end_el = my_elems_it->second.end();
932 for (; el != end_el; ++el)
935 const Elem * elem = *el;
941 unsigned local_node_number = elem->
local_node(global_id);
946 const unsigned short n_edges = elem->
n_edges();
951 switch (elem->
type())
955 switch (local_node_number)
959 neighbor_set.insert(elem->
node_ptr(1));
964 neighbor_set.insert(elem->
node_ptr(0));
968 libmesh_error_msg(
"Invalid local node number: " << local_node_number <<
" found." << std::endl);
975 switch (local_node_number)
980 neighbor_set.insert(elem->
node_ptr(2));
985 neighbor_set.insert(elem->
node_ptr(0));
986 neighbor_set.insert(elem->
node_ptr(1));
990 libmesh_error_msg(
"Invalid local node number: " << local_node_number <<
" found." << std::endl);
997 switch (local_node_number)
1001 neighbor_set.insert(elem->
node_ptr(2));
1006 neighbor_set.insert(elem->
node_ptr(3));
1011 neighbor_set.insert(elem->
node_ptr(0));
1012 neighbor_set.insert(elem->
node_ptr(3));
1017 neighbor_set.insert(elem->
node_ptr(1));
1018 neighbor_set.insert(elem->
node_ptr(2));
1022 libmesh_error_msg(
"Invalid local node number: " << local_node_number <<
" found." << std::endl);
1033 unsigned current_edge = 0;
1037 while (current_edge < n_edges)
1040 bool found_edge =
false;
1041 for (; current_edge<n_edges; ++current_edge)
1051 const Node * node_to_save =
nullptr;
1054 for (
unsigned other_node_this_edge = 0; other_node_this_edge !=
n_nodes; other_node_this_edge++)
1056 (elem->
node_id(other_node_this_edge) != global_id))
1059 node_to_save = elem->
node_ptr(other_node_this_edge);
1064 libmesh_assert(node_to_save !=
nullptr);
1066 neighbor_set.insert(node_to_save);
1078 neighbors.assign(neighbor_set.begin(), neighbor_set.end());
1084 std::map<
dof_id_type, std::vector<dof_id_type>> & hanging_nodes)
1088 if (elem->type() ==
QUAD4)
1089 for (
auto s : elem->side_index_range())
1096 if (neigh !=
nullptr)
1099 if (neigh->
level() < elem->level())
1101 const Elem * ancestor = elem;
1103 ancestor = ancestor->
parent();
1105 libmesh_assert_less (s_neigh, neigh->
n_neighbors());
1108 unsigned int local_node1=0;
1109 unsigned int local_node2=0;
1111 bool found_in_neighbor =
false;
1114 while (!elem->is_node_on_side(local_node1++,s)) { }
1118 local_node2=local_node1+1;
1121 while (!elem->is_node_on_side(local_node2++,s)) { }
1134 for (
unsigned int n=0;n<neigh->
n_sides();n++)
1135 if (neigh->
node_id(n) == node1)
1136 found_in_neighbor=
true;
1140 if (!found_in_neighbor)
1153 local_node2=local_node1+1;
1160 if (hanging_nodes[hanging_node].size()<2)
1162 hanging_nodes[hanging_node].push_back(neigh->
node_id(local_node1));
1163 hanging_nodes[hanging_node].push_back(neigh->
node_id(local_node2));
1175 LOG_SCOPE(
"libmesh_assert_equal_n_systems()",
"MeshTools");
1182 n_sys = elem->n_systems();
1184 libmesh_assert_equal_to (elem->n_systems(), n_sys);
1190 n_sys = node->n_systems();
1192 libmesh_assert_equal_to (node->n_systems(), n_sys);
1198 #ifdef LIBMESH_ENABLE_AMR 1201 LOG_SCOPE(
"libmesh_assert_old_dof_objects()",
"MeshTools");
1209 if (elem->has_dofs())
1210 libmesh_assert(elem->old_dof_object);
1212 for (
auto & node : elem->node_ref_range())
1213 if (node.has_dofs())
1214 libmesh_assert(node.old_dof_object);
1219 #endif // LIBMESH_ENABLE_AMR 1225 LOG_SCOPE(
"libmesh_assert_valid_node_pointers()",
"MeshTools");
1232 libmesh_assert (elem);
1235 elem->libmesh_assert_valid_node_pointers();
1236 for (
auto n : elem->neighbor_ptr_range())
1238 n->libmesh_assert_valid_node_pointers();
1240 libmesh_assert_not_equal_to (elem->parent(),
remote_elem);
1241 elem = elem->parent();
1249 LOG_SCOPE(
"libmesh_assert_valid_remote_elems()",
"MeshTools");
1254 libmesh_assert (elem);
1259 for (
auto n : elem->neighbor_ptr_range())
1262 #ifdef LIBMESH_ENABLE_AMR 1265 libmesh_assert_not_equal_to (parent,
remote_elem);
1269 if (elem->active() && elem->has_children())
1270 for (
auto & child : elem->child_ref_range())
1271 libmesh_assert_not_equal_to (&child,
remote_elem);
1278 const Elem * bad_elem)
1282 libmesh_assert (elem);
1283 libmesh_assert_not_equal_to (elem->parent(), bad_elem);
1284 for (
auto n : elem->neighbor_ptr_range())
1285 libmesh_assert_not_equal_to (n, bad_elem);
1287 #ifdef LIBMESH_ENABLE_AMR 1288 if (elem->has_children())
1289 for (
auto & child : elem->child_ref_range())
1290 libmesh_assert_not_equal_to (&child, bad_elem);
1299 LOG_SCOPE(
"libmesh_assert_valid_elem_ids()",
"MeshTools");
1306 libmesh_assert (elem);
1310 libmesh_assert_greater_equal (elemid, lastelemid);
1311 libmesh_assert_greater_equal (elemprocid, lastprocid);
1313 lastelemid = elemid;
1314 lastprocid = elemprocid;
1322 LOG_SCOPE(
"libmesh_assert_valid_amr_elem_ids()",
"MeshTools");
1326 libmesh_assert (elem);
1332 libmesh_assert_greater_equal (elem->id(), parent->
id());
1333 libmesh_assert_greater_equal (elem->processor_id(), parent->
processor_id());
1342 LOG_SCOPE(
"libmesh_assert_valid_amr_interior_parents()",
"MeshTools");
1346 libmesh_assert (elem);
1350 if (elem->dim() >= LIBMESH_DIM)
1362 if (ip->
level() == elem->level())
1363 libmesh_assert_equal_to (ip->
parent(),
1367 libmesh_assert_less (ip->
level(), elem->level());
1378 LOG_SCOPE(
"libmesh_assert_connected_nodes()",
"MeshTools");
1380 std::set<const Node *> used_nodes;
1384 libmesh_assert (elem);
1386 for (
auto & n : elem->node_ref_range())
1387 used_nodes.insert(&n);
1392 libmesh_assert(node);
1393 libmesh_assert(used_nodes.count(node));
1399 namespace MeshTools {
1403 LOG_SCOPE(
"libmesh_assert_valid_boundary_ids()",
"MeshTools");
1408 libmesh_parallel_only(
mesh.
comm());
1418 const unsigned int my_n_nodes = elem ? elem->
n_nodes() : 0;
1419 const unsigned int my_n_edges = elem ? elem->
n_edges() : 0;
1420 const unsigned int my_n_sides = elem ? elem->
n_sides() : 0;
1423 n_edges = my_n_edges,
1424 n_sides = my_n_sides;
1432 libmesh_assert_equal_to(my_n_nodes,
n_nodes);
1433 libmesh_assert_equal_to(my_n_edges, n_edges);
1434 libmesh_assert_equal_to(my_n_sides, n_sides);
1440 std::vector<boundary_id_type> all_bcids;
1442 for (
unsigned int n=0; n !=
n_nodes; ++n)
1444 std::vector<boundary_id_type> bcids;
1447 boundary_info.boundary_ids(elem->
node_ptr(n), bcids);
1450 std::sort(bcids.begin(), bcids.end());
1454 all_bcids.insert(all_bcids.end(), bcids.begin(),
1460 for (
unsigned short e=0; e != n_edges; ++e)
1462 std::vector<boundary_id_type> bcids;
1466 boundary_info.edge_boundary_ids(elem, e, bcids);
1469 std::sort(bcids.begin(), bcids.end());
1474 all_bcids.insert(all_bcids.end(), bcids.begin(),
1481 boundary_info.raw_edge_boundary_ids(elem, e, bcids);
1484 std::sort(bcids.begin(), bcids.end());
1486 all_bcids.insert(all_bcids.end(), bcids.begin(),
1495 for (
unsigned short s=0; s != n_sides; ++s)
1497 std::vector<boundary_id_type> bcids;
1501 boundary_info.boundary_ids(elem, s, bcids);
1504 std::sort(bcids.begin(), bcids.end());
1506 all_bcids.insert(all_bcids.end(), bcids.begin(),
1516 boundary_info.raw_boundary_ids(elem, s, bcids);
1519 std::sort(bcids.begin(), bcids.end());
1521 all_bcids.insert(all_bcids.end(), bcids.begin(),
1530 for (
unsigned short sf=0; sf != 2; ++sf)
1532 std::vector<boundary_id_type> bcids;
1536 boundary_info.shellface_boundary_ids(elem, sf, bcids);
1539 std::sort(bcids.begin(), bcids.end());
1541 all_bcids.insert(all_bcids.end(), bcids.begin(),
1551 boundary_info.raw_shellface_boundary_ids(elem, sf, bcids);
1554 std::sort(bcids.begin(), bcids.end());
1556 all_bcids.insert(all_bcids.end(), bcids.begin(),
1566 (elem ? &all_bcids :
nullptr));
1573 LOG_SCOPE(
"libmesh_assert_valid_dof_ids()",
"MeshTools");
1578 libmesh_parallel_only(
mesh.
comm());
1584 assert_semiverify_dofobj(
mesh.
comm(),
1592 assert_semiverify_dofobj(
mesh.
comm(),
1600 LOG_SCOPE(
"libmesh_assert_contiguous_dof_ids()",
"MeshTools");
1605 libmesh_parallel_only(
mesh.
comm());
1613 for (
unsigned int v=0, nvars = node->n_vars(sysnum);
1615 for (
unsigned int c=0; c != node->n_comp(sysnum, v); ++c)
1618 min_dof_id =
std::min (min_dof_id,
id);
1619 max_dof_id =
std::max (max_dof_id,
id);
1628 for (
unsigned int v=0, nvars = node->n_vars(sysnum);
1630 for (
unsigned int c=0; c != node->n_comp(sysnum, v); ++c)
1633 libmesh_assert (
id < min_dof_id ||
1640 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1643 LOG_SCOPE(
"libmesh_assert_valid_unique_ids()",
"MeshTools");
1645 libmesh_parallel_only(
mesh.
comm());
1673 libmesh_parallel_only(
mesh.
comm());
1678 for (
dof_id_type i=0; i != parallel_max_elem_id; ++i)
1690 for (
dof_id_type i=0; i != parallel_max_node_id; ++i)
1703 libmesh_parallel_only(
mesh.
comm());
1709 for (
dof_id_type i=0; i != parallel_max_elem_id; ++i)
1713 const unsigned int my_n_nodes = elem ? elem->
n_nodes() : 0;
1714 unsigned int n_nodes = my_n_nodes;
1720 for (
unsigned int n=0; n !=
n_nodes; ++n)
1722 const Node * node = elem ? elem->
node_ptr(n) :
nullptr;
1735 LOG_SCOPE(
"libmesh_assert_topology_consistent_procids()",
"MeshTools");
1742 #ifdef LIBMESH_ENABLE_AMR 1748 libmesh_assert(elem);
1750 if (!elem->active() && !elem->subactive())
1759 bool matching_child_id =
false;
1767 matching_child_id =
true;
1768 libmesh_assert(matching_child_id);
1779 LOG_SCOPE(
"libmesh_assert_parallel_consistent_procids()",
"MeshTools");
1784 libmesh_parallel_only(
mesh.
comm());
1792 parallel_max_elem_id =
std::max(parallel_max_elem_id,
1798 for (
dof_id_type i=0; i != parallel_max_elem_id; ++i)
1814 libmesh_assert_equal_to (min_id, elem->
processor_id());
1815 libmesh_assert_equal_to (max_id, elem->
processor_id());
1819 libmesh_assert(elem);
1828 LOG_SCOPE(
"libmesh_assert_topology_consistent_procids()",
"MeshTools");
1833 libmesh_parallel_only(
mesh.
comm());
1845 parallel_max_node_id =
std::max(parallel_max_node_id,
1850 std::vector<bool> node_touched_by_me(parallel_max_node_id,
false);
1855 libmesh_assert (elem);
1857 for (
auto & node : elem->node_ref_range())
1860 node_touched_by_me[nodeid] =
true;
1863 std::vector<bool> node_touched_by_anyone(node_touched_by_me);
1868 libmesh_assert(node);
1870 libmesh_assert(!node_touched_by_anyone[nodeid] ||
1871 node_touched_by_me[nodeid]);
1879 LOG_SCOPE(
"libmesh_assert_parallel_consistent_new_node_procids()",
"MeshTools");
1884 libmesh_parallel_only(
mesh.
comm());
1892 std::vector<bool> elem_touched_by_anyone(parallel_max_elem_id,
false);
1894 for (
dof_id_type i=0; i != parallel_max_elem_id; ++i)
1898 const unsigned int my_n_nodes = elem ? elem->
n_nodes() : 0;
1899 unsigned int n_nodes = my_n_nodes;
1905 for (
unsigned int n=0; n !=
n_nodes; ++n)
1907 const Node * node = elem ? elem->
node_ptr(n) :
nullptr;
1917 LOG_SCOPE(
"libmesh_assert_parallel_consistent_procids()",
"MeshTools");
1922 libmesh_parallel_only(
mesh.
comm());
1934 parallel_max_node_id =
std::max(parallel_max_node_id,
1938 std::vector<bool> node_touched_by_anyone(parallel_max_node_id,
false);
1943 libmesh_assert (elem);
1945 for (
auto & node : elem->node_ref_range())
1948 node_touched_by_anyone[nodeid] =
true;
1955 for (
dof_id_type i=0; i != parallel_max_node_id; ++i)
1957 if (!node_touched_by_anyone[i])
1971 for (
auto & node : elem->node_ref_range())
1972 libmesh_assert_equal_to
1973 (node.processor_id(),
1974 node.choose_processor_id(node.processor_id(),
1975 elem->processor_id()));
1984 #ifdef LIBMESH_ENABLE_AMR 1987 LOG_SCOPE(
"libmesh_assert_valid_refinement_flags()",
"MeshTools");
1989 libmesh_parallel_only(
mesh.
comm());
1996 std::vector<unsigned char> my_elem_h_state(pmax_elem_id, 255);
1997 std::vector<unsigned char> my_elem_p_state(pmax_elem_id, 255);
2001 libmesh_assert (elem);
2004 my_elem_h_state[elemid] =
2005 static_cast<unsigned char>(elem->refinement_flag());
2007 my_elem_p_state[elemid] =
2008 static_cast<unsigned char>(elem->p_refinement_flag());
2010 std::vector<unsigned char> min_elem_h_state(my_elem_h_state);
2013 std::vector<unsigned char> min_elem_p_state(my_elem_p_state);
2018 libmesh_assert(my_elem_h_state[i] == 255 ||
2019 my_elem_h_state[i] == min_elem_h_state[i]);
2020 libmesh_assert(my_elem_p_state[i] == 255 ||
2021 my_elem_p_state[i] == min_elem_p_state[i]);
2028 #endif // LIBMESH_ENABLE_AMR 2032 #ifdef LIBMESH_ENABLE_AMR 2035 LOG_SCOPE(
"libmesh_assert_valid_refinement_tree()",
"MeshTools");
2039 libmesh_assert(elem);
2040 if (elem->has_children())
2041 for (
auto & child : elem->child_ref_range())
2043 libmesh_assert_equal_to (child.parent(), elem);
2046 libmesh_assert(!elem->ancestor());
2047 libmesh_assert(!elem->subactive());
2049 else if (elem->ancestor())
2051 libmesh_assert(!elem->subactive());
2054 libmesh_assert(elem->subactive());
2057 libmesh_assert_greater(elem->p_level(), 0);
2064 #endif // LIBMESH_ENABLE_AMR 2069 bool assert_valid_remote_elems)
2071 LOG_SCOPE(
"libmesh_assert_valid_neighbors()",
"MeshTools");
2075 libmesh_assert (elem);
2076 elem->libmesh_assert_valid_neighbors();
2082 libmesh_parallel_only(
mesh.
comm());
2091 const unsigned int my_n_neigh = elem ? elem->
n_neighbors() : 0;
2092 unsigned int n_neigh = my_n_neigh;
2095 libmesh_assert_equal_to (my_n_neigh, n_neigh);
2097 for (
unsigned int n = 0; n != n_neigh; ++n)
2106 p_my_neighbor = &my_neighbor;
2113 if (!assert_valid_remote_elems &&
2116 p_my_neighbor =
nullptr;
2132 typedef std::unordered_map<dof_id_type, processor_id_type> proc_id_map_type;
2136 typedef unsigned char datum;
2138 SyncNodeSet(std::unordered_set<const Node *> & _set,
2147 void gather_data (
const std::vector<dof_id_type> & ids,
2148 std::vector<datum> &
data)
2151 data.resize(ids.size());
2153 for (std::size_t i=0; i != ids.size(); ++i)
2166 bool act_on_data (
const std::vector<dof_id_type> & ids,
2167 const std::vector<datum> in_set)
2169 bool data_changed =
false;
2172 for (std::size_t i=0; i != ids.size(); ++i)
2180 data_changed =
true;
2185 return data_changed;
2190 struct NodesNotInSet
2192 NodesNotInSet(
const std::unordered_set<const Node *> _set)
2195 bool operator() (
const Node * node)
const 2202 const std::unordered_set<const Node *>
node_set;
2206 struct SyncProcIdsFromMap
2210 SyncProcIdsFromMap(
const proc_id_map_type & _map,
2219 void gather_data (
const std::vector<dof_id_type> & ids,
2220 std::vector<datum> &
data)
2223 data.resize(ids.size());
2225 for (std::size_t i=0; i != ids.size(); ++i)
2228 const proc_id_map_type::const_iterator it =
new_proc_ids.find(
id);
2233 data[i] = it->second;
2238 data[i] = node.processor_id();
2244 void act_on_data (
const std::vector<dof_id_type> & ids,
2245 const std::vector<datum> proc_ids)
2248 for (std::size_t i=0; i != ids.size(); ++i)
2261 LOG_SCOPE(
"correct_node_proc_ids()",
"MeshTools");
2264 libmesh_parallel_only(
mesh.
comm());
2294 std::unordered_set<const Node *> valid_nodes;
2301 if (!repartition_all_nodes)
2304 for (
const auto & node : elem->node_ref_range())
2305 if (elem->processor_id() == node.processor_id())
2306 valid_nodes.insert(&node);
2308 SyncNodeSet syncv(valid_nodes,
mesh);
2321 for (
auto & node : elem->node_ref_range())
2324 const proc_id_map_type::iterator it =
new_proc_ids.find(
id);
2328 it->second = node.choose_processor_id(it->second, pid);
2333 std::map<processor_id_type, std::vector<std::pair<dof_id_type, processor_id_type>>>
2339 const proc_id_map_type::iterator it =
new_proc_ids.find(
id);
2343 if (node->processor_id() != DofObject::invalid_processor_id)
2344 ids_to_push[node->processor_id()].push_back(std::make_pair(
id, pid));
2347 auto action_functor =
2350 const std::vector<std::pair<dof_id_type, processor_id_type>> &
data)
2352 for (
auto & p :
data)
2356 const proc_id_map_type::iterator it =
new_proc_ids.find(
id);
2368 std::vector<Parallel::Request> push_requests;
2371 (
mesh.
comm(), ids_to_push, push_requests, action_functor);
2377 std::unordered_set<Node *> ex_local_nodes;
2380 const proc_id_map_type::iterator it =
new_proc_ids.find(node->id());
2382 ex_local_nodes.insert(node);
2389 if (repartition_all_nodes)
2394 NodesNotInSet nnis(valid_nodes);
2401 for (
const auto & node : ex_local_nodes)
2403 if (valid_nodes.count(node))
2407 const proc_id_map_type::iterator it =
new_proc_ids.find(
id);
2409 node->processor_id() = it->second;
2416 MeshTools::libmesh_assert_valid_procids<Node>(
mesh);
void wait(std::vector< Request > &r)
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
const Elem * parent() const
A geometric point in (x,y,z) space associated with a DOF.
const unsigned int invalid_uint
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
virtual node_iterator pid_nodes_end(processor_id_type proc_id)=0
unsigned int n_comp(const unsigned int s, const unsigned int var) const
std::unique_ptr< PointLocatorBase > sub_point_locator() const
A geometric object representing a sphere.
const Elem * interior_parent() const
void skip_partitioning(bool skip)
const Elem * top_parent() const
virtual element_iterator local_elements_begin()=0
virtual element_iterator unpartitioned_elements_begin()=0
The base class for all geometric element types.
uint8_t processor_id_type
void assign_global_indices(MeshBase &) const
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
unique_id_type unique_id() const
const Parallel::Communicator & comm() const
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
Utility class for defining generic ranges for threading.
const unsigned int n_vars
const BoundaryInfo & get_boundary_info() const
virtual element_iterator active_local_subdomain_elements_end(subdomain_id_type subdomain_id)=0
long double max(long double a, double b)
processor_id_type choose_processor_id(processor_id_type pid1, processor_id_type pid2) const
SimpleRange< ChildRefIter > child_ref_range()
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
bool semiverify(const T *r) const
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const =0
processor_id_type n_processors() const
virtual bool is_serial() const
void libmesh_ignore(const Args &...)
const dof_id_type n_nodes
virtual element_iterator active_local_subdomain_elements_begin(subdomain_id_type subdomain_id)=0
static const boundary_id_type invalid_id
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual node_iterator local_nodes_end()=0
virtual unsigned int n_nodes() const =0
static const processor_id_type invalid_processor_id
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
unsigned int which_neighbor_am_i(const Elem *e) const
virtual element_iterator type_elements_end(ElemType type)=0
unsigned int n_systems() const
virtual element_iterator elements_end()=0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual SimpleRange< node_iterator > node_ptr_range()=0
virtual dof_id_type max_elem_id() const =0
Used by the Mesh to keep track of boundary nodes and elements.
SimpleRange< I > as_range(const std::pair< I, I > &p)
virtual element_iterator local_elements_end()=0
static const dof_id_type invalid_id
virtual unsigned int n_edges() const =0
void sync_dofobject_data_by_id(const Communicator &comm, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
std::string enum_to_string(const T e)
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
virtual unsigned int n_sides() const =0
virtual node_iterator local_nodes_begin()=0
const Elem * neighbor_ptr(unsigned int i) const
unsigned int level() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual node_iterator nodes_end()=0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual element_iterator type_elements_begin(ElemType type)=0
const Node * node_ptr(const unsigned int i) const
unsigned int n_neighbors() const
void parallel_reduce(const Range &range, Body &body)
virtual element_iterator unpartitioned_elements_end()=0
virtual const Node & node_ref(const dof_id_type i) const
unsigned int local_node(const dof_id_type i) const
void push_parallel_vector_data(const Communicator &comm, const MapToVectors &data, RequestContainer &reqs, ActionFunctor &act_on_data)
virtual dof_id_type max_node_id() const =0
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual element_iterator active_type_elements_end(ElemType type)=0
processor_id_type processor_id() const
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
processor_id_type processor_id() const
virtual ElemType type() const =0
long double min(long double a, double b)
A geometric point in (x,y,z) space.
dof_id_type node_id(const unsigned int i) const
bool has_children() const
virtual dof_id_type n_nodes() const =0
virtual element_iterator active_type_elements_begin(ElemType type)=0
const RemoteElem * remote_elem
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
bool verify(const T &r) const