Created local grid that is used to populate global grid

This commit is contained in:
Aidan Thompson
2021-08-22 16:03:50 -06:00
parent a0197644f0
commit 347e5a5978
2 changed files with 10 additions and 23 deletions

View File

@ -37,7 +37,6 @@ ComputeSNAGrid::ComputeSNAGrid(LAMMPS *lmp, int narg, char **arg) :
ComputeGrid(lmp, narg, arg), cutsq(nullptr),
radelem(nullptr), wjelem(nullptr)
{
double rfac0, rmin0;
int twojmax, switchflag, bzeroflag, bnormflag, wselfallflag;
@ -208,21 +207,6 @@ void ComputeSNAGrid::compute_array()
{
invoked_array = update->ntimestep;
// // invoke full neighbor list (will copy or build if necessary)
// neighbor->build_one(list);
// int mynxlo = static_cast<int> (comm->xsplit[comm->myloc[0]] * nx);
// int mynxhi = static_cast<int> (comm->xsplit[comm->myloc[0]+1] * nx) - 1;
// int mynylo = static_cast<int> (comm->ysplit[comm->myloc[1]] * ny);
// int mynyhi = static_cast<int> (comm->ysplit[comm->myloc[1]+1] * ny) - 1;
// int mynzlo = static_cast<int> (comm->zsplit[comm->myloc[2]] * nz);
// int mynzhi = static_cast<int> (comm->zsplit[comm->myloc[2]+1] * nz) - 1;
// int myngridlocal = (nxhi - nxlo + 1) * (nyhi - nylo + 1) * (nzhi - nzlo + 1);
// compute sna for each gridpoint
double** const x = atom->x;
@ -285,7 +269,7 @@ void ComputeSNAGrid::compute_array()
snaptr->compute_zi();
snaptr->compute_bi(ielem);
// linear contributions
// linear contributions
for (int icoeff = 0; icoeff < ncoeff; icoeff++)
gridlocal[size_array_cols_base+icoeff][iz][iy][ix] = snaptr->blist[icoeff];
@ -302,16 +286,17 @@ void ComputeSNAGrid::compute_array()
}
}
}
for (int iz = nzlo; iz <= nzhi; iz++)
for (int iy = nylo; iy <= nyhi; iy++)
for (int ix = nxlo; ix <= nxhi; ix++) {
const int igrid = iz*(nx*ny) + iy*nx + ix;
for (int j = 0; j < nvalues; j++)
grid[igrid][size_array_cols_base + j] = gridlocal[size_array_cols_base + j][iz][iy][ix];
const int igrid = iz*(nx*ny) + iy*nx + ix;
for (int j = 0; j < nvalues; j++)
grid[igrid][size_array_cols_base + j] = gridlocal[size_array_cols_base + j][iz][iy][ix];
}
MPI_Allreduce(&grid[0][0],&gridall[0][0],ngrid*size_array_cols,MPI_DOUBLE,MPI_SUM,world);
}

View File

@ -207,8 +207,11 @@ void ComputeGrid::allocate()
memory->destroy(local_flags);
if (gridlocal_allocated) {
gridlocal_allocated = 0;
// can't seem to do this without seg-fault
// MEMORY LEAK!!
// can't seem to free this memory without seg-fault
// printf("Before allocate destroy4d, proc %d %p\n",comm->me,gridlocal);
// memory->destroy4d_offset(gridlocal,nzlo,nylo,nxlo);
// printf("After allocate destroy4d, proc %d %p\n",comm->me,gridlocal);
}
memory->create(grid,size_array_rows,size_array_cols,"grid:grid");
@ -310,7 +313,6 @@ void ComputeGrid::set_grid_local()
ngridlocal = (nxhi - nxlo + 1) * (nyhi - nylo + 1) * (nzhi - nzlo + 1);
printf("me = %d n = %d x %d %d y %d %d z %d %d \n", comm->me, ngridlocal, nxlo, nxhi, nylo, nyhi, nzlo, nzhi);
}
/* ----------------------------------------------------------------------