Skip to content

Commit

Permalink
fix(ranks ordering)
Browse files Browse the repository at this point in the history
  • Loading branch information
YL-codehub committed Aug 29, 2024
1 parent fab3b9a commit 98ac4ce
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ExampleCodes/SWFFT/SWFFT_poisson/swfft_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ swfft_solver(MultiFab& rhs, MultiFab& soln, Geometry& geom, int verbose)
amrex::Error("NBOXES NOT COMPUTED CORRECTLY");
amrex::Print() << "Number of boxes:\t" << nboxes << std::endl;

Vector<int> rank_mapping;
rank_mapping.resize(nboxes);

DistributionMapping dmap = rhs.DistributionMap();

for (int ib = 0; ib < nboxes; ++ib)
{
int i = ba[ib].smallEnd(0) / nx;
int j = ba[ib].smallEnd(1) / ny;
int k = ba[ib].smallEnd(2) / nz;

int local_index = k*nbx*nby + j*nbx + i;

rank_mapping[local_index] = dmap[ib];
if (verbose)
amrex::Print() << "LOADING RANK NUMBER " << dmap[ib] << " FOR GRID NUMBER " << ib
<< " WHICH IS LOCAL NUMBER " << local_index << std::endl;
}


Real h = geom.CellSize(0);
Real hsq = h*h;
Expand All @@ -54,7 +73,6 @@ swfft_solver(MultiFab& rhs, MultiFab& soln, Geometry& geom, int verbose)

int Ndims[3] = { nbz, nby, nbx };
int n[3] = {domain.length(2), domain.length(1), domain.length(0)};
Vector<int> rank_mapping = rhs.DistributionMap().ProcessorMap(); // copy the ranks' ordering
hacc::Distribution d(MPI_COMM_WORLD,n,Ndims,&rank_mapping[0]);
hacc::Dfft dfft(d);

Expand Down

0 comments on commit 98ac4ce

Please sign in to comment.