1 #ifndef SRC_EXCHANGER_LINEAR_EXCHANGER_HPP_
2 #define SRC_EXCHANGER_LINEAR_EXCHANGER_HPP_
5 #include <athena/globals.hpp>
6 #include <athena/mesh/mesh.hpp>
20 color_.resize(Globals::nranks);
21 brank_.resize(Globals::nranks);
27 int b = brank_[Globals::my_rank];
37 CoordinateDirection dir) {
38 NeighborBlock bblock, tblock;
42 if (pmb->block_size.x1min <= pmb->pmy_mesh->mesh_size.x1min) {
46 if (pmb->block_size.x1max >= pmb->pmy_mesh->mesh_size.x1max) {
50 }
else if (dir == X2DIR) {
51 if (pmb->block_size.x2min <= pmb->pmy_mesh->mesh_size.x2min) {
55 if (pmb->block_size.x2max >= pmb->pmy_mesh->mesh_size.x2max) {
60 if (pmb->block_size.x3min <= pmb->pmy_mesh->mesh_size.x3min) {
64 if (pmb->block_size.x3max >= pmb->pmy_mesh->mesh_size.x3max) {
71 MPI_Allgather(&bblock.snb.rank, 1, MPI_INT, brank_.data(), 1, MPI_INT,
77 std::fill(color_.begin(), color_.end(), -1);
79 for (
int i = 0; i < Globals::nranks; ++i) {
81 if (brank_[i] == -1) {
82 if (color_[i] == -1) color_[i] = c++;
84 color_[i] = color_[brank_[i]];
88 if (mpi_comm_ != MPI_COMM_WORLD) {
89 MPI_Comm_free(&mpi_comm_);
92 MPI_Comm_split(MPI_COMM_WORLD, color_[Globals::my_rank], Globals::my_rank,
int GetRankInGroup() const
void Regroup(MeshBlock const *pmb, CoordinateDirection dir)
void find_neighbors(MeshBlock const *pmb, CoordinateDirection dir, NeighborBlock *bblock, NeighborBlock *tblock)
find neighbors in one coordinate direction