Skip to content

Commit

Permalink
remove useless silly function
Browse files Browse the repository at this point in the history
  • Loading branch information
aeriforme committed Oct 4, 2024
1 parent 2ff840b commit e9f1bc2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 41 deletions.
39 changes: 0 additions & 39 deletions Source/ablastr/fields/IntegratedGreenFunctionSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -121,45 +121,6 @@ namespace ablastr::fields
return G_value;
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void
arianna (amrex::Box const & realspace_box, amrex::BoxArray & realspace_ba, amrex::DistributionMapping & dm_global_fft){
// Define a new distribution mapping which is decomposed purely along z
// and has one box per MPI rank
int const nprocs = amrex::ParallelDescriptor::NProcs();

int realspace_nx = realspace_box.length(0);
int realspace_ny = realspace_box.length(1);
int realspace_nz = realspace_box.length(2);
int minsize_z = realspace_nz / nprocs;
int nleft_z = realspace_nz - minsize_z*nprocs;

AMREX_ALWAYS_ASSERT(realspace_nz >= nprocs);
// We are going to split realspace_box in such a way that the first
// nleft boxes has minsize_z+1 nodes and the others minsize
// nodes. We do it this way instead of BoxArray::maxSize to make
// sure there are exactly nprocs boxes and there are no overlaps.
amrex::BoxList bl(amrex::IndexType::TheNodeType());
for (int iproc = 0; iproc < nprocs; ++iproc) {
int zlo, zhi;
if (iproc < nleft_z) {
zlo = iproc*(minsize_z+1);
zhi = zlo + minsize_z;
} else {
zlo = iproc*minsize_z + nleft_z;
zhi = zlo + minsize_z - 1;
}
amrex::Box tbx(amrex::IntVect(0,0,zlo),amrex::IntVect(realspace_nx-1,realspace_ny-1,zhi),amrex::IntVect(1));
tbx.shift(realspace_box.smallEnd());
bl.push_back(tbx);
}
realspace_ba.define(std::move(bl));
amrex::Vector<int> pmap(nprocs);
std::iota(pmap.begin(), pmap.end(), 0);
dm_global_fft.define(std::move(pmap));
}


/** @brief Compute the electrostatic potential using the Integrated Green Function method
* as in http://dx.doi.org/10.1103/PhysRevSTAB.9.044204
*
Expand Down
36 changes: 34 additions & 2 deletions Source/ablastr/fields/IntegratedGreenFunctionSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,42 @@ computePhiIGF ( amrex::MultiFab const & rho,
amrex::DistributionMapping dm_global_fft;

if(is_2d_slices || is_3d_distributed){
arianna(realspace_box, realspace_ba, dm_global_fft);
// Define a new distribution mapping which is decomposed purely along z
// and has one box per MPI rank
int const nprocs = amrex::ParallelDescriptor::NProcs();

int realspace_nx = realspace_box.length(0);
int realspace_ny = realspace_box.length(1);
int realspace_nz = realspace_box.length(2);
int minsize_z = realspace_nz / nprocs;
int nleft_z = realspace_nz - minsize_z*nprocs;

AMREX_ALWAYS_ASSERT(realspace_nz >= nprocs);
// We are going to split realspace_box in such a way that the first
// nleft boxes has minsize_z+1 nodes and the others minsize
// nodes. We do it this way instead of BoxArray::maxSize to make
// sure there are exactly nprocs boxes and there are no overlaps.
amrex::BoxList bl(amrex::IndexType::TheNodeType());
for (int iproc = 0; iproc < nprocs; ++iproc) {
int zlo, zhi;
if (iproc < nleft_z) {
zlo = iproc*(minsize_z+1);
zhi = zlo + minsize_z;
} else {
zlo = iproc*minsize_z + nleft_z;
zhi = zlo + minsize_z - 1;
}
amrex::Box tbx(amrex::IntVect(0,0,zlo),amrex::IntVect(realspace_nx-1,realspace_ny-1,zhi),amrex::IntVect(1));
tbx.shift(realspace_box.smallEnd());
bl.push_back(tbx);
}
realspace_ba.define(std::move(bl));
amrex::Vector<int> pmap(nprocs);
std::iota(pmap.begin(), pmap.end(), 0);
dm_global_fft.define(std::move(pmap));
}
else{
// Without distributed FFTs (i.e. without heFFTe):
// In 3D without distributed FFTs (i.e. without heFFTe):
// allocate the 2x wider array on a single box
realspace_ba = amrex::BoxArray(realspace_box);
// Define a distribution mapping for the global FFT, with only one box
Expand Down

0 comments on commit e9f1bc2

Please sign in to comment.