21#include "libmesh/boundary_info.h"
22#include "libmesh/distributed_mesh.h"
23#include "libmesh/elem.h"
24#include "libmesh/ghosting_functor.h"
25#include "libmesh/libmesh_config.h"
26#include "libmesh/libmesh_common.h"
27#include "libmesh/libmesh_logging.h"
28#include "libmesh/mesh_base.h"
29#include "libmesh/mesh_communication.h"
30#include "libmesh/null_output_iterator.h"
31#include "libmesh/mesh_tools.h"
32#include "libmesh/parallel.h"
33#include "libmesh/parallel_elem.h"
34#include "libmesh/parallel_node.h"
35#include "libmesh/parallel_ghost_sync.h"
36#include "libmesh/utility.h"
37#include "libmesh/remote_elem.h"
38#include "libmesh/int_range.h"
39#include "libmesh/elem_side_builder.h"
44#include <unordered_set>
45#include <unordered_map>
57 typedef std::vector<dof_id_type> datum;
65 void gather_data (
const std::vector<dof_id_type> & ids,
66 std::vector<datum> & neighbors)
const
68 neighbors.resize(ids.size());
78 neighbors[i].resize(n_neigh);
79 for (
unsigned int n = 0; n != n_neigh; ++n)
85 neighbors[i][n] = neigh->
id();
93 void act_on_data (
const std::vector<dof_id_type> & ids,
94 const std::vector<datum> & neighbors)
const
100 const datum & new_neigh = neighbors[i];
103 libmesh_assert_equal_to (n_neigh, new_neigh.size());
105 for (
unsigned int n = 0; n != n_neigh; ++n)
111 libmesh_assert_equal_to(old_neigh->
id(), new_neigh_id);
145 std::unordered_set<const Elem *> constraining_nodes_elems;
146 for (
const Elem * elem : connected_elements)
148 for (
const Node & node : elem->node_ref_range())
151 if (
const auto it = constraint_rows.find(&node);
152 it != constraint_rows.end())
153 for (
auto & p : it->second)
155 const Elem * constraining_elem = p.first.first;
158 if (!connected_elements.count(constraining_elem) &&
159 !new_connected_elements.count(constraining_elem))
160 constraining_nodes_elems.insert(constraining_elem);
165 newer_connected_elements.insert(constraining_nodes_elems.begin(),
166 constraining_nodes_elems.end());
169#ifdef LIBMESH_ENABLE_AMR
186 connected_elem_set_type::reverse_iterator
187 elem_rit = new_connected_elements.rbegin();
189 for (; elem_rit != new_connected_elements.rend(); ++elem_rit)
191 const Elem * elem = *elem_rit;
197 for (
const Elem * parent = elem->
parent(); parent;
198 parent = parent->parent())
199 if (!connected_elements.count(parent) &&
200 !new_connected_elements.count(parent))
201 newer_connected_elements.insert (parent);
203 auto total_family_insert =
204 [&connected_elements, &new_connected_elements,
205 &newer_connected_elements]
208 if (e->active() && e->has_children())
210 std::vector<const Elem *> subactive_family;
211 e->total_family_tree(subactive_family);
212 for (
const auto & f : subactive_family)
215 if (!connected_elements.count(f) &&
216 !new_connected_elements.count(f))
217 newer_connected_elements.insert(f);
222 total_family_insert(elem);
234 if (interior_parent &&
236 !connected_elements.count(interior_parent) &&
237 !new_connected_elements.count(interior_parent))
239 newer_connected_elements.insert (interior_parent);
240 total_family_insert(interior_parent);
250 [&connected_elements,
251 &new_connected_elements,
252 &newer_connected_elements]
259 new_connected_elements.count(parent) ||
260 newer_connected_elements.count(parent));
263 for (
const auto & elem : connected_elements)
265 for (
const auto & elem : new_connected_elements)
267 for (
const auto & elem : newer_connected_elements)
281 for (
const auto & elem : new_connected_elements)
282 for (auto & n : elem->node_ref_range())
283 if (!connected_nodes.count(&n) &&
284 !new_connected_nodes.count(&n))
285 newer_connected_nodes.insert(&n);
309 (*gf)(elem_it, elem_end, pid, elements_to_ghost);
313 for (
auto & pr : elements_to_ghost)
315 const Elem * elem = pr.first;
318 connected_elements.insert(elem);
324 for (; elem_it != elem_end; ++elem_it)
325 connected_elements.insert(*elem_it);
337#ifdef LIBMESH_ENABLE_AMR
341 for (
const auto & elem :
as_range(elem_it, elem_end))
346 connected_elements.insert(&child);
357 connected_nodes.clear();
360 connect_nodes(connected_elements, connected_nodes, connected_nodes,
373 new_connected_elements.swap(connected_elements);
374 new_connected_nodes.swap(connected_nodes);
376 while (!new_connected_elements.empty() ||
377 !new_connected_nodes.empty())
379 auto [newer_connected_elements,
380 newer_connected_nodes] =
382 (
mesh, connected_elements, connected_nodes,
383 new_connected_elements, new_connected_nodes);
386 connected_elements.merge(new_connected_elements);
387 connected_nodes.merge(new_connected_nodes);
395 new_connected_elements.swap(newer_connected_elements);
396 new_connected_nodes.swap(newer_connected_nodes);
401std::pair<connected_elem_set_type, connected_node_set_type>
408 std::pair<connected_elem_set_type, connected_node_set_type> returnval;
409 auto & [newer_connected_elements, newer_connected_nodes] = returnval;
410 connect_element_families(connected_elements, new_connected_elements,
411 newer_connected_elements, &
mesh);
413 connect_nodes(new_connected_elements, connected_nodes,
414 new_connected_nodes, newer_connected_nodes);
431#ifndef LIBMESH_HAVE_MPI
442 bool newly_coarsened_only)
const
469 mesh.unpartitioned_elements_end()) == 0);
471 LOG_SCOPE(
"redistribute()",
"MeshCommunication");
474 typedef std::remove_const<MeshBase::const_element_iterator::value_type>::type nc_v_t;
478 std::unordered_map<processor_id_type, std::vector<nc_v_t>> send_to_pid;
481#ifdef LIBMESH_ENABLE_AMR
482 newly_coarsened_only ?
485 mesh.active_elements_begin();
488#ifdef LIBMESH_ENABLE_AMR
489 newly_coarsened_only ?
492 mesh.active_elements_end();
495 for (
auto & elem :
as_range(send_elems_begin, send_elems_end))
496 if (elem->processor_id() !=
mesh.processor_id())
497 send_to_pid[elem->processor_id()].push_back(elem);
499 std::map<processor_id_type, std::vector<const Node *>> all_nodes_to_send;
500 std::map<processor_id_type, std::vector<const Elem *>> all_elems_to_send;
508 bool have_constraint_rows = !constraint_rows.empty();
516 typedef std::vector<std::pair<std::pair<dof_id_type, unsigned int>,
Real>>
519 std::vector<std::pair<dof_id_type, serialized_row_type>>>
520 all_constraint_rows_to_send;
525 for (
const auto & [pid, p_elements] : send_to_pid)
539 v_t * elempp = p_elements.data();
540 v_t * elemend = elempp + p_elements.size();
542#ifndef LIBMESH_ENABLE_AMR
565 mesh.pid_elements_end(pid),
573 all_nodes_to_send[pid].assign(connected_nodes.begin(),
574 connected_nodes.end());
576 all_elems_to_send[pid].assign(elements_to_send.begin(),
577 elements_to_send.end());
579 for (
auto & [node, row] : constraint_rows)
581 if (!connected_nodes.count(node))
584 serialized_row_type serialized_row;
585 for (
auto [elem_and_node, coef] : row)
586 serialized_row.emplace_back(
std::make_pair(elem_and_node.first->id(),
587 elem_and_node.second),
590 all_constraint_rows_to_send[pid].emplace_back
591 (node->id(), std::move(serialized_row));
596 auto null_node_action = [](
processor_id_type,
const std::vector<const Node*>&){};
597 auto null_elem_action = [](
processor_id_type,
const std::vector<const Elem*>&){};
608 if (have_constraint_rows)
610 auto constraint_row_action =
611 [&
mesh, &constraint_rows]
613 const std::vector<std::pair<dof_id_type, serialized_row_type>> rows)
615 for (
auto & [node_id, serialized_row] : rows)
618 for (
auto [elem_and_node, coef] : serialized_row)
619 row.emplace_back(
std::make_pair(
mesh.elem_ptr(elem_and_node.first),
620 elem_and_node.second),
628 all_constraint_rows_to_send,
629 constraint_row_action);
642 libmesh_assert_equal_to(n_constraint_rows, new_n_constraint_rows);
654 mesh.MeshBase::redistribute();
660#ifndef LIBMESH_HAVE_MPI
679 LOG_SCOPE(
"gather_neighboring_elements()",
"MeshCommunication");
725 std::vector<processor_id_type> adjacent_processors;
727 if (pid !=
mesh.processor_id())
728 adjacent_processors.push_back (pid);
732 cast_int<processor_id_type>(adjacent_processors.size());
738 std::vector<dof_id_type> my_interface_node_list;
739 std::vector<const Elem *> my_interface_elements;
741 std::set<dof_id_type> my_interface_node_set;
747 for (
const auto & elem :
mesh.active_local_element_ptr_range())
753 my_interface_elements.push_back(elem);
755 for (
auto s : elem->side_index_range())
756 if (elem->neighbor_ptr(s) == nullptr)
758 const Elem & side = side_builder(*elem, s);
761 my_interface_node_set.insert (side.node_id(n));
766 my_interface_node_list.reserve (my_interface_node_set.size());
767 my_interface_node_list.insert (my_interface_node_list.end(),
768 my_interface_node_set.begin(),
769 my_interface_node_set.end());
779 std::vector<std::vector<dof_id_type>>
780 my_interface_node_xfer_buffers (n_adjacent_processors, my_interface_node_list);
781 std::map<processor_id_type, unsigned char> n_comm_steps;
783 std::vector<Parallel::Request> send_requests (3*n_adjacent_processors);
784 unsigned int current_request = 0;
786 for (
unsigned int comm_step=0; comm_step<n_adjacent_processors; comm_step++)
788 n_comm_steps[adjacent_processors[comm_step]]=1;
790 my_interface_node_xfer_buffers[comm_step],
791 send_requests[current_request++],
792 element_neighbors_tag);
803 adjacent_processors.clear();
805 std::vector<dof_id_type> common_interface_node_list;
820 for (
unsigned int comm_step=0; comm_step<3*n_adjacent_processors; comm_step++)
826 element_neighbors_tag));
828 source_pid_idx = cast_int<processor_id_type>(
status.source()),
829 dest_pid_idx = source_pid_idx;
833 if (n_comm_steps[source_pid_idx] == 1)
835 n_comm_steps[source_pid_idx]++;
838 common_interface_node_list,
839 element_neighbors_tag);
851 common_interface_node_list.erase
852 (std::set_intersection (my_interface_node_list.begin(),
853 my_interface_node_list.end(),
854 common_interface_node_list.begin(),
855 common_interface_node_list.end(),
856 common_interface_node_list.begin()),
857 common_interface_node_list.end());
885 if (common_interface_node_list.empty())
895 connected_nodes.begin(),
896 connected_nodes.end(),
897 send_requests[current_request++],
898 element_neighbors_tag);
902 elements_to_send.begin(),
903 elements_to_send.end(),
904 send_requests[current_request++],
905 element_neighbors_tag);
910 adjacent_processors.push_back(source_pid_idx);
914 for (
auto & elem : my_interface_elements)
916 std::size_t n_shared_nodes = 0;
919 if (
std::binary_search (common_interface_node_list.begin(),
920 common_interface_node_list.end(),
928 if (n_shared_nodes > 0)
break;
937 if (!elements_to_send.count(elem))
939#ifdef LIBMESH_ENABLE_AMR
948 elements_to_send.insert (elem);
950 for (
auto & n : elem->node_ref_range())
951 connected_nodes.insert (&n);
962 libmesh_assert (connected_nodes.empty() || !elements_to_send.empty());
963 libmesh_assert (!connected_nodes.empty() || elements_to_send.empty());
968 connected_nodes.begin(),
969 connected_nodes.end(),
970 send_requests[current_request++],
971 element_neighbors_tag);
976 elements_to_send.begin(),
977 elements_to_send.end(),
978 send_requests[current_request++],
979 element_neighbors_tag);
984 else if (n_comm_steps[source_pid_idx] == 2)
986 n_comm_steps[source_pid_idx]++;
992 element_neighbors_tag);
996 else if (n_comm_steps[source_pid_idx] == 3)
998 n_comm_steps[source_pid_idx]++;
1004 element_neighbors_tag);
1010 libMesh::err <<
"ERROR: unexpected number of replies: "
1011 << n_comm_steps[source_pid_idx]
1031 SyncNeighbors nsync(
mesh);
1039#ifndef LIBMESH_HAVE_MPI
1057#ifndef LIBMESH_ENABLE_AMR
1058 libmesh_error_msg(
"Calling MeshCommunication::send_coarse_ghosts() requires AMR to be enabled. "
1059 "Please configure libmesh with --enable-amr.");
1068 typedef std::unordered_map<processor_id_type, std::vector<Elem *>> ghost_map;
1069 ghost_map coarsening_elements_to_ghost;
1073 for (
auto elem :
as_range(
mesh.flagged_pid_elements_begin(
Elem::COARSEN, proc_id),
1074 mesh.flagged_pid_elements_end(
Elem::COARSEN, proc_id)))
1084 if (their_proc_id != proc_id)
1085 coarsening_elements_to_ghost[their_proc_id].push_back(elem);
1088 std::map<processor_id_type, std::vector<const Node *>> all_nodes_to_send;
1089 std::map<processor_id_type, std::vector<const Elem *>> all_elems_to_send;
1099 std::set<const Node *> nodes_to_send;
1101 if (
const auto it = std::as_const(coarsening_elements_to_ghost).find(p);
1102 it != coarsening_elements_to_ghost.end())
1104 const std::vector<Elem *> & elems = it->second;
1109 Elem *
const * elempp =
const_cast<Elem *
const *
>(elems.data());
1110 Elem *
const * elemend = elempp+elems.size();
1116 for (
auto & gf :
as_range(
mesh.ghosting_functors_begin(),
1117 mesh.ghosting_functors_end()))
1121 (*gf)(elem_it, elem_end, p, elements_to_ghost);
1125 for (
auto & pr : elements_to_ghost)
1127 const Elem * elem = pr.first;
1132 elements_to_send.insert(elem);
1133 for (
auto & n : elem->node_ref_range())
1134 nodes_to_send.insert(&n);
1140 all_nodes_to_send[p].assign(nodes_to_send.begin(), nodes_to_send.end());
1141 all_elems_to_send[p].assign(elements_to_send.begin(), elements_to_send.end());
1146 auto null_node_action = [](
processor_id_type,
const std::vector<const Node*>&){};
1147 auto null_elem_action = [](
processor_id_type,
const std::vector<const Elem*>&){};
1161#ifndef LIBMESH_HAVE_MPI
1178 libmesh_parallel_only(
mesh.
comm());
1180 LOG_SCOPE(
"broadcast()",
"MeshCommunication");
1216 for (
unsigned int l=0; l != n_levels; ++l)
1218 mesh.level_elements_begin(l),
1219 mesh.level_elements_end(l),
1239 bool have_constraint_rows = !constraint_rows.empty();
1241 if (have_constraint_rows)
1244 std::vector<std::tuple<dof_id_type, unsigned int, Real>>>
1247 for (
auto & row : constraint_rows)
1249 const Node * node = row.first;
1253 std::vector<std::tuple<dof_id_type, unsigned int, Real>>
1255 for (
auto & entry : row.second)
1256 serialized_row.push_back
1257 (
std::make_tuple(entry.first.first->id(),
1258 entry.first.second, entry.second));
1260 serialized_rows.emplace(rowid, std::move(serialized_row));
1266 constraint_rows.clear();
1268 for (
auto & row : serialized_rows)
1273 std::vector<std::pair<std::pair<const Elem *, unsigned int>,
Real>>
1275 for (
auto & entry : row.second)
1276 deserialized_row.push_back
1277 (
std::make_pair(
std::make_pair(
mesh.elem_ptr(
std::get<0>(entry)),
1278 std::get<1>(entry)),
1279 std::get<2>(entry)));
1281 constraint_rows.emplace(node, deserialized_row);
1301 MeshTools::libmesh_assert_valid_procids<Elem>(
mesh);
1302 MeshTools::libmesh_assert_valid_procids<Node>(
mesh);
1309#ifndef LIBMESH_HAVE_MPI
1325 libmesh_parallel_only(
mesh.
comm());
1327 LOG_SCOPE(
"(all)gather()",
"MeshCommunication");
1330 static const std::size_t approx_total_buffer_size = 1e8;
1331 const std::size_t approx_each_buffer_size =
1340 approx_each_buffer_size) :
1342 mesh.comm().gather_packed_range (root_id,
1347 approx_each_buffer_size);
1353 for (
unsigned int l=0; l != n_levels; ++l)
1357 mesh.level_elements_begin(l),
1358 mesh.level_elements_end(l),
1360 approx_each_buffer_size) :
1364 mesh.level_elements_begin(l),
1365 mesh.level_elements_end(l),
1367 approx_each_buffer_size);
1382 bool have_constraint_rows = !constraint_rows.empty();
1384 if (have_constraint_rows)
1387 std::vector<std::tuple<dof_id_type, unsigned int, Real>>>
1390 for (
auto & row : constraint_rows)
1392 const Node * node = row.first;
1396 std::vector<std::tuple<dof_id_type, unsigned int, Real>>
1398 for (
auto & entry : row.second)
1399 serialized_row.push_back
1400 (
std::make_tuple(entry.first.first->id(),
1401 entry.first.second, entry.second));
1403 serialized_rows.emplace(rowid, std::move(serialized_row));
1414 for (
auto & row : serialized_rows)
1419 std::vector<std::pair<std::pair<const Elem *, unsigned int>,
Real>>
1421 for (
auto & entry : row.second)
1422 deserialized_row.push_back
1423 (
std::make_pair(
std::make_pair(
mesh.elem_ptr(
std::get<0>(entry)),
1424 std::get<1>(entry)),
1425 std::get<2>(entry)));
1427 constraint_rows.emplace(node, deserialized_row);
1469 SyncIds(
MeshBase & _mesh, renumber_obj _renumberer) :
1479 void gather_data (
const std::vector<dof_id_type> & ids,
1480 std::vector<datum> & ids_out)
const
1485 void act_on_data (
const std::vector<dof_id_type> & old_ids,
1486 const std::vector<datum> & new_ids)
const
1489 if (old_ids[i] != new_ids[i])
1507 typedef std::unordered_set<const Node *> uset_type;
1513 typedef std::unordered_map<dof_id_type, dof_id_type> umap_type;
1521 void gather_data (
const std::vector<dof_id_type> & ids,
1522 std::vector<datum> & ids_out)
const
1537 bool act_on_data (
const std::vector<dof_id_type> & old_ids,
1538 const std::vector<datum> & new_ids)
1540 bool data_changed =
false;
1558 libmesh_assert_equal_to
1559 (new_id, definitive_renumbering[old_id]);
1571 data_changed =
true;
1577 if (old_id != new_id)
1585 data_changed =
true;
1589 return data_changed;
1594#ifdef LIBMESH_ENABLE_AMR
1597 typedef std::pair<unsigned char,unsigned char> datum;
1605 void gather_data (
const std::vector<dof_id_type> & ids,
1606 std::vector<datum> & ids_out)
const
1608 ids_out.reserve(ids.size());
1610 for (
const auto &
id : ids)
1614 (std::make_pair(cast_int<unsigned char>(elem.
p_level()),
1619 void act_on_data (
const std::vector<dof_id_type> & old_ids,
1620 const std::vector<datum> & new_p_levels)
const
1627 (new_p_levels[i].first,
1637#ifdef LIBMESH_ENABLE_UNIQUE_ID
1638template <
typename DofObjSub
class>
1644 SyncUniqueIds(
MeshBase &_mesh, query_obj _querier) :
1653 void gather_data (
const std::vector<dof_id_type> & ids,
1654 std::vector<datum> & ids_out)
const
1656 ids_out.reserve(ids.size());
1658 for (
const auto &
id : ids)
1662 ids_out.push_back(d->unique_id());
1666 void act_on_data (
const std::vector<dof_id_type> & ids,
1667 const std::vector<datum> & unique_ids)
const
1671 DofObjSubclass * d = (
mesh.*
query)(ids[i]);
1673 d->set_unique_id(unique_ids[i]);
1679template <
typename DofObjSub
class>
1682 typedef std::vector<boundary_id_type> datum;
1691 void gather_data (
const std::vector<dof_id_type> & ids,
1692 std::vector<datum> & ids_out)
const
1694 ids_out.reserve(ids.size());
1698 for (
const auto &
id : ids)
1702 std::vector<boundary_id_type> bcids;
1704 ids_out.push_back(std::move(bcids));
1708 void act_on_data (
const std::vector<dof_id_type> & ids,
1709 const std::vector<datum> & bcids)
const
1717 boundary_info.
add_node(n, bcids[i]);
1730 libmesh_parallel_only(
mesh.
comm());
1740 LOG_SCOPE (
"make_node_ids_parallel_consistent()",
"MeshCommunication");
1742 SyncNodeIds syncids(
mesh);
1762 libmesh_parallel_only(
mesh.
comm());
1764#ifdef LIBMESH_ENABLE_UNIQUE_ID
1765 LOG_SCOPE (
"make_node_unique_ids_parallel_consistent()",
"MeshCommunication");
1783 libmesh_parallel_only(
mesh.
comm());
1785 LOG_SCOPE (
"make_node_bcids_parallel_consistent()",
"MeshCommunication");
1787 SyncBCIds<Node> syncbcids(
mesh);
1802 libmesh_parallel_only(
mesh.
comm());
1804 LOG_SCOPE (
"make_elems_parallel_consistent()",
"MeshCommunication");
1808 (
mesh,
mesh.active_elements_begin(),
1809 mesh.active_elements_end(), syncids);
1811#ifdef LIBMESH_ENABLE_UNIQUE_ID
1815 mesh.active_elements_end(), syncuniqueids);
1822#ifdef LIBMESH_ENABLE_AMR
1826 libmesh_parallel_only(
mesh.
comm());
1828 LOG_SCOPE (
"make_p_levels_parallel_consistent()",
"MeshCommunication");
1830 SyncPLevels syncplevels(
mesh);
1851 void gather_data (
const std::vector<dof_id_type> & ids,
1852 std::vector<datum> & data)
1855 data.resize(ids.size());
1873 bool act_on_data (
const std::vector<dof_id_type> & ids,
1874 const std::vector<datum> proc_ids)
1876 bool data_changed =
false;
1892 data_changed =
true;
1897 return data_changed;
1902struct ElemNodesMaybeNew
1904 ElemNodesMaybeNew() {}
1906 bool operator() (
const Elem * elem)
const
1910#ifdef LIBMESH_ENABLE_AMR
1918 for (
auto neigh : elem->neighbor_ptr_range())
1930 for (
const auto & node :
mesh.node_ptr_range())
1931 if (node->processor_id() ==
DofObject::invalid_processor_id)
1935 bool operator() (
const Elem * elem,
unsigned int local_node_num)
const
1952 LOG_SCOPE (
"make_node_proc_ids_parallel_consistent()",
"MeshCommunication");
1955 libmesh_parallel_only(
mesh.
comm());
1970 SyncProcIds sync(
mesh);
1981 LOG_SCOPE (
"make_new_node_proc_ids_parallel_consistent()",
"MeshCommunication");
1984 libmesh_parallel_only(
mesh.
comm());
2013 auto node_unpartitioned =
2014 [](
const Elem * elem,
unsigned int local_node_num)
2018 SyncProcIds sync(
mesh);
2020 sync_node_data_by_element_id_once
2021 (
mesh,
mesh.not_local_elements_begin(),
2023 node_unpartitioned, sync);
2031 NodeWasNew node_was_new(
mesh);
2034 for (
auto & elem :
mesh.element_ptr_range())
2036 if (node_was_new.was_new.count(&node))
2045 ElemNodesMaybeNew(), node_was_new, sync);
2060 libmesh_parallel_only(
mesh.
comm());
2105 libmesh_parallel_only(
mesh.
comm());
2145 const std::set<Elem *> & extra_ghost_elem_ids)
const
2150 LOG_SCOPE(
"delete_remote_elements()",
"MeshCommunication");
2170 for (
const auto & elem : extra_ghost_elem_ids)
2172 std::vector<const Elem *> active_family;
2173#ifdef LIBMESH_ENABLE_AMR
2178 active_family.push_back(elem);
2180 for (
const auto & f : active_family)
2181 elements_to_keep.insert(f);
2216 for (
int l = n_levels - 1; l >= 0; --l)
2217 for (
auto & elem :
as_range(
mesh.level_elements_begin(l),
2218 mesh.level_elements_end(l)))
2222 const bool keep_me = elements_to_keep.count(elem);
2234 for (
auto & node :
mesh.node_ptr_range())
2237 if (!connected_nodes.count(node))
2253 gf->delete_remote_elements();
2257 libmesh_assert_equal_to(n_constraint_rows, n_new_constraint_rows);
void max(const T &r, T &o, Request &req) const
void allgather_packed_range(Context *context, Iter range_begin, const Iter range_end, OutputIter out, std::size_t approx_buffer_size=1000000) const
processor_id_type size() const
void broadcast_packed_range(const Context *context1, Iter range_begin, const Iter range_end, OutputContext *context2, OutputIter out, const unsigned int root_id=0, std::size_t approx_buffer_size=1000000) const
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
void receive_packed_range(const unsigned int dest_processor_id, Context *context, OutputIter out, const T *output_type, const MessageTag &tag=any_tag) const
status probe(const unsigned int src_processor_id, const MessageTag &tag=any_tag) const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
timpi_pure bool verify(const T &r) const
void set_union(T &data, const unsigned int root_id) const
void gather_packed_range(const unsigned int root_id, Context *context, Iter range_begin, const Iter range_end, OutputIter out, std::size_t approx_buffer_size=1000000) const
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
void send_packed_range(const unsigned int dest_processor_id, const Context *context, Iter range_begin, const Iter range_end, const MessageTag &tag=no_tag, std::size_t approx_buffer_size=1000000) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
std::map< boundary_id_type, std::string > & set_sideset_name_map()
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
std::map< boundary_id_type, std::string > & set_nodeset_name_map()
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
processor_id_type processor_id() const
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Helper for building element sides that minimizes the construction of new elements.
This is the base class from which all geometric element types are derived.
void family_tree(std::vector< const Elem * > &family, bool reset=true) const
Fills the vector family with the children of this element, recursively.
RefinementState refinement_flag() const
void hack_p_level_and_refinement_flag(const unsigned int p, RefinementState pflag)
Sets the value of the p-refinement level for the element without altering the p-level of its ancestor...
const Node & node_ref(const unsigned int i) const
bool has_children() const
const Elem * parent() const
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
unsigned int n_neighbors() const
SimpleRange< NodeRefIter > node_ref_range()
Returns a range with all nodes of an element, usable in range-based for loops.
RefinementState
Enumeration of possible element refinement states.
SimpleRange< ChildRefIter > child_ref_range()
Returns a range with all children of a parent element, usable in range-based for loops.
void make_links_to_me_remote()
Resets this element's neighbors' appropriate neighbor pointers and its parent's and children's approp...
const Node * node_ptr(const unsigned int i) const
void active_family_tree(std::vector< const Elem * > &active_family, bool reset=true) const
Same as the family_tree() member, but only adds the active children.
const Elem * interior_parent() const
unsigned int p_level() const
RefinementState p_refinement_flag() const
void set_p_level(const unsigned int p)
Sets the value of the p-refinement level for the element.
const Elem * neighbor_ptr(unsigned int i) const
const Elem * top_parent() const
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?
This is the MeshBase class.
virtual const Node & node_ref(const dof_id_type i) const
virtual bool is_serial() const
void set_default_mapping_data(const unsigned char data)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
virtual void renumber_elem(dof_id_type old_id, dof_id_type new_id)=0
Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in t...
void allow_find_neighbors(bool allow)
If false is passed then this mesh will no longer work to find element neighbors when being prepared f...
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
virtual dof_id_type n_nodes() const =0
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh.
virtual dof_id_type max_node_id() const =0
virtual const Node * query_node_ptr(const dof_id_type i) const =0
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
GhostingFunctorIterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual void renumber_node(dof_id_type old_id, dof_id_type new_id)=0
Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the ...
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh.
virtual dof_id_type max_elem_id() const =0
virtual void clear()
Deletes all the element and node data that is currently stored.
void set_default_mapping_type(const ElemMappingType type)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
constraint_rows_type _constraint_rows
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
dof_id_type n_constraint_rows() const
Returns how many total constraint rows we have.
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true, const bool check_non_remote=true)=0
Locate element face (edge in 2D) neighbors.
virtual const Elem & elem_ref(const dof_id_type i) const
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
void clear_point_locator()
Releases the current PointLocator object.
GhostingFunctorIterator ghosting_functors_end() const
End of range of ghosting functors.
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
dof_id_type count_constraint_rows()
Helper function for subclasses to use to set _n_constraint_rows.
void make_node_unique_ids_parallel_consistent(MeshBase &)
Assuming all unique_ids on local nodes are globally unique, and assuming all processor ids are parall...
void delete_remote_elements(DistributedMesh &, const std::set< Elem * > &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void clear()
Clears all data structures and resets to a pristine state.
void redistribute(DistributedMesh &mesh, bool newly_coarsened_only=false) const
This method takes a parallel distributed mesh and redistributes the elements.
void make_elems_parallel_consistent(MeshBase &)
Copy ids of ghost elements from their local processors.
void make_node_bcids_parallel_consistent(MeshBase &)
Assuming all processor ids are parallel consistent, this function makes all ghost boundary ids on nod...
void send_coarse_ghosts(MeshBase &) const
Examine a just-coarsened mesh, and for any newly-coarsened elements, send the associated ghosted elem...
void make_p_levels_parallel_consistent(MeshBase &)
Copy p levels of ghost elements from their local processors.
void make_node_ids_parallel_consistent(MeshBase &)
Assuming all ids on local nodes are globally unique, and assuming all processor ids are parallel cons...
void make_node_proc_ids_parallel_consistent(MeshBase &)
Assuming all processor ids on nodes touching local elements are parallel consistent,...
void make_nodes_parallel_consistent(MeshBase &)
Copy processor_ids and ids on ghost nodes from their local processors.
void gather_neighboring_elements(DistributedMesh &) const
void gather(const processor_id_type root_id, MeshBase &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void make_new_node_proc_ids_parallel_consistent(MeshBase &)
Assuming all processor ids on nodes touching local elements are parallel consistent,...
void make_new_nodes_parallel_consistent(MeshBase &)
Copy processor_ids and ids on new nodes from their local processors.
void broadcast(MeshBase &) const
This method takes a mesh (which is assumed to reside on processor 0) and broadcasts it to all the oth...
A Node is like a Point, but with more information.
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
In parallel meshes where a ghost element has neighbors which do not exist on the local processor,...
std::unordered_set< const Node * > was_new
umap_type definitive_renumbering
void push_parallel_vector_data(const Communicator &comm, MapToVectors &&data, const ActionFunctor &act_on_data)
const unsigned int any_source
void push_parallel_packed_range(const Communicator &comm, MapToContainers &&data, Context *context, const ActionFunctor &act_on_data)
void family_tree(T elem, std::vector< T > &family, bool reset=true)
LIBMESH_DEVICE_INLINE ResultVector row(const TensorLike &T_in, const unsigned int row_index)
void sync_element_data_by_parent_id(MeshBase &mesh, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
Request data about a range of ghost elements uniquely identified by their parent id and which child t...
void sync_node_data_by_element_id(MeshBase &mesh, const MeshBase::const_element_iterator &range_begin, const MeshBase::const_element_iterator &range_end, const ElemCheckFunctor &elem_check, const NodeCheckFunctor &node_check, SyncFunctor &sync)
Synchronize data about a range of ghost nodes uniquely identified by an element id and local node id,...
void sync_dofobject_data_by_id(const Communicator &comm, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
Request data about a range of ghost dofobjects uniquely identified by their id.
The libMesh namespace provides an interface to certain functionality in the library.
void reconnect_nodes(connected_elem_set_type &connected_elements, connected_node_set_type &connected_nodes)
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
std::set< const Elem *, CompareElemIdsByLevel > connected_elem_set_type
void query_ghosting_functors(const MeshBase &mesh, processor_id_type pid, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, connected_elem_set_type &connected_elements)
void libmesh_ignore(const Args &...)
ElemMappingType
Enumeration of possible element master->physical mapping types.
const RemoteElem * remote_elem
std::set< const Node * > connected_node_set_type
void connect_element_dependencies(const MeshBase &mesh, connected_elem_set_type &connected_elements, connected_node_set_type &connected_nodes)
void connect_children(const MeshBase &mesh, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, connected_elem_set_type &connected_elements)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
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...
The definition of the const_element_iterator struct.
Used to iterate over non-nullptr entries in a container.
A do-nothing class for templated methods that expect output iterator arguments.