Skip to content

Commit

Permalink
Fix neighbor indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed May 20, 2021
1 parent ea20f3d commit 83cec77
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cajita/src/Cajita_ParticleGridDistributor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@ class ParticleGridDistributor
nid[d] = 2;
}

// Compute the destination MPI rank.
// Compute the destination MPI rank [ni + 3*(nj + 3*nk) in 3d].
int neighbor_index = nid[0];
for ( std::size_t d = 1; d < num_space_dim; ++d )
neighbor_index += pow( 3, d ) * nid[d];
{
int npower = 1;
for ( std::size_t dp = 1; dp <= d; ++dp )
npower *= 3;
neighbor_index += npower * nid[d];
}
destinations( p ) = neighbor_ranks( neighbor_index );

// Shift particles through periodic boundaries.
Expand Down

0 comments on commit 83cec77

Please sign in to comment.