11std::shared_ptr<chi::ChiMPICommunicatorSet>
16 std::set<int> local_graph_edges;
20 local_graph_edges.insert(
Chi::mpi.location_id);
23 for (
auto& face : cell.faces_)
25 if (face.has_neighbor_)
26 if (not face.IsNeighborLocal(*
this))
27 local_graph_edges.insert(face.GetNeighborPartitionID(*
this));
34 std::vector<int> local_connections(local_graph_edges.begin(),
35 local_graph_edges.end());
39 <<
"Communicating local connections.";
41 std::vector<std::vector<int>> global_graph(
Chi::mpi.process_count,
45 int locI_num_connections =
static_cast<int>(local_connections.size());
50 MPI_Bcast(&locI_num_connections,1,MPI_INT,locI,
Chi::mpi.comm);
53 {global_graph[locI].resize(locI_num_connections,-1);}
56 std::copy(local_connections.begin(),
57 local_connections.end(),
58 std::back_inserter(global_graph[locI]));
70 MPI_Bcast(global_graph[locI].data(),
71 static_cast<int>(global_graph[locI].size()),
76 <<
"Done communicating local connections.";
80 MPI_Group world_group;
81 MPI_Comm_group(
Chi::mpi.comm,&world_group);
83 std::vector<MPI_Group> location_groups;
84 location_groups.resize(
Chi::mpi.process_count, MPI_Group());
88 MPI_Group_incl(world_group,
89 static_cast<int>(global_graph[locI].size()),
90 global_graph[locI].data(),
91 &location_groups[locI]);
95 std::vector<MPI_Comm> communicators;
97 <<
"Building communicators.";
98 communicators.resize(
Chi::mpi.process_count, MPI_Comm());
102 int err = MPI_Comm_create_group(
Chi::mpi.comm,
103 location_groups[locI],
105 &communicators[locI]);
107 if (err != MPI_SUCCESS)
110 <<
"Communicator creation failed.";
115 <<
"Done building communicators.";
117 return std::make_shared<chi::ChiMPICommunicatorSet>(
118 communicators, location_groups, world_group);
static chi::MPI_Info & mpi
const int & process_count
Total number of processes.
LocalCellHandler local_cells
MPILocalCommSetPtr MakeMPILocalCommunicatorSet() const