Eliminated global storage for grid/local

This commit is contained in:
Aidan Thompson
2022-06-15 20:28:22 -06:00
parent 70f836e275
commit 483e3cf049
4 changed files with 18 additions and 85 deletions

View File

@ -200,21 +200,6 @@ ComputeSNAGridLocal::~ComputeSNAGridLocal()
void ComputeSNAGridLocal::init()
{
// if (force->pair == nullptr)
// error->all(FLERR,"Compute sna/grid/local requires a pair style be defined");
// if (cutmax > force->pair->cutforce)
// error->all(FLERR,"Compute sna/grid/local cutoff is longer than pairwise cutoff");
// // need an occasional full neighbor list
// int irequest = neighbor->request(this,instance_me);
// neighbor->requests[irequest]->pair = 0;
// neighbor->requests[irequest]->compute = 1;
// neighbor->requests[irequest]->half = 0;
// neighbor->requests[irequest]->full = 1;
// neighbor->requests[irequest]->occasional = 1;
int count = 0;
for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"sna/grid/local") == 0) count++;
@ -234,7 +219,6 @@ void ComputeSNAGridLocal::init_list(int /*id*/, NeighList *ptr)
void ComputeSNAGridLocal::compute_local()
{
printf("Entering compute_local()\n");
invoked_array = update->ntimestep;
// compute sna for each gridpoint
@ -248,6 +232,7 @@ void ComputeSNAGridLocal::compute_local()
snaptr->grow_rij(ntotal);
int igrid = 0;
for (int iz = nzlo; iz <= nzhi; iz++)
for (int iy = nylo; iy <= nyhi; iy++)
for (int ix = nxlo; ix <= nxhi; ix++) {
@ -307,8 +292,7 @@ void ComputeSNAGridLocal::compute_local()
// linear contributions
for (int icoeff = 0; icoeff < ncoeff; icoeff++)
gridlocal[size_local_cols_base+icoeff][iz][iy][ix] =
snaptr->blist[icoeff];
alocal[igrid][size_local_cols_base+icoeff] = snaptr->blist[icoeff];
// quadratic contributions
@ -316,19 +300,14 @@ void ComputeSNAGridLocal::compute_local()
int ncount = ncoeff;
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
double bveci = snaptr->blist[icoeff];
gridlocal[size_local_cols_base+ncount++][iz][iy][ix] =
0.5*bveci*bveci;
alocal[igrid][size_local_cols_base+ncount++] = 0.5*bveci*bveci;
for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++)
gridlocal[size_local_cols_base+ncount++][iz][iy][ix] =
alocal[igrid][size_local_cols_base+ncount++] =
bveci*snaptr->blist[jcoeff];
}
}
igrid++;
}
// copy 4d array to 2d array
copy_gridlocal_to_local_array();
printf("Exiting compute_local()\n");
}
@ -340,7 +319,7 @@ double ComputeSNAGridLocal::memory_usage()
{
double nbytes = snaptr->memory_usage(); // SNA object
int n = atom->ntypes+1;
nbytes += (double)n*sizeof(int); // map
nbytes += (double)n*sizeof(int); // map
return nbytes;
}

View File

@ -59,12 +59,6 @@ void PairSNAGrid::init_style()
if (force->newton_pair == 0)
error->all(FLERR,"Pair style sna/grid requires newton pair on");
// // need a full neighbor list
// int irequest = neighbor->request(this,instance_me);
// neighbor->requests[irequest]->half = 0;
// neighbor->requests[irequest]->full = 1;
snaptr = new SNA(lmp, rfac0, twojmax,
rmin0, switchflag, bzeroflag,
chemflag, bnormflag, wselfallflag,

View File

@ -117,8 +117,6 @@ void ComputeGridLocal::allocate()
{
if (nxlo <= nxhi && nylo <= nyhi && nzlo <= nzhi) {
gridlocal_allocated = 1;
memory->create4d_offset(gridlocal,size_local_cols,nzlo,nzhi,nylo,nyhi,
nxlo,nxhi,"grid:gridlocal");
memory->create(alocal, size_local_rows, size_local_cols, "compute/grid/local:alocal");
array_local = alocal;
}
@ -132,7 +130,6 @@ void ComputeGridLocal::deallocate()
{
if (gridlocal_allocated) {
gridlocal_allocated = 0;
memory->destroy4d_offset(gridlocal,nzlo,nylo,nxlo);
memory->destroy(alocal);
}
array_local = nullptr;
@ -208,19 +205,6 @@ void ComputeGridLocal::set_grid_local()
zfrachi = comm->mysplit[2][1];
}
// // not fully clear why this works
// // without, sometimes get uneven assignments
// // in case where ngridz is multiple of nprocz
// double MYEPS = 1.0e-10;
// xfraclo += MYEPS;
// xfrachi += MYEPS;
// yfraclo += MYEPS;
// yfrachi += MYEPS;
// zfraclo += MYEPS;
// zfrachi += MYEPS;
nxlo = static_cast<int> (xfraclo * nx);
if (1.0*nxlo != xfraclo*nx) nxlo++;
nxhi = static_cast<int> (xfrachi * nx);
@ -255,27 +239,20 @@ void ComputeGridLocal::assign_coords()
alocal[igrid][2] = iz;
double xgrid[3];
// For triclinic: create gridpoint in lamda coordinates and transform after check.
// For orthorombic: create gridpoint in box coordinates.
// for triclinic: create gridpoint in lamda coordinates and transform after check.
// for orthorombic: create gridpoint in box coordinates.
if (triclinic)
{
grid2lamda(ix, iy, iz, xgrid);
}
else
{
grid2x(ix, iy, iz, xgrid);
}
if (triclinic)
grid2lamda(ix, iy, iz, xgrid);
else
grid2x(ix, iy, iz, xgrid);
// Ensure gridpoint is not strictly outside subdomain.
// There have been some problem with a gridpoint being something like 2e-17 outside of the subdomain,
// thus the EPISLON check.
if ((sublo[0]-xgrid[0]) > EPSILON || (xgrid[0]-subhi[0]) > EPSILON ||
(sublo[1]-xgrid[1]) > EPSILON || (xgrid[1]-subhi[1]) > EPSILON ||
(sublo[2]-xgrid[2]) > EPSILON || (xgrid[2]-subhi[2]) > EPSILON)
{
error->one(FLERR,"Invalid gridpoint position in compute grid/local");
}
// ensure gridpoint is not strictly outside subdomain
if ((sublo[0]-xgrid[0]) > EPSILON || (xgrid[0]-subhi[0]) > EPSILON ||
(sublo[1]-xgrid[1]) > EPSILON || (xgrid[1]-subhi[1]) > EPSILON ||
(sublo[2]-xgrid[2]) > EPSILON || (xgrid[2]-subhi[2]) > EPSILON)
error->one(FLERR,"Invalid gridpoint position in compute grid/local");
// convert lamda to x, y, z, after sudomain check
@ -288,22 +265,6 @@ void ComputeGridLocal::assign_coords()
}
}
/* ----------------------------------------------------------------------
copy the 4d gridlocal array values to the 2d local array
------------------------------------------------------------------------- */
void ComputeGridLocal::copy_gridlocal_to_local_array()
{
int igrid = 0;
for (int iz = nzlo; iz <= nzhi; iz++)
for (int iy = nylo; iy <= nyhi; iy++)
for (int ix = nxlo; ix <= nxhi; ix++) {
for (int icol = size_local_cols_base; icol < size_local_cols; icol++)
alocal[igrid][icol] = gridlocal[icol][iz][iy][ix];
igrid++;
}
}
/* ----------------------------------------------------------------------
memory usage of local data
------------------------------------------------------------------------- */

View File

@ -53,7 +53,6 @@ class ComputeGridLocal : public Compute {
void set_grid_global(); // set global grid
void set_grid_local(); // set bounds for local grid
void assign_coords(); // assign coords for grid
void copy_gridlocal_to_local_array();// copy 4d gridlocal array to 2d local array
private:
};