remove whitespace
This commit is contained in:
102
src/grid2d.cpp
102
src/grid2d.cpp
@ -2,7 +2,7 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
LAMMPS Development team: developers@lammps.org
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
@ -58,7 +58,7 @@ Grid2d::Grid2d(LAMMPS *lmp, MPI_Comm gcomm, int gnx, int gny) : Pointers(lmp)
|
||||
|
||||
// default settings, can be overridden by set() methods
|
||||
// these affect assignment of owned and ghost cells
|
||||
|
||||
|
||||
maxdist = 0.0;
|
||||
stencil_grid_lo = stencil_grid_hi = 0;
|
||||
stencil_atom_lo = stencil_atom_hi = 0;
|
||||
@ -94,7 +94,7 @@ Grid2d::Grid2d(LAMMPS *lmp, MPI_Comm gcomm, int gnx, int gny,
|
||||
ny = gny;
|
||||
|
||||
// store owned/ghost indices provided by caller
|
||||
|
||||
|
||||
inxlo = ixlo;
|
||||
inxhi = ixhi;
|
||||
inylo = iylo;
|
||||
@ -142,14 +142,14 @@ Grid2d::~Grid2d()
|
||||
memory->destroy(copy[i].unpacklist);
|
||||
}
|
||||
memory->sfree(copy);
|
||||
|
||||
|
||||
delete [] requests;
|
||||
delete [] requests_remap;
|
||||
|
||||
memory->sfree(rcbinfo);
|
||||
|
||||
// remap data structs
|
||||
|
||||
|
||||
deallocate_remap();
|
||||
}
|
||||
|
||||
@ -328,9 +328,9 @@ void Grid2d::setup_grid(int &ixlo, int &ixhi, int &iylo, int &iyhi,
|
||||
{
|
||||
// owned grid cells = those whose grid point is within proc subdomain
|
||||
// shift_grid = 0.5 for grid point at cell center, 0.0 for lower-left corner
|
||||
|
||||
|
||||
double fraclo,frachi;
|
||||
|
||||
|
||||
if (comm->layout != Comm::LAYOUT_TILED) {
|
||||
fraclo = comm->xsplit[comm->myloc[0]];
|
||||
frachi = comm->xsplit[comm->myloc[0]+1];
|
||||
@ -355,9 +355,9 @@ void Grid2d::setup_grid(int &ixlo, int &ixhi, int &iylo, int &iyhi,
|
||||
// other constructor invokes this directly
|
||||
|
||||
initialize();
|
||||
|
||||
|
||||
// return values
|
||||
|
||||
|
||||
ixlo = inxlo;
|
||||
ixhi = inxhi;
|
||||
iylo = inylo;
|
||||
@ -384,7 +384,7 @@ void Grid2d::initialize()
|
||||
// default = caller grid is allocated to ghost grid
|
||||
// used when computing pack/unpack lists in indices()
|
||||
// these values can be overridden using set_caller_grid()
|
||||
|
||||
|
||||
fullxlo = outxlo;
|
||||
fullxhi = outxhi;
|
||||
fullylo = outylo;
|
||||
@ -476,7 +476,7 @@ void Grid2d::ghost_grid()
|
||||
}
|
||||
|
||||
// for triclinic, maxdist = different value in each orthogonal direction
|
||||
|
||||
|
||||
double dist[3] = {0.0,0.0,0.0};
|
||||
if (triclinic == 0) dist[0] = dist[1] = dist[2] = maxdist;
|
||||
else MathExtra::tribbox(domain->h,maxdist,&dist[0]);
|
||||
@ -488,11 +488,11 @@ void Grid2d::ghost_grid()
|
||||
// ghost cell layers needed in each dim/dir = max of two extension effects
|
||||
// OFFSET allows generation of negative indices with static_cast
|
||||
// out xyz lo/hi = index range of owned + ghost cells
|
||||
|
||||
|
||||
double dxinv = nx / prd[0];
|
||||
double dyinv = ny / prd[1];
|
||||
double dyinv_slab = ny / (prd[1] * yfactor);
|
||||
|
||||
|
||||
int lo, hi;
|
||||
|
||||
lo = static_cast<int>((sublo[0]-dist[0]-boxlo[0]) * dxinv + shift_atom_lo + OFFSET) - OFFSET;
|
||||
@ -571,7 +571,7 @@ void Grid2d::extract_comm_info()
|
||||
ysplit = new double[comm->procgrid[1]+1];
|
||||
memcpy(xsplit,comm->xsplit,(comm->procgrid[0]+1)*sizeof(double));
|
||||
memcpy(ysplit,comm->ysplit,(comm->procgrid[1]+1)*sizeof(double));
|
||||
|
||||
|
||||
memory->create(grid2proc,comm->procgrid[0],comm->procgrid[1],comm->procgrid[2],
|
||||
"grid3d:grid2proc");
|
||||
memcpy(&grid2proc[0][0][0],&comm->grid2proc[0][0][0],
|
||||
@ -593,7 +593,7 @@ void Grid2d::extract_comm_info()
|
||||
if (rcbone.dim <= 0) rcbone.cut = inxlo;
|
||||
else if (rcbone.dim == 1) rcbone.cut = inylo;
|
||||
MPI_Allgather(&rcbone,sizeof(RCBinfo),MPI_CHAR,
|
||||
rcbinfo,sizeof(RCBinfo),MPI_CHAR,gridcomm);
|
||||
rcbinfo,sizeof(RCBinfo),MPI_CHAR,gridcomm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -866,7 +866,7 @@ void Grid2d::setup_comm_tiled(int &nbuf1, int &nbuf2)
|
||||
// content: me, index of my overlap, box that overlaps with its owned cells
|
||||
// ncopy = # of overlaps with myself, across a periodic boundary
|
||||
// skip copy to self when non-PBC
|
||||
|
||||
|
||||
int *proclist;
|
||||
memory->create(proclist,noverlap,"grid2d:proclist");
|
||||
srequest = (Request *)
|
||||
@ -955,7 +955,7 @@ void Grid2d::setup_comm_tiled(int &nbuf1, int &nbuf2)
|
||||
|
||||
// create Copy data struct from overlaps with self
|
||||
// skip copy to self when non-PBC
|
||||
|
||||
|
||||
copy = (Copy *) memory->smalloc(ncopy*sizeof(Copy),"grid2d:copy");
|
||||
|
||||
ncopy = 0;
|
||||
@ -1088,13 +1088,13 @@ void Grid2d::forward_comm(int caller, void *ptr, int nper, int nbyte, int which,
|
||||
if (layout != Comm::LAYOUT_TILED) {
|
||||
if (caller == KSPACE)
|
||||
forward_comm_brick<KSpace>((KSpace *) ptr,nper,nbyte,which,
|
||||
buf1,buf2,datatype);
|
||||
buf1,buf2,datatype);
|
||||
else if (caller == PAIR)
|
||||
forward_comm_brick<Pair>((Pair *) ptr,nper,nbyte,which,
|
||||
buf1,buf2,datatype);
|
||||
buf1,buf2,datatype);
|
||||
else if (caller == FIX)
|
||||
forward_comm_brick<Fix>((Fix *) ptr,nper,nbyte,which,
|
||||
buf1,buf2,datatype);
|
||||
buf1,buf2,datatype);
|
||||
} else {
|
||||
if (caller == KSPACE)
|
||||
forward_comm_tiled<KSpace>((KSpace *) ptr,nper,nbyte,which,
|
||||
@ -1115,7 +1115,7 @@ void Grid2d::forward_comm(int caller, void *ptr, int nper, int nbyte, int which,
|
||||
template < class T >
|
||||
void Grid2d::
|
||||
forward_comm_brick(T *ptr, int nper, int /*nbyte*/, int which,
|
||||
void *buf1, void *buf2, MPI_Datatype datatype)
|
||||
void *buf1, void *buf2, MPI_Datatype datatype)
|
||||
{
|
||||
int m;
|
||||
MPI_Request request;
|
||||
@ -1193,13 +1193,13 @@ void Grid2d::reverse_comm(int caller, void *ptr, int nper, int nbyte, int which,
|
||||
if (layout != Comm::LAYOUT_TILED) {
|
||||
if (caller == KSPACE)
|
||||
reverse_comm_brick<KSpace>((KSpace *) ptr,nper,nbyte,which,
|
||||
buf1,buf2,datatype);
|
||||
buf1,buf2,datatype);
|
||||
else if (caller == PAIR)
|
||||
reverse_comm_brick<Pair>((Pair *) ptr,nper,nbyte,which,
|
||||
buf1,buf2,datatype);
|
||||
buf1,buf2,datatype);
|
||||
else if (caller == FIX)
|
||||
reverse_comm_brick<Fix>((Fix *) ptr,nper,nbyte,which,
|
||||
buf1,buf2,datatype);
|
||||
buf1,buf2,datatype);
|
||||
} else {
|
||||
if (caller == KSPACE)
|
||||
reverse_comm_tiled<KSpace>((KSpace *) ptr,nper,nbyte,which,
|
||||
@ -1220,7 +1220,7 @@ void Grid2d::reverse_comm(int caller, void *ptr, int nper, int nbyte, int which,
|
||||
template < class T >
|
||||
void Grid2d::
|
||||
reverse_comm_brick(T *ptr, int nper, int /*nbyte*/, int which,
|
||||
void *buf1, void *buf2, MPI_Datatype datatype)
|
||||
void *buf1, void *buf2, MPI_Datatype datatype)
|
||||
{
|
||||
int m;
|
||||
MPI_Request request;
|
||||
@ -1311,7 +1311,7 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
int *box;
|
||||
|
||||
// deallocated existing remap data structs
|
||||
|
||||
|
||||
deallocate_remap();
|
||||
|
||||
// set layout to current Comm layout
|
||||
@ -1331,7 +1331,7 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
|
||||
// use overlap_old to construct send and copy lists
|
||||
// skip overlaps that contain no grid cells
|
||||
|
||||
|
||||
self_remap = 0;
|
||||
|
||||
nsend_remap = 0;
|
||||
@ -1343,19 +1343,19 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
}
|
||||
|
||||
send_remap = new Send[nsend_remap];
|
||||
|
||||
|
||||
nsend_remap = 0;
|
||||
for (m = 0; m < noverlap_old; m++) {
|
||||
box = overlap_old[m].box;
|
||||
if (box[0] > box[1] || box[2] > box[3]) continue;
|
||||
if (overlap_old[m].proc == me) {
|
||||
copy_remap.npack =
|
||||
old->indices(copy_remap.packlist,box[0],box[1],box[2],box[3]);
|
||||
old->indices(copy_remap.packlist,box[0],box[1],box[2],box[3]);
|
||||
} else {
|
||||
send_remap[nsend_remap].proc = overlap_old[m].proc;
|
||||
send_remap[nsend_remap].npack =
|
||||
old->indices(send_remap[nsend_remap].packlist,
|
||||
box[0],box[1],box[2],box[3]);
|
||||
old->indices(send_remap[nsend_remap].packlist,
|
||||
box[0],box[1],box[2],box[3]);
|
||||
nsend_remap++;
|
||||
}
|
||||
}
|
||||
@ -1381,7 +1381,7 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
if (box[0] > box[1] || box[2] > box[3]) continue;
|
||||
if (overlap_new[m].proc != me) nrecv_remap++;
|
||||
}
|
||||
|
||||
|
||||
recv_remap = new Recv[nrecv_remap];
|
||||
|
||||
nrecv_remap = 0;
|
||||
@ -1390,12 +1390,12 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
if (box[0] > box[1] || box[2] > box[3]) continue;
|
||||
if (overlap_new[m].proc == me) {
|
||||
copy_remap.nunpack =
|
||||
indices(copy_remap.unpacklist,box[0],box[1],box[2],box[3]);
|
||||
indices(copy_remap.unpacklist,box[0],box[1],box[2],box[3]);
|
||||
} else {
|
||||
recv_remap[nrecv_remap].proc = overlap_new[m].proc;
|
||||
recv_remap[nrecv_remap].nunpack =
|
||||
indices(recv_remap[nrecv_remap].unpacklist,
|
||||
box[0],box[1],box[2],box[3]);
|
||||
indices(recv_remap[nrecv_remap].unpacklist,
|
||||
box[0],box[1],box[2],box[3]);
|
||||
nrecv_remap++;
|
||||
}
|
||||
}
|
||||
@ -1417,7 +1417,7 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
|
||||
clean_overlap();
|
||||
old->clean_overlap();
|
||||
|
||||
|
||||
// nremap_buf1 = largest pack or unpack in any Send or Recv or Copy
|
||||
// nremap_buf2 = sum of all unpacks in Recv
|
||||
|
||||
@ -1444,7 +1444,7 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Grid2d::remap(int caller, void *ptr, int nper, int nbyte,
|
||||
void *buf1, void *buf2, MPI_Datatype datatype)
|
||||
void *buf1, void *buf2, MPI_Datatype datatype)
|
||||
{
|
||||
if (caller == FIX) remap_style<Fix>((Fix *) ptr,nper,nbyte,buf1,buf2,datatype);
|
||||
}
|
||||
@ -1453,7 +1453,7 @@ void Grid2d::remap(int caller, void *ptr, int nper, int nbyte,
|
||||
|
||||
template < class T >
|
||||
void Grid2d::remap_style(T *ptr, int nper, int nbyte,
|
||||
void *buf1, void *vbuf2, MPI_Datatype datatype)
|
||||
void *buf1, void *vbuf2, MPI_Datatype datatype)
|
||||
{
|
||||
int i,m,offset;
|
||||
|
||||
@ -1487,7 +1487,7 @@ void Grid2d::remap_style(T *ptr, int nper, int nbyte,
|
||||
MPI_Waitany(nrecv_remap,requests_remap,&m,MPI_STATUS_IGNORE);
|
||||
offset = nper * recv_remap[m].offset * nbyte;
|
||||
ptr->unpack_remap_grid((void *) &buf2[offset],
|
||||
recv_remap[m].nunpack,recv_remap[m].unpacklist);
|
||||
recv_remap[m].nunpack,recv_remap[m].unpacklist);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1535,7 +1535,7 @@ void Grid2d::read_file_style(T *ptr, FILE *fp, int nchunk, int maxline)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Grid2d::write_file(int caller, void *ptr, int which,
|
||||
int nper, int nbyte, MPI_Datatype datatype)
|
||||
int nper, int nbyte, MPI_Datatype datatype)
|
||||
{
|
||||
if (caller == FIX)
|
||||
write_file_style<Fix>((Fix *) ptr, which, nper, nbyte, datatype);
|
||||
@ -1550,7 +1550,7 @@ void Grid2d::write_file(int caller, void *ptr, int which,
|
||||
|
||||
template < class T >
|
||||
void Grid2d::write_file_style(T *ptr, int which,
|
||||
int nper, int nbyte, MPI_Datatype datatype)
|
||||
int nper, int nbyte, MPI_Datatype datatype)
|
||||
{
|
||||
// maxsize = max size of grid data owned by any proc
|
||||
|
||||
@ -1603,7 +1603,7 @@ void Grid2d::write_file_style(T *ptr, int which,
|
||||
}
|
||||
|
||||
// clean up
|
||||
|
||||
|
||||
memory->destroy(onebuf);
|
||||
}
|
||||
|
||||
@ -1640,7 +1640,7 @@ void Grid2d::write_file_style(T *ptr, int which,
|
||||
int Grid2d::compute_overlap(int ghostflag, int *box, int *pbc, Overlap *&overlap)
|
||||
{
|
||||
int obox[4];
|
||||
|
||||
|
||||
memory->create(overlap_procs,nprocs,"grid2d:overlap_procs");
|
||||
noverlap_list = maxoverlap_list = 0;
|
||||
overlap_list = nullptr;
|
||||
@ -1653,11 +1653,11 @@ int Grid2d::compute_overlap(int ghostflag, int *box, int *pbc, Overlap *&overlap
|
||||
}
|
||||
|
||||
// test obox against appropriate layout
|
||||
|
||||
|
||||
if (layout != Comm::LAYOUT_TILED) {
|
||||
|
||||
// find comm->procgrid indices in each dim for box bounds
|
||||
|
||||
|
||||
int iproclo = proc_index_uniform(box[0],nx,shift_grid,0,xsplit);
|
||||
int iprochi = proc_index_uniform(box[1],nx,shift_grid,0,xsplit);
|
||||
int jproclo = proc_index_uniform(box[2],ny,shift_grid,1,ysplit);
|
||||
@ -1690,12 +1690,12 @@ int Grid2d::compute_overlap(int ghostflag, int *box, int *pbc, Overlap *&overlap
|
||||
obox[1] = nx-1;
|
||||
obox[2] = 0;
|
||||
obox[3] = ny-1;
|
||||
|
||||
|
||||
partition_tiled(overlap_list[m].proc,0,nprocs-1,obox);
|
||||
|
||||
if (me == 1) printf("OBOX: proc %d obox %d %d: %d %d\n",
|
||||
overlap_list[m].proc,obox[0],obox[1],obox[2],obox[3]);
|
||||
|
||||
|
||||
overlap_list[m].box[0] = MAX(box[0],obox[0]);
|
||||
overlap_list[m].box[1] = MIN(box[1],obox[1]);
|
||||
overlap_list[m].box[2] = MAX(box[2],obox[2]);
|
||||
@ -1860,7 +1860,7 @@ void Grid2d::deallocate_remap()
|
||||
for (int i = 0; i < nsend_remap; i++)
|
||||
memory->destroy(send_remap[i].packlist);
|
||||
delete [] send_remap;
|
||||
|
||||
|
||||
for (int i = 0; i < nrecv_remap; i++)
|
||||
memory->destroy(recv_remap[i].unpacklist);
|
||||
delete [] recv_remap;
|
||||
@ -1913,12 +1913,12 @@ int Grid2d::proc_index_uniform(int igrid, int n, double shift, int dim, double *
|
||||
// compute the grid bounds for that proc
|
||||
// if igrid falls within those bounds, return m = proc index
|
||||
// same logic as in partition_grid()
|
||||
|
||||
|
||||
int m;
|
||||
for (m = 0; m < comm->procgrid[dim]; m++) {
|
||||
fraclo = split[m];
|
||||
frachi = split[m+1];
|
||||
|
||||
|
||||
lo = static_cast<int> (fraclo * n);
|
||||
while (lo+shift < fraclo*n) lo++;
|
||||
hi = static_cast<int> (frachi * n);
|
||||
@ -1953,7 +1953,7 @@ void Grid2d::partition_tiled(int proc, int proclower, int procupper, int *box)
|
||||
int cut = rcbinfo[procmid].cut;
|
||||
|
||||
// adjust box to reflect which half of partition the proc is in
|
||||
|
||||
|
||||
if (proc < procmid) {
|
||||
box[2*dim+1] = cut-1;
|
||||
partition_tiled(proc,proclower,procmid-1,box);
|
||||
|
||||
Reference in New Issue
Block a user