25#ifndef VULPES_GEOMETRY_PARALLEL_MESH_HPP_
26#define VULPES_GEOMETRY_PARALLEL_MESH_HPP_
37#include <boost/unordered/unordered_flat_map.hpp>
38#include <boost/unordered/unordered_flat_set.hpp>
73template <
typename Mesh>
83 using SetType = boost::unordered_flat_set<index_t>;
92 inline static constexpr auto self_dim = Mesh::self_dim;
112 std::unique_ptr<Mesh> mesh_ptr;
114 mesh_ptr = std::make_unique<Mesh>(generator());
129 template <
class Archive>
131 ar&
static_cast<Mesh&
>(*this);
153 return (
static_cast<const Mesh&
>(lhs) ==
static_cast<const Mesh&
>(rhs)) &&
182 assert(
mpi::size() < rank0_mesh->numCells());
184 std::cout <<
"Initializing parallel mesh" << std::endl;
187 std::cout <<
"partitionWithParmetis" << std::endl;
189 std::vector<index_t> partition;
190 if constexpr (std::is_same_v<index_t, SCOTCH_Num>) {
191 partition = std::move(partition_parmetis);
193 partition.assign(partition_parmetis.begin(), partition_parmetis.end());
195 std::cout <<
"buildGhostCells" << std::endl;
197 std::cout <<
"buildLocalCellToEntityMaps" << std::endl;
199 std::cout <<
"buildLocalRenumbering" << std::endl;
201 std::cout <<
"buildLocalEntityToCellMaps" << std::endl;
203 std::cout <<
"buildLocalToLocalMaps" << std::endl;
241 constexpr static inline bool parallel() {
return true; }
282 template <std::
size_t req_dim>
284 if constexpr (req_dim == 0) {
286 }
else if constexpr (
self_dim == 2 && req_dim == 1) {
288 }
else if constexpr (
self_dim == 3 && req_dim == 1) {
290 }
else if constexpr (
self_dim == 3 && req_dim == 2) {
293 static_assert(
false,
"getEntityToCellGlobalMap: unsupported dimension");
383 const std::vector<index_t>& vertex_numbering,
int destination);
509template <
typename Mesh>
511 using real_t = float;
515 std::vector<SCOTCH_Num> vtxdist(size + 1);
517 std::vector<SCOTCH_Num> xadj;
518 std::vector<SCOTCH_Num> adjncy;
525 for (
int i = 0; i < size; ++i) {
527 vtxdist[i] + dual.size() / size + (i < (dual.size() % size));
529 assert(vtxdist.back() == dual.size());
532 for (
int p = 1; p < size; ++p) {
533 xadj.resize(vtxdist[p + 1] - vtxdist[p] + 1);
534 const std::size_t adjncy_size =
535 dual.indices()[vtxdist[p + 1]] - dual.indices()[vtxdist[p]];
536 const auto offset = dual.indices()[vtxdist[p]];
537 for (std::size_t j = 0; j < xadj.size(); ++j) {
538 xadj[j] = dual.indices()[j + vtxdist[p]] - offset;
542 mpi::send(&dual.data()[offset], adjncy_size, p);
547 dual.indices().begin(), dual.indices().begin() + vtxdist[1] + 1);
549 dual.data().begin(), dual.data().begin() + dual.indices()[vtxdist[1]]);
553 mpi::recv(adjncy.data(),
static_cast<int32_t
>(adjncy.size()), 0);
559 SCOTCH_Num wgtflag = 0;
560 SCOTCH_Num numflag = 0;
561 SCOTCH_Num nparts = size;
563 const SCOTCH_Num random_seed = 0;
564 SCOTCH_Num options[3] = {1, 0, random_seed};
565 std::vector<real_t> tpwgts(nparts);
566 for (
int i = 0; i < size; ++i) {
567 tpwgts[i] = 1. /
static_cast<double>(nparts);
571 std::vector<SCOTCH_Num> part(vtxdist[rank + 1] - vtxdist[rank]);
573 std::cout <<
"Partition the graph;" << std::endl;
575 auto comm = MPI_COMM_WORLD;
576 ParMETIS_V3_PartKway(
577 vtxdist.data(), xadj.data(), adjncy.data(),
nullptr,
nullptr, &wgtflag,
578 &numflag, &ncon, &nparts, tpwgts.data(), &ubvec, options, &
m_edgecut,
583template <
typename Mesh>
585 std::vector<index_t>& part) {
587 std::vector<index_t> all_parts;
590 std::cout <<
"Partitioning completed. Edge cuts: " <<
m_edgecut
594 for (
int p = 1; p < size; ++p) {
597 all_parts.insert(all_parts.end(), part.begin(), part.end());
604 Eigen::MatrixXi dense_proc_adj = Eigen::MatrixXi::Zero(size, size);
605 for (
index_t cell_id = 0; cell_id < dual.size(); ++cell_id) {
606 const auto src_cell_proc = all_parts[cell_id];
607 for (
index_t neigh_cell_id : dual[cell_id]) {
608 const auto dst_cell_proc = all_parts[neigh_cell_id];
609 dense_proc_adj(src_cell_proc, dst_cell_proc) = 1;
613 uncomp_proc_adj.
resize(size);
614 for (Eigen::Index i = 0; i < dense_proc_adj.rows(); ++i) {
615 for (Eigen::Index j = 0; j < dense_proc_adj.cols(); ++j) {
616 if (dense_proc_adj(i, j)) {
621 const auto proc_adj = uncomp_proc_adj.template compress<index_t>();
622 const auto [perm, perm_inv] =
624 for (std::size_t i = 0; i < all_parts.size(); ++i) {
625 all_parts[i] = perm[all_parts[i]];
628 for (std::size_t cell_id = 0; cell_id < all_parts.size(); ++cell_id) {
632 for (
int p = 0; p < size; ++p) {
637 for (
int p = 1; p < size; ++p) {
650template <
typename Mesh>
656 auto it = std::lower_bound(
660 ghost_cell_set.insert(glob_neigh_id);
668 ghost_cell_set.end());
671template <
typename Mesh>
679 for (
int p = 1; p < size; ++p) {
695template <
typename Mesh>
713template <
typename Mesh>
718 for (
int p = 1; p < size; ++p) {
721 const auto cell_to_vtx_loc =
724 const auto cell_to_facet_loc =
m_rank0_mesh->getCellToFacetMap().slice(
728 const auto cell_to_edge_loc =
m_rank0_mesh->getCellToEdgeMap().slice(
736 this->getCellToVtxMap() =
738 this->getCellToFacetMap() =
741 this->getCellToEdgeMap() =
m_rank0_mesh->getCellToEdgeMap().slice(
754template <
typename Mesh>
759 for (
int p = 0; p < size; ++p) {
760 const auto cell_to_vtx_loc =
765 this->getCellToVtxMap() = cell_to_vtx_loc;
772 const auto& vtx_loc = this->getCellToVtxMap().data();
773 SetType need_vtxs_set(vtx_loc.begin(), vtx_loc.end());
774 std::vector<index_t> need_vtxs(need_vtxs_set.begin(), need_vtxs_set.end());
777 std::vector<index_t> need_vtxs_tmp;
778 for (
int p = 1; p < size; ++p) {
782 this->getVtxToCellMap() =
m_rank0_mesh->getVtxToCellMap().slice(need_vtxs);
788 boost::unordered_flat_map<index_t, index_t> vtx_glob_to_loc;
789 for (std::size_t i = 0; i < need_vtxs.size(); ++i) {
790 vtx_glob_to_loc[need_vtxs[i]] = i;
793 const auto n_loc_cell = this->getCellToVtxMap().size();
795 weak_dual_uncompressed.
resize(n_loc_cell);
796 for (
index_t loc_cell_id = 0; loc_cell_id < n_loc_cell; ++loc_cell_id) {
798 for (
auto glob_vtx_id : this->getCellToVtxMap()[loc_cell_id]) {
799 const auto loc_vtx_id = vtx_glob_to_loc[glob_vtx_id];
800 for (
auto glob_neigh_cell : this->getVtxToCellMap()[loc_vtx_id]) {
801 weak_neigh.insert(glob_neigh_cell);
804 weak_dual_uncompressed[loc_cell_id].assign(
805 weak_neigh.begin(), weak_neigh.end());
807 m_weak_dual = weak_dual_uncompressed.template compress<index_t>();
810template <
typename Mesh>
812 SetType vtx_idxs, facet_idxs, edge_idxs;
816 for (
index_t cell_id = 0; cell_id < n_owned_cells; ++cell_id) {
817 for (
const auto vtx_id : this->getCellToVtxMap()[cell_id]) {
818 vtx_idxs.insert(vtx_id);
820 for (
const auto facet_id : this->getCellToFacetMap()[cell_id]) {
821 facet_idxs.insert(facet_id);
824 for (
const auto edge_id : this->getCellToEdgeMap()[cell_id]) {
825 edge_idxs.insert(edge_id);
835 for (std::size_t d = 0; d <
self_dim; ++d) {
840 const auto n_total_cells = n_ghost_cells + n_owned_cells;
841 for (
index_t cell_id = n_owned_cells; cell_id < n_total_cells; ++cell_id) {
842 for (
const auto vtx_id : this->getCellToVtxMap()[cell_id]) {
843 const auto [it, inserted] = vtx_idxs.insert(vtx_id);
848 for (
const auto facet_id : this->getCellToFacetMap()[cell_id]) {
849 const auto [it, inserted] = facet_idxs.insert(facet_id);
855 for (
const auto edge_id : this->getCellToEdgeMap()[cell_id]) {
856 const auto [it, inserted] = edge_idxs.insert(edge_id);
863 for (std::size_t d = 0; d <
self_dim; ++d) {
868 for (std::size_t d = 0; d <
self_dim + 1; ++d) {
870 for (std::size_t i = 0; i < local_map.size(); ++i) {
876template <
typename Mesh>
878 const auto initialize_dim = [
this](std::size_t dim) {
879 auto& local_tag_table = this->getMeshTags().tags[dim];
880 local_tag_table.clear();
882 std::vector<std::string> tag_names;
884 const auto& global_tag_table =
m_rank0_mesh->getMeshTags().tags[dim];
885 for (
const auto& [tag_name, tag_values] : global_tag_table) {
886 if (tag_values.size() ==
888 tag_names.push_back(tag_name);
892 std::sort(tag_names.begin(), tag_names.end());
895 std::size_t n_tags = tag_names.size();
898 tag_names.resize(n_tags);
901 for (
auto& tag_name : tag_names) {
905 const auto build_local_tag =
906 [](
const std::vector<index_t>& global_tag,
907 const std::vector<index_t>& local_to_global) {
908 std::vector<index_t> local_tag;
909 local_tag.reserve(local_to_global.size());
910 for (
const auto global_id : local_to_global) {
911 local_tag.push_back(global_tag[global_id]);
916 const auto& global_tag_table =
m_rank0_mesh->getMeshTags().tags[dim];
918 for (
const auto& tag_name : tag_names) {
919 local_tag_table[tag_name] = build_local_tag(
924 for (
const auto& tag_name : tag_names) {
925 local_tag_table[tag_name] = {};
929 initialize_dim(Mesh::VtxEnty);
930 initialize_dim(Mesh::CellEnty);
933template <
typename Mesh>
935 const std::vector<index_t>& vertex_numbering,
int destination) {
937 const auto build_local_tag = [](
const std::vector<index_t>& global_tag,
938 const std::vector<index_t>& local_to_global) {
939 std::vector<index_t> local_tag;
940 local_tag.reserve(local_to_global.size());
941 for (
const auto global_id : local_to_global) {
942 local_tag.push_back(global_tag[global_id]);
946 const auto send_dim = [
this, destination, &build_local_tag](
948 const std::vector<index_t>& numbering) {
949 const auto& global_tag_table =
m_rank0_mesh->getMeshTags().tags[dim];
950 const auto& local_tag_table = this->getMeshTags().tags[dim];
952 std::vector<std::string> tag_names;
953 tag_names.reserve(local_tag_table.size());
954 for (
const auto& [tag_name, tag_values] : local_tag_table) {
955 tag_names.push_back(tag_name);
957 std::sort(tag_names.begin(), tag_names.end());
959 for (
const auto& tag_name : tag_names) {
960 const auto local_tag =
961 build_local_tag(global_tag_table.at(tag_name), numbering);
966 send_dim(Mesh::VtxEnty, vertex_numbering);
971template <
typename Mesh>
973 const auto receive_dim = [
this](std::size_t dim) {
974 auto& local_tag_table = this->getMeshTags().tags[dim];
976 std::vector<std::string> tag_names;
977 tag_names.reserve(local_tag_table.size());
978 for (
const auto& [tag_name, tag_values] : local_tag_table) {
979 tag_names.push_back(tag_name);
982 std::sort(tag_names.begin(), tag_names.end());
984 for (
const auto& tag_name : tag_names) {
985 std::vector<index_t> local_tag;
987 local_tag_table[tag_name] = std::move(local_tag);
991 receive_dim(Mesh::VtxEnty);
992 receive_dim(Mesh::CellEnty);
995template <
typename Mesh>
1005 std::array<std::vector<index_t>,
self_dim> local_numbering;
1006 for (
int p = 1; p < size; ++p) {
1008 for (std::size_t d = 0; d <
self_dim; ++d) {
1015 const auto vtx_loc =
1021 const auto facet_to_vtx_loc =
m_rank0_mesh->getFacetToVtxMap().slice(
1026 const auto edge_to_cell_loc =
m_rank0_mesh->getEdgeToCellMap().slice(
1037 this->getVertexes() =
1041 this->getFacetToVtxMap() =
1043 this->getVtxToCellMap() =
1046 this->getEdgeToCellMap() =
m_rank0_mesh->getEdgeToCellMap().slice(
1053 for (std::size_t d = 0; d <
self_dim; ++d) {
1061 mpi::recv(this->getFacetToCellMap(), 0);
1072template <
typename Mesh>
1083 owned_table[global_cell_id] =
true;
1087 this->getDualMap().size() ==
1089 for (
auto& glob_cell_id : this->getDualMap().data()) {
1090 if (!owned_table[glob_cell_id]) {
1094 this->getDualMap().remove(-1);
1096 const auto n_loc_faces = this->getFacetToCellMap().size();
1097 for (std::size_t loc_face_id = 0; loc_face_id < n_loc_faces; ++loc_face_id) {
1098 for (
auto& glob_cell_id : this->getFacetToCellMap()[loc_face_id]) {
1099 if (glob_cell_id == -1) {
1102 if (!owned_table[glob_cell_id]) {
1108 for (
auto& glob_cell_id : this->getVtxToCellMap().data()) {
1109 if (!owned_table[glob_cell_id]) {
1113 this->getVtxToCellMap().remove(-1);
1116 for (
auto& glob_cell_id : this->getEdgeToCellMap().data()) {
1117 if (!owned_table[glob_cell_id]) {
1121 this->getEdgeToCellMap().remove(-1);
1125template <
typename Mesh>
1128 for (std::size_t d = 0; d <
self_dim + 1; ++d) {
1135template <
typename Mesh>
1144 for (
auto& cid : this->m_dual_graph.data()) {
1147 for (
auto& fid : this->m_cell_to_facet.data()) {
1150 for (
auto& vid : this->m_cell_to_vtx.data()) {
1153 for (
auto& cid0cid1 : this->m_facet_to_cell) {
1154 if (cid0cid1[0] !=
static_cast<index_t>(-1)) {
1157 if (cid0cid1[1] !=
static_cast<index_t>(-1)) {
1161 for (
auto& vid : this->m_facet_to_vtx.data()) {
1164 for (
auto& cid : this->m_vtx_to_cell.data()) {
1173 for (
auto& v1v2 : this->m_edge_to_vtx) {
1177 for (
auto& eid : this->m_cell_to_edge.data()) {
1180 for (
auto& cid : this->m_edge_to_cell.data()) {
1186template <
typename Mesh>
1191 int is_periodic = 0;
1195 ((md.doubles.count(
"XPeriod") > 0) && (md.doubles.count(
"YPeriod") > 0))
1205 std::vector<double> x_period, y_period, ghost_x, ghost_y;
1206 std::vector<index_t> global_n_vtx_vec;
1207 std::vector<index_t> serial_cdata, serial_cindices;
1211 x_period = md.doubles.at(
"XPeriod");
1212 y_period = md.doubles.at(
"YPeriod");
1213 ghost_x = md.doubles.at(
"GhostVertices_x");
1214 ghost_y = md.doubles.at(
"GhostVertices_y");
1215 global_n_vtx_vec = {
1216 static_cast<index_t>(md.ints.at(
"NumVertices").front())};
1220 const auto& ct =
m_rank0_mesh->getMeshTags().tags[Mesh::CellEnty];
1221 if (ct.count(
"CellToVtxMap_with_ghosts_data")) {
1222 serial_cdata.assign(
1223 ct.at(
"CellToVtxMap_with_ghosts_data").begin(),
1224 ct.at(
"CellToVtxMap_with_ghosts_data").end());
1225 serial_cindices.assign(
1226 ct.at(
"CellToVtxMap_with_ghosts_indices").begin(),
1227 ct.at(
"CellToVtxMap_with_ghosts_indices").end());
1229 serial_cdata = md.ints.at(
"CellToVtxMap_with_ghosts_data");
1230 serial_cindices = md.ints.at(
"CellToVtxMap_with_ghosts_indices");
1242 const index_t global_n_vtx = global_n_vtx_vec[0];
1251 std::vector<index_t> local_cdata;
1252 std::vector<index_t> local_cindices;
1253 local_cindices.reserve(n_local_cells + 1);
1254 local_cindices.push_back(0);
1256 for (
index_t loc_cid = 0; loc_cid < n_local_cells; ++loc_cid) {
1258 const index_t start = serial_cindices[glob_cid];
1259 const index_t end = serial_cindices[glob_cid + 1];
1260 for (
index_t k = start; k < end; ++k) {
1261 const index_t vtx = serial_cdata[k];
1262 if (vtx < global_n_vtx) {
1269 local_cdata.push_back(local_n_vtx + (vtx - global_n_vtx));
1272 local_cindices.push_back(
static_cast<index_t>(local_cdata.size()));
1277 auto& md = this->getMetadata();
1278 md.doubles[
"XPeriod"] = std::move(x_period);
1279 md.doubles[
"YPeriod"] = std::move(y_period);
1280 md.doubles[
"GhostVertices_x"] = std::move(ghost_x);
1281 md.doubles[
"GhostVertices_y"] = std::move(ghost_y);
1282 md.ints[
"NumVertices"] = {local_n_vtx};
1283 md.ints[
"CellToVtxMap_with_ghosts_data"] = std::move(local_cdata);
1284 md.ints[
"CellToVtxMap_with_ghosts_indices"] = std::move(local_cindices);
A class that behaves like a vector of vectors, providing automatic row range checking.
Definition crs_map.hpp:758
constexpr void resize(std::size_t new_size)
Resizes the map to contain the specified number of SmallVector objects.
Definition crs_map.hpp:807
constexpr void push_back(const SmallVector< DataType, N > &value)
Appends a copy of a SmallVector to the map.
Definition crs_map.hpp:830
Definition crs_map.hpp:72
constexpr const auto & localToGlobal(std::size_t d) const
Local to global map for geometric entities of a certain dim.
Definition parallel_mesh.hpp:246
std::vector< index_t > m_all_ghost_size
number of ghost cells for each proc, only rank 0 knows it
Definition parallel_mesh.hpp:496
static constexpr auto self_dim
The dimension of the mesh (e.g., 2 for a 2D mesh, 3 for a 3D mesh).
Definition parallel_mesh.hpp:92
Mesh::EdgeToCellMap m_edge_to_cell_glob
Definition parallel_mesh.hpp:506
void sendMeshTags(const std::vector< index_t > &vertex_numbering, int destination)
Builds and sends local mesh tags from rank 0 to another rank.
Definition parallel_mesh.hpp:934
void reconstructPartitioningAndScatterDual(std::vector< index_t > &part)
Reconstructs the full mesh partitioning on rank 0 and scatters the (strong) dual graph.
Definition parallel_mesh.hpp:584
Mesh::EdgeToVtxMap m_edge_to_vtx_glob
Definition parallel_mesh.hpp:504
Mesh::FacetToVtxMap m_facet_to_vtx_glob
Definition parallel_mesh.hpp:502
std::array< index_t, Mesh::self_dim+1 > m_global_entity_size
global number of vertices, edges, faces, cells
Definition parallel_mesh.hpp:452
void initFromRank0(std::unique_ptr< Mesh > rank0_mesh)
Parallelizes a mesh that has already been built on rank 0.
Definition parallel_mesh.hpp:180
constexpr index_t nOwnedCells() const
Number of cells owned by this proc.
Definition parallel_mesh.hpp:219
const auto & getFacetToCellGlobalMap() const
Definition parallel_mesh.hpp:267
boost::unordered_flat_map< index_t, index_t > GlobalToLocalMap
Alias for an unordered map from global indices to local indices.
Definition parallel_mesh.hpp:87
const auto & getRank0Mesh() const
Returns a constant reference to the original mesh on rank 0, valid only for root.
Definition parallel_mesh.hpp:262
void buildLocalCellToEntityMaps()
Builds and distributes local cell-to-entity maps.
Definition parallel_mesh.hpp:714
Mesh::DualMap m_dual_graph_glob
Definition parallel_mesh.hpp:498
const auto & getCellToVtxGlobalMap() const
Definition parallel_mesh.hpp:266
void collectGhostCellsInRoot()
Gathers ghost cell information on the root process.
Definition parallel_mesh.hpp:672
Mesh::FacetToCellMap m_facet_to_cell_glob
Definition parallel_mesh.hpp:501
std::array< index_t, Mesh::self_dim+1 > m_ghost_enty_size
number of ghost [vtxs, edge, facet, cell] owned by this process, they are the last ones in the local ...
Definition parallel_mesh.hpp:475
const auto & getFacetToVtxGlobalMap() const
Definition parallel_mesh.hpp:268
void initializeMeshTags()
Initializes vertex and cell mesh tags.
Definition parallel_mesh.hpp:877
std::vector< std::vector< index_t > > m_all_own_and_ghost_cell_id
global mesh partitioning, only rank 0 knows it
Definition parallel_mesh.hpp:488
void buildWeakDual()
Builds the weak dual graph of the local mesh partition.
Definition parallel_mesh.hpp:755
void buildLocalToLocalMaps()
Converts global entity numbering in the maps to local numbering.
Definition parallel_mesh.hpp:1136
const auto & getCellToEdgeGlobalMap() const
Definition parallel_mesh.hpp:271
const auto & getEdgeToVtxGlobalMap() const
Definition parallel_mesh.hpp:270
void buildGhostCells(std::vector< index_t > &part)
Builds the ghost cells for the mesh.
Definition parallel_mesh.hpp:696
std::array< index_t, Mesh::self_dim+1 > m_own_enty_size
number of [vtxs, edge, facet, cell] owned by this process
Definition parallel_mesh.hpp:470
SCOTCH_Num m_edgecut
number of edge cuts ParMetis makes
Definition parallel_mesh.hpp:480
Mesh::CellToFacetMap m_cell_to_facet_glob
Definition parallel_mesh.hpp:499
constexpr index_t nLocEntity(std::size_t dim) const
Number of geometric entities of a certain dim (see enum Entity) owned by this proc.
Definition parallel_mesh.hpp:212
ParallelMesh()=default
Default constructor.
static constexpr bool parallel()
Returns true if the mesh is parallel, which it is.
Definition parallel_mesh.hpp:241
std::unique_ptr< Mesh > m_rank0_mesh
A unique pointer to the original mesh.
Definition parallel_mesh.hpp:442
void buildLocalEntityToCellMaps()
Builds and distributes local entity-to-cell maps.
Definition parallel_mesh.hpp:996
std::vector< SCOTCH_Num > partitionWithParmetis()
Partitions the mesh's dual graph using ParMETIS.
Definition parallel_mesh.hpp:510
typename Mesh::index_t index_t
Alias for the index type of the base mesh class.
Definition parallel_mesh.hpp:79
void receiveMeshTags()
Receives local vertex and cell tags from rank 0.
Definition parallel_mesh.hpp:972
std::array< GlobalToLocalMap, Mesh::self_dim+1 > m_global_numbering
global to local numbering of vertices, edges, faces, cells
Definition parallel_mesh.hpp:465
std::vector< index_t > m_all_own_size
number of owned cells for each proc, only rank 0 knows it
Definition parallel_mesh.hpp:492
void serialize(Archive &ar, const unsigned int)
Serializes the parallel mesh data.
Definition parallel_mesh.hpp:130
boost::unordered_flat_set< index_t > SetType
Alias for an unordered set of indices, optimized for performance.
Definition parallel_mesh.hpp:83
ParallelMesh(const MeshGenerator &generator)
Constructor that generates a mesh on rank 0 and then parallelizes it.
Definition parallel_mesh.hpp:111
constexpr index_t nGhostEntity(std::size_t dim) const
Number of ghost geometric entities of a certain dim (see enum Entity) for this proc.
Definition parallel_mesh.hpp:225
datastructure::CrsMap< index_t, index_t > m_weak_dual
cell to cell mapping of cells that share at least a vertex
Definition parallel_mesh.hpp:447
void removeNotOwnedFromLocalEntityToCellMaps()
Removes references to non-owned cells from the local entity-to-cell maps.
Definition parallel_mesh.hpp:1073
const auto & getVtxToCellGlobalMap() const
Definition parallel_mesh.hpp:269
friend bool operator==(const ParallelMesh &lhs, const ParallelMesh &rhs)
Compares two ParallelMesh objects for equality.
Definition parallel_mesh.hpp:152
const auto & getCellToFacetGlobalMap() const
Definition parallel_mesh.hpp:265
std::function< Mesh()> MeshGenerator
A function object that generates a serial mesh.
Definition parallel_mesh.hpp:97
Mesh::CellToVtxMap m_cell_to_vtx_glob
Definition parallel_mesh.hpp:500
Mesh::VtxToCellMap m_vtx_to_cell_glob
Definition parallel_mesh.hpp:503
const auto & getEdgeToCellGlobalMap() const
Definition parallel_mesh.hpp:272
void buildGhostCellsFromWeakDual()
Determines ghost cells based on the weak dual graph.
Definition parallel_mesh.hpp:651
void buildLocalRenumbering()
Establishes local-to-global and global-to-local numbering for all entities.
Definition parallel_mesh.hpp:811
constexpr index_t nEntity(std::size_t dim) const
Global number of geometric entities of a certain dim (see enum Entity).
Definition parallel_mesh.hpp:233
void distributePeriodicMetadata()
If the serial mesh had periodic topology, broadcasts the periodic ghost-vertex metadata from rank 0 a...
Definition parallel_mesh.hpp:1187
constexpr auto & getEntityToCellGlobalMap() const
A template function that returns the global entity-to-cell map for a given dimension.
Definition parallel_mesh.hpp:283
constexpr const auto & globalToLocal(std::size_t d) const
Global to local map for geometric entities of a certain dim.
Definition parallel_mesh.hpp:252
void buildGlobalEntitySize()
Gathers and broadcasts the total number of global entities.
Definition parallel_mesh.hpp:1126
const auto & getDualGlobalMap() const
Definition parallel_mesh.hpp:264
std::array< std::vector< index_t >, Mesh::self_dim+1 > m_local_numbering
local to global numbering of vertices, edges, faces, cells
Definition parallel_mesh.hpp:459
Mesh::CellToEdgeMap m_cell_to_edge_glob
Definition parallel_mesh.hpp:505
Permutation< T > computeReverseCuthillMckeeOrdering(const datastructure::CrsMap< T, T > &sparsity_pattern, bool reversed)
Returns the permutation array that orders a sparse CSR matrix in Reverse-Cuthill McKee ordering.
Definition numbering.hpp:89
Definition abs_agg_model.cpp:40
void recv(T *data, int count, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
Receive count contiguous values of type T from a source rank.
Definition mpi_wrappers.hpp:311
static int rank()
Return the MPI rank in MPI_COMM_WORLD.
Definition mpi_wrappers.hpp:116
static int size()
Return the size of MPI_COMM_WORLD.
Definition mpi_wrappers.hpp:124
static bool root()
Return true if the rank in MPI_COMM_WORLD is zero.
Definition mpi_wrappers.hpp:132
void send(const T *data, int count, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
Send count contiguous values of type T to a destination rank.
Definition mpi_wrappers.hpp:149
void bcast(T *data, int count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Broadcast count contiguous values of type T from root.
Definition mpi_wrappers.hpp:495
std::vector< T > slice(const std::vector< T > &source, const std::vector< IndexType > &indices)
Build a new vector by selecting elements of source at the given indices.
Definition vvutils.hpp:117
Definition cell_manager.hpp:38
#define PROFILE_INTERVAL(func)
Time a single execution of func under the label #func using Profiler::startInterval()/stopInterval().
Definition profiler.hpp:56