From ab1c3f649832aa37f770dd9c1775050ce4075b7a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 30 Nov 2018 11:54:48 -0700 Subject: [PATCH 01/49] rendevous comm option for special bonds and fix rigid/small --- src/RIGID/fix_rigid_small.cpp | 491 +++++++-------- src/RIGID/fix_rigid_small.h | 26 +- src/comm.cpp | 51 ++ src/comm.h | 4 + src/create_atoms.cpp | 37 +- src/hashlittle.cpp | 333 ++++++++++ src/hashlittle.h | 5 + src/irregular.cpp | 17 +- src/read_data.cpp | 15 + src/read_restart.cpp | 15 + src/replicate.cpp | 8 +- src/special.cpp | 1095 ++++++++++++++++----------------- src/special.h | 27 +- 13 files changed, 1249 insertions(+), 875 deletions(-) create mode 100644 src/hashlittle.cpp create mode 100644 src/hashlittle.h diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 44e1870e0a..4421d9ae17 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -34,6 +34,7 @@ #include "variable.h" #include "random_mars.h" #include "math_const.h" +#include "hashlittle.h" #include "memory.h" #include "error.h" @@ -70,8 +71,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : xcmimage(NULL), displace(NULL), eflags(NULL), orient(NULL), dorient(NULL), avec_ellipsoid(NULL), avec_line(NULL), avec_tri(NULL), counts(NULL), itensor(NULL), mass_body(NULL), langextra(NULL), random(NULL), - id_dilate(NULL), onemols(NULL), hash(NULL), bbox(NULL), ctr(NULL), - idclose(NULL), rsqclose(NULL) + id_dilate(NULL), onemols(NULL) { int i; @@ -107,18 +107,18 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // parse args for rigid body specification int *mask = atom->mask; - tagint *bodyid = NULL; + tagint *bodyID = NULL; int nlocal = atom->nlocal; if (narg < 4) error->all(FLERR,"Illegal fix rigid/small command"); if (strcmp(arg[3],"molecule") == 0) { if (atom->molecule_flag == 0) error->all(FLERR,"Fix rigid/small requires atom attribute molecule"); - bodyid = atom->molecule; + bodyID = atom->molecule; } else if (strcmp(arg[3],"custom") == 0) { if (narg < 5) error->all(FLERR,"Illegal fix rigid/small command"); - bodyid = new tagint[nlocal]; + bodyID = new tagint[nlocal]; customflag = 1; // determine whether atom-style variable or atom property is used. @@ -126,9 +126,11 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : int is_double=0; int custom_index = atom->find_custom(arg[4]+2,is_double); if (custom_index == -1) - error->all(FLERR,"Fix rigid/small custom requires previously defined property/atom"); + error->all(FLERR,"Fix rigid/small custom requires " + "previously defined property/atom"); else if (is_double) - error->all(FLERR,"Fix rigid/small custom requires integer-valued property/atom"); + error->all(FLERR,"Fix rigid/small custom requires " + "integer-valued property/atom"); int minval = INT_MAX; int *value = atom->ivector[custom_index]; @@ -139,15 +141,17 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) - bodyid[i] = (tagint)(value[i] - minval + 1); - else bodyid[i] = 0; + bodyID[i] = (tagint)(value[i] - minval + 1); + else bodyID[i] = 0; } else if (strstr(arg[4],"v_") == arg[4]) { int ivariable = input->variable->find(arg[4]+2); if (ivariable < 0) - error->all(FLERR,"Variable name for fix rigid/small custom does not exist"); + error->all(FLERR,"Variable name for fix rigid/small custom " + "does not exist"); if (input->variable->atomstyle(ivariable) == 0) - error->all(FLERR,"Fix rigid/small custom variable is no atom-style variable"); + error->all(FLERR,"Fix rigid/small custom variable is not " + "atom-style variable"); double *value = new double[nlocal]; input->variable->compute_atom(ivariable,0,value,1,0); int minval = INT_MAX; @@ -158,8 +162,8 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) - bodyid[i] = (tagint)((tagint)value[i] - minval + 1); - else bodyid[0] = 0; + bodyID[i] = (tagint)((tagint)value[i] - minval + 1); + else bodyID[0] = 0; delete[] value; } else error->all(FLERR,"Unsupported fix rigid custom property"); } else error->all(FLERR,"Illegal fix rigid/small command"); @@ -167,10 +171,11 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : if (atom->map_style == 0) error->all(FLERR,"Fix rigid/small requires an atom map, see atom_modify"); - // maxmol = largest bodyid # + // maxmol = largest bodyID # + maxmol = -1; for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) maxmol = MAX(maxmol,bodyid[i]); + if (mask[i] & groupbit) maxmol = MAX(maxmol,bodyID[i]); tagint itmp; MPI_Allreduce(&maxmol,&itmp,1,MPI_LMP_TAGINT,MPI_MAX,world); @@ -400,8 +405,19 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // sets bodytag for owned atoms // body attributes are computed later by setup_bodies() - create_bodies(bodyid); - if (customflag) delete [] bodyid; + double time1 = MPI_Wtime(); + + create_bodies(bodyID); + if (customflag) delete [] bodyID; + + double time2 = MPI_Wtime(); + + if (comm->me == 0) { + if (screen) + fprintf(screen," create_bodies CPU = %g secs\n",time2-time1); + if (logfile) + fprintf(logfile," create_bodies CPU = %g secs\n",time2-time1); + } // set nlocal_body and allocate bodies I own @@ -1514,175 +1530,71 @@ void FixRigidSmall::set_v() set bodytag for all owned atoms ------------------------------------------------------------------------- */ -void FixRigidSmall::create_bodies(tagint *bodyid) +void FixRigidSmall::create_bodies(tagint *bodyID) { - int i,m,n; - double unwrap[3]; + int i,m; - // error check on image flags of atoms in rigid bodies - - imageint *image = atom->image; + // allocate buffer for input to rendezvous comm + // ncount = # of my atoms in bodies + int *mask = atom->mask; int nlocal = atom->nlocal; - int *periodicity = domain->periodicity; - int xbox,ybox,zbox; - - int flag = 0; - for (i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - xbox = (image[i] & IMGMASK) - IMGMAX; - ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; - zbox = (image[i] >> IMG2BITS) - IMGMAX; - if ((xbox && !periodicity[0]) || (ybox && !periodicity[1]) || - (zbox && !periodicity[2])) flag = 1; - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall) error->all(FLERR,"Fix rigid/small atom has non-zero image flag " - "in a non-periodic dimension"); - - // allocate buffer for passing messages around ring of procs - // percount = max number of values to put in buffer for each of ncount - int ncount = 0; for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) ncount++; - int percount = 5; - double *buf; - memory->create(buf,ncount*percount,"rigid/small:buf"); + int *proclist; + memory->create(proclist,ncount,"rigid/small:proclist"); + InRvous *inbuf = (InRvous *) + memory->smalloc(ncount*sizeof(InRvous),"rigid/small:inbuf"); - // create map hash for storing unique body IDs of my atoms - // key = body ID - // value = index into per-body data structure - // n = # of entries in hash - - hash = new std::map(); - hash->clear(); - - // setup hash - // key = body ID - // value = index into N-length data structure - // n = count of unique bodies my atoms are part of - - n = 0; - for (i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - if (hash->find(bodyid[i]) == hash->end()) (*hash)[bodyid[i]] = n++; - } - - // bbox = bounding box of each rigid body my atoms are part of - - memory->create(bbox,n,6,"rigid/small:bbox"); - - for (i = 0; i < n; i++) { - bbox[i][0] = bbox[i][2] = bbox[i][4] = BIG; - bbox[i][1] = bbox[i][3] = bbox[i][5] = -BIG; - } - - // pack my atoms into buffer as body ID, unwrapped coords + // setup buf to pass to rendezvous comm + // one BodyMsg datum for each constituent atom + // datum = me, local index of atom, atomID, bodyID, unwrapped coords + // owning proc for each datum = random hash of bodyID double **x = atom->x; - - m = 0; - for (i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - domain->unmap(x[i],image[i],unwrap); - buf[m++] = bodyid[i]; - buf[m++] = unwrap[0]; - buf[m++] = unwrap[1]; - buf[m++] = unwrap[2]; - } - - // pass buffer around ring of procs - // func = update bbox with atom coords from every proc - // when done, have full bbox for every rigid body my atoms are part of - - comm->ring(m,sizeof(double),buf,1,ring_bbox,NULL,(void *)this); - - // check if any bbox is size 0.0, meaning rigid body is a single particle - - flag = 0; - for (i = 0; i < n; i++) - if (bbox[i][0] == bbox[i][1] && bbox[i][2] == bbox[i][3] && - bbox[i][4] == bbox[i][5]) flag = 1; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall) - error->all(FLERR,"One or more rigid bodies are a single particle"); - - // ctr = center pt of each rigid body my atoms are part of - - memory->create(ctr,n,6,"rigid/small:bbox"); - - for (i = 0; i < n; i++) { - ctr[i][0] = 0.5 * (bbox[i][0] + bbox[i][1]); - ctr[i][1] = 0.5 * (bbox[i][2] + bbox[i][3]); - ctr[i][2] = 0.5 * (bbox[i][4] + bbox[i][5]); - } - - // idclose = ID of atom in body closest to center pt (smaller ID if tied) - // rsqclose = distance squared from idclose to center pt - - memory->create(idclose,n,"rigid/small:idclose"); - memory->create(rsqclose,n,"rigid/small:rsqclose"); - - for (i = 0; i < n; i++) rsqclose[i] = BIG; - - // pack my atoms into buffer as body ID, atom ID, unwrapped coords - tagint *tag = atom->tag; + imageint *image = atom->image; m = 0; for (i = 0; i < nlocal; i++) { if (!(mask[i] & groupbit)) continue; - domain->unmap(x[i],image[i],unwrap); - buf[m++] = bodyid[i]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = unwrap[0]; - buf[m++] = unwrap[1]; - buf[m++] = unwrap[2]; + proclist[m] = hashlittle(&bodyID[i],sizeof(tagint),0) % nprocs; + inbuf[m].me = me; + inbuf[m].ilocal = i; + inbuf[m].atomID = tag[i]; + inbuf[m].bodyID = bodyID[i]; + domain->unmap(x[i],image[i],inbuf[m].x); + m++; } - // pass buffer around ring of procs - // func = update idclose,rsqclose with atom IDs from every proc - // when done, have idclose for every rigid body my atoms are part of + // perform rendezvous operation + // each proc owns random subset of bodies, receives all atoms in the bodies + // func = compute bbox of each body, flag atom closest to geometric center + // when done: each atom has atom ID of owning atom of its body - comm->ring(m,sizeof(double),buf,2,ring_nearest,NULL,(void *)this); + char *buf; + int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), + rendezvous_body,buf,sizeof(OutRvous), + (void *) this); + OutRvous *outbuf = (OutRvous *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); - // set bodytag of all owned atoms, based on idclose - // find max value of rsqclose across all procs + // set bodytag of all owned atoms based on outbuf info for constituent atoms - double rsqmax = 0.0; - for (i = 0; i < nlocal; i++) { - bodytag[i] = 0; - if (!(mask[i] & groupbit)) continue; - m = hash->find(bodyid[i])->second; - bodytag[i] = idclose[m]; - rsqmax = MAX(rsqmax,rsqclose[m]); - } + for (i = 0; i < nlocal; i++) + if (!(mask[i] & groupbit)) bodytag[i] = 0; - // pack my atoms into buffer as bodytag of owning atom, unwrapped coords + for (m = 0; m < nreturn; m++) + bodytag[outbuf[m].ilocal] = outbuf[m].atomID; - m = 0; - for (i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - domain->unmap(x[i],image[i],unwrap); - buf[m++] = ubuf(bodytag[i]).d; - buf[m++] = unwrap[0]; - buf[m++] = unwrap[1]; - buf[m++] = unwrap[2]; - } + memory->sfree(outbuf); - // pass buffer around ring of procs - // func = update rsqfar for atoms belonging to bodies I own - // when done, have rsqfar for all atoms in bodies I own - - rsqfar = 0.0; - comm->ring(m,sizeof(double),buf,3,ring_farthest,NULL,(void *)this); - - // find maxextent of rsqfar across all procs + // maxextent = max of rsqfar across all procs // if defined, include molecule->maxextent MPI_Allreduce(&rsqfar,&maxextent,1,MPI_DOUBLE,MPI_MAX,world); @@ -1691,125 +1603,151 @@ void FixRigidSmall::create_bodies(tagint *bodyid) for (int i = 0; i < nmol; i++) maxextent = MAX(maxextent,onemols[i]->maxextent); } +} + +/* ---------------------------------------------------------------------- + process rigid bodies assigned to me + buf = list of N BodyMsg datums +------------------------------------------------------------------------- */ + +int FixRigidSmall::rendezvous_body(int n, char *inbuf, + int *&proclist, char *&outbuf, + void *ptr) +{ + int i,j,m; + double delx,dely,delz,rsq; + int *iclose; + tagint *idclose; + double *x,*xown,*rsqclose; + double **bbox,**ctr; + + FixRigidSmall *frsptr = (FixRigidSmall *) ptr; + Memory *memory = frsptr->memory; + Error *error = frsptr->error; + MPI_Comm world = frsptr->world; + + // setup hash + // ncount = number of bodies assigned to me + // key = body ID + // value = index into Ncount-length data structure + + InRvous *in = (InRvous *) inbuf; + std::map hash; + tagint id; + + int ncount = 0; + for (i = 0; i < n; i++) { + id = in[i].bodyID; + if (hash.find(id) == hash.end()) hash[id] = ncount++; + } + + // bbox = bounding box of each rigid body + + memory->create(bbox,ncount,6,"rigid/small:bbox"); + + for (m = 0; m < ncount; m++) { + bbox[m][0] = bbox[m][2] = bbox[m][4] = BIG; + bbox[m][1] = bbox[m][3] = bbox[m][5] = -BIG; + } + + for (i = 0; i < n; i++) { + m = hash.find(in[i].bodyID)->second; + x = in[i].x; + bbox[m][0] = MIN(bbox[m][0],x[0]); + bbox[m][1] = MAX(bbox[m][1],x[0]); + bbox[m][2] = MIN(bbox[m][2],x[1]); + bbox[m][3] = MAX(bbox[m][3],x[1]); + bbox[m][4] = MIN(bbox[m][4],x[2]); + bbox[m][5] = MAX(bbox[m][5],x[2]); + } + + // check if any bbox is size 0.0, meaning rigid body is a single particle + + int flag = 0; + for (m = 0; m < ncount; m++) + if (bbox[m][0] == bbox[m][1] && bbox[m][2] == bbox[m][3] && + bbox[m][4] == bbox[m][5]) flag = 1; + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); // sync here? + if (flagall) + error->all(FLERR,"One or more rigid bodies are a single particle"); + + // ctr = geometric center pt of each rigid body + + memory->create(ctr,ncount,3,"rigid/small:bbox"); + + for (m = 0; m < ncount; m++) { + ctr[m][0] = 0.5 * (bbox[m][0] + bbox[m][1]); + ctr[m][1] = 0.5 * (bbox[m][2] + bbox[m][3]); + ctr[m][2] = 0.5 * (bbox[m][4] + bbox[m][5]); + } + + // idclose = atomID closest to center point of each body + + memory->create(idclose,ncount,"rigid/small:idclose"); + memory->create(iclose,ncount,"rigid/small:iclose"); + memory->create(rsqclose,ncount,"rigid/small:rsqclose"); + for (m = 0; m < ncount; m++) rsqclose[m] = BIG; + + for (i = 0; i < n; i++) { + m = hash.find(in[i].bodyID)->second; + x = in[i].x; + delx = x[0] - ctr[m][0]; + dely = x[1] - ctr[m][1]; + delz = x[2] - ctr[m][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq <= rsqclose[m]) { + if (rsq == rsqclose[m] && in[i].atomID > idclose[m]) continue; + iclose[m] = i; + idclose[m] = in[i].atomID; + rsqclose[m] = rsq; + } + } + + // compute rsqfar for all bodies I own + // set rsqfar back in caller + + double rsqfar = 0.0; + + for (int i = 0; i < n; i++) { + m = hash.find(in[i].bodyID)->second; + xown = in[iclose[m]].x; + x = in[i].x; + delx = x[0] - xown[0]; + dely = x[1] - xown[1]; + delz = x[2] - xown[2]; + rsq = delx*delx + dely*dely + delz*delz; + rsqfar = MAX(rsqfar,rsq); + } + + frsptr->rsqfar = rsqfar; + + // pass list of OutRvous datums back to comm->rendezvous + + int nout = n; + memory->create(proclist,nout,"rigid/small:proclist"); + OutRvous *out = (OutRvous *) + memory->smalloc(nout*sizeof(OutRvous),"rigid/small:out"); + + for (int i = 0; i < nout; i++) { + proclist[i] = in[i].me; + out[i].ilocal = in[i].ilocal; + m = hash.find(in[i].bodyID)->second; + out[i].atomID = idclose[m]; + } + + outbuf = (char *) out; // clean up + // Comm::rendezvous will delete proclist and out (outbuf) - delete hash; - memory->destroy(buf); memory->destroy(bbox); memory->destroy(ctr); memory->destroy(idclose); + memory->destroy(iclose); memory->destroy(rsqclose); -} -/* ---------------------------------------------------------------------- - process rigid body atoms from another proc - update bounding box for rigid bodies my atoms are part of -------------------------------------------------------------------------- */ - -void FixRigidSmall::ring_bbox(int n, char *cbuf, void *ptr) -{ - FixRigidSmall *frsptr = (FixRigidSmall *) ptr; - std::map *hash = frsptr->hash; - double **bbox = frsptr->bbox; - - double *buf = (double *) cbuf; - int ndatums = n/4; - - int j,imol; - double *x; - - int m = 0; - for (int i = 0; i < ndatums; i++, m += 4) { - imol = static_cast (buf[m]); - if (hash->find(imol) != hash->end()) { - j = hash->find(imol)->second; - x = &buf[m+1]; - bbox[j][0] = MIN(bbox[j][0],x[0]); - bbox[j][1] = MAX(bbox[j][1],x[0]); - bbox[j][2] = MIN(bbox[j][2],x[1]); - bbox[j][3] = MAX(bbox[j][3],x[1]); - bbox[j][4] = MIN(bbox[j][4],x[2]); - bbox[j][5] = MAX(bbox[j][5],x[2]); - } - } -} - -/* ---------------------------------------------------------------------- - process rigid body atoms from another proc - update nearest atom to body center for rigid bodies my atoms are part of -------------------------------------------------------------------------- */ - -void FixRigidSmall::ring_nearest(int n, char *cbuf, void *ptr) -{ - FixRigidSmall *frsptr = (FixRigidSmall *) ptr; - std::map *hash = frsptr->hash; - double **ctr = frsptr->ctr; - tagint *idclose = frsptr->idclose; - double *rsqclose = frsptr->rsqclose; - - double *buf = (double *) cbuf; - int ndatums = n/5; - - int j,imol; - tagint tag; - double delx,dely,delz,rsq; - double *x; - - int m = 0; - for (int i = 0; i < ndatums; i++, m += 5) { - imol = static_cast (buf[m]); - if (hash->find(imol) != hash->end()) { - j = hash->find(imol)->second; - tag = (tagint) ubuf(buf[m+1]).i; - x = &buf[m+2]; - delx = x[0] - ctr[j][0]; - dely = x[1] - ctr[j][1]; - delz = x[2] - ctr[j][2]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= rsqclose[j]) { - if (rsq == rsqclose[j] && tag > idclose[j]) continue; - idclose[j] = tag; - rsqclose[j] = rsq; - } - } - } -} - -/* ---------------------------------------------------------------------- - process rigid body atoms from another proc - update rsqfar = distance from owning atom to other atom -------------------------------------------------------------------------- */ - -void FixRigidSmall::ring_farthest(int n, char *cbuf, void *ptr) -{ - FixRigidSmall *frsptr = (FixRigidSmall *) ptr; - double **x = frsptr->atom->x; - imageint *image = frsptr->atom->image; - int nlocal = frsptr->atom->nlocal; - - double *buf = (double *) cbuf; - int ndatums = n/4; - - int iowner; - tagint tag; - double delx,dely,delz,rsq; - double *xx; - double unwrap[3]; - - int m = 0; - for (int i = 0; i < ndatums; i++, m += 4) { - tag = (tagint) ubuf(buf[m]).i; - iowner = frsptr->atom->map(tag); - if (iowner < 0 || iowner >= nlocal) continue; - frsptr->domain->unmap(x[iowner],image[iowner],unwrap); - xx = &buf[m+1]; - delx = xx[0] - unwrap[0]; - dely = xx[1] - unwrap[1]; - delz = xx[2] - unwrap[2]; - rsq = delx*delx + dely*dely + delz*delz; - frsptr->rsqfar = MAX(frsptr->rsqfar,rsq); - } + return nout; } /* ---------------------------------------------------------------------- @@ -2472,9 +2410,9 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) int nlocal = atom->nlocal; - hash = new std::map(); + std::map hash; for (i = 0; i < nlocal; i++) - if (bodyown[i] >= 0) (*hash)[atom->molecule[i]] = bodyown[i]; + if (bodyown[i] >= 0) hash[atom->molecule[i]] = bodyown[i]; // open file and read header @@ -2533,11 +2471,11 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) id = ATOTAGINT(values[0]); if (id <= 0 || id > maxmol) error->all(FLERR,"Invalid rigid body ID in fix rigid/small file"); - if (hash->find(id) == hash->end()) { + if (hash.find(id) == hash.end()) { buf = next + 1; continue; } - m = (*hash)[id]; + m = hash[id]; inbody[m] = 1; if (which == 0) { @@ -2576,7 +2514,6 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) delete [] buffer; delete [] values; - delete hash; } /* ---------------------------------------------------------------------- diff --git a/src/RIGID/fix_rigid_small.h b/src/RIGID/fix_rigid_small.h index 3f6826f9bb..a820efcdea 100644 --- a/src/RIGID/fix_rigid_small.h +++ b/src/RIGID/fix_rigid_small.h @@ -23,7 +23,7 @@ FixStyle(rigid/small,FixRigidSmall) #include "fix.h" // replace this later -#include +//#include namespace LAMMPS_NS { @@ -180,13 +180,21 @@ class FixRigidSmall : public Fix { // class data used by ring communication callbacks - std::map *hash; - double **bbox; - double **ctr; - tagint *idclose; - double *rsqclose; double rsqfar; + struct InRvous { + int me,ilocal; + tagint atomID,bodyID; + double x[3]; + }; + + struct OutRvous { + int ilocal; + tagint atomID; + }; + + // local methods + void image_shift(); void set_xv(); void set_v(); @@ -199,11 +207,9 @@ class FixRigidSmall : public Fix { void grow_body(); void reset_atom2body(); - // callback functions for ring communication + // callback function for rendezvous communication - static void ring_bbox(int, char *, void *); - static void ring_nearest(int, char *, void *); - static void ring_farthest(int, char *, void *); + static int rendezvous_body(int, char *, int *&, char *&, void *); // debug diff --git a/src/comm.cpp b/src/comm.cpp index f355a562fc..5fcfa141d0 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -28,6 +28,7 @@ #include "dump.h" #include "group.h" #include "procmap.h" +#include "irregular.h" #include "accelerator_kokkos.h" #include "memory.h" #include "error.h" @@ -725,6 +726,56 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, memory->destroy(bufcopy); } +/* ---------------------------------------------------------------------- + rendezvous communication operation +------------------------------------------------------------------------- */ + +int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, + int (*callback)(int, char *, int *&, char *&, void *), + char *&outbuf, int outsize, void *ptr) +{ + // comm data from caller decomposition to rendezvous decomposition + + Irregular *irregular = new Irregular(lmp); + + int n_rvous = irregular->create_data(n,proclist); // add sort + char *inbuf_rvous = (char *) memory->smalloc((bigint) n_rvous*insize, + "rendezvous:inbuf_rvous"); + irregular->exchange_data(inbuf,insize,inbuf_rvous); + + irregular->destroy_data(); + delete irregular; + + // peform rendezvous computation via callback() + // callback() allocates proclist_rvous and outbuf_rvous + + int *proclist_rvous; + char *outbuf_rvous; + + int nout_rvous = + callback(n_rvous,inbuf_rvous,proclist_rvous,outbuf_rvous,ptr); + + memory->sfree(inbuf_rvous); + + // comm data from rendezvous decomposition back to caller + // caller will free outbuf + + irregular = new Irregular(lmp); + + int nout = irregular->create_data(nout_rvous,proclist_rvous); + outbuf = (char *) memory->smalloc((bigint) nout*outsize,"rendezvous:outbuf"); + irregular->exchange_data(outbuf_rvous,outsize,outbuf); + + irregular->destroy_data(); + delete irregular; + memory->destroy(proclist_rvous); + memory->sfree(outbuf_rvous); + + // return number of datums + + return nout; +} + /* ---------------------------------------------------------------------- proc 0 reads Nlines from file into buf and bcasts buf to all procs caller allocates buf to max size needed diff --git a/src/comm.h b/src/comm.h index 2579f9b283..8bb057a0c1 100644 --- a/src/comm.h +++ b/src/comm.h @@ -109,6 +109,10 @@ class Comm : protected Pointers { void ring(int, int, void *, int, void (*)(int, char *, void *), void *, void *, int self = 1); + int rendezvous(int, int *, char *, int, + int (*)(int, char *, int *&, char *&, void *), + char *&, int, void *); + int read_lines_from_file(FILE *, int, int, char *); int read_lines_from_file_universe(FILE *, int, int, char *); diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 383c60f1cd..ecbf612f70 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -513,9 +513,6 @@ void CreateAtoms::command(int narg, char **arg) if (domain->triclinic) domain->lamda2x(atom->nlocal); } - MPI_Barrier(world); - double time2 = MPI_Wtime(); - // clean up delete ranmol; @@ -525,21 +522,6 @@ void CreateAtoms::command(int narg, char **arg) delete [] ystr; delete [] zstr; - // print status - - if (comm->me == 0) { - if (screen) { - fprintf(screen,"Created " BIGINT_FORMAT " atoms\n", - atom->natoms-natoms_previous); - fprintf(screen," Time spent = %g secs\n",time2-time1); - } - if (logfile) { - fprintf(logfile,"Created " BIGINT_FORMAT " atoms\n", - atom->natoms-natoms_previous); - fprintf(logfile," Time spent = %g secs\n",time2-time1); - } - } - // for MOLECULE mode: // create special bond lists for molecular systems, // but not for atom style template @@ -549,6 +531,25 @@ void CreateAtoms::command(int narg, char **arg) if (atom->molecular == 1 && onemol->bondflag && !onemol->specialflag) { Special special(lmp); special.build(); + + } + } + + // print status + + MPI_Barrier(world); + double time2 = MPI_Wtime(); + + if (comm->me == 0) { + if (screen) { + fprintf(screen,"Created " BIGINT_FORMAT " atoms\n", + atom->natoms-natoms_previous); + fprintf(screen," create_atoms CPU = %g secs\n",time2-time1); + } + if (logfile) { + fprintf(logfile,"Created " BIGINT_FORMAT " atoms\n", + atom->natoms-natoms_previous); + fprintf(logfile," create_atoms CPU = %g secs\n",time2-time1); } } } diff --git a/src/hashlittle.cpp b/src/hashlittle.cpp new file mode 100644 index 0000000000..be930217a1 --- /dev/null +++ b/src/hashlittle.cpp @@ -0,0 +1,333 @@ +// Hash function hashlittle() +// from lookup3.c, by Bob Jenkins, May 2006, Public Domain +// bob_jenkins@burtleburtle.net + +#include "stddef.h" +#include "stdint.h" + +#define HASH_LITTLE_ENDIAN 1 // Intel and AMD are little endian + +#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) + +/* +------------------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. + +This is reversible, so any information in (a,b,c) before mix() is +still in (a,b,c) after mix(). + +If four pairs of (a,b,c) inputs are run through mix(), or through +mix() in reverse, there are at least 32 bits of the output that +are sometimes the same for one pair and different for another pair. +This was tested for: +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that +satisfy this are + 4 6 8 16 19 4 + 9 15 3 18 27 15 + 14 9 3 7 17 3 +Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing +for "differ" defined as + with a one-bit base and a two-bit delta. I +used http://burtleburtle.net/bob/hash/avalanche.html to choose +the operations, constants, and arrangements of the variables. + +This does not achieve avalanche. There are input bits of (a,b,c) +that fail to affect some output bits of (a,b,c), especially of a. The +most thoroughly mixed value is c, but it doesn't really even achieve +avalanche in c. + +This allows some parallelism. Read-after-writes are good at doubling +the number of bits affected, so the goal of mixing pulls in the opposite +direction as the goal of parallelism. I did what I could. Rotates +seem to cost as much as shifts on every machine I could lay my hands +on, and rotates are much kinder to the top and bottom bits, so I used +rotates. +------------------------------------------------------------------------------- +*/ +#define mix(a,b,c) \ +{ \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c,16); c += b; \ + b -= a; b ^= rot(a,19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ +} + +/* +------------------------------------------------------------------------------- +final -- final mixing of 3 32-bit values (a,b,c) into c + +Pairs of (a,b,c) values differing in only a few bits will usually +produce values of c that look totally different. This was tested for +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +These constants passed: + 14 11 25 16 4 14 24 + 12 14 25 16 4 14 24 +and these came close: + 4 8 15 26 3 22 24 + 10 8 15 26 3 22 24 + 11 8 15 26 3 22 24 +------------------------------------------------------------------------------- +*/ +#define final(a,b,c) \ +{ \ + c ^= b; c -= rot(b,14); \ + a ^= c; a -= rot(c,11); \ + b ^= a; b -= rot(a,25); \ + c ^= b; c -= rot(b,16); \ + a ^= c; a -= rot(c,4); \ + b ^= a; b -= rot(a,14); \ + c ^= b; c -= rot(b,24); \ +} + +/* +------------------------------------------------------------------------------- +hashlittle() -- hash a variable-length key into a 32-bit value + k : the key (the unaligned variable-length array of bytes) + length : the length of the key, counting by bytes + initval : can be any 4-byte value +Returns a 32-bit value. Every bit of the key affects every bit of +the return value. Two keys differing by one or two bits will have +totally different hash values. + +The best hash table sizes are powers of 2. There is no need to do +mod a prime (mod is sooo slow!). If you need less than 32 bits, +use a bitmask. For example, if you need only 10 bits, do + h = (h & hashmask(10)); +In which case, the hash table should have hashsize(10) elements. + +If you are hashing n strings (uint8_t **)k, do it like this: + for (i=0, h=0; i 12) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 12; + k += 3; + } + + /*----------------------------- handle the last (probably partial) block */ + /* + * "k[2]&0xffffff" actually reads beyond the end of the string, but + * then masks off the part it's not allowed to read. Because the + * string is aligned, the masked-off tail is in the same word as the + * rest of the string. Every machine with memory protection I've seen + * does it on word boundaries, so is OK with this. But VALGRIND will + * still catch it and complain. The masking trick does make the hash + * noticably faster for short strings (like English words). + */ +#ifndef VALGRIND + + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; + case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; + case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=k[1]&0xffffff; a+=k[0]; break; + case 6 : b+=k[1]&0xffff; a+=k[0]; break; + case 5 : b+=k[1]&0xff; a+=k[0]; break; + case 4 : a+=k[0]; break; + case 3 : a+=k[0]&0xffffff; break; + case 2 : a+=k[0]&0xffff; break; + case 1 : a+=k[0]&0xff; break; + case 0 : return c; /* zero length strings require no mixing */ + } + +#else /* make valgrind happy */ + + k8 = (const uint8_t *)k; + switch(length) + { + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; + case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ + case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[1]; a+=k[0]; break; + case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ + case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]; break; + case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ + case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ + case 1 : a+=k8[0]; break; + case 0 : return c; + } + +#endif /* !valgrind */ + + } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { + const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ + const uint8_t *k8; + + /*--------------- all but last block: aligned reads and different mixing */ + while (length > 12) + { + a += k[0] + (((uint32_t)k[1])<<16); + b += k[2] + (((uint32_t)k[3])<<16); + c += k[4] + (((uint32_t)k[5])<<16); + mix(a,b,c); + length -= 12; + k += 6; + } + + /*----------------------------- handle the last (probably partial) block */ + k8 = (const uint8_t *)k; + switch(length) + { + case 12: c+=k[4]+(((uint32_t)k[5])<<16); + b+=k[2]+(((uint32_t)k[3])<<16); + a+=k[0]+(((uint32_t)k[1])<<16); + break; + case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ + case 10: c+=k[4]; + b+=k[2]+(((uint32_t)k[3])<<16); + a+=k[0]+(((uint32_t)k[1])<<16); + break; + case 9 : c+=k8[8]; /* fall through */ + case 8 : b+=k[2]+(((uint32_t)k[3])<<16); + a+=k[0]+(((uint32_t)k[1])<<16); + break; + case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ + case 6 : b+=k[2]; + a+=k[0]+(((uint32_t)k[1])<<16); + break; + case 5 : b+=k8[4]; /* fall through */ + case 4 : a+=k[0]+(((uint32_t)k[1])<<16); + break; + case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ + case 2 : a+=k[0]; + break; + case 1 : a+=k8[0]; + break; + case 0 : return c; /* zero length requires no mixing */ + } + + } else { /* need to read the key one byte at a time */ + const uint8_t *k = (const uint8_t *)key; + + /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ + while (length > 12) + { + a += k[0]; + a += ((uint32_t)k[1])<<8; + a += ((uint32_t)k[2])<<16; + a += ((uint32_t)k[3])<<24; + b += k[4]; + b += ((uint32_t)k[5])<<8; + b += ((uint32_t)k[6])<<16; + b += ((uint32_t)k[7])<<24; + c += k[8]; + c += ((uint32_t)k[9])<<8; + c += ((uint32_t)k[10])<<16; + c += ((uint32_t)k[11])<<24; + mix(a,b,c); + length -= 12; + k += 12; + } + + /*-------------------------------- last block: affect all 32 bits of (c) */ + switch(length) /* all the case statements fall through */ + { + case 12: c+=((uint32_t)k[11])<<24; + case 11: c+=((uint32_t)k[10])<<16; + case 10: c+=((uint32_t)k[9])<<8; + case 9 : c+=k[8]; + case 8 : b+=((uint32_t)k[7])<<24; + case 7 : b+=((uint32_t)k[6])<<16; + case 6 : b+=((uint32_t)k[5])<<8; + case 5 : b+=k[4]; + case 4 : a+=((uint32_t)k[3])<<24; + case 3 : a+=((uint32_t)k[2])<<16; + case 2 : a+=((uint32_t)k[1])<<8; + case 1 : a+=k[0]; + break; + case 0 : return c; + } + } + + final(a,b,c); + return c; + +#else /* PURIFY_HATES_HASHLITTLE */ +/* I don't know what it is about Jenkins' hashlittle function, but + * it drives purify insane, even with VALGRIND defined. It makes + * purify unusable!! The code execution doesn't even make sense. + * Below is a (probably) weaker hash function that at least allows + * testing with purify. + */ +#define MAXINT_DIV_PHI 11400714819323198485U + + uint32_t h, rest, *p, bytes, num_bytes; + char *byteptr; + + num_bytes = length; + + /* First hash the uint32_t-sized portions of the key */ + h = 0; + for (p = (uint32_t *)key, bytes=num_bytes; + bytes >= (uint32_t) sizeof(uint32_t); + bytes-=sizeof(uint32_t), p++){ + h = (h^(*p))*MAXINT_DIV_PHI; + } + + /* Then take care of the remaining bytes, if any */ + rest = 0; + for (byteptr = (char *)p; bytes > 0; bytes--, byteptr++){ + rest = (rest<<8) | (*byteptr); + } + + /* If extra bytes, merge the two parts */ + if (rest) + h = (h^rest)*MAXINT_DIV_PHI; + + return h; +#endif /* PURIFY_HATES_HASHLITTLE */ +} diff --git a/src/hashlittle.h b/src/hashlittle.h new file mode 100644 index 0000000000..7b57a35c80 --- /dev/null +++ b/src/hashlittle.h @@ -0,0 +1,5 @@ +// Hash function hashlittle() +// from lookup3.c, by Bob Jenkins, May 2006, Public Domain +// bob_jenkins@burtleburtle.net + +uint32_t hashlittle(const void *key, size_t length, uint32_t); diff --git a/src/irregular.cpp b/src/irregular.cpp index 9c15f135d0..60025249cf 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -501,7 +501,8 @@ int compare_standalone(const int i, const int j, void *ptr) void Irregular::exchange_atom(double *sendbuf, int *sizes, double *recvbuf) { - int i,m,n,offset,count; + int i,m,n,count; + bigint offset; // post all receives @@ -739,11 +740,13 @@ int Irregular::create_data(int n, int *proclist, int sortflag) void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf) { - int i,m,n,offset,count; + int i,n,count; + bigint m; // these 2 lines enable send/recv buf to be larger than 2 GB + char *dest; // post all receives, starting after self copies - offset = num_self*nbytes; + bigint offset = num_self*nbytes; for (int irecv = 0; irecv < nrecv_proc; irecv++) { MPI_Irecv(&recvbuf[offset],num_recv[irecv]*nbytes,MPI_CHAR, proc_recv[irecv],0,world,&request[irecv]); @@ -765,18 +768,22 @@ void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf) n = 0; for (int isend = 0; isend < nsend_proc; isend++) { count = num_send[isend]; + dest = buf; for (i = 0; i < count; i++) { m = index_send[n++]; - memcpy(&buf[i*nbytes],&sendbuf[m*nbytes],nbytes); + memcpy(dest,&sendbuf[m*nbytes],nbytes); + dest += nbytes; } MPI_Send(buf,count*nbytes,MPI_CHAR,proc_send[isend],0,world); } // copy datums to self, put at beginning of recvbuf + dest = recvbuf; for (i = 0; i < num_self; i++) { m = index_self[i]; - memcpy(&recvbuf[i*nbytes],&sendbuf[m*nbytes],nbytes); + memcpy(dest,&sendbuf[m*nbytes],nbytes); + dest += nbytes; } // wait on all incoming messages diff --git a/src/read_data.cpp b/src/read_data.cpp index 373ba30151..d7bd298e7b 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -120,6 +120,9 @@ void ReadData::command(int narg, char **arg) { if (narg < 1) error->all(FLERR,"Illegal read_data command"); + MPI_Barrier(world); + double time1 = MPI_Wtime; + // optional args addflag = NONE; @@ -905,6 +908,18 @@ void ReadData::command(int narg, char **arg) force->kspace = saved_kspace; } + + // total time + + MPI_Barrier(world); + double time2 = MPI_Wtime; + + if (comm->me == 0) { + if (screen) + fprintf(screen," read_atoms CPU = %g secs\n",time2-time1); + if (logfile) + fprintf(logfile," read_atoms CPU = %g secs\n",time2-time1); + } } /* ---------------------------------------------------------------------- diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 82028d8316..a338a843d7 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -81,6 +81,9 @@ void ReadRestart::command(int narg, char **arg) if (domain->box_exist) error->all(FLERR,"Cannot read_restart after simulation box is defined"); + MPI_Barrier(world); + double time1 = MPI_Wtime; + MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); @@ -562,6 +565,18 @@ void ReadRestart::command(int narg, char **arg) Special special(lmp); special.build(); } + + // total time + + MPI_Barrier(world); + double time2 = MPI_Wtime; + + if (comm->me == 0) { + if (screen) + fprintf(screen," read_restart CPU = %g secs\n",time2-time1); + if (logfile) + fprintf(logfile," read_restart CPU = %g secs\n",time2-time1); + } } /* ---------------------------------------------------------------------- diff --git a/src/replicate.cpp b/src/replicate.cpp index cdadf1fd1f..3c8f4a8aee 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -76,7 +76,7 @@ void Replicate::command(int narg, char **arg) if (atom->nextra_grow || atom->nextra_restart || atom->nextra_store) error->all(FLERR,"Cannot replicate with fixes that store atom quantities"); - // Record wall time for atom replication + // record wall time for atom replication MPI_Barrier(world); double time1 = MPI_Wtime(); @@ -762,15 +762,15 @@ void Replicate::command(int narg, char **arg) special.build(); } - // Wall time + // total time MPI_Barrier(world); double time2 = MPI_Wtime(); if (me == 0) { if (screen) - fprintf(screen," Time spent = %g secs\n",time2-time1); + fprintf(screen," replicate CPU = %g secs\n",time2-time1); if (logfile) - fprintf(logfile," Time spent = %g secs\n",time2-time1); + fprintf(logfile," replicate CPU = %g secs\n",time2-time1); } } diff --git a/src/special.cpp b/src/special.cpp index fccc930353..a18c597765 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -21,9 +21,10 @@ #include "modify.h" #include "fix.h" #include "accelerator_kokkos.h" +#include "hashlittle.h" +#include "atom_masks.h" #include "memory.h" #include "error.h" -#include "atom_masks.h" using namespace LAMMPS_NS; @@ -54,11 +55,12 @@ Special::~Special() void Special::build() { - int i,j,k,size; - int max,maxall,nbuf; - tagint *buf; + int i,j,k,m,n,size,proc; + int max,maxall; + char *buf; MPI_Barrier(world); + double time1 = MPI_Wtime(); int nlocal = atom->nlocal; @@ -87,99 +89,88 @@ void Special::build() // ----------------------------------------------------- // compute nspecial[i][0] = # of 1-2 neighbors of atom i + // create onetwo[i] = list of 1-2 neighbors for atom i // ----------------------------------------------------- - // bond partners stored by atom itself + // ncount = # of my datums to send (newton or newton off) + // include nlocal datums with owner of each atom - for (i = 0; i < nlocal; i++) nspecial[i][0] = num_bond[i]; + int newton_bond = force->newton_bond; - // if newton_bond off, then done - // else only counted 1/2 of all bonds, so count other half + int ncount = 0; + for (i = 0; i < nlocal; i++) ncount += num_bond[i]; + if (newton_bond) ncount *= 2; + ncount += nlocal; - if (force->newton_bond) { + int *proclist; + memory->create(proclist,ncount,"special:proclist"); + InRvous *inbuf = (InRvous *) + memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = global tag of 2nd atom in each bond + // setup input buf to rendezvous comm + // one datum for each owned atom: datum = proc, atomID + // one datum for each bond partner: datum = atomID, bond partner ID + // owning proc for each datum = random hash of atomID - nbuf = 0; - for (i = 0; i < nlocal; i++) nbuf += num_bond[i]; - memory->create(buf,nbuf,"special:buf"); + m = 0; + for (i = 0; i < nlocal; i++) { + proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; + proclist[m] = proc; + inbuf[m].me = me; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = 0; + m++; - // fill buffer with global tags of bond partners of my atoms - - size = 0; - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_bond[i]; j++) - buf[size++] = bond_atom[i][j]; - - // cycle buffer around ring of procs back to self - // when receive buffer, scan tags for atoms I own - // when find one, increment nspecial count for that atom - - comm->ring(size,sizeof(tagint),buf,1,ring_one,NULL,(void *)this); - - memory->destroy(buf); + for (j = 0; j < num_bond[i]; j++) { + proclist[m] = proc; + inbuf[m].me = -1; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = bond_atom[i][j]; + m++; + } + if (newton_bond) { + for (j = 0; j < num_bond[i]; j++) { + proclist[m] = hashlittle(&bond_atom[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -1; + inbuf[m].atomID = bond_atom[i][j]; + inbuf[m].partnerID = tag[i]; + m++; + } + } } - // ---------------------------------------------------- - // create onetwo[i] = list of 1-2 neighbors for atom i - // ---------------------------------------------------- + // perform rendezvous operation + // each proc owns random subset of atoms, receives all their bond partners - max = 0; - for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][0]); + int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), + rendezvous_1234, + buf,sizeof(OutRvous),(void *) this); + OutRvous *outbuf = (OutRvous *) buf; - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + memory->destroy(proclist); + memory->sfree(inbuf); + + // set nspecial[0] and onetwo for all owned atoms based on output info + + MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onetwo,nlocal,maxall,"special:onetwo"); + + for (i = 0; i < nlocal; i++) nspecial[i][0] = 0; + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onetwo[i][nspecial[i][0]++] = outbuf[m].partnerID; + } + + memory->sfree(outbuf); + + // compute and print max # of 1-2 neighbors if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-2 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-2 neighbors\n",maxall); } - memory->create(onetwo,nlocal,maxall,"special:onetwo"); - - // count = accumulating counter - - memory->create(count,nlocal,"special:count"); - for (i = 0; i < nlocal; i++) count[i] = 0; - - // add bond partners stored by atom to onetwo list - - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_bond[i]; j++) - onetwo[i][count[i]++] = bond_atom[i][j]; - - // if newton_bond off, then done - // else only stored 1/2 of all bonds, so store other half - - if (force->newton_bond) { - - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = 2 global tags in each bond - - nbuf = 0; - for (i = 0; i < nlocal; i++) nbuf += 2*num_bond[i]; - memory->create(buf,nbuf,"special:buf"); - - // fill buffer with global tags of both atoms in bond - - size = 0; - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_bond[i]; j++) { - buf[size++] = tag[i]; - buf[size++] = bond_atom[i][j]; - } - - // cycle buffer around ring of procs back to self - // when receive buffer, scan 2nd-atom tags for atoms I own - // when find one, add 1st-atom tag to onetwo list for 2nd atom - - comm->ring(size,sizeof(tagint),buf,2,ring_two,NULL,(void *)this); - - memory->destroy(buf); - } - - memory->destroy(count); - // ----------------------------------------------------- // done if special_bond weights for 1-3, 1-4 are set to 1.0 // ----------------------------------------------------- @@ -189,114 +180,83 @@ void Special::build() dedup(); combine(); fix_alteration(); + timer_output(time1); return; } // ----------------------------------------------------- // compute nspecial[i][1] = # of 1-3 neighbors of atom i + // create onethree[i] = list of 1-3 neighbors for atom i // ----------------------------------------------------- - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = 2 scalars + list of 1-2 neighbors + // ncount = # of my datums to send + // include nlocal datums with owner of each atom - nbuf = 0; - for (i = 0; i < nlocal; i++) nbuf += 2 + nspecial[i][0]; - memory->create(buf,nbuf,"special:buf"); + ncount = nlocal; + for (i = 0; i < nlocal; i++) ncount += nspecial[i][0]*(nspecial[i][0]-1); - // fill buffer with: - // (1) = counter for 1-3 neighbors, initialized to 0 - // (2) = # of 1-2 neighbors - // (3:N) = list of 1-2 neighbors + memory->create(proclist,ncount,"special:proclist"); + inbuf = (InRvous *) + memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - size = 0; + // setup input buf to rendezvous comm + // one datum for each owned atom: datum = proc, atomID + // one datum for each bond partner: datum = atomID, bond partner ID + // owning proc for each datum = random hash of atomID + + m = 0; for (i = 0; i < nlocal; i++) { - buf[size++] = 0; - buf[size++] = nspecial[i][0]; - for (j = 0; j < nspecial[i][0]; j++) buf[size++] = onetwo[i][j]; + proclist[m] = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; + inbuf[m].me = me; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = 0; + m++; + + for (j = 0; j < nspecial[i][0]; j++) { + proc = hashlittle(&onetwo[i][j],sizeof(tagint),0) % nprocs; + for (k = 0; k < nspecial[i][0]; k++) { + if (j == k) continue; + proclist[m] = proc; + inbuf[m].me = -1; + inbuf[m].atomID = onetwo[i][j]; + inbuf[m].partnerID = onetwo[i][k]; + m++; + } + } } - // cycle buffer around ring of procs back to self - // when receive buffer, scan list of 1-2 neighbors for atoms I own - // when find one, increment 1-3 count by # of 1-2 neighbors of my atom, - // subtracting one since my list will contain original atom + // perform rendezvous operation + // each proc owns random subset of atoms, receives all their bond partners - comm->ring(size,sizeof(tagint),buf,3,ring_three,buf,(void *)this); + nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), + rendezvous_1234, + buf,sizeof(OutRvous),(void *) this); + outbuf = (OutRvous *) buf; - // extract count from buffer that has cycled back to me - // nspecial[i][1] = # of 1-3 neighbors of atom i + memory->destroy(proclist); + memory->sfree(inbuf); - j = 0; - for (i = 0; i < nlocal; i++) { - nspecial[i][1] = buf[j]; - j += 2 + nspecial[i][0]; + // set nspecial[1] and onethree for all owned atoms based on output info + + MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onethree,nlocal,maxall,"special:onethree"); + + for (i = 0; i < nlocal; i++) nspecial[i][1] = 0; + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onethree[i][nspecial[i][1]++] = outbuf[m].partnerID; } - memory->destroy(buf); + memory->destroy(outbuf); - // ---------------------------------------------------- - // create onethree[i] = list of 1-3 neighbors for atom i - // ---------------------------------------------------- - - max = 0; - for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][1]); - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + // compute and print max # of 1-3 neighbors if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-3 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-3 neighbors\n",maxall); } - memory->create(onethree,nlocal,maxall,"special:onethree"); - - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = 4 scalars + list of 1-2 neighs + list of 1-3 neighs - - nbuf = 0; - for (i = 0; i < nlocal; i++) nbuf += 4 + nspecial[i][0] + nspecial[i][1]; - memory->create(buf,nbuf,"special:buf"); - - // fill buffer with: - // (1) = global tag of original atom - // (2) = # of 1-2 neighbors - // (3) = # of 1-3 neighbors - // (4) = counter for 1-3 neighbors, initialized to 0 - // (5:N) = list of 1-2 neighbors - // (N+1:2N) space for list of 1-3 neighbors - - size = 0; - for (i = 0; i < nlocal; i++) { - buf[size++] = tag[i]; - buf[size++] = nspecial[i][0]; - buf[size++] = nspecial[i][1]; - buf[size++] = 0; - for (j = 0; j < nspecial[i][0]; j++) buf[size++] = onetwo[i][j]; - size += nspecial[i][1]; - } - - // cycle buffer around ring of procs back to self - // when receive buffer, scan list of 1-2 neighbors for atoms I own - // when find one, add its neighbors to 1-3 list - // increment the count in buf(i+4) - // exclude the atom whose tag = original - // this process may include duplicates but they will be culled later - - comm->ring(size,sizeof(tagint),buf,4,ring_four,buf,(void *)this); - - // fill onethree with buffer values that have been returned to me - // sanity check: accumulated buf[i+3] count should equal - // nspecial[i][1] for each atom - - j = 0; - for (i = 0; i < nlocal; i++) { - if (buf[j+3] != nspecial[i][1]) - error->one(FLERR,"1-3 bond count is inconsistent"); - j += 4 + nspecial[i][0]; - for (k = 0; k < nspecial[i][1]; k++) - onethree[i][k] = buf[j++]; - } - - memory->destroy(buf); - // done if special_bond weights for 1-4 are set to 1.0 if (force->special_lj[3] == 1.0 && force->special_coul[3] == 1.0) { @@ -304,117 +264,92 @@ void Special::build() if (force->special_angle) angle_trim(); combine(); fix_alteration(); + timer_output(time1); return; } // ----------------------------------------------------- // compute nspecial[i][2] = # of 1-4 neighbors of atom i + // create onefour[i] = list of 1-4 neighbors for atom i // ----------------------------------------------------- - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = 2 scalars + list of 1-3 neighbors + // ncount = # of my datums to send + // include nlocal datums with owner of each atom - nbuf = 0; - for (i = 0; i < nlocal; i++) nbuf += 2 + nspecial[i][1]; - memory->create(buf,nbuf,"special:buf"); + ncount = nlocal; + for (i = 0; i < nlocal; i++) ncount += nspecial[i][1]*nspecial[i][0]; - // fill buffer with: - // (1) = counter for 1-4 neighbors, initialized to 0 - // (2) = # of 1-3 neighbors - // (3:N) = list of 1-3 neighbors + memory->create(proclist,ncount,"special:proclist"); + inbuf = (InRvous *) + memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - size = 0; + // setup input buf to rendezvous comm + // one datum for each owned atom: datum = proc, atomID + // one datum for each partner: datum = atomID, bond partner ID + // owning proc for each datum = random hash of atomID + + m = 0; for (i = 0; i < nlocal; i++) { - buf[size++] = 0; - buf[size++] = nspecial[i][1]; - for (j = 0; j < nspecial[i][1]; j++) buf[size++] = onethree[i][j]; + proclist[m] = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; + inbuf[m].me = me; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = 0; + m++; + + for (j = 0; j < nspecial[i][1]; j++) { + proc = hashlittle(&onethree[i][j],sizeof(tagint),0) % nprocs; + for (k = 0; k < nspecial[i][0]; k++) { + proclist[m] = proc; + inbuf[m].me = -1; + inbuf[m].atomID = onethree[i][j]; + inbuf[m].partnerID = onetwo[i][k]; + m++; + } + } } - // cycle buffer around ring of procs back to self - // when receive buffer, scan list of 1-3 neighbors for atoms I own - // when find one, increment 1-4 count by # of 1-2 neighbors of my atom - // may include duplicates and original atom but they will be culled later + // perform rendezvous operation + // each proc owns random subset of bodies, receives all atoms in the bodies + // func = compute bbox of each body, flag atom closest to geometric center + // when done: each atom has atom ID of owning atom of its body - comm->ring(size,sizeof(tagint),buf,5,ring_five,buf,(void *)this); + nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), + rendezvous_1234, + buf,sizeof(OutRvous),(void *) this); + outbuf = (OutRvous *) buf; - // extract count from buffer that has cycled back to me - // nspecial[i][2] = # of 1-4 neighbors of atom i + memory->destroy(proclist); + memory->sfree(inbuf); - j = 0; - for (i = 0; i < nlocal; i++) { - nspecial[i][2] = buf[j]; - j += 2 + nspecial[i][1]; + // set nspecial[2] and onefour for all owned atoms based on output info + + MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onefour,nlocal,maxall,"special:onefour"); + + for (i = 0; i < nlocal; i++) nspecial[i][2] = 0; + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onefour[i][nspecial[i][2]++] = outbuf[m].partnerID; } - memory->destroy(buf); + memory->destroy(outbuf); - // ---------------------------------------------------- - // create onefour[i] = list of 1-4 neighbors for atom i - // ---------------------------------------------------- - - max = 0; - for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][2]); - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + // compute and print max # of 1-4 neighbors if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-4 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-4 neighbors\n",maxall); } - memory->create(onefour,nlocal,maxall,"special:onefour"); - - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = 3 scalars + list of 1-3 neighs + list of 1-4 neighs - - nbuf = 0; - for (i = 0; i < nlocal; i++) - nbuf += 3 + nspecial[i][1] + nspecial[i][2]; - memory->create(buf,nbuf,"special:buf"); - - // fill buffer with: - // (1) = # of 1-3 neighbors - // (2) = # of 1-4 neighbors - // (3) = counter for 1-4 neighbors, initialized to 0 - // (4:N) = list of 1-3 neighbors - // (N+1:2N) space for list of 1-4 neighbors - - size = 0; - for (i = 0; i < nlocal; i++) { - buf[size++] = nspecial[i][1]; - buf[size++] = nspecial[i][2]; - buf[size++] = 0; - for (j = 0; j < nspecial[i][1]; j++) buf[size++] = onethree[i][j]; - size += nspecial[i][2]; - } - - // cycle buffer around ring of procs back to self - // when receive buffer, scan list of 1-3 neighbors for atoms I own - // when find one, add its neighbors to 1-4 list - // incrementing the count in buf(i+4) - // this process may include duplicates but they will be culled later - - comm->ring(size,sizeof(tagint),buf,6,ring_six,buf,(void *)this); - - // fill onefour with buffer values that have been returned to me - // sanity check: accumulated buf[i+2] count should equal - // nspecial[i][2] for each atom - - j = 0; - for (i = 0; i < nlocal; i++) { - if (buf[j+2] != nspecial[i][2]) - error->one(FLERR,"1-4 bond count is inconsistent"); - j += 3 + nspecial[i][1]; - for (k = 0; k < nspecial[i][2]; k++) - onefour[i][k] = buf[j++]; - } - - memory->destroy(buf); + // finish processing the onetwo, onethree, onefour lists dedup(); if (force->special_angle) angle_trim(); if (force->special_dihedral) dihedral_trim(); combine(); fix_alteration(); + timer_output(time1); } /* ---------------------------------------------------------------------- @@ -663,17 +598,19 @@ void Special::combine() void Special::angle_trim() { - int i,j,m,n; + int i,j,m,n,proc,index; int *num_angle = atom->num_angle; int *num_dihedral = atom->num_dihedral; tagint **angle_atom1 = atom->angle_atom1; + tagint **angle_atom2 = atom->angle_atom2; tagint **angle_atom3 = atom->angle_atom3; tagint **dihedral_atom1 = atom->dihedral_atom1; tagint **dihedral_atom2 = atom->dihedral_atom2; tagint **dihedral_atom3 = atom->dihedral_atom3; tagint **dihedral_atom4 = atom->dihedral_atom4; int **nspecial = atom->nspecial; + tagint *tag = atom->tag; int nlocal = atom->nlocal; // stats on old 1-3 neighbor counts @@ -697,68 +634,125 @@ void Special::angle_trim() if ((num_angle && atom->nangles) || (num_dihedral && atom->ndihedrals)) { - // dflag = flag for 1-3 neighs of all owned atoms - - int maxcount = 0; - for (i = 0; i < nlocal; i++) maxcount = MAX(maxcount,nspecial[i][1]); - memory->create(dflag,nlocal,maxcount,"special::dflag"); + // ncount = # of my datums to send in 3 parts for each owned atom + // proc owner, onethree list, angle end points + // angle end points are from angle list and 1-3 and 2-4 pairs in dihedrals + // latter is only for angles or dihedrlas where I own atom2 + int ncount = nlocal; + for (i = 0; i < nlocal; i++) ncount += nspecial[i][1]; for (i = 0; i < nlocal; i++) { - n = nspecial[i][1]; - for (j = 0; j < n; j++) dflag[i][j] = 0; + for (j = 0; j < num_angle[i]; j++) { + index = atom->map(angle_atom2[i][j]); + if (index >= 0 && index < nlocal) ncount += 2; + } + for (j = 0; j < num_dihedral[i]; j++) { + index = atom->map(dihedral_atom2[i][j]); + if (index >= 0 && index < nlocal) ncount += 4; + } } - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = list of 1,3 atoms in each angle stored by atom - // and list of 1,3 and 2,4 atoms in each dihedral stored by atom + int *proclist; + memory->create(proclist,ncount,"special:proclist"); + InRvous *inbuf = (InRvous *) + memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - int nbuf = 0; + // setup input buf to rendezvous comm + // one datum for each owned atom: datum = proc, atomID + // sent to owner of atomID + // one datum for each 1-4 partner: datum = atomID, ID + // sent to owner of atomID + // two datums for each dihedral 1-4 endatoms : datum = atomID, ID + // sent to owner of atomID + + m = 0; for (i = 0; i < nlocal; i++) { - if (num_angle && atom->nangles) nbuf += 2*num_angle[i]; - if (num_dihedral && atom->ndihedrals) nbuf += 2*2*num_dihedral[i]; - } - int *buf; - memory->create(buf,nbuf,"special:buf"); + proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; + proclist[m] = proc; + inbuf[m].me = me; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = 0; + m++; - // fill buffer with list of 1,3 atoms in each angle - // and with list of 1,3 and 2,4 atoms in each dihedral + for (j = 0; j < nspecial[i][1]; j++) { + proclist[m] = proc; + inbuf[m].me = -1; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = onethree[i][j]; + m++; + } - int size = 0; - if (num_angle && atom->nangles) - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_angle[i]; j++) { - buf[size++] = angle_atom1[i][j]; - buf[size++] = angle_atom3[i][j]; - } + for (j = 0; j < num_angle[i]; j++) { + index = atom->map(angle_atom2[i][j]); + if (index < 0 || index >= nlocal) continue; - if (num_dihedral && atom->ndihedrals) - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_dihedral[i]; j++) { - buf[size++] = dihedral_atom1[i][j]; - buf[size++] = dihedral_atom3[i][j]; - buf[size++] = dihedral_atom2[i][j]; - buf[size++] = dihedral_atom4[i][j]; - } + proclist[m] = hashlittle(&angle_atom1[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = angle_atom1[i][j]; + inbuf[m].partnerID = angle_atom3[i][j]; + m++; - // cycle buffer around ring of procs back to self - // when receive buffer, scan list of 1,3 atoms looking for atoms I own - // when find one, scan its 1-3 neigh list and mark I,J as in an angle + proclist[m] = hashlittle(&angle_atom3[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = angle_atom3[i][j]; + inbuf[m].partnerID = angle_atom1[i][j]; + m++; + } - comm->ring(size,sizeof(tagint),buf,7,ring_seven,NULL,(void *)this); + for (j = 0; j < num_dihedral[i]; j++) { + index = atom->map(dihedral_atom2[i][j]); + if (index < 0 || index >= nlocal) continue; - // delete 1-3 neighbors if they are not flagged in dflag + proclist[m] = hashlittle(&dihedral_atom1[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = dihedral_atom1[i][j]; + inbuf[m].partnerID = dihedral_atom3[i][j]; + m++; - for (i = 0; i < nlocal; i++) { - m = 0; - for (j = 0; j < nspecial[i][1]; j++) - if (dflag[i][j]) onethree[i][m++] = onethree[i][j]; - nspecial[i][1] = m; + proclist[m] = hashlittle(&dihedral_atom2[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = dihedral_atom2[i][j]; + inbuf[m].partnerID = dihedral_atom4[i][j]; + m++; + + proclist[m] = hashlittle(&dihedral_atom3[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = dihedral_atom3[i][j]; + inbuf[m].partnerID = dihedral_atom1[i][j]; + m++; + + proclist[m] = hashlittle(&dihedral_atom4[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = dihedral_atom4[i][j]; + inbuf[m].partnerID = dihedral_atom2[i][j]; + m++; + } } - // clean up + // perform rendezvous operation + // each proc owns random subset of atoms + // func = compute bbox of each body, flag atom closest to geometric center + // when done: each atom has atom ID of owning atom of its body + + char *buf; + int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), + rendezvous_trim, + buf,sizeof(OutRvous),(void *) this); + OutRvous *outbuf = (OutRvous *) buf; - memory->destroy(dflag); - memory->destroy(buf); + memory->destroy(proclist); + memory->sfree(inbuf); + + // reset nspecial[1] and onethree for all owned atoms based on output info + + for (i = 0; i < nlocal; i++) nspecial[i][1] = 0; + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onethree[i][nspecial[i][1]++] = outbuf[m].partnerID; + } + + memory->destroy(outbuf); // if no angles or dihedrals are defined, delete all 1-3 neighs @@ -789,12 +783,14 @@ void Special::angle_trim() void Special::dihedral_trim() { - int i,j,m,n; + int i,j,m,n,proc,index; int *num_dihedral = atom->num_dihedral; tagint **dihedral_atom1 = atom->dihedral_atom1; + tagint **dihedral_atom2 = atom->dihedral_atom2; tagint **dihedral_atom4 = atom->dihedral_atom4; int **nspecial = atom->nspecial; + tagint *tag = atom->tag; int nlocal = atom->nlocal; // stats on old 1-4 neighbor counts @@ -813,57 +809,95 @@ void Special::dihedral_trim() " %g = # of 1-4 neighbors before dihedral trim\n",allcount); } - // if dihedrals are defined, flag each 1-4 neigh if it appears in a dihedral + // if dihedrals are defined, rendezvous onefour list with dihedral 1-4 pairs if (num_dihedral && atom->ndihedrals) { - // dflag = flag for 1-4 neighs of all owned atoms - - int maxcount = 0; - for (i = 0; i < nlocal; i++) maxcount = MAX(maxcount,nspecial[i][2]); - memory->create(dflag,nlocal,maxcount,"special::dflag"); + // ncount = # of my datums to send in 3 parts for each owned atom + // onefour list, proc owner, dihedral end points + // latter is only for dihedrals where I own atom2 + int ncount = nlocal; + for (i = 0; i < nlocal; i++) ncount += nspecial[i][2]; for (i = 0; i < nlocal; i++) { - n = nspecial[i][2]; - for (j = 0; j < n; j++) dflag[i][j] = 0; + for (j = 0; j < num_dihedral[i]; j++) { + index = atom->map(dihedral_atom2[i][j]); + if (index >= 0 && index < nlocal) ncount += 2; + } } - // nbufmax = largest buffer needed to hold info from any proc - // info for each atom = list of 1,4 atoms in each dihedral stored by atom + int *proclist; + memory->create(proclist,ncount,"special:proclist"); + InRvous *inbuf = (InRvous *) + memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - int nbuf = 0; - for (i = 0; i < nlocal; i++) nbuf += 2*num_dihedral[i]; - int *buf; - memory->create(buf,nbuf,"special:buf"); + // setup input buf to rendezvous comm + // one datum for each owned atom: datum = proc, atomID + // sent to owner of atomID + // one datum for each 1-4 partner: datum = atomID, ID + // sent to owner of atomID + // two datums for each dihedral 1-4 endatoms : datum = atomID, ID + // sent to owner of atomID - // fill buffer with list of 1,4 atoms in each dihedral + m = 0; + for (i = 0; i < nlocal; i++) { + proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; + proclist[m] = proc; + inbuf[m].me = me; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = 0; + m++; - int size = 0; - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_dihedral[i]; j++) { - buf[size++] = dihedral_atom1[i][j]; - buf[size++] = dihedral_atom4[i][j]; + for (j = 0; j < nspecial[i][2]; j++) { + proclist[m] = proc; + inbuf[m].me = -1; + inbuf[m].atomID = tag[i]; + inbuf[m].partnerID = onefour[i][j]; + m++; } - // cycle buffer around ring of procs back to self - // when receive buffer, scan list of 1,4 atoms looking for atoms I own - // when find one, scan its 1-4 neigh list and mark I,J as in a dihedral + for (j = 0; j < num_dihedral[i]; j++) { + index = atom->map(dihedral_atom2[i][j]); + if (index < 0 || index >= nlocal) continue; - comm->ring(size,sizeof(tagint),buf,8,ring_eight,NULL,(void *)this); + proclist[m] = hashlittle(&dihedral_atom1[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = dihedral_atom1[i][j]; + inbuf[m].partnerID = dihedral_atom4[i][j]; + m++; - // delete 1-4 neighbors if they are not flagged in dflag - - for (i = 0; i < nlocal; i++) { - m = 0; - for (j = 0; j < nspecial[i][2]; j++) - if (dflag[i][j]) onefour[i][m++] = onefour[i][j]; - nspecial[i][2] = m; + proclist[m] = hashlittle(&dihedral_atom4[i][j],sizeof(tagint),0) % nprocs; + inbuf[m].me = -2; + inbuf[m].atomID = dihedral_atom4[i][j]; + inbuf[m].partnerID = dihedral_atom1[i][j]; + m++; + } } - // clean up + // perform rendezvous operation + // each proc owns random subset of atoms + // func = compute bbox of each body, flag atom closest to geometric center + // when done: each atom has atom ID of owning atom of its body + + char *buf; + int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), + rendezvous_trim, + buf,sizeof(OutRvous),(void *) this); + OutRvous *outbuf = (OutRvous *) buf; - memory->destroy(dflag); - memory->destroy(buf); + memory->destroy(proclist); + memory->sfree(inbuf); + + // reset nspecial[2] and onefour for all owned atoms based on output info + + for (i = 0; i < nlocal; i++) nspecial[i][2] = 0; + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onefour[i][nspecial[i][2]++] = outbuf[m].partnerID; + } + + memory->destroy(outbuf); // if no dihedrals are defined, delete all 1-4 neighs @@ -888,262 +922,213 @@ void Special::dihedral_trim() } /* ---------------------------------------------------------------------- - when receive buffer, scan tags for atoms I own - when find one, increment nspecial count for that atom + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N InRvous datums + create outbuf = list of Nout OutRvous datums ------------------------------------------------------------------------- */ -void Special::ring_one(int ndatum, char *cbuf, void *ptr) +int Special::rendezvous_1234(int n, char *inbuf, + int *&proclist, char *&outbuf, + void *ptr) { + int i,j,m; + Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; + Memory *memory = sptr->memory; - tagint *buf = (tagint *) cbuf; - int m; + // setup hash + // ncount = number of atoms assigned to me + // key = atom ID + // value = index into Ncount-length data structure - for (int i = 0; i < ndatum; i++) { - m = atom->map(buf[i]); - if (m >= 0 && m < nlocal) nspecial[m][0]++; + InRvous *in = (InRvous *) inbuf; + std::map hash; + tagint id; + + int ncount = 0; + for (i = 0; i < n; i++) + if (in[i].me >= 0) + hash[in[i].atomID] = ncount++; + + // procowner = caller proc that owns each atom + // atomID = ID of each rendezvous atom I own + + int *procowner,*npartner; + tagint *atomID; + memory->create(procowner,ncount,"special:procowner"); + memory->create(atomID,ncount,"special:atomID"); + memory->create(npartner,ncount,"special:npartner"); + for (m = 0; m < ncount; m++) npartner[m] = 0; + + for (i = 0; i < n; i++) { + m = hash.find(in[i].atomID)->second; + if (in[i].me >= 0) { + procowner[m] = in[i].me; + atomID[m] = in[i].atomID; + } else npartner[m]++; } -} -/* ---------------------------------------------------------------------- - when receive buffer, scan 2nd-atom tags for atoms I own - when find one, add 1st-atom tag to onetwo list for 2nd atom -------------------------------------------------------------------------- */ + int max = 0; + for (m = 0; m < ncount; m++) + max = MAX(max,npartner[m]); + sptr->max_rvous = max; -void Special::ring_two(int ndatum, char *cbuf, void *ptr) -{ - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int nlocal = atom->nlocal; + int **partner; + memory->create(partner,ncount,max,"special:partner"); + for (m = 0; m < ncount; m++) npartner[m] = 0; - tagint **onetwo = sptr->onetwo; - int *count = sptr->count; - - tagint *buf = (tagint *) cbuf; - int m; - - for (int i = 1; i < ndatum; i += 2) { - m = atom->map(buf[i]); - if (m >= 0 && m < nlocal) onetwo[m][count[m]++] = buf[i-1]; + for (i = 0; i < n; i++) { + if (in[i].me >= 0) continue; + m = hash.find(in[i].atomID)->second; + partner[m][npartner[m]++] = in[i].partnerID; } -} -/* ---------------------------------------------------------------------- - when receive buffer, scan list of 1-2 neighbors for atoms I own - when find one, increment 1-3 count by # of 1-2 neighbors of my atom, - subtracting one since my list will contain original atom -------------------------------------------------------------------------- */ + // pass list of OutRvous datums back to comm->rendezvous -void Special::ring_three(int ndatum, char *cbuf, void *ptr) -{ - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; + int nout = 0; + for (m = 0; m < ncount; m++) nout += npartner[m]; - tagint *buf = (tagint *) cbuf; - int i,j,m,n,num12; + memory->create(proclist,nout,"special:proclist"); + OutRvous *out = (OutRvous *) + memory->smalloc((bigint) nout*sizeof(OutRvous),"special:out"); - i = 0; - while (i < ndatum) { - n = buf[i]; - num12 = buf[i+1]; - for (j = 0; j < num12; j++) { - m = atom->map(buf[i+2+j]); - if (m >= 0 && m < nlocal) - n += nspecial[m][0] - 1; + nout = 0; + for (m = 0; m < ncount; m++) + for (j = 0; j < npartner[m]; j++) { + proclist[nout] = procowner[m]; + out[nout].atomID = atomID[m]; + out[nout].partnerID = partner[m][j]; + nout++; } - buf[i] = n; - i += 2 + num12; - } + + outbuf = (char *) out; + + // clean up + // Comm::rendezvous will delete proclist and out (outbuf) + + memory->destroy(procowner); + memory->destroy(atomID); + memory->destroy(npartner); + memory->destroy(partner); + + return nout; } /* ---------------------------------------------------------------------- - when receive buffer, scan list of 1-2 neighbors for atoms I own - when find one, add its neighbors to 1-3 list - increment the count in buf(i+4) - exclude the atom whose tag = original - this process may include duplicates but they will be culled later + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N InRvous datums + create outbuf = list of Nout OutRvous datums ------------------------------------------------------------------------- */ -void Special::ring_four(int ndatum, char *cbuf, void *ptr) +int Special::rendezvous_trim(int n, char *inbuf, + int *&proclist, char *&outbuf, + void *ptr) { + int i,j,m; + Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; + Memory *memory = sptr->memory; - tagint **onetwo = sptr->onetwo; + // setup hash + // ncount = number of atoms assigned to me + // key = atom ID + // value = index into Ncount-length data structure - tagint *buf = (tagint *) cbuf; - tagint original; - int i,j,k,m,n,num12,num13; + InRvous *in = (InRvous *) inbuf; + std::map hash; + tagint id; + + int ncount = 0; + for (i = 0; i < n; i++) + if (in[i].me >= 0) + hash[in[i].atomID] = ncount++; - i = 0; - while (i < ndatum) { - original = buf[i]; - num12 = buf[i+1]; - num13 = buf[i+2]; - n = buf[i+3]; - for (j = 0; j < num12; j++) { - m = atom->map(buf[i+4+j]); - if (m >= 0 && m < nlocal) - for (k = 0; k < nspecial[m][0]; k++) - if (onetwo[m][k] != original) - buf[i+4+num12+(n++)] = onetwo[m][k]; + // procowner = caller proc that owns each atom + // atomID = ID of each rendezvous atom I own + // npartner = # of 1-3 partners for each atom I own + + int *procowner,*npartner; + tagint *atomID; + memory->create(procowner,ncount,"special:procowner"); + memory->create(atomID,ncount,"special:atomID"); + memory->create(npartner,ncount,"special:npartner"); + for (m = 0; m < ncount; m++) npartner[m] = 0; + + for (i = 0; i < n; i++) { + m = hash.find(in[i].atomID)->second; + if (in[i].me >= 0) { + procowner[m] = in[i].me; + atomID[m] = in[i].atomID; + } else if (in[i].me == -1) npartner[m]++; + } + + int max = 0; + for (m = 0; m < ncount; m++) max = MAX(max,npartner[m]); + + // partner = list of 1-3 or 1-4 partners for each atom I own + + int **partner; + memory->create(partner,ncount,max,"special:partner"); + for (m = 0; m < ncount; m++) npartner[m] = 0; + + for (i = 0; i < n; i++) { + if (in[i].me >= 0 || in[i].me == -2) continue; + m = hash.find(in[i].atomID)->second; + partner[m][npartner[m]++] = in[i].partnerID; + } + + // flag = 1 if partner is in an actual angle or in a dihedral + + int **flag; + memory->create(flag,ncount,max,"special:flag"); + + for (i = 0; i < ncount; i++) + for (j = 0; j < npartner[i]; j++) + flag[i][j] = 0; + + tagint actual; + for (i = 0; i < n; i++) { + if (in[i].me != -2) continue; + actual = in[i].partnerID; + m = hash.find(in[i].atomID)->second; + for (j = 0; j < npartner[m]; j++) + if (partner[m][j] == actual) { + flag[m][j] = 1; + break; + } + } + + // pass list of OutRvous datums back to comm->rendezvous + + int nout = 0; + for (m = 0; m < ncount; m++) nout += npartner[m]; + + memory->create(proclist,nout,"special:proclist"); + OutRvous *out = (OutRvous *) + memory->smalloc((bigint) nout*sizeof(OutRvous),"special:out"); + + nout = 0; + for (m = 0; m < ncount; m++) + for (j = 0; j < npartner[m]; j++) { + if (flag[m][j] == 0) continue; + proclist[nout] = procowner[m]; + out[nout].atomID = atomID[m]; + out[nout].partnerID = partner[m][j]; + nout++; } - buf[i+3] = n; - i += 4 + num12 + num13; - } -} -/* ---------------------------------------------------------------------- - when receive buffer, scan list of 1-3 neighbors for atoms I own - when find one, increment 1-4 count by # of 1-2 neighbors of my atom - may include duplicates and original atom but they will be culled later -------------------------------------------------------------------------- */ + outbuf = (char *) out; -void Special::ring_five(int ndatum, char *cbuf, void *ptr) -{ - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; + // clean up + // Comm::rendezvous will delete proclist and out (outbuf) - tagint *buf = (tagint *) cbuf; - int i,j,m,n,num13; + memory->destroy(procowner); + memory->destroy(atomID); + memory->destroy(npartner); + memory->destroy(partner); + memory->destroy(flag); - i = 0; - while (i < ndatum) { - n = buf[i]; - num13 = buf[i+1]; - for (j = 0; j < num13; j++) { - m = atom->map(buf[i+2+j]); - if (m >= 0 && m < nlocal) n += nspecial[m][0]; - } - buf[i] = n; - i += 2 + num13; - } -} - -/* ---------------------------------------------------------------------- - when receive buffer, scan list of 1-3 neighbors for atoms I own - when find one, add its neighbors to 1-4 list - incrementing the count in buf(i+4) - this process may include duplicates but they will be culled later -------------------------------------------------------------------------- */ - -void Special::ring_six(int ndatum, char *cbuf, void *ptr) -{ - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - tagint **onetwo = sptr->onetwo; - - tagint *buf = (tagint *) cbuf; - int i,j,k,m,n,num13,num14; - - i = 0; - while (i < ndatum) { - num13 = buf[i]; - num14 = buf[i+1]; - n = buf[i+2]; - for (j = 0; j < num13; j++) { - m = atom->map(buf[i+3+j]); - if (m >= 0 && m < nlocal) - for (k = 0; k < nspecial[m][0]; k++) - buf[i+3+num13+(n++)] = onetwo[m][k]; - } - buf[i+2] = n; - i += 3 + num13 + num14; - } -} - -/* ---------------------------------------------------------------------- - when receive buffer, scan list of 1,3 atoms looking for atoms I own - when find one, scan its 1-3 neigh list and mark I,J as in an angle -------------------------------------------------------------------------- */ - -void Special::ring_seven(int ndatum, char *cbuf, void *ptr) -{ - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - tagint **onethree = sptr->onethree; - int **dflag = sptr->dflag; - - tagint *buf = (tagint *) cbuf; - tagint iglobal,jglobal; - int i,m,ilocal,jlocal; - - i = 0; - while (i < ndatum) { - iglobal = buf[i]; - jglobal = buf[i+1]; - ilocal = atom->map(iglobal); - jlocal = atom->map(jglobal); - if (ilocal >= 0 && ilocal < nlocal) - for (m = 0; m < nspecial[ilocal][1]; m++) - if (jglobal == onethree[ilocal][m]) { - dflag[ilocal][m] = 1; - break; - } - if (jlocal >= 0 && jlocal < nlocal) - for (m = 0; m < nspecial[jlocal][1]; m++) - if (iglobal == onethree[jlocal][m]) { - dflag[jlocal][m] = 1; - break; - } - i += 2; - } -} - -/* ---------------------------------------------------------------------- - when receive buffer, scan list of 1,4 atoms looking for atoms I own - when find one, scan its 1-4 neigh list and mark I,J as in a dihedral -------------------------------------------------------------------------- */ - -void Special::ring_eight(int ndatum, char *cbuf, void *ptr) -{ - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - tagint **onefour = sptr->onefour; - int **dflag = sptr->dflag; - - tagint *buf = (tagint *) cbuf; - tagint iglobal,jglobal; - int i,m,ilocal,jlocal; - - i = 0; - while (i < ndatum) { - iglobal = buf[i]; - jglobal = buf[i+1]; - ilocal = atom->map(iglobal); - jlocal = atom->map(jglobal); - if (ilocal >= 0 && ilocal < nlocal) - for (m = 0; m < nspecial[ilocal][2]; m++) - if (jglobal == onefour[ilocal][m]) { - dflag[ilocal][m] = 1; - break; - } - if (jlocal >= 0 && jlocal < nlocal) - for (m = 0; m < nspecial[jlocal][2]; m++) - if (iglobal == onefour[jlocal][m]) { - dflag[jlocal][m] = 1; - break; - } - i += 2; - } + return nout; } /* ---------------------------------------------------------------------- @@ -1159,3 +1144,15 @@ void Special::fix_alteration() modify->fix[ifix]->rebuild_special(); } +/* ---------------------------------------------------------------------- + print timing output +------------------------------------------------------------------------- */ + +void Special::timer_output(double time1) +{ + double t2 = MPI_Wtime(); + if (comm->me == 0) { + if (screen) fprintf(screen," special bonds CPU = %g secs\n",t2-t1); + if (logfile) fprintf(logfile," special bonds CPU = %g secs\n",t2-t1); + } +} diff --git a/src/special.h b/src/special.h index 9f25200336..f7892075ac 100644 --- a/src/special.h +++ b/src/special.h @@ -28,27 +28,30 @@ class Special : protected Pointers { int me,nprocs; tagint **onetwo,**onethree,**onefour; - // data used by ring callback methods + // data used by rendezvous callback methods - int *count; - int **dflag; + int max_rvous; + + struct InRvous { + int me; + tagint atomID,partnerID; + }; + + struct OutRvous { + tagint atomID,partnerID; + }; void dedup(); void angle_trim(); void dihedral_trim(); void combine(); void fix_alteration(); + void timer_output(double); - // callback functions for ring communication + // callback function for rendezvous communication - static void ring_one(int, char *, void *); - static void ring_two(int, char *, void *); - static void ring_three(int, char *, void *); - static void ring_four(int, char *, void *); - static void ring_five(int, char *, void *); - static void ring_six(int, char *, void *); - static void ring_seven(int, char *, void *); - static void ring_eight(int, char *, void *); + static int rendezvous_1234(int, char *, int *&, char *&, void *); + static int rendezvous_trim(int, char *, int *&, char *&, void *); }; } From 2e0d69b005ef26ccf1fdf0bcc671bfd8a61fafea Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 30 Nov 2018 13:06:31 -0700 Subject: [PATCH 02/49] replace STL map with atom->map in special, better code comments --- src/RIGID/fix_rigid_small.cpp | 8 ++-- src/comm.cpp | 20 ++++++-- src/read_data.cpp | 8 ++-- src/read_restart.cpp | 4 +- src/special.cpp | 89 +++++++++++++++++++++++++---------- 5 files changed, 92 insertions(+), 37 deletions(-) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 4421d9ae17..fc51e0aa4f 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -1571,9 +1571,9 @@ void FixRigidSmall::create_bodies(tagint *bodyID) } // perform rendezvous operation - // each proc owns random subset of bodies, receives all atoms in the bodies - // func = compute bbox of each body, flag atom closest to geometric center - // when done: each atom has atom ID of owning atom of its body + // each proc owns random subset of bodies + // receives all atoms in those bodies + // func = compute bbox of each body, find atom closest to geometric center char *buf; int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), @@ -1627,6 +1627,8 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf, MPI_Comm world = frsptr->world; // setup hash + // use STL map instead of atom->map + // b/c know nothing about body ID values specified by user // ncount = number of bodies assigned to me // key = body ID // value = index into Ncount-length data structure diff --git a/src/comm.cpp b/src/comm.cpp index 5fcfa141d0..6512b21fef 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -728,13 +728,27 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, /* ---------------------------------------------------------------------- rendezvous communication operation + three stages: + first Irregular converts inbuf from caller decomp to rvous decomp + callback operates on data in rendevous decomp + last Irregular converts outbuf from rvous decomp back to caller decomp + inputs: + n = # of input datums + proclist = proc that owns each input datum in rendezvous decomposition + inbuf = list of input datums + insize = size in bytes of each input datum + callback = caller function to invoke in rendezvous decomposition + outputs: + nout = # of output datums (function return) + outbuf = list of output datums + outsize = size in bytes of each output datum ------------------------------------------------------------------------- */ int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, int (*callback)(int, char *, int *&, char *&, void *), char *&outbuf, int outsize, void *ptr) { - // comm data from caller decomposition to rendezvous decomposition + // comm inbuf from caller decomposition to rendezvous decomposition Irregular *irregular = new Irregular(lmp); @@ -747,7 +761,7 @@ int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, delete irregular; // peform rendezvous computation via callback() - // callback() allocates proclist_rvous and outbuf_rvous + // callback() allocates/populates proclist_rvous and outbuf_rvous int *proclist_rvous; char *outbuf_rvous; @@ -757,7 +771,7 @@ int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, memory->sfree(inbuf_rvous); - // comm data from rendezvous decomposition back to caller + // comm outbuf from rendezvous decomposition back to caller // caller will free outbuf irregular = new Irregular(lmp); diff --git a/src/read_data.cpp b/src/read_data.cpp index d7bd298e7b..cdeda03066 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -121,7 +121,7 @@ void ReadData::command(int narg, char **arg) if (narg < 1) error->all(FLERR,"Illegal read_data command"); MPI_Barrier(world); - double time1 = MPI_Wtime; + double time1 = MPI_Wtime(); // optional args @@ -912,13 +912,13 @@ void ReadData::command(int narg, char **arg) // total time MPI_Barrier(world); - double time2 = MPI_Wtime; + double time2 = MPI_Wtime(); if (comm->me == 0) { if (screen) - fprintf(screen," read_atoms CPU = %g secs\n",time2-time1); + fprintf(screen," read_data CPU = %g secs\n",time2-time1); if (logfile) - fprintf(logfile," read_atoms CPU = %g secs\n",time2-time1); + fprintf(logfile," read_data CPU = %g secs\n",time2-time1); } } diff --git a/src/read_restart.cpp b/src/read_restart.cpp index a338a843d7..b61fb2278f 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -82,7 +82,7 @@ void ReadRestart::command(int narg, char **arg) error->all(FLERR,"Cannot read_restart after simulation box is defined"); MPI_Barrier(world); - double time1 = MPI_Wtime; + double time1 = MPI_Wtime(); MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); @@ -569,7 +569,7 @@ void ReadRestart::command(int narg, char **arg) // total time MPI_Barrier(world); - double time2 = MPI_Wtime; + double time2 = MPI_Wtime(); if (comm->me == 0) { if (screen) diff --git a/src/special.cpp b/src/special.cpp index a18c597765..6dad30a9a7 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -108,9 +108,11 @@ void Special::build() memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); // setup input buf to rendezvous comm - // one datum for each owned atom: datum = proc, atomID - // one datum for each bond partner: datum = atomID, bond partner ID + // input datums = pairs of bonded atoms // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each bond partner: datum = atomID, bond partner ID + // add inverted datum when netwon_bond on m = 0; for (i = 0; i < nlocal; i++) { @@ -140,7 +142,8 @@ void Special::build() } // perform rendezvous operation - // each proc owns random subset of atoms, receives all their bond partners + // each proc owns random subset of atoms + // receives all info to form and return their onetwo lists int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), rendezvous_1234, @@ -151,6 +154,7 @@ void Special::build() memory->sfree(inbuf); // set nspecial[0] and onetwo for all owned atoms based on output info + // output datums = pairs of atoms that are 1-2 neighbors MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); memory->create(onetwo,nlocal,maxall,"special:onetwo"); @@ -200,9 +204,10 @@ void Special::build() memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); // setup input buf to rendezvous comm - // one datum for each owned atom: datum = proc, atomID - // one datum for each bond partner: datum = atomID, bond partner ID + // input datums = all pairs of onetwo atoms (they are 1-3 neighbors) // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each onetwo pair: datum = atomID1, atomID2 m = 0; for (i = 0; i < nlocal; i++) { @@ -226,7 +231,8 @@ void Special::build() } // perform rendezvous operation - // each proc owns random subset of atoms, receives all their bond partners + // each proc owns random subset of atoms + // receives all info to form and return their onethree lists nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), rendezvous_1234, @@ -237,6 +243,7 @@ void Special::build() memory->sfree(inbuf); // set nspecial[1] and onethree for all owned atoms based on output info + // output datums = pairs of atoms that are 1-3 neighbors MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); memory->create(onethree,nlocal,maxall,"special:onethree"); @@ -284,9 +291,10 @@ void Special::build() memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); // setup input buf to rendezvous comm - // one datum for each owned atom: datum = proc, atomID - // one datum for each partner: datum = atomID, bond partner ID + // input datums = all pairs of onethree and onetwo atoms (they're 1-4 neighbors) // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each onethree/onetwo pair: datum = atomID1, atomID2 m = 0; for (i = 0; i < nlocal; i++) { @@ -309,9 +317,8 @@ void Special::build() } // perform rendezvous operation - // each proc owns random subset of bodies, receives all atoms in the bodies - // func = compute bbox of each body, flag atom closest to geometric center - // when done: each atom has atom ID of owning atom of its body + // each proc owns random subset of atoms + // receives all info to form and return their onefour lists nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), rendezvous_1234, @@ -322,6 +329,7 @@ void Special::build() memory->sfree(inbuf); // set nspecial[2] and onefour for all owned atoms based on output info + // output datums = pairs of atoms that are 1-4 neighbors MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); memory->create(onefour,nlocal,maxall,"special:onefour"); @@ -934,21 +942,28 @@ int Special::rendezvous_1234(int n, char *inbuf, int i,j,m; Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; Memory *memory = sptr->memory; - // setup hash + // clear atom map so it can be here as a hash table + // faster than an STL map for large atom counts + + atom->map_clear(); + + // initialize hash // ncount = number of atoms assigned to me // key = atom ID // value = index into Ncount-length data structure InRvous *in = (InRvous *) inbuf; - std::map hash; + //std::map hash; tagint id; int ncount = 0; for (i = 0; i < n; i++) if (in[i].me >= 0) - hash[in[i].atomID] = ncount++; + //hash[in[i].atomID] = ncount++; + atom->map_one(in[i].atomID,ncount++); // procowner = caller proc that owns each atom // atomID = ID of each rendezvous atom I own @@ -961,7 +976,8 @@ int Special::rendezvous_1234(int n, char *inbuf, for (m = 0; m < ncount; m++) npartner[m] = 0; for (i = 0; i < n; i++) { - m = hash.find(in[i].atomID)->second; + //m = hash.find(in[i].atomID)->second; + m = atom->map(in[i].atomID); if (in[i].me >= 0) { procowner[m] = in[i].me; atomID[m] = in[i].atomID; @@ -979,7 +995,8 @@ int Special::rendezvous_1234(int n, char *inbuf, for (i = 0; i < n; i++) { if (in[i].me >= 0) continue; - m = hash.find(in[i].atomID)->second; + //m = hash.find(in[i].atomID)->second; + m = atom->map(in[i].atomID); partner[m][npartner[m]++] = in[i].partnerID; } @@ -1011,6 +1028,12 @@ int Special::rendezvous_1234(int n, char *inbuf, memory->destroy(npartner); memory->destroy(partner); + // re-create atom map + + atom->map_init(0); + atom->nghost = 0; + atom->map_set(); + return nout; } @@ -1027,21 +1050,28 @@ int Special::rendezvous_trim(int n, char *inbuf, int i,j,m; Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; Memory *memory = sptr->memory; - // setup hash + // clear atom map so it can be here as a hash table + // faster than an STL map for large atom counts + + atom->map_clear(); + + // initialize hash // ncount = number of atoms assigned to me // key = atom ID // value = index into Ncount-length data structure InRvous *in = (InRvous *) inbuf; - std::map hash; + //std::map hash; tagint id; int ncount = 0; for (i = 0; i < n; i++) if (in[i].me >= 0) - hash[in[i].atomID] = ncount++; + //hash[in[i].atomID] = ncount++; + atom->map_one(in[i].atomID,ncount++); // procowner = caller proc that owns each atom // atomID = ID of each rendezvous atom I own @@ -1055,7 +1085,8 @@ int Special::rendezvous_trim(int n, char *inbuf, for (m = 0; m < ncount; m++) npartner[m] = 0; for (i = 0; i < n; i++) { - m = hash.find(in[i].atomID)->second; + //m = hash.find(in[i].atomID)->second; + m = atom->map(in[i].atomID); if (in[i].me >= 0) { procowner[m] = in[i].me; atomID[m] = in[i].atomID; @@ -1073,7 +1104,8 @@ int Special::rendezvous_trim(int n, char *inbuf, for (i = 0; i < n; i++) { if (in[i].me >= 0 || in[i].me == -2) continue; - m = hash.find(in[i].atomID)->second; + //m = hash.find(in[i].atomID)->second; + m = atom->map(in[i].atomID); partner[m][npartner[m]++] = in[i].partnerID; } @@ -1090,7 +1122,8 @@ int Special::rendezvous_trim(int n, char *inbuf, for (i = 0; i < n; i++) { if (in[i].me != -2) continue; actual = in[i].partnerID; - m = hash.find(in[i].atomID)->second; + //m = hash.find(in[i].atomID)->second; + m = atom->map(in[i].atomID); for (j = 0; j < npartner[m]; j++) if (partner[m][j] == actual) { flag[m][j] = 1; @@ -1128,6 +1161,12 @@ int Special::rendezvous_trim(int n, char *inbuf, memory->destroy(partner); memory->destroy(flag); + // re-create atom map + + atom->map_init(0); + atom->nghost = 0; + atom->map_set(); + return nout; } @@ -1150,9 +1189,9 @@ void Special::fix_alteration() void Special::timer_output(double time1) { - double t2 = MPI_Wtime(); + double time2 = MPI_Wtime(); if (comm->me == 0) { - if (screen) fprintf(screen," special bonds CPU = %g secs\n",t2-t1); - if (logfile) fprintf(logfile," special bonds CPU = %g secs\n",t2-t1); + if (screen) fprintf(screen," special bonds CPU = %g secs\n",time2-time1); + if (logfile) fprintf(logfile," special bonds CPU = %g secs\n",time2-time1); } } From ece1aff7e9c33b7145973880677e3fbdb3b5e37a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 7 Dec 2018 15:46:27 -0700 Subject: [PATCH 03/49] less comm version of special bonds rendezvous --- src/comm.cpp | 8 +- src/comm.h | 2 +- src/special.cpp | 834 ++++++++++++++++++++++++++++-------------------- src/special.h | 26 +- 4 files changed, 517 insertions(+), 353 deletions(-) diff --git a/src/comm.cpp b/src/comm.cpp index 6512b21fef..9bdaf0798a 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -745,7 +745,7 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, ------------------------------------------------------------------------- */ int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, - int (*callback)(int, char *, int *&, char *&, void *), + int (*callback)(int, char *, int &, int *&, char *&, void *), char *&outbuf, int outsize, void *ptr) { // comm inbuf from caller decomposition to rendezvous decomposition @@ -763,13 +763,15 @@ int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, // peform rendezvous computation via callback() // callback() allocates/populates proclist_rvous and outbuf_rvous + int flag; int *proclist_rvous; char *outbuf_rvous; int nout_rvous = - callback(n_rvous,inbuf_rvous,proclist_rvous,outbuf_rvous,ptr); + callback(n_rvous,inbuf_rvous,flag,proclist_rvous,outbuf_rvous,ptr); - memory->sfree(inbuf_rvous); + if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous + if (flag == 0) return 0; // all nout_rvous are 0, no 2nd irregular // comm outbuf from rendezvous decomposition back to caller // caller will free outbuf diff --git a/src/comm.h b/src/comm.h index 8bb057a0c1..a1bac53ac8 100644 --- a/src/comm.h +++ b/src/comm.h @@ -110,7 +110,7 @@ class Comm : protected Pointers { void ring(int, int, void *, int, void (*)(int, char *, void *), void *, void *, int self = 1); int rendezvous(int, int *, char *, int, - int (*)(int, char *, int *&, char *&, void *), + int (*)(int, char *, int &, int *&, char *&, void *), char *&, int, void *); int read_lines_from_file(FILE *, int, int, char *); diff --git a/src/special.cpp b/src/special.cpp index 6dad30a9a7..79d2f77e46 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -55,20 +55,9 @@ Special::~Special() void Special::build() { - int i,j,k,m,n,size,proc; - int max,maxall; - char *buf; - MPI_Barrier(world); double time1 = MPI_Wtime(); - int nlocal = atom->nlocal; - - tagint *tag = atom->tag; - int *num_bond = atom->num_bond; - tagint **bond_atom = atom->bond_atom; - int **nspecial = atom->nspecial; - if (me == 0 && screen) { const double * const special_lj = force->special_lj; const double * const special_coul = force->special_coul; @@ -81,183 +70,51 @@ void Special::build() // initialize nspecial counters to 0 - for (i = 0; i < nlocal; i++) { + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { nspecial[i][0] = 0; nspecial[i][1] = 0; nspecial[i][2] = 0; } - // ----------------------------------------------------- - // compute nspecial[i][0] = # of 1-2 neighbors of atom i + // setup atomIDs and procowner vectors in rendezvous decomposition + + atom_owners(); + + // tally nspecial[i][0] = # of 1-2 neighbors of atom i // create onetwo[i] = list of 1-2 neighbors for atom i - // ----------------------------------------------------- - // ncount = # of my datums to send (newton or newton off) - // include nlocal datums with owner of each atom + if (force->newton_bond) onetwo_build_newton(); + else onetwo_build_newton_off(); - int newton_bond = force->newton_bond; - - int ncount = 0; - for (i = 0; i < nlocal; i++) ncount += num_bond[i]; - if (newton_bond) ncount *= 2; - ncount += nlocal; - - int *proclist; - memory->create(proclist,ncount,"special:proclist"); - InRvous *inbuf = (InRvous *) - memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // input datums = pairs of bonded atoms - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - // one datum for each bond partner: datum = atomID, bond partner ID - // add inverted datum when netwon_bond on - - m = 0; - for (i = 0; i < nlocal; i++) { - proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; - proclist[m] = proc; - inbuf[m].me = me; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = 0; - m++; - - for (j = 0; j < num_bond[i]; j++) { - proclist[m] = proc; - inbuf[m].me = -1; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = bond_atom[i][j]; - m++; - } - if (newton_bond) { - for (j = 0; j < num_bond[i]; j++) { - proclist[m] = hashlittle(&bond_atom[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -1; - inbuf[m].atomID = bond_atom[i][j]; - inbuf[m].partnerID = tag[i]; - m++; - } - } - } - - // perform rendezvous operation - // each proc owns random subset of atoms - // receives all info to form and return their onetwo lists - - int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), - rendezvous_1234, - buf,sizeof(OutRvous),(void *) this); - OutRvous *outbuf = (OutRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set nspecial[0] and onetwo for all owned atoms based on output info - // output datums = pairs of atoms that are 1-2 neighbors - - MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onetwo,nlocal,maxall,"special:onetwo"); - - for (i = 0; i < nlocal; i++) nspecial[i][0] = 0; - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - onetwo[i][nspecial[i][0]++] = outbuf[m].partnerID; - } - - memory->sfree(outbuf); - - // compute and print max # of 1-2 neighbors + // print max # of 1-2 neighbors if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-2 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-2 neighbors\n",maxall); } - // ----------------------------------------------------- // done if special_bond weights for 1-3, 1-4 are set to 1.0 - // ----------------------------------------------------- if (force->special_lj[2] == 1.0 && force->special_coul[2] == 1.0 && force->special_lj[3] == 1.0 && force->special_coul[3] == 1.0) { dedup(); combine(); fix_alteration(); + memory->destroy(procowner); + memory->destroy(atomIDs); timer_output(time1); return; } - // ----------------------------------------------------- - // compute nspecial[i][1] = # of 1-3 neighbors of atom i + // tally nspecial[i][1] = # of 1-3 neighbors of atom i // create onethree[i] = list of 1-3 neighbors for atom i - // ----------------------------------------------------- - // ncount = # of my datums to send - // include nlocal datums with owner of each atom + onethree_build(); - ncount = nlocal; - for (i = 0; i < nlocal; i++) ncount += nspecial[i][0]*(nspecial[i][0]-1); - - memory->create(proclist,ncount,"special:proclist"); - inbuf = (InRvous *) - memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // input datums = all pairs of onetwo atoms (they are 1-3 neighbors) - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - // one datum for each onetwo pair: datum = atomID1, atomID2 - - m = 0; - for (i = 0; i < nlocal; i++) { - proclist[m] = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; - inbuf[m].me = me; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = 0; - m++; - - for (j = 0; j < nspecial[i][0]; j++) { - proc = hashlittle(&onetwo[i][j],sizeof(tagint),0) % nprocs; - for (k = 0; k < nspecial[i][0]; k++) { - if (j == k) continue; - proclist[m] = proc; - inbuf[m].me = -1; - inbuf[m].atomID = onetwo[i][j]; - inbuf[m].partnerID = onetwo[i][k]; - m++; - } - } - } - - // perform rendezvous operation - // each proc owns random subset of atoms - // receives all info to form and return their onethree lists - - nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), - rendezvous_1234, - buf,sizeof(OutRvous),(void *) this); - outbuf = (OutRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set nspecial[1] and onethree for all owned atoms based on output info - // output datums = pairs of atoms that are 1-3 neighbors - - MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onethree,nlocal,maxall,"special:onethree"); - - for (i = 0; i < nlocal; i++) nspecial[i][1] = 0; - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - onethree[i][nspecial[i][1]++] = outbuf[m].partnerID; - } - - memory->destroy(outbuf); - - // compute and print max # of 1-3 neighbors + // print max # of 1-3 neighbors if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-3 neighbors\n",maxall); @@ -271,79 +128,18 @@ void Special::build() if (force->special_angle) angle_trim(); combine(); fix_alteration(); + memory->destroy(procowner); + memory->destroy(atomIDs); timer_output(time1); return; } - // ----------------------------------------------------- - // compute nspecial[i][2] = # of 1-4 neighbors of atom i + // tally nspecial[i][2] = # of 1-4 neighbors of atom i // create onefour[i] = list of 1-4 neighbors for atom i - // ----------------------------------------------------- - // ncount = # of my datums to send - // include nlocal datums with owner of each atom + onefour_build(); - ncount = nlocal; - for (i = 0; i < nlocal; i++) ncount += nspecial[i][1]*nspecial[i][0]; - - memory->create(proclist,ncount,"special:proclist"); - inbuf = (InRvous *) - memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // input datums = all pairs of onethree and onetwo atoms (they're 1-4 neighbors) - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - // one datum for each onethree/onetwo pair: datum = atomID1, atomID2 - - m = 0; - for (i = 0; i < nlocal; i++) { - proclist[m] = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; - inbuf[m].me = me; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = 0; - m++; - - for (j = 0; j < nspecial[i][1]; j++) { - proc = hashlittle(&onethree[i][j],sizeof(tagint),0) % nprocs; - for (k = 0; k < nspecial[i][0]; k++) { - proclist[m] = proc; - inbuf[m].me = -1; - inbuf[m].atomID = onethree[i][j]; - inbuf[m].partnerID = onetwo[i][k]; - m++; - } - } - } - - // perform rendezvous operation - // each proc owns random subset of atoms - // receives all info to form and return their onefour lists - - nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), - rendezvous_1234, - buf,sizeof(OutRvous),(void *) this); - outbuf = (OutRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set nspecial[2] and onefour for all owned atoms based on output info - // output datums = pairs of atoms that are 1-4 neighbors - - MPI_Allreduce(&max_rvous,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onefour,nlocal,maxall,"special:onefour"); - - for (i = 0; i < nlocal; i++) nspecial[i][2] = 0; - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - onefour[i][nspecial[i][2]++] = outbuf[m].partnerID; - } - - memory->destroy(outbuf); - - // compute and print max # of 1-4 neighbors + // print max # of 1-4 neighbors if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-4 neighbors\n",maxall); @@ -357,9 +153,380 @@ void Special::build() if (force->special_dihedral) dihedral_trim(); combine(); fix_alteration(); + memory->destroy(procowner); + memory->destroy(atomIDs); + timer_output(time1); } +/* ---------------------------------------------------------------------- + setup atomIDs and procowner +------------------------------------------------------------------------- */ + +void Special::atom_owners() +{ + tagint *tag = atom->tag; + int nlocal = atom->nlocal; + + int *proclist; + memory->create(proclist,nlocal,"special:proclist"); + IDRvous *idbuf = (IDRvous *) + memory->smalloc((bigint) nlocal*sizeof(IDRvous),"special:idbuf"); + + // setup input buf to rendezvous comm + // input datums = pairs of bonded atoms + // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each bond partner: datum = atomID, bond partner ID + // add inverted datum when netwon_bond on + + for (int i = 0; i < nlocal; i++) { + //proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; + proclist[i] = tag[i] % nprocs; + idbuf[i].me = me; + idbuf[i].atomID = tag[i]; + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all info to form and return their onetwo lists + + char *buf; + comm->rendezvous(nlocal,proclist, + (char *) idbuf,sizeof(PairRvous), + rendezvous_ids,buf,sizeof(PairRvous), + (void *) this); + + memory->destroy(proclist); + memory->sfree(idbuf); +} + +/* ---------------------------------------------------------------------- + onetwo build +------------------------------------------------------------------------- */ + +void Special::onetwo_build_newton() +{ + int i,j,m; + + tagint *tag = atom->tag; + int *num_bond = atom->num_bond; + tagint **bond_atom = atom->bond_atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + // ncount = # of my datums to send + // include nlocal datums with owner of each atom + + int ncount = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < num_bond[i]; j++) { + m = atom->map(bond_atom[i][j]); + if (m < 0 || m >= nlocal) ncount++; + } + } + + int *proclist; + memory->create(proclist,ncount,"special:proclist"); + PairRvous *inbuf = (PairRvous *) + memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + + // setup input buf to rendezvous comm + // input datums = pairs of bonded atoms + // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each bond partner: datum = atomID, bond partner ID + // add inverted datum when netwon_bond on + + ncount = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < num_bond[i]; j++) { + m = atom->map(bond_atom[i][j]); + if (m >= 0 && m < nlocal) continue; + proclist[ncount] = bond_atom[i][j] % nprocs; + inbuf[ncount].atomID = bond_atom[i][j]; + inbuf[ncount].partnerID = tag[i]; + ncount++; + } + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all info to form and return their onetwo lists + + char *buf; + int nreturn = comm->rendezvous(ncount,proclist, + (char *) inbuf,sizeof(PairRvous), + rendezvous_1234,buf,sizeof(PairRvous), + (void *) this); + PairRvous *outbuf = (PairRvous *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); + + // set nspecial[0] and onetwo for all owned atoms based on output info + // output datums = pairs of atoms that are 1-2 neighbors + + for (i = 0; i < nlocal; i++) { + nspecial[i][0] = num_bond[i]; + for (j = 0; j < num_bond[i]; j++) { + m = atom->map(bond_atom[i][j]); + if (m >= 0 && m < nlocal) nspecial[m][0]++; + } + } + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + nspecial[i][0]++; + } + + int max = 0; + for (i = 0; i < nlocal; i++) + max = MAX(max,nspecial[i][0]); + + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onetwo,nlocal,maxall,"special:onetwo"); + + for (i = 0; i < nlocal; i++) nspecial[i][0] = 0; + + for (i = 0; i < nlocal; i++) { + for (j = 0; j < num_bond[i]; j++) { + onetwo[i][nspecial[i][0]++] = bond_atom[i][j]; + m = atom->map(bond_atom[i][j]); + if (m >= 0 && m < nlocal) onetwo[m][nspecial[m][0]++] = tag[i]; + } + } + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onetwo[i][nspecial[i][0]++] = outbuf[m].partnerID; + } + + memory->sfree(outbuf); +} + +/* ---------------------------------------------------------------------- + onetwo build with newton_bond flag off + no need for rendezvous comm +------------------------------------------------------------------------- */ + +void Special::onetwo_build_newton_off() +{ +} + +/* ---------------------------------------------------------------------- + onetwo build with newton_bond flag off + no need for rendezvous comm +------------------------------------------------------------------------- */ + +void Special::onethree_build() +{ + int i,j,k,m,proc; + + tagint *tag = atom->tag; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + // ncount = # of my datums to send + // include nlocal datums with owner of each atom + + int ncount = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][0]; j++) { + m = atom->map(onetwo[i][j]); + if (m < 0 || m >= nlocal) ncount += nspecial[i][0]-1; + } + } + + int *proclist; + memory->create(proclist,ncount,"special:proclist"); + PairRvous *inbuf = (PairRvous *) + memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + + // setup input buf to rendezvous comm + // input datums = all pairs of onetwo atoms (they are 1-3 neighbors) + // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each onetwo pair: datum = atomID1, atomID2 + + ncount = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][0]; j++) { + m = atom->map(onetwo[i][j]); + if (m >= 0 && m < nlocal) continue; + proc = onetwo[i][j] % nprocs; + for (k = 0; k < nspecial[i][0]; k++) { + if (j == k) continue; + proclist[ncount] = proc; + inbuf[ncount].atomID = onetwo[i][j]; + inbuf[ncount].partnerID = onetwo[i][k]; + ncount++; + } + } + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all info to form and return their onethree lists + + char *buf; + int nreturn = comm->rendezvous(ncount,proclist, + (char *) inbuf,sizeof(PairRvous), + rendezvous_1234,buf,sizeof(PairRvous), + (void *) this); + PairRvous *outbuf = (PairRvous *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); + + // set nspecial[1] and onethree for all owned atoms based on output info + // output datums = pairs of atoms that are 1-3 neighbors + + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][0]; j++) { + m = atom->map(onetwo[i][j]); + if (m >= 0 && m < nlocal) nspecial[m][1] += nspecial[i][0]-1; + } + } + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + nspecial[i][1]++; + } + + int max = 0; + for (i = 0; i < nlocal; i++) + max = MAX(max,nspecial[i][1]); + + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onethree,nlocal,maxall,"special:onethree"); + + for (i = 0; i < nlocal; i++) nspecial[i][1] = 0; + + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][0]; j++) { + m = atom->map(onetwo[i][j]); + if (m < 0 || m >= nlocal) continue; + for (k = 0; k < nspecial[i][0]; k++) { + if (j == k) continue; + onethree[m][nspecial[m][1]++] = onetwo[i][k]; + } + } + } + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onethree[i][nspecial[i][1]++] = outbuf[m].partnerID; + } + + memory->sfree(outbuf); +} + +/* ---------------------------------------------------------------------- + remove duplicates within each of onetwo, onethree, onefour individually +------------------------------------------------------------------------- */ + +void Special::onefour_build() +{ + int i,j,k,m,proc; + + tagint *tag = atom->tag; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + // ncount = # of my datums to send + // include nlocal datums with owner of each atom + + int ncount = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][1]; j++) { + m = atom->map(onethree[i][j]); + if (m < 0 || m >= nlocal) ncount += nspecial[i][0]; + } + } + + int *proclist; + memory->create(proclist,ncount,"special:proclist"); + PairRvous *inbuf = (PairRvous *) + memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + + // setup input buf to rendezvous comm + // input datums = all pairs of onethree and onetwo atoms (they're 1-4 neighbors) + // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + // one datum for each onethree/onetwo pair: datum = atomID1, atomID2 + + ncount = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][1]; j++) { + m = atom->map(onethree[i][j]); + if (m >= 0 && m < nlocal) continue; + proc = onethree[i][j] % nprocs; + for (k = 0; k < nspecial[i][0]; k++) { + proclist[ncount] = proc; + inbuf[ncount].atomID = onethree[i][j]; + inbuf[ncount].partnerID = onetwo[i][k]; + ncount++; + } + } + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all info to form and return their onefour lists + + char *buf; + int nreturn = comm->rendezvous(ncount,proclist, + (char *) inbuf,sizeof(PairRvous), + rendezvous_1234,buf,sizeof(PairRvous), + (void *) this); + PairRvous *outbuf = (PairRvous *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); + + // set nspecial[2] and onefour for all owned atoms based on output info + // output datums = pairs of atoms that are 1-4 neighbors + + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][1]; j++) { + m = atom->map(onethree[i][j]); + if (m >= 0 && m < nlocal) nspecial[m][2] += nspecial[i][0]; + } + } + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + nspecial[i][2]++; + } + + int max = 0; + for (i = 0; i < nlocal; i++) + max = MAX(max,nspecial[i][2]); + + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onefour,nlocal,maxall,"special:onefour"); + + for (i = 0; i < nlocal; i++) nspecial[i][2] = 0; + + for (i = 0; i < nlocal; i++) { + for (j = 0; j < nspecial[i][1]; j++) { + m = atom->map(onethree[i][j]); + if (m < 0 || m >= nlocal) continue; + for (k = 0; k < nspecial[i][0]; k++) { + onefour[m][nspecial[m][2]++] = onetwo[i][k]; + } + } + } + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + onefour[i][nspecial[i][2]++] = outbuf[m].partnerID; + } + + memory->sfree(outbuf); +} + /* ---------------------------------------------------------------------- remove duplicates within each of onetwo, onethree, onefour individually ------------------------------------------------------------------------- */ @@ -662,8 +829,8 @@ void Special::angle_trim() int *proclist; memory->create(proclist,ncount,"special:proclist"); - InRvous *inbuf = (InRvous *) - memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); + PairRvous *inbuf = (PairRvous *) + memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm // one datum for each owned atom: datum = proc, atomID @@ -675,16 +842,9 @@ void Special::angle_trim() m = 0; for (i = 0; i < nlocal; i++) { - proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; - proclist[m] = proc; - inbuf[m].me = me; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = 0; - m++; - for (j = 0; j < nspecial[i][1]; j++) { proclist[m] = proc; - inbuf[m].me = -1; + //inbuf[m].me = -1; inbuf[m].atomID = tag[i]; inbuf[m].partnerID = onethree[i][j]; m++; @@ -695,13 +855,13 @@ void Special::angle_trim() if (index < 0 || index >= nlocal) continue; proclist[m] = hashlittle(&angle_atom1[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = angle_atom1[i][j]; inbuf[m].partnerID = angle_atom3[i][j]; m++; proclist[m] = hashlittle(&angle_atom3[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = angle_atom3[i][j]; inbuf[m].partnerID = angle_atom1[i][j]; m++; @@ -712,25 +872,25 @@ void Special::angle_trim() if (index < 0 || index >= nlocal) continue; proclist[m] = hashlittle(&dihedral_atom1[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = dihedral_atom1[i][j]; inbuf[m].partnerID = dihedral_atom3[i][j]; m++; proclist[m] = hashlittle(&dihedral_atom2[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = dihedral_atom2[i][j]; inbuf[m].partnerID = dihedral_atom4[i][j]; m++; proclist[m] = hashlittle(&dihedral_atom3[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = dihedral_atom3[i][j]; inbuf[m].partnerID = dihedral_atom1[i][j]; m++; proclist[m] = hashlittle(&dihedral_atom4[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = dihedral_atom4[i][j]; inbuf[m].partnerID = dihedral_atom2[i][j]; m++; @@ -743,10 +903,11 @@ void Special::angle_trim() // when done: each atom has atom ID of owning atom of its body char *buf; - int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), - rendezvous_trim, - buf,sizeof(OutRvous),(void *) this); - OutRvous *outbuf = (OutRvous *) buf; + int nreturn = comm->rendezvous(ncount,proclist, + (char *) inbuf,sizeof(PairRvous), + rendezvous_trim,buf,sizeof(PairRvous), + (void *) this); + PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); @@ -836,8 +997,8 @@ void Special::dihedral_trim() int *proclist; memory->create(proclist,ncount,"special:proclist"); - InRvous *inbuf = (InRvous *) - memory->smalloc((bigint) ncount*sizeof(InRvous),"special:inbuf"); + PairRvous *inbuf = (PairRvous *) + memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm // one datum for each owned atom: datum = proc, atomID @@ -851,14 +1012,14 @@ void Special::dihedral_trim() for (i = 0; i < nlocal; i++) { proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; proclist[m] = proc; - inbuf[m].me = me; + //inbuf[m].me = me; inbuf[m].atomID = tag[i]; inbuf[m].partnerID = 0; m++; for (j = 0; j < nspecial[i][2]; j++) { proclist[m] = proc; - inbuf[m].me = -1; + //inbuf[m].me = -1; inbuf[m].atomID = tag[i]; inbuf[m].partnerID = onefour[i][j]; m++; @@ -869,13 +1030,13 @@ void Special::dihedral_trim() if (index < 0 || index >= nlocal) continue; proclist[m] = hashlittle(&dihedral_atom1[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = dihedral_atom1[i][j]; inbuf[m].partnerID = dihedral_atom4[i][j]; m++; proclist[m] = hashlittle(&dihedral_atom4[i][j],sizeof(tagint),0) % nprocs; - inbuf[m].me = -2; + //inbuf[m].me = -2; inbuf[m].atomID = dihedral_atom4[i][j]; inbuf[m].partnerID = dihedral_atom1[i][j]; m++; @@ -888,10 +1049,11 @@ void Special::dihedral_trim() // when done: each atom has atom ID of owning atom of its body char *buf; - int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), - rendezvous_trim, - buf,sizeof(OutRvous),(void *) this); - OutRvous *outbuf = (OutRvous *) buf; + int nreturn = comm->rendezvous(ncount,proclist, + (char *) inbuf,sizeof(PairRvous), + rendezvous_trim,buf,sizeof(PairRvous), + (void *) this); + PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); @@ -931,16 +1093,55 @@ void Special::dihedral_trim() /* ---------------------------------------------------------------------- process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N InRvous datums - create outbuf = list of Nout OutRvous datums + inbuf = list of N PairRvous datums + outbuf = empty +------------------------------------------------------------------------- */ + +int Special::rendezvous_ids(int n, char *inbuf, + int &flag, int *&proclist, char *&outbuf, + void *ptr) +{ + Special *sptr = (Special *) ptr; + Memory *memory = sptr->memory; + + int *procowner; + tagint *atomIDs; + + memory->create(procowner,n,"special:procowner"); + memory->create(atomIDs,n,"special:atomIDs"); + // NOTE: when to free these vectors + + IDRvous *in = (IDRvous *) inbuf; + + for (int i = 0; i < n; i++) { + procowner[i] = in[i].me; + atomIDs[i] = in[i].atomID; + } + + // store rendezvous data in Special class + + sptr->ncount = n; + sptr->procowner = procowner; + sptr->atomIDs = atomIDs; + + proclist = NULL; + outbuf = NULL; + + flag = 0; + return 0; +} + + +/* ---------------------------------------------------------------------- + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N PairRvous datums + outbuf = same list of N PairRvous datums, routed to different procs ------------------------------------------------------------------------- */ int Special::rendezvous_1234(int n, char *inbuf, - int *&proclist, char *&outbuf, + int &flag, int *&proclist, char *&outbuf, void *ptr) { - int i,j,m; - Special *sptr = (Special *) ptr; Atom *atom = sptr->atom; Memory *memory = sptr->memory; @@ -950,105 +1151,52 @@ int Special::rendezvous_1234(int n, char *inbuf, atom->map_clear(); - // initialize hash - // ncount = number of atoms assigned to me - // key = atom ID - // value = index into Ncount-length data structure - - InRvous *in = (InRvous *) inbuf; - //std::map hash; - tagint id; + // hash atom IDs stored in rendezvous decomposition - int ncount = 0; - for (i = 0; i < n; i++) - if (in[i].me >= 0) - //hash[in[i].atomID] = ncount++; - atom->map_one(in[i].atomID,ncount++); + int ncount = sptr->ncount; + tagint *atomIDs = sptr->atomIDs; - // procowner = caller proc that owns each atom - // atomID = ID of each rendezvous atom I own + for (int i = 0; i < ncount; i++) + atom->map_one(atomIDs[i],i); - int *procowner,*npartner; - tagint *atomID; - memory->create(procowner,ncount,"special:procowner"); - memory->create(atomID,ncount,"special:atomID"); - memory->create(npartner,ncount,"special:npartner"); - for (m = 0; m < ncount; m++) npartner[m] = 0; + // proclist = owner of atomID in caller decomposition + + PairRvous *in = (PairRvous *) inbuf; + int *procowner = sptr->procowner; + memory->create(proclist,n,"special:proclist"); - for (i = 0; i < n; i++) { - //m = hash.find(in[i].atomID)->second; + int m; + for (int i = 0; i < n; i++) { m = atom->map(in[i].atomID); - if (in[i].me >= 0) { - procowner[m] = in[i].me; - atomID[m] = in[i].atomID; - } else npartner[m]++; + proclist[i] = procowner[m]; } - int max = 0; - for (m = 0; m < ncount; m++) - max = MAX(max,npartner[m]); - sptr->max_rvous = max; - - int **partner; - memory->create(partner,ncount,max,"special:partner"); - for (m = 0; m < ncount; m++) npartner[m] = 0; - - for (i = 0; i < n; i++) { - if (in[i].me >= 0) continue; - //m = hash.find(in[i].atomID)->second; - m = atom->map(in[i].atomID); - partner[m][npartner[m]++] = in[i].partnerID; - } - - // pass list of OutRvous datums back to comm->rendezvous - - int nout = 0; - for (m = 0; m < ncount; m++) nout += npartner[m]; - - memory->create(proclist,nout,"special:proclist"); - OutRvous *out = (OutRvous *) - memory->smalloc((bigint) nout*sizeof(OutRvous),"special:out"); - - nout = 0; - for (m = 0; m < ncount; m++) - for (j = 0; j < npartner[m]; j++) { - proclist[nout] = procowner[m]; - out[nout].atomID = atomID[m]; - out[nout].partnerID = partner[m][j]; - nout++; - } - - outbuf = (char *) out; - - // clean up - // Comm::rendezvous will delete proclist and out (outbuf) - - memory->destroy(procowner); - memory->destroy(atomID); - memory->destroy(npartner); - memory->destroy(partner); - + outbuf = inbuf; + // NOTE: set out = in flag + // re-create atom map atom->map_init(0); atom->nghost = 0; atom->map_set(); - return nout; + flag = 1; + return n; } /* ---------------------------------------------------------------------- process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N InRvous datums - create outbuf = list of Nout OutRvous datums + inbuf = list of N PairRvous datums + create outbuf = list of Nout PairRvous datums ------------------------------------------------------------------------- */ int Special::rendezvous_trim(int n, char *inbuf, - int *&proclist, char *&outbuf, + int &flag, int *&proclist, char *&outbuf, void *ptr) { int i,j,m; + /* Special *sptr = (Special *) ptr; Atom *atom = sptr->atom; Memory *memory = sptr->memory; @@ -1063,7 +1211,7 @@ int Special::rendezvous_trim(int n, char *inbuf, // key = atom ID // value = index into Ncount-length data structure - InRvous *in = (InRvous *) inbuf; + PairRvous *in = (PairRvous *) inbuf; //std::map hash; tagint id; @@ -1131,14 +1279,14 @@ int Special::rendezvous_trim(int n, char *inbuf, } } - // pass list of OutRvous datums back to comm->rendezvous + // pass list of PairRvous datums back to comm->rendezvous int nout = 0; for (m = 0; m < ncount; m++) nout += npartner[m]; memory->create(proclist,nout,"special:proclist"); - OutRvous *out = (OutRvous *) - memory->smalloc((bigint) nout*sizeof(OutRvous),"special:out"); + PairRvous *out = (PairRvous *) + memory->smalloc((bigint) nout*sizeof(PairRvous),"special:out"); nout = 0; for (m = 0; m < ncount; m++) @@ -1167,7 +1315,11 @@ int Special::rendezvous_trim(int n, char *inbuf, atom->nghost = 0; atom->map_set(); - return nout; + */ + + //return nout; + flag = 2; + return 0; } /* ---------------------------------------------------------------------- diff --git a/src/special.h b/src/special.h index f7892075ac..772ba613ac 100644 --- a/src/special.h +++ b/src/special.h @@ -26,20 +26,29 @@ class Special : protected Pointers { private: int me,nprocs; + int maxall; tagint **onetwo,**onethree,**onefour; // data used by rendezvous callback methods - int max_rvous; + int ncount; + tagint *atomIDs; + int *procowner; - struct InRvous { + struct IDRvous { int me; + tagint atomID; + }; + + struct PairRvous { tagint atomID,partnerID; }; - struct OutRvous { - tagint atomID,partnerID; - }; + void atom_owners(); + void onetwo_build_newton(); + void onetwo_build_newton_off(); + void onethree_build(); + void onefour_build(); void dedup(); void angle_trim(); @@ -48,10 +57,11 @@ class Special : protected Pointers { void fix_alteration(); void timer_output(double); - // callback function for rendezvous communication + // callback functions for rendezvous communication - static int rendezvous_1234(int, char *, int *&, char *&, void *); - static int rendezvous_trim(int, char *, int *&, char *&, void *); + static int rendezvous_ids(int, char *, int &, int *&, char *&, void *); + static int rendezvous_1234(int, char *, int &, int *&, char *&, void *); + static int rendezvous_trim(int, char *, int &, int *&, char *&, void *); }; } From 7c3d6dc051976664acf315a321e2846c93d407e2 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 7 Dec 2018 16:43:01 -0700 Subject: [PATCH 04/49] propagate rendezvous changes to fix rigid/small --- src/RIGID/fix_rigid_small.cpp | 3 ++- src/RIGID/fix_rigid_small.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index fc51e0aa4f..3da516894c 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -1611,7 +1611,7 @@ void FixRigidSmall::create_bodies(tagint *bodyID) ------------------------------------------------------------------------- */ int FixRigidSmall::rendezvous_body(int n, char *inbuf, - int *&proclist, char *&outbuf, + int &rflag, int *&proclist, char *&outbuf, void *ptr) { int i,j,m; @@ -1749,6 +1749,7 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf, memory->destroy(iclose); memory->destroy(rsqclose); + rflag = 2; return nout; } diff --git a/src/RIGID/fix_rigid_small.h b/src/RIGID/fix_rigid_small.h index a820efcdea..f6ad1b7206 100644 --- a/src/RIGID/fix_rigid_small.h +++ b/src/RIGID/fix_rigid_small.h @@ -209,7 +209,7 @@ class FixRigidSmall : public Fix { // callback function for rendezvous communication - static int rendezvous_body(int, char *, int *&, char *&, void *); + static int rendezvous_body(int, char *, int &, int *&, char *&, void *); // debug From e538fd5c6d9594edc15554f8bded8cd9baa32704 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 12 Dec 2018 17:14:56 -0700 Subject: [PATCH 05/49] added rendezvous alg to fix shake --- src/RIGID/fix_rigid_small.cpp | 6 +- src/RIGID/fix_shake.cpp | 795 +++++++++++++++++++++++----------- src/RIGID/fix_shake.h | 43 +- src/special.cpp | 633 +++++++++++++-------------- src/special.h | 7 +- 5 files changed, 899 insertions(+), 585 deletions(-) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 3da516894c..e20c64487b 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -414,9 +414,9 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : if (comm->me == 0) { if (screen) - fprintf(screen," create_bodies CPU = %g secs\n",time2-time1); + fprintf(screen," create bodies CPU = %g secs\n",time2-time1); if (logfile) - fprintf(logfile," create_bodies CPU = %g secs\n",time2-time1); + fprintf(logfile," create bodies CPU = %g secs\n",time2-time1); } // set nlocal_body and allocate bodies I own @@ -1749,6 +1749,8 @@ int FixRigidSmall::rendezvous_body(int n, char *inbuf, memory->destroy(iclose); memory->destroy(rsqclose); + // flag = 2: new outbuf + rflag = 2; return nout; } diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index e0d1bf132b..66c92d42c5 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -219,8 +219,19 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : // identify all SHAKE clusters + double time1 = MPI_Wtime(); + find_clusters(); + double time2 = MPI_Wtime(); + + if (comm->me == 0) { + if (screen) + fprintf(screen," find clusters CPU = %g secs\n",time2-time1); + if (logfile) + fprintf(logfile," find clusters CPU = %g secs\n",time2-time1); + } + // initialize list of SHAKE clusters to constrain maxlist = 0; @@ -707,13 +718,6 @@ void FixShake::find_clusters() int nlocal = atom->nlocal; int angles_allow = atom->avec->angles_allow; - // setup ring of procs - - int next = me + 1; - int prev = me -1; - if (next == nprocs) next = 0; - if (prev < 0) prev = nprocs - 1; - // ----------------------------------------------------- // allocate arrays for self (1d) and bond partners (2d) // max = max # of bond partners for owned atoms = 2nd dim of partner arrays @@ -755,6 +759,10 @@ void FixShake::find_clusters() memory->create(partner_shake,nlocal,max,"shake:partner_shake"); memory->create(partner_nshake,nlocal,max,"shake:partner_nshake"); + // setup atomIDs and procowner vectors in rendezvous decomposition + + atom_owners(); + // ----------------------------------------------------- // set npartner and partner_tag from special arrays // ----------------------------------------------------- @@ -778,86 +786,13 @@ void FixShake::find_clusters() } // ----------------------------------------------------- - // set partner_mask, partner_type, partner_massflag, partner_bondtype - // for bonded partners - // requires communication for off-proc partners + // set partner_mask, partner_type, partner_massflag, + // partner_bondtype for all my bonded partners + // requires rendezvous communication for off-proc partners // ----------------------------------------------------- - // fill in mask, type, massflag, bondtype if own bond partner - // info to store in buf for each off-proc bond = nper = 6 - // 2 atoms IDs in bond, space for mask, type, massflag, bondtype - // nbufmax = largest buffer needed to hold info from any proc - - int nper = 6; - - nbuf = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - partner_mask[i][j] = 0; - partner_type[i][j] = 0; - partner_massflag[i][j] = 0; - partner_bondtype[i][j] = 0; - - m = atom->map(partner_tag[i][j]); - if (m >= 0 && m < nlocal) { - partner_mask[i][j] = mask[m]; - partner_type[i][j] = type[m]; - if (nmass) { - if (rmass) massone = rmass[m]; - else massone = mass[type[m]]; - partner_massflag[i][j] = masscheck(massone); - } - n = bondtype_findset(i,tag[i],partner_tag[i][j],0); - if (n) partner_bondtype[i][j] = n; - else { - n = bondtype_findset(m,tag[i],partner_tag[i][j],0); - if (n) partner_bondtype[i][j] = n; - } - } else nbuf += nper; - } - } - - memory->create(buf,nbuf,"shake:buf"); - - // fill buffer with info - - size = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - m = atom->map(partner_tag[i][j]); - if (m < 0 || m >= nlocal) { - buf[size] = tag[i]; - buf[size+1] = partner_tag[i][j]; - buf[size+2] = 0; - buf[size+3] = 0; - buf[size+4] = 0; - n = bondtype_findset(i,tag[i],partner_tag[i][j],0); - if (n) buf[size+5] = n; - else buf[size+5] = 0; - size += nper; - } - } - } - - // cycle buffer around ring of procs back to self - - comm->ring(size,sizeof(tagint),buf,1,ring_bonds,buf,(void *)this); - - // store partner info returned to me - - m = 0; - while (m < size) { - i = atom->map(buf[m]); - for (j = 0; j < npartner[i]; j++) - if (buf[m+1] == partner_tag[i][j]) break; - partner_mask[i][j] = buf[m+2]; - partner_type[i][j] = buf[m+3]; - partner_massflag[i][j] = buf[m+4]; - partner_bondtype[i][j] = buf[m+5]; - m += nper; - } - - memory->destroy(buf); + partner_info(npartner,partner_tag,partner_mask,partner_type, + partner_massflag,partner_bondtype); // error check for unfilled partner info // if partner_type not set, is an error @@ -868,17 +803,18 @@ void FixShake::find_clusters() // else it's an error flag = 0; + int flag2 = 0; for (i = 0; i < nlocal; i++) for (j = 0; j < npartner[i]; j++) { - if (partner_type[i][j] == 0) flag = 1; + if (partner_type[i][j] == 0) flag++; if (!(mask[i] & groupbit)) continue; if (!(partner_mask[i][j] & groupbit)) continue; - if (partner_bondtype[i][j] == 0) flag = 1; + if (partner_bondtype[i][j] == 0) flag2++; } MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); if (flag_all) error->all(FLERR,"Did not find fix shake partner info"); - + // ----------------------------------------------------- // identify SHAKEable bonds // set nshake[i] = # of SHAKE bonds attached to atom i @@ -931,56 +867,11 @@ void FixShake::find_clusters() // ----------------------------------------------------- // set partner_nshake for bonded partners - // requires communication for off-proc partners + // requires rendezvous communication for off-proc partners // ----------------------------------------------------- - // fill in partner_nshake if own bond partner - // info to store in buf for each off-proc bond = - // 2 atoms IDs in bond, space for nshake value - // nbufmax = largest buffer needed to hold info from any proc - - nbuf = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - m = atom->map(partner_tag[i][j]); - if (m >= 0 && m < nlocal) partner_nshake[i][j] = nshake[m]; - else nbuf += 3; - } - } - - memory->create(buf,nbuf,"shake:buf"); - - // fill buffer with info - - size = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - m = atom->map(partner_tag[i][j]); - if (m < 0 || m >= nlocal) { - buf[size] = tag[i]; - buf[size+1] = partner_tag[i][j]; - size += 3; - } - } - } - - // cycle buffer around ring of procs back to self - - comm->ring(size,sizeof(tagint),buf,2,ring_nshake,buf,(void *)this); - - // store partner info returned to me - - m = 0; - while (m < size) { - i = atom->map(buf[m]); - for (j = 0; j < npartner[i]; j++) - if (buf[m+1] == partner_tag[i][j]) break; - partner_nshake[i][j] = buf[m+2]; - m += 3; - } - - memory->destroy(buf); - + nshake_info(npartner,partner_tag,partner_nshake); + // ----------------------------------------------------- // error checks // no atom with nshake > 3 @@ -988,7 +879,7 @@ void FixShake::find_clusters() // ----------------------------------------------------- flag = 0; - for (i = 0; i < nlocal; i++) if (nshake[i] > 3) flag = 1; + for (i = 0; i < nlocal; i++) if (nshake[i] > 3) flag++; MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); if (flag_all) error->all(FLERR,"Shake cluster of more than 4 atoms"); @@ -996,7 +887,7 @@ void FixShake::find_clusters() for (i = 0; i < nlocal; i++) { if (nshake[i] <= 1) continue; for (j = 0; j < npartner[i]; j++) - if (partner_shake[i][j] && partner_nshake[i][j] > 1) flag = 1; + if (partner_shake[i][j] && partner_nshake[i][j] > 1) flag++; } MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); if (flag_all) error->all(FLERR,"Shake clusters are connected"); @@ -1067,60 +958,7 @@ void FixShake::find_clusters() // requires communication for off-proc atoms // ----------------------------------------------------- - // fill in shake arrays for each bond partner I own - // info to store in buf for each off-proc bond = - // all values from shake_flag, shake_atom, shake_type - // nbufmax = largest buffer needed to hold info from any proc - - nbuf = 0; - for (i = 0; i < nlocal; i++) { - if (shake_flag[i] == 0) continue; - for (j = 0; j < npartner[i]; j++) { - if (partner_shake[i][j] == 0) continue; - m = atom->map(partner_tag[i][j]); - if (m >= 0 && m < nlocal) { - shake_flag[m] = shake_flag[i]; - shake_atom[m][0] = shake_atom[i][0]; - shake_atom[m][1] = shake_atom[i][1]; - shake_atom[m][2] = shake_atom[i][2]; - shake_atom[m][3] = shake_atom[i][3]; - shake_type[m][0] = shake_type[i][0]; - shake_type[m][1] = shake_type[i][1]; - shake_type[m][2] = shake_type[i][2]; - } else nbuf += 9; - } - } - - memory->create(buf,nbuf,"shake:buf"); - - // fill buffer with info - - size = 0; - for (i = 0; i < nlocal; i++) { - if (shake_flag[i] == 0) continue; - for (j = 0; j < npartner[i]; j++) { - if (partner_shake[i][j] == 0) continue; - m = atom->map(partner_tag[i][j]); - if (m < 0 || m >= nlocal) { - buf[size] = partner_tag[i][j]; - buf[size+1] = shake_flag[i]; - buf[size+2] = shake_atom[i][0]; - buf[size+3] = shake_atom[i][1]; - buf[size+4] = shake_atom[i][2]; - buf[size+5] = shake_atom[i][3]; - buf[size+6] = shake_type[i][0]; - buf[size+7] = shake_type[i][1]; - buf[size+8] = shake_type[i][2]; - size += 9; - } - } - } - - // cycle buffer around ring of procs back to self - - comm->ring(size,sizeof(tagint),buf,3,ring_shake,NULL,(void *)this); - - memory->destroy(buf); + shake_info(npartner,partner_tag,partner_shake); // ----------------------------------------------------- // free local memory @@ -1199,98 +1037,549 @@ void FixShake::find_clusters() } /* ---------------------------------------------------------------------- - when receive buffer, scan bond partner IDs for atoms I own - if I own partner: - fill in mask and type and massflag - search for bond with 1st atom and fill in bondtype + setup atomIDs and procowner ------------------------------------------------------------------------- */ -void FixShake::ring_bonds(int ndatum, char *cbuf, void *ptr) +void FixShake::atom_owners() { - FixShake *fsptr = (FixShake *)ptr; - Atom *atom = fsptr->atom; + tagint *tag = atom->tag; + int nlocal = atom->nlocal; + + int *proclist; + memory->create(proclist,nlocal,"shake:proclist"); + IDRvous *idbuf = (IDRvous *) + memory->smalloc((bigint) nlocal*sizeof(IDRvous),"shake:idbuf"); + + // setup input buf to rendezvous comm + // input datums = pairs of bonded atoms + // owning proc for each datum = random hash of atomID + // one datum for each owned atom: datum = owning proc, atomID + + for (int i = 0; i < nlocal; i++) { + proclist[i] = tag[i] % nprocs; + idbuf[i].me = me; + idbuf[i].atomID = tag[i]; + } + + // perform rendezvous operation + // each proc assigned every 1/Pth atom + + char *buf; + comm->rendezvous(nlocal,proclist, + (char *) idbuf,sizeof(IDRvous), + rendezvous_ids,buf,0,(void *) this); + + memory->destroy(proclist); + memory->sfree(idbuf); +} + +/* ---------------------------------------------------------------------- + setup partner_mask, partner_type, partner_massflag, partner_bondtype +------------------------------------------------------------------------- */ + +void FixShake::partner_info(int *npartner, tagint **partner_tag, + int **partner_mask, int **partner_type, + int **partner_massflag, int **partner_bondtype) +{ + int i,j,m,n; + int nlocal = atom->nlocal; + + // nsend = # of my datums to send + // one datum for every off-processor partner + + int nsend = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + m = atom->map(partner_tag[i][j]); + if (m < 0 || m >= nlocal) nsend++; + } + } + + int *proclist; + memory->create(proclist,nsend,"special:proclist"); + PartnerInfo *inbuf = (PartnerInfo *) + memory->smalloc((bigint) nsend*sizeof(PartnerInfo),"special:inbuf"); + + // set values in 4 partner arrays for all partner atoms I own + // also setup input buf to rendezvous comm + // input datums = pair of bonded atoms where I do not own partner + // owning proc for each datum = partner_tag % nprocs + // datum: atomID = partner_tag (off-proc), partnerID = tag (on-proc) + // 4 values for my owned atom + double *rmass = atom->rmass; double *mass = atom->mass; - int *mask = atom->mask; int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + + double massone; + + nsend = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + partner_mask[i][j] = 0; + partner_type[i][j] = 0; + partner_massflag[i][j] = 0; + partner_bondtype[i][j] = 0; + + m = atom->map(partner_tag[i][j]); + + if (m >= 0 && m < nlocal) { + partner_mask[i][j] = mask[m]; + partner_type[i][j] = type[m]; + if (nmass) { + if (rmass) massone = rmass[m]; + else massone = mass[type[m]]; + partner_massflag[i][j] = masscheck(massone); + } + n = bondtype_findset(i,tag[i],partner_tag[i][j],0); + if (n) partner_bondtype[i][j] = n; + else { + n = bondtype_findset(m,tag[i],partner_tag[i][j],0); + if (n) partner_bondtype[i][j] = n; + } + + } else { + proclist[nsend] = partner_tag[i][j] % nprocs; + inbuf[nsend].atomID = partner_tag[i][j]; + inbuf[nsend].partnerID = tag[i]; + inbuf[nsend].mask = mask[i]; + inbuf[nsend].type = type[i]; + if (nmass) { + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + inbuf[nsend].massflag = masscheck(massone); + } else inbuf[nsend].massflag = 0; + + // my atom may own bond, in which case set partner_bondtype + // else receiver of this datum will own the bond and return the value + + n = bondtype_findset(i,tag[i],partner_tag[i][j],0); + if (n) { + partner_bondtype[i][j] = n; + inbuf[nsend].bondtype = n; + } else inbuf[nsend].bondtype = 0; + + nsend++; + } + } + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all data needed to populate un-owned partner 4 values + + char *buf; + int nreturn = comm->rendezvous(nsend,proclist, + (char *) inbuf,sizeof(PartnerInfo), + rendezvous_partners_info,buf,sizeof(PartnerInfo), + (void *) this); + PartnerInfo *outbuf = (PartnerInfo *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); + + // set partner 4 values for un-onwed partners based on output info + // outbuf.atomID = my owned atom, outbuf.partnerID = partner the info is for + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + for (j = 0; j < npartner[i]; j++) + if (partner_tag[i][j] == outbuf[m].partnerID) break; + partner_mask[i][j] = outbuf[m].mask; + partner_type[i][j] = outbuf[m].type; + partner_massflag[i][j] = outbuf[m].massflag; + + // only set partner_bondtype if my atom did not set it when setting up rendezvous + // if this proc set it, then sender of this datum set outbuf.bondtype = 0 + + if (partner_bondtype[i][j] == 0) + partner_bondtype[i][j] = outbuf[m].bondtype; + } + + memory->sfree(outbuf); +} + +/* ---------------------------------------------------------------------- + setup partner_nshake +------------------------------------------------------------------------- */ + +void FixShake::nshake_info(int *npartner, tagint **partner_tag, + int **partner_nshake) +{ + int i,j,m,n; int nlocal = atom->nlocal; + + // nsend = # of my datums to send + // one datum for every off-processor partner + + int nsend = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + m = atom->map(partner_tag[i][j]); + if (m < 0 || m >= nlocal) nsend++; + } + } + + int *proclist; + memory->create(proclist,nsend,"special:proclist"); + NShakeInfo *inbuf = (NShakeInfo *) + memory->smalloc((bigint) nsend*sizeof(NShakeInfo),"special:inbuf"); + + // set partner_nshake for all partner atoms I own + // also setup input buf to rendezvous comm + // input datums = pair of bonded atoms where I do not own partner + // owning proc for each datum = partner_tag % nprocs + // datum: atomID = partner_tag (off-proc), partnerID = tag (on-proc) + // nshake value for my owned atom + + tagint *tag = atom->tag; + + nsend = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + partner_nshake[i][j] = 0; + m = atom->map(partner_tag[i][j]); + if (m >= 0 && m < nlocal) { + partner_nshake[i][j] = nshake[m]; + } else { + proclist[nsend] = partner_tag[i][j] % nprocs; + inbuf[nsend].atomID = partner_tag[i][j]; + inbuf[nsend].partnerID = tag[i]; + inbuf[nsend].nshake = nshake[i]; + nsend++; + } + } + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all data needed to populate un-owned partner nshake + + char *buf; + int nreturn = comm->rendezvous(nsend,proclist, + (char *) inbuf,sizeof(NShakeInfo), + rendezvous_nshake,buf,sizeof(NShakeInfo), + (void *) this); + NShakeInfo *outbuf = (NShakeInfo *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); + + // set partner nshake for un-onwed partners based on output info + // outbuf.atomID = my owned atom, outbuf.partnerID = partner the info is for + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + for (j = 0; j < npartner[i]; j++) + if (partner_tag[i][j] == outbuf[m].partnerID) break; + partner_nshake[i][j] = outbuf[m].nshake; + } + + memory->sfree(outbuf); +} + +/* ---------------------------------------------------------------------- + setup shake_flag, shake_atom, shake_type +------------------------------------------------------------------------- */ + +void FixShake::shake_info(int *npartner, tagint **partner_tag, + int **partner_shake) +{ + int i,j,m,n; + int nlocal = atom->nlocal; + + // nsend = # of my datums to send + // one datum for every off-processor partner + + int nsend = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + m = atom->map(partner_tag[i][j]); + if (m < 0 || m >= nlocal) nsend++; + } + } + + int *proclist; + memory->create(proclist,nsend,"special:proclist"); + ShakeInfo *inbuf = (ShakeInfo *) + memory->smalloc((bigint) nsend*sizeof(ShakeInfo),"special:inbuf"); + + // set 3 shake arrays for all partner atoms I own + // also setup input buf to rendezvous comm + // input datums = partner atom where I do not own partner + // owning proc for each datum = partner_tag % nprocs + // datum: atomID = partner_tag (off-proc) + // values in 3 shake arrays + + nsend = 0; + for (i = 0; i < nlocal; i++) { + if (shake_flag[i] == 0) continue; + for (j = 0; j < npartner[i]; j++) { + if (partner_shake[i][j] == 0) continue; + m = atom->map(partner_tag[i][j]); + + if (m >= 0 && m < nlocal) { + shake_flag[m] = shake_flag[i]; + shake_atom[m][0] = shake_atom[i][0]; + shake_atom[m][1] = shake_atom[i][1]; + shake_atom[m][2] = shake_atom[i][2]; + shake_atom[m][3] = shake_atom[i][3]; + shake_type[m][0] = shake_type[i][0]; + shake_type[m][1] = shake_type[i][1]; + shake_type[m][2] = shake_type[i][2]; + + } else { + proclist[nsend] = partner_tag[i][j] % nprocs; + inbuf[nsend].atomID = partner_tag[i][j]; + inbuf[nsend].shake_flag = shake_flag[i]; + inbuf[nsend].shake_atom[0] = shake_atom[i][0]; + inbuf[nsend].shake_atom[1] = shake_atom[i][1]; + inbuf[nsend].shake_atom[2] = shake_atom[i][2]; + inbuf[nsend].shake_atom[3] = shake_atom[i][3]; + inbuf[nsend].shake_type[0] = shake_type[i][0]; + inbuf[nsend].shake_type[1] = shake_type[i][1]; + inbuf[nsend].shake_type[2] = shake_type[i][2]; + nsend++; + } + } + } + + // perform rendezvous operation + // each proc owns random subset of atoms + // receives all data needed to populate un-owned shake info + + char *buf; + int nreturn = comm->rendezvous(nsend,proclist, + (char *) inbuf,sizeof(ShakeInfo), + rendezvous_shake,buf,sizeof(ShakeInfo), + (void *) this); + ShakeInfo *outbuf = (ShakeInfo *) buf; + + memory->destroy(proclist); + memory->sfree(inbuf); + + // set shake info for un-onwed partners based on output info + + for (m = 0; m < nreturn; m++) { + i = atom->map(outbuf[m].atomID); + shake_flag[i] = outbuf[m].shake_flag; + shake_atom[i][0] = outbuf[m].shake_atom[0]; + shake_atom[i][1] = outbuf[m].shake_atom[1]; + shake_atom[i][2] = outbuf[m].shake_atom[2]; + shake_atom[i][3] = outbuf[m].shake_atom[3]; + shake_type[i][0] = outbuf[m].shake_type[0]; + shake_type[i][1] = outbuf[m].shake_type[1]; + shake_type[i][2] = outbuf[m].shake_type[2]; + } + + memory->sfree(outbuf); +} + +/* ---------------------------------------------------------------------- + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N IDRvous datums + no outbuf +------------------------------------------------------------------------- */ + +int FixShake::rendezvous_ids(int n, char *inbuf, + int &flag, int *&proclist, char *&outbuf, + void *ptr) +{ + FixShake *fsptr = (FixShake *) ptr; + Memory *memory = fsptr->memory; + + int *procowner; + tagint *atomIDs; + + memory->create(procowner,n,"special:procowner"); + memory->create(atomIDs,n,"special:atomIDs"); + + IDRvous *in = (IDRvous *) inbuf; + + for (int i = 0; i < n; i++) { + procowner[i] = in[i].me; + atomIDs[i] = in[i].atomID; + } + + // store rendezvous data in FixShake class + + fsptr->nrvous = n; + fsptr->procowner = procowner; + fsptr->atomIDs = atomIDs; + + // flag = 0: no 2nd irregular comm needed in comm->rendezvous + + flag = 0; + return 0; +} + +/* ---------------------------------------------------------------------- + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N PairRvous datums + outbuf = same list of N PairRvous datums, routed to different procs +------------------------------------------------------------------------- */ + +int FixShake::rendezvous_partners_info(int n, char *inbuf, + int &flag, int *&proclist, char *&outbuf, + void *ptr) +{ + int i,m; + + FixShake *fsptr = (FixShake *) ptr; + Atom *atom = fsptr->atom; + Memory *memory = fsptr->memory; + + // clear atom map so it can be here as a hash table + // faster than an STL map for large atom counts + + atom->map_clear(); + + // hash atom IDs stored in rendezvous decomposition + + int nrvous = fsptr->nrvous; + tagint *atomIDs = fsptr->atomIDs; + + for (i = 0; i < nrvous; i++) + atom->map_one(atomIDs[i],i); + + // proclist = owner of atomID in caller decomposition + // outbuf = info about owned atomID = 4 values + + PartnerInfo *in = (PartnerInfo *) inbuf; + int *procowner = fsptr->procowner; + memory->create(proclist,n,"shake:proclist"); + + double massone; int nmass = fsptr->nmass; - tagint *buf = (tagint *) cbuf; - int m,n; - double massone; - - for (int i = 0; i < ndatum; i += 6) { - m = atom->map(buf[i+1]); - if (m >= 0 && m < nlocal) { - buf[i+2] = mask[m]; - buf[i+3] = type[m]; - if (nmass) { - if (rmass) massone = rmass[m]; - else massone = mass[type[m]]; - buf[i+4] = fsptr->masscheck(massone); - } - if (buf[i+5] == 0) { - n = fsptr->bondtype_findset(m,buf[i],buf[i+1],0); - if (n) buf[i+5] = n; - } - } + for (i = 0; i < n; i++) { + m = atom->map(in[i].atomID); + proclist[i] = procowner[m]; } + + outbuf = inbuf; + + // re-create atom map + + atom->map_init(0); + atom->nghost = 0; + atom->map_set(); + + // flag = 1: outbuf = inbuf + + flag = 1; + return n; } /* ---------------------------------------------------------------------- - when receive buffer, scan bond partner IDs for atoms I own - if I own partner, fill in nshake value + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N NShakeInfo datums + outbuf = same list of N NShakeInfo datums, routed to different procs ------------------------------------------------------------------------- */ -void FixShake::ring_nshake(int ndatum, char *cbuf, void *ptr) +int FixShake::rendezvous_nshake(int n, char *inbuf, + int &flag, int *&proclist, char *&outbuf, + void *ptr) { - FixShake *fsptr = (FixShake *)ptr; + int i,j,m; + + FixShake *fsptr = (FixShake *) ptr; Atom *atom = fsptr->atom; - int nlocal = atom->nlocal; + Memory *memory = fsptr->memory; - int *nshake = fsptr->nshake; + // clear atom map so it can be here as a hash table + // faster than an STL map for large atom counts - tagint *buf = (tagint *) cbuf; - int m; + atom->map_clear(); - for (int i = 0; i < ndatum; i += 3) { - m = atom->map(buf[i+1]); - if (m >= 0 && m < nlocal) buf[i+2] = nshake[m]; + // hash atom IDs stored in rendezvous decomposition + + int nrvous = fsptr->nrvous; + tagint *atomIDs = fsptr->atomIDs; + + for (i = 0; i < nrvous; i++) + atom->map_one(atomIDs[i],i); + + // proclist = owner of atomID in caller decomposition + // outbuf = info about owned atomID + + NShakeInfo *in = (NShakeInfo *) inbuf; + int *procowner = fsptr->procowner; + memory->create(proclist,n,"shake:proclist"); + + for (i = 0; i < n; i++) { + m = atom->map(in[i].atomID); + proclist[i] = procowner[m]; } + + outbuf = inbuf; + + // re-create atom map + + atom->map_init(0); + atom->nghost = 0; + atom->map_set(); + + // flag = 1: outbuf = inbuf + + flag = 1; + return n; } - /* ---------------------------------------------------------------------- - when receive buffer, scan bond partner IDs for atoms I own - if I own partner, fill in nshake value + process data for atoms assigned to me in rendezvous decomposition + inbuf = list of N PairRvous datums + outbuf = same list of N PairRvous datums, routed to different procs ------------------------------------------------------------------------- */ -void FixShake::ring_shake(int ndatum, char *cbuf, void *ptr) +int FixShake::rendezvous_shake(int n, char *inbuf, + int &flag, int *&proclist, char *&outbuf, + void *ptr) { - FixShake *fsptr = (FixShake *)ptr; + int i,j,m; + + FixShake *fsptr = (FixShake *) ptr; Atom *atom = fsptr->atom; - int nlocal = atom->nlocal; + Memory *memory = fsptr->memory; - int *shake_flag = fsptr->shake_flag; - tagint **shake_atom = fsptr->shake_atom; - int **shake_type = fsptr->shake_type; + // clear atom map so it can be here as a hash table + // faster than an STL map for large atom counts - tagint *buf = (tagint *) cbuf; - int m; + atom->map_clear(); - for (int i = 0; i < ndatum; i += 9) { - m = atom->map(buf[i]); - if (m >= 0 && m < nlocal) { - shake_flag[m] = buf[i+1]; - shake_atom[m][0] = buf[i+2]; - shake_atom[m][1] = buf[i+3]; - shake_atom[m][2] = buf[i+4]; - shake_atom[m][3] = buf[i+5]; - shake_type[m][0] = buf[i+6]; - shake_type[m][1] = buf[i+7]; - shake_type[m][2] = buf[i+8]; - } + // hash atom IDs stored in rendezvous decomposition + + int nrvous = fsptr->nrvous; + tagint *atomIDs = fsptr->atomIDs; + + for (i = 0; i < nrvous; i++) + atom->map_one(atomIDs[i],i); + + // proclist = owner of atomID in caller decomposition + // outbuf = info about owned atomID + + ShakeInfo *in = (ShakeInfo *) inbuf; + int *procowner = fsptr->procowner; + memory->create(proclist,n,"shake:proclist"); + + for (i = 0; i < n; i++) { + m = atom->map(in[i].atomID); + proclist[i] = procowner[m]; } + + outbuf = inbuf; + + // re-create atom map + + atom->map_init(0); + atom->nghost = 0; + atom->map_set(); + + // flag = 1: outbuf = inbuf; + + flag = 1; + return n; } /* ---------------------------------------------------------------------- diff --git a/src/RIGID/fix_shake.h b/src/RIGID/fix_shake.h index d4e7b85ec4..2baea90a4a 100644 --- a/src/RIGID/fix_shake.h +++ b/src/RIGID/fix_shake.h @@ -120,6 +120,11 @@ class FixShake : public Fix { int nmol; void find_clusters(); + void atom_owners(); + void partner_info(int *, tagint **, int **, int **, int **, int **); + void nshake_info(int *, tagint **, int **); + void shake_info(int *, tagint **, int **); + int masscheck(double); void unconstrained_update(); void unconstrained_update_respa(int); @@ -131,12 +136,40 @@ class FixShake : public Fix { int bondtype_findset(int, tagint, tagint, int); int angletype_findset(int, tagint, tagint, int); - // static variable for ring communication callback to access class data - // callback functions for ring communication + // data used by rendezvous callback methods - static void ring_bonds(int, char *, void *); - static void ring_nshake(int, char *, void *); - static void ring_shake(int, char *, void *); + int nrvous; + tagint *atomIDs; + int *procowner; + + struct IDRvous { + int me; + tagint atomID; + }; + + struct PartnerInfo { + tagint atomID,partnerID; + int mask,type,massflag,bondtype; + }; + + struct NShakeInfo { + tagint atomID,partnerID; + int nshake; + }; + + struct ShakeInfo { + tagint atomID; + int shake_flag; + int shake_atom[4]; + int shake_type[3]; + }; + + // callback functions for rendezvous communication + + static int rendezvous_ids(int, char *, int &, int *&, char *&, void *); + static int rendezvous_partners_info(int, char *, int &, int *&, char *&, void *); + static int rendezvous_nshake(int, char *, int &, int *&, char *&, void *); + static int rendezvous_shake(int, char *, int &, int *&, char *&, void *); }; } diff --git a/src/special.cpp b/src/special.cpp index 79d2f77e46..b0d5bc7dca 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -21,7 +21,6 @@ #include "modify.h" #include "fix.h" #include "accelerator_kokkos.h" -#include "hashlittle.h" #include "atom_masks.h" #include "memory.h" #include "error.h" @@ -177,25 +176,20 @@ void Special::atom_owners() // input datums = pairs of bonded atoms // owning proc for each datum = random hash of atomID // one datum for each owned atom: datum = owning proc, atomID - // one datum for each bond partner: datum = atomID, bond partner ID - // add inverted datum when netwon_bond on for (int i = 0; i < nlocal; i++) { - //proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; proclist[i] = tag[i] % nprocs; idbuf[i].me = me; idbuf[i].atomID = tag[i]; } // perform rendezvous operation - // each proc owns random subset of atoms - // receives all info to form and return their onetwo lists + // each proc assigned every 1/Pth atom char *buf; comm->rendezvous(nlocal,proclist, - (char *) idbuf,sizeof(PairRvous), - rendezvous_ids,buf,sizeof(PairRvous), - (void *) this); + (char *) idbuf,sizeof(IDRvous), + rendezvous_ids,buf,0,(void *) this); memory->destroy(proclist); memory->sfree(idbuf); @@ -215,49 +209,45 @@ void Special::onetwo_build_newton() int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - // ncount = # of my datums to send - // include nlocal datums with owner of each atom + // nsend = # of my datums to send - int ncount = 0; + int nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < num_bond[i]; j++) { m = atom->map(bond_atom[i][j]); - if (m < 0 || m >= nlocal) ncount++; + if (m < 0 || m >= nlocal) nsend++; } } int *proclist; - memory->create(proclist,ncount,"special:proclist"); + memory->create(proclist,nsend,"special:proclist"); PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm // input datums = pairs of bonded atoms - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - // one datum for each bond partner: datum = atomID, bond partner ID - // add inverted datum when netwon_bond on + // owning proc for each datum = atomID % nprocs + // one datum for each bond partner: bond partner ID, atomID - ncount = 0; + nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < num_bond[i]; j++) { m = atom->map(bond_atom[i][j]); if (m >= 0 && m < nlocal) continue; - proclist[ncount] = bond_atom[i][j] % nprocs; - inbuf[ncount].atomID = bond_atom[i][j]; - inbuf[ncount].partnerID = tag[i]; - ncount++; + proclist[nsend] = bond_atom[i][j] % nprocs; + inbuf[nsend].atomID = bond_atom[i][j]; + inbuf[nsend].partnerID = tag[i]; + nsend++; } } // perform rendezvous operation // each proc owns random subset of atoms - // receives all info to form and return their onetwo lists char *buf; - int nreturn = comm->rendezvous(ncount,proclist, + int nreturn = comm->rendezvous(nsend,proclist, (char *) inbuf,sizeof(PairRvous), - rendezvous_1234,buf,sizeof(PairRvous), + rendezvous_pairs,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; @@ -312,6 +302,28 @@ void Special::onetwo_build_newton() void Special::onetwo_build_newton_off() { + int i,j; + + int *num_bond = atom->num_bond; + tagint **bond_atom = atom->bond_atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + int max = 0; + for (i = 0; i < nlocal; i++) + max = MAX(max,num_bond[i]); + + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + memory->create(onetwo,nlocal,maxall,"special:onetwo"); + + // nsend = # of my datums to send + // include nlocal datums with owner of each atom + + for (i = 0; i < nlocal; i++) { + nspecial[i][0] = num_bond[i]; + for (j = 0; j < num_bond[i]; j++) + onetwo[i][j] = bond_atom[i][j]; + } } /* ---------------------------------------------------------------------- @@ -327,21 +339,20 @@ void Special::onethree_build() int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - // ncount = # of my datums to send - // include nlocal datums with owner of each atom + // nsend = # of my datums to send - int ncount = 0; + int nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < nspecial[i][0]; j++) { m = atom->map(onetwo[i][j]); - if (m < 0 || m >= nlocal) ncount += nspecial[i][0]-1; + if (m < 0 || m >= nlocal) nsend += nspecial[i][0]-1; } } int *proclist; - memory->create(proclist,ncount,"special:proclist"); + memory->create(proclist,nsend,"special:proclist"); PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm // input datums = all pairs of onetwo atoms (they are 1-3 neighbors) @@ -349,7 +360,7 @@ void Special::onethree_build() // one datum for each owned atom: datum = owning proc, atomID // one datum for each onetwo pair: datum = atomID1, atomID2 - ncount = 0; + nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < nspecial[i][0]; j++) { m = atom->map(onetwo[i][j]); @@ -357,10 +368,10 @@ void Special::onethree_build() proc = onetwo[i][j] % nprocs; for (k = 0; k < nspecial[i][0]; k++) { if (j == k) continue; - proclist[ncount] = proc; - inbuf[ncount].atomID = onetwo[i][j]; - inbuf[ncount].partnerID = onetwo[i][k]; - ncount++; + proclist[nsend] = proc; + inbuf[nsend].atomID = onetwo[i][j]; + inbuf[nsend].partnerID = onetwo[i][k]; + nsend++; } } } @@ -370,9 +381,9 @@ void Special::onethree_build() // receives all info to form and return their onethree lists char *buf; - int nreturn = comm->rendezvous(ncount,proclist, + int nreturn = comm->rendezvous(nsend,proclist, (char *) inbuf,sizeof(PairRvous), - rendezvous_1234,buf,sizeof(PairRvous), + rendezvous_pairs,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; @@ -434,21 +445,21 @@ void Special::onefour_build() int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - // ncount = # of my datums to send + // nsend = # of my datums to send // include nlocal datums with owner of each atom - int ncount = 0; + int nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < nspecial[i][1]; j++) { m = atom->map(onethree[i][j]); - if (m < 0 || m >= nlocal) ncount += nspecial[i][0]; + if (m < 0 || m >= nlocal) nsend += nspecial[i][0]; } } int *proclist; - memory->create(proclist,ncount,"special:proclist"); + memory->create(proclist,nsend,"special:proclist"); PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm // input datums = all pairs of onethree and onetwo atoms (they're 1-4 neighbors) @@ -456,17 +467,17 @@ void Special::onefour_build() // one datum for each owned atom: datum = owning proc, atomID // one datum for each onethree/onetwo pair: datum = atomID1, atomID2 - ncount = 0; + nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < nspecial[i][1]; j++) { m = atom->map(onethree[i][j]); if (m >= 0 && m < nlocal) continue; proc = onethree[i][j] % nprocs; for (k = 0; k < nspecial[i][0]; k++) { - proclist[ncount] = proc; - inbuf[ncount].atomID = onethree[i][j]; - inbuf[ncount].partnerID = onetwo[i][k]; - ncount++; + proclist[nsend] = proc; + inbuf[nsend].atomID = onethree[i][j]; + inbuf[nsend].partnerID = onetwo[i][k]; + nsend++; } } } @@ -476,9 +487,9 @@ void Special::onefour_build() // receives all info to form and return their onefour lists char *buf; - int nreturn = comm->rendezvous(ncount,proclist, + int nreturn = comm->rendezvous(nsend,proclist, (char *) inbuf,sizeof(PairRvous), - rendezvous_1234,buf,sizeof(PairRvous), + rendezvous_pairs,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; @@ -773,7 +784,7 @@ void Special::combine() void Special::angle_trim() { - int i,j,m,n,proc,index; + int i,j,k,m;; int *num_angle = atom->num_angle; int *num_dihedral = atom->num_dihedral; @@ -804,96 +815,89 @@ void Special::angle_trim() " %g = # of 1-3 neighbors before angle trim\n",allcount); } - // if angles or dihedrals are defined, - // flag each 1-3 neigh if it appears in an angle or dihedral + // if angles or dihedrals are defined + // rendezvous angle 1-3 and dihedral 1-3,2-4 pairs if ((num_angle && atom->nangles) || (num_dihedral && atom->ndihedrals)) { - // ncount = # of my datums to send in 3 parts for each owned atom - // proc owner, onethree list, angle end points - // angle end points are from angle list and 1-3 and 2-4 pairs in dihedrals - // latter is only for angles or dihedrlas where I own atom2 + // nsend = # of my datums to send + // latter is only for angles or dihedrlas where I own atom2 (newton bond off) - int ncount = nlocal; - for (i = 0; i < nlocal; i++) ncount += nspecial[i][1]; + int nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < num_angle[i]; j++) { - index = atom->map(angle_atom2[i][j]); - if (index >= 0 && index < nlocal) ncount += 2; + if (tag[i] != angle_atom2[i][j]) continue; + m = atom->map(angle_atom1[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(angle_atom3[i][j]); + if (m < 0 || m >= nlocal) nsend++; } for (j = 0; j < num_dihedral[i]; j++) { - index = atom->map(dihedral_atom2[i][j]); - if (index >= 0 && index < nlocal) ncount += 4; + if (tag[i] != dihedral_atom2[i][j]) continue; + m = atom->map(dihedral_atom1[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(dihedral_atom3[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(dihedral_atom4[i][j]); + if (m < 0 || m >= nlocal) nsend++; } } int *proclist; - memory->create(proclist,ncount,"special:proclist"); + memory->create(proclist,nsend,"special:proclist"); PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); + memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm - // one datum for each owned atom: datum = proc, atomID - // sent to owner of atomID - // one datum for each 1-4 partner: datum = atomID, ID - // sent to owner of atomID - // two datums for each dihedral 1-4 endatoms : datum = atomID, ID - // sent to owner of atomID - m = 0; + nsend = 0; for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][1]; j++) { - proclist[m] = proc; - //inbuf[m].me = -1; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = onethree[i][j]; - m++; - } - for (j = 0; j < num_angle[i]; j++) { - index = atom->map(angle_atom2[i][j]); - if (index < 0 || index >= nlocal) continue; + if (tag[i] != angle_atom2[i][j]) continue; - proclist[m] = hashlittle(&angle_atom1[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = angle_atom1[i][j]; - inbuf[m].partnerID = angle_atom3[i][j]; - m++; + m = atom->map(angle_atom1[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = angle_atom1[i][j] % nprocs; + inbuf[nsend].atomID = angle_atom1[i][j]; + inbuf[nsend].partnerID = angle_atom3[i][j]; + nsend++; + } - proclist[m] = hashlittle(&angle_atom3[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = angle_atom3[i][j]; - inbuf[m].partnerID = angle_atom1[i][j]; - m++; + m = atom->map(angle_atom3[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = angle_atom3[i][j] % nprocs; + inbuf[nsend].atomID = angle_atom3[i][j]; + inbuf[nsend].partnerID = angle_atom1[i][j]; + nsend++; + } } for (j = 0; j < num_dihedral[i]; j++) { - index = atom->map(dihedral_atom2[i][j]); - if (index < 0 || index >= nlocal) continue; + if (tag[i] != dihedral_atom2[i][j]) continue; - proclist[m] = hashlittle(&dihedral_atom1[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = dihedral_atom1[i][j]; - inbuf[m].partnerID = dihedral_atom3[i][j]; - m++; + m = atom->map(dihedral_atom1[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom1[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom1[i][j]; + inbuf[nsend].partnerID = dihedral_atom3[i][j]; + nsend++; + } - proclist[m] = hashlittle(&dihedral_atom2[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = dihedral_atom2[i][j]; - inbuf[m].partnerID = dihedral_atom4[i][j]; - m++; + m = atom->map(dihedral_atom3[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom3[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom3[i][j]; + inbuf[nsend].partnerID = dihedral_atom1[i][j]; + nsend++; + } - proclist[m] = hashlittle(&dihedral_atom3[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = dihedral_atom3[i][j]; - inbuf[m].partnerID = dihedral_atom1[i][j]; - m++; - - proclist[m] = hashlittle(&dihedral_atom4[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = dihedral_atom4[i][j]; - inbuf[m].partnerID = dihedral_atom2[i][j]; - m++; + m = atom->map(dihedral_atom4[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom4[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom4[i][j]; + inbuf[nsend].partnerID = dihedral_atom2[i][j]; + nsend++; + } } } @@ -903,26 +907,112 @@ void Special::angle_trim() // when done: each atom has atom ID of owning atom of its body char *buf; - int nreturn = comm->rendezvous(ncount,proclist, + int nreturn = comm->rendezvous(nsend,proclist, (char *) inbuf,sizeof(PairRvous), - rendezvous_trim,buf,sizeof(PairRvous), + rendezvous_pairs,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); - // reset nspecial[1] and onethree for all owned atoms based on output info + // flag all onethree atoms to keep - for (i = 0; i < nlocal; i++) nspecial[i][1] = 0; + int max = 0; + for (i = 0; i < nlocal; i++) + max = MAX(max,nspecial[i][1]); + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + + int **flag; + memory->create(flag,nlocal,maxall,"special:flag"); + + for (i = 0; i < nlocal; i++) + for (j = 0; j < nspecial[i][1]; j++) + flag[i][j] = 0; + + // reset nspecial[1] and onethree for all owned atoms based on output info + + for (i = 0; i < nlocal; i++) { + for (j = 0; j < num_angle[i]; j++) { + if (tag[i] != angle_atom2[i][j]) continue; + + m = atom->map(angle_atom1[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == angle_atom3[i][j]) { + flag[m][k] = 1; + break; + } + } + + m = atom->map(angle_atom3[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == angle_atom1[i][j]) { + flag[m][k] = 1; + break; + } + } + } + + for (j = 0; j < num_dihedral[i]; j++) { + if (tag[i] != dihedral_atom2[i][j]) continue; + + m = atom->map(dihedral_atom1[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == dihedral_atom3[i][j]) { + flag[m][k] = 1; + break; + } + } + + m = atom->map(dihedral_atom3[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == dihedral_atom1[i][j]) { + flag[m][k] = 1; + break; + } + } + + m = atom->map(dihedral_atom4[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == dihedral_atom2[i][j]) { + flag[m][k] = 1; + break; + } + } + } + } for (m = 0; m < nreturn; m++) { i = atom->map(outbuf[m].atomID); - onethree[i][nspecial[i][1]++] = outbuf[m].partnerID; + for (k = 0; k < nspecial[i][1]; k++) + if (onethree[i][k] == outbuf[m].partnerID) { + flag[i][k] = 1; + break; + } } - + memory->destroy(outbuf); + // use flag values to compress onefour list for each atom + + for (i = 0; i < nlocal; i++) { + j = 0; + while (j < nspecial[i][1]) { + if (flag[i][j] == 0) { + onethree[i][j] = onethree[i][nspecial[i][1]-1]; + flag[i][j] = flag[i][nspecial[i][1]-1]; + nspecial[i][1]--; + } else j++; + } + } + + memory->destroy(flag); + // if no angles or dihedrals are defined, delete all 1-3 neighs } else { @@ -952,7 +1042,7 @@ void Special::angle_trim() void Special::dihedral_trim() { - int i,j,m,n,proc,index; + int i,j,k,m; int *num_dihedral = atom->num_dihedral; tagint **dihedral_atom1 = atom->dihedral_atom1; @@ -978,68 +1068,51 @@ void Special::dihedral_trim() " %g = # of 1-4 neighbors before dihedral trim\n",allcount); } - // if dihedrals are defined, rendezvous onefour list with dihedral 1-4 pairs + // if dihedrals are defined, rendezvous dihedral 1-4 pairs if (num_dihedral && atom->ndihedrals) { - // ncount = # of my datums to send in 3 parts for each owned atom - // onefour list, proc owner, dihedral end points - // latter is only for dihedrals where I own atom2 + // nsend = # of my datums to send + // latter is only for dihedrals where I own atom2 (newton bond off) - int ncount = nlocal; - for (i = 0; i < nlocal; i++) ncount += nspecial[i][2]; + int nsend = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < num_dihedral[i]; j++) { - index = atom->map(dihedral_atom2[i][j]); - if (index >= 0 && index < nlocal) ncount += 2; + if (tag[i] != dihedral_atom2[i][j]) continue; + m = atom->map(dihedral_atom1[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(dihedral_atom4[i][j]); + if (m < 0 || m >= nlocal) nsend++; } } int *proclist; - memory->create(proclist,ncount,"special:proclist"); + memory->create(proclist,nsend,"special:proclist"); PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) ncount*sizeof(PairRvous),"special:inbuf"); - + memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); + // setup input buf to rendezvous comm - // one datum for each owned atom: datum = proc, atomID - // sent to owner of atomID - // one datum for each 1-4 partner: datum = atomID, ID - // sent to owner of atomID - // two datums for each dihedral 1-4 endatoms : datum = atomID, ID - // sent to owner of atomID - m = 0; + nsend = 0; for (i = 0; i < nlocal; i++) { - proc = hashlittle(&tag[i],sizeof(tagint),0) % nprocs; - proclist[m] = proc; - //inbuf[m].me = me; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = 0; - m++; - - for (j = 0; j < nspecial[i][2]; j++) { - proclist[m] = proc; - //inbuf[m].me = -1; - inbuf[m].atomID = tag[i]; - inbuf[m].partnerID = onefour[i][j]; - m++; - } - for (j = 0; j < num_dihedral[i]; j++) { - index = atom->map(dihedral_atom2[i][j]); - if (index < 0 || index >= nlocal) continue; + if (tag[i] != dihedral_atom2[i][j]) continue; - proclist[m] = hashlittle(&dihedral_atom1[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = dihedral_atom1[i][j]; - inbuf[m].partnerID = dihedral_atom4[i][j]; - m++; + m = atom->map(dihedral_atom1[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom1[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom1[i][j]; + inbuf[nsend].partnerID = dihedral_atom4[i][j]; + nsend++; + } - proclist[m] = hashlittle(&dihedral_atom4[i][j],sizeof(tagint),0) % nprocs; - //inbuf[m].me = -2; - inbuf[m].atomID = dihedral_atom4[i][j]; - inbuf[m].partnerID = dihedral_atom1[i][j]; - m++; + m = atom->map(dihedral_atom4[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom4[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom4[i][j]; + inbuf[nsend].partnerID = dihedral_atom1[i][j]; + nsend++; + } } } @@ -1049,26 +1122,81 @@ void Special::dihedral_trim() // when done: each atom has atom ID of owning atom of its body char *buf; - int nreturn = comm->rendezvous(ncount,proclist, + int nreturn = comm->rendezvous(nsend,proclist, (char *) inbuf,sizeof(PairRvous), - rendezvous_trim,buf,sizeof(PairRvous), + rendezvous_pairs,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); + // flag all onefour atoms to keep + + int max = 0; + for (i = 0; i < nlocal; i++) + max = MAX(max,nspecial[i][2]); + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); + + int **flag; + memory->create(flag,nlocal,maxall,"special:flag"); + + for (i = 0; i < nlocal; i++) + for (j = 0; j < nspecial[i][2]; j++) + flag[i][j] = 0; + // reset nspecial[2] and onefour for all owned atoms based on output info - for (i = 0; i < nlocal; i++) nspecial[i][2] = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < num_dihedral[i]; j++) { + if (tag[i] != dihedral_atom2[i][j]) continue; + + m = atom->map(dihedral_atom1[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][2]; k++) + if (onefour[m][k] == dihedral_atom4[i][j]) { + flag[m][k] = 1; + break; + } + } + + m = atom->map(dihedral_atom4[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][2]; k++) + if (onefour[m][k] == dihedral_atom1[i][j]) { + flag[m][k] = 1; + break; + } + } + } + } for (m = 0; m < nreturn; m++) { i = atom->map(outbuf[m].atomID); - onefour[i][nspecial[i][2]++] = outbuf[m].partnerID; + for (k = 0; k < nspecial[i][2]; k++) + if (onefour[i][k] == outbuf[m].partnerID) { + flag[i][k] = 1; + break; + } } memory->destroy(outbuf); + // use flag values to compress onefour list for each atom + + for (i = 0; i < nlocal; i++) { + j = 0; + while (j < nspecial[i][2]) { + if (flag[i][j] == 0) { + onefour[i][j] = onefour[i][nspecial[i][2]-1]; + flag[i][j] = flag[i][nspecial[i][2]-1]; + nspecial[i][2]--; + } else j++; + } + } + + memory->destroy(flag); + // if no dihedrals are defined, delete all 1-4 neighs } else { @@ -1093,8 +1221,8 @@ void Special::dihedral_trim() /* ---------------------------------------------------------------------- process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N PairRvous datums - outbuf = empty + inbuf = list of N IDRvous datums + no outbuf ------------------------------------------------------------------------- */ int Special::rendezvous_ids(int n, char *inbuf, @@ -1109,7 +1237,6 @@ int Special::rendezvous_ids(int n, char *inbuf, memory->create(procowner,n,"special:procowner"); memory->create(atomIDs,n,"special:atomIDs"); - // NOTE: when to free these vectors IDRvous *in = (IDRvous *) inbuf; @@ -1120,13 +1247,12 @@ int Special::rendezvous_ids(int n, char *inbuf, // store rendezvous data in Special class - sptr->ncount = n; + sptr->nrvous = n; sptr->procowner = procowner; sptr->atomIDs = atomIDs; - proclist = NULL; - outbuf = NULL; - + // flag = 0: no 2nd irregular comm needed in comm->rendezvous + flag = 0; return 0; } @@ -1138,7 +1264,7 @@ int Special::rendezvous_ids(int n, char *inbuf, outbuf = same list of N PairRvous datums, routed to different procs ------------------------------------------------------------------------- */ -int Special::rendezvous_1234(int n, char *inbuf, +int Special::rendezvous_pairs(int n, char *inbuf, int &flag, int *&proclist, char *&outbuf, void *ptr) { @@ -1153,10 +1279,10 @@ int Special::rendezvous_1234(int n, char *inbuf, // hash atom IDs stored in rendezvous decomposition - int ncount = sptr->ncount; + int nrvous = sptr->nrvous; tagint *atomIDs = sptr->atomIDs; - for (int i = 0; i < ncount; i++) + for (int i = 0; i < nrvous; i++) atom->map_one(atomIDs[i],i); // proclist = owner of atomID in caller decomposition @@ -1172,7 +1298,6 @@ int Special::rendezvous_1234(int n, char *inbuf, } outbuf = inbuf; - // NOTE: set out = in flag // re-create atom map @@ -1180,148 +1305,12 @@ int Special::rendezvous_1234(int n, char *inbuf, atom->nghost = 0; atom->map_set(); + // flag = 1: outbuf = inbuf + flag = 1; return n; } -/* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N PairRvous datums - create outbuf = list of Nout PairRvous datums -------------------------------------------------------------------------- */ - -int Special::rendezvous_trim(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) -{ - int i,j,m; - - /* - Special *sptr = (Special *) ptr; - Atom *atom = sptr->atom; - Memory *memory = sptr->memory; - - // clear atom map so it can be here as a hash table - // faster than an STL map for large atom counts - - atom->map_clear(); - - // initialize hash - // ncount = number of atoms assigned to me - // key = atom ID - // value = index into Ncount-length data structure - - PairRvous *in = (PairRvous *) inbuf; - //std::map hash; - tagint id; - - int ncount = 0; - for (i = 0; i < n; i++) - if (in[i].me >= 0) - //hash[in[i].atomID] = ncount++; - atom->map_one(in[i].atomID,ncount++); - - // procowner = caller proc that owns each atom - // atomID = ID of each rendezvous atom I own - // npartner = # of 1-3 partners for each atom I own - - int *procowner,*npartner; - tagint *atomID; - memory->create(procowner,ncount,"special:procowner"); - memory->create(atomID,ncount,"special:atomID"); - memory->create(npartner,ncount,"special:npartner"); - for (m = 0; m < ncount; m++) npartner[m] = 0; - - for (i = 0; i < n; i++) { - //m = hash.find(in[i].atomID)->second; - m = atom->map(in[i].atomID); - if (in[i].me >= 0) { - procowner[m] = in[i].me; - atomID[m] = in[i].atomID; - } else if (in[i].me == -1) npartner[m]++; - } - - int max = 0; - for (m = 0; m < ncount; m++) max = MAX(max,npartner[m]); - - // partner = list of 1-3 or 1-4 partners for each atom I own - - int **partner; - memory->create(partner,ncount,max,"special:partner"); - for (m = 0; m < ncount; m++) npartner[m] = 0; - - for (i = 0; i < n; i++) { - if (in[i].me >= 0 || in[i].me == -2) continue; - //m = hash.find(in[i].atomID)->second; - m = atom->map(in[i].atomID); - partner[m][npartner[m]++] = in[i].partnerID; - } - - // flag = 1 if partner is in an actual angle or in a dihedral - - int **flag; - memory->create(flag,ncount,max,"special:flag"); - - for (i = 0; i < ncount; i++) - for (j = 0; j < npartner[i]; j++) - flag[i][j] = 0; - - tagint actual; - for (i = 0; i < n; i++) { - if (in[i].me != -2) continue; - actual = in[i].partnerID; - //m = hash.find(in[i].atomID)->second; - m = atom->map(in[i].atomID); - for (j = 0; j < npartner[m]; j++) - if (partner[m][j] == actual) { - flag[m][j] = 1; - break; - } - } - - // pass list of PairRvous datums back to comm->rendezvous - - int nout = 0; - for (m = 0; m < ncount; m++) nout += npartner[m]; - - memory->create(proclist,nout,"special:proclist"); - PairRvous *out = (PairRvous *) - memory->smalloc((bigint) nout*sizeof(PairRvous),"special:out"); - - nout = 0; - for (m = 0; m < ncount; m++) - for (j = 0; j < npartner[m]; j++) { - if (flag[m][j] == 0) continue; - proclist[nout] = procowner[m]; - out[nout].atomID = atomID[m]; - out[nout].partnerID = partner[m][j]; - nout++; - } - - outbuf = (char *) out; - - // clean up - // Comm::rendezvous will delete proclist and out (outbuf) - - memory->destroy(procowner); - memory->destroy(atomID); - memory->destroy(npartner); - memory->destroy(partner); - memory->destroy(flag); - - // re-create atom map - - atom->map_init(0); - atom->nghost = 0; - atom->map_set(); - - */ - - //return nout; - flag = 2; - return 0; -} - /* ---------------------------------------------------------------------- allow fixes to alter special list currently, only fix drude does this diff --git a/src/special.h b/src/special.h index 772ba613ac..d02a8522f6 100644 --- a/src/special.h +++ b/src/special.h @@ -31,7 +31,7 @@ class Special : protected Pointers { // data used by rendezvous callback methods - int ncount; + int nrvous; tagint *atomIDs; int *procowner; @@ -44,6 +44,8 @@ class Special : protected Pointers { tagint atomID,partnerID; }; + // private methods + void atom_owners(); void onetwo_build_newton(); void onetwo_build_newton_off(); @@ -60,8 +62,7 @@ class Special : protected Pointers { // callback functions for rendezvous communication static int rendezvous_ids(int, char *, int &, int *&, char *&, void *); - static int rendezvous_1234(int, char *, int &, int *&, char *&, void *); - static int rendezvous_trim(int, char *, int &, int *&, char *&, void *); + static int rendezvous_pairs(int, char *, int &, int *&, char *&, void *); }; } From fd8130859b9dc840af8d4b459c7de3d055be5c60 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 19 Dec 2018 17:40:35 -0700 Subject: [PATCH 06/49] fix a small memory leak in SHAKE setup --- src/RIGID/fix_shake.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 66c92d42c5..51121f0853 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -955,7 +955,7 @@ void FixShake::find_clusters() // ----------------------------------------------------- // set shake_flag,shake_atom,shake_type for non-central atoms - // requires communication for off-proc atoms + // requires rendezvous communication for off-proc atoms // ----------------------------------------------------- shake_info(npartner,partner_tag,partner_shake); @@ -964,6 +964,9 @@ void FixShake::find_clusters() // free local memory // ----------------------------------------------------- + memory->destroy(atomIDs); + memory->destroy(procowner); + memory->destroy(npartner); memory->destroy(nshake); memory->destroy(partner_tag); @@ -1390,24 +1393,24 @@ int FixShake::rendezvous_ids(int n, char *inbuf, FixShake *fsptr = (FixShake *) ptr; Memory *memory = fsptr->memory; - int *procowner; tagint *atomIDs; + int *procowner; - memory->create(procowner,n,"special:procowner"); memory->create(atomIDs,n,"special:atomIDs"); + memory->create(procowner,n,"special:procowner"); IDRvous *in = (IDRvous *) inbuf; for (int i = 0; i < n; i++) { - procowner[i] = in[i].me; atomIDs[i] = in[i].atomID; + procowner[i] = in[i].me; } // store rendezvous data in FixShake class fsptr->nrvous = n; - fsptr->procowner = procowner; fsptr->atomIDs = atomIDs; + fsptr->procowner = procowner; // flag = 0: no 2nd irregular comm needed in comm->rendezvous From 9de0262155461bcaee5132df2c0719486812d5d3 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 23 Jan 2019 14:49:52 -0700 Subject: [PATCH 07/49] added rendezvous via all2all --- src/RIGID/fix_rigid_small.cpp | 5 +- src/RIGID/fix_shake.cpp | 30 ++-- src/comm.cpp | 318 +++++++++++++++++++++++++++++++--- src/comm.h | 12 +- src/irregular.cpp | 185 +++++++++++++++++++- src/irregular.h | 2 + src/special.cpp | 119 +++++++------ 7 files changed, 566 insertions(+), 105 deletions(-) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index e20c64487b..957438fc55 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -1576,8 +1576,9 @@ void FixRigidSmall::create_bodies(tagint *bodyID) // func = compute bbox of each body, find atom closest to geometric center char *buf; - int nreturn = comm->rendezvous(ncount,proclist,(char *) inbuf,sizeof(InRvous), - rendezvous_body,buf,sizeof(OutRvous), + int nreturn = comm->rendezvous(1,ncount,(char *) inbuf,sizeof(InRvous), + 0,proclist, + rendezvous_body,0,buf,sizeof(OutRvous), (void *) this); OutRvous *outbuf = (OutRvous *) buf; diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 51121f0853..35153de839 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -1068,9 +1068,9 @@ void FixShake::atom_owners() // each proc assigned every 1/Pth atom char *buf; - comm->rendezvous(nlocal,proclist, - (char *) idbuf,sizeof(IDRvous), - rendezvous_ids,buf,0,(void *) this); + comm->rendezvous(1,nlocal,(char *) idbuf,sizeof(IDRvous), + 0,proclist, + rendezvous_ids,0,buf,0,(void *) this); memory->destroy(proclist); memory->sfree(idbuf); @@ -1174,9 +1174,10 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, // receives all data needed to populate un-owned partner 4 values char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(PartnerInfo), - rendezvous_partners_info,buf,sizeof(PartnerInfo), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PartnerInfo), + 0,proclist, + rendezvous_partners_info, + 0,buf,sizeof(PartnerInfo), (void *) this); PartnerInfo *outbuf = (PartnerInfo *) buf; @@ -1194,7 +1195,8 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, partner_type[i][j] = outbuf[m].type; partner_massflag[i][j] = outbuf[m].massflag; - // only set partner_bondtype if my atom did not set it when setting up rendezvous + // only set partner_bondtype if my atom did not set it + // when setting up rendezvous // if this proc set it, then sender of this datum set outbuf.bondtype = 0 if (partner_bondtype[i][j] == 0) @@ -1261,9 +1263,9 @@ void FixShake::nshake_info(int *npartner, tagint **partner_tag, // receives all data needed to populate un-owned partner nshake char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(NShakeInfo), - rendezvous_nshake,buf,sizeof(NShakeInfo), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(NShakeInfo), + 0,proclist, + rendezvous_nshake,0,buf,sizeof(NShakeInfo), (void *) this); NShakeInfo *outbuf = (NShakeInfo *) buf; @@ -1354,9 +1356,9 @@ void FixShake::shake_info(int *npartner, tagint **partner_tag, // receives all data needed to populate un-owned shake info char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(ShakeInfo), - rendezvous_shake,buf,sizeof(ShakeInfo), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(ShakeInfo), + 0,proclist, + rendezvous_shake,0,buf,sizeof(ShakeInfo), (void *) this); ShakeInfo *outbuf = (ShakeInfo *) buf; @@ -1412,7 +1414,7 @@ int FixShake::rendezvous_ids(int n, char *inbuf, fsptr->atomIDs = atomIDs; fsptr->procowner = procowner; - // flag = 0: no 2nd irregular comm needed in comm->rendezvous + // flag = 0: no second comm needed in rendezvous flag = 0; return 0; diff --git a/src/comm.cpp b/src/comm.cpp index 9bdaf0798a..39d4311aa2 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -729,34 +729,78 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, /* ---------------------------------------------------------------------- rendezvous communication operation three stages: - first Irregular converts inbuf from caller decomp to rvous decomp + first comm sends inbuf from caller decomp to rvous decomp callback operates on data in rendevous decomp - last Irregular converts outbuf from rvous decomp back to caller decomp + second comm sends outbuf from rvous decomp back to caller decomp inputs: - n = # of input datums - proclist = proc that owns each input datum in rendezvous decomposition - inbuf = list of input datums - insize = size in bytes of each input datum + which = perform (0) irregular or (1) MPI_All2allv communication + n = # of datums in inbuf + inbuf = vector of input datums + insize = byte size of each input datum + inorder = 0 for inbuf in random proc order, 1 for datums ordered by proc + procs: inorder 0 = proc to send each datum to, 1 = # of datums/proc, callback = caller function to invoke in rendezvous decomposition + takes input datums, returns output datums + outorder = same as inorder, but for datums returned by callback() + ptr = pointer to caller class, passed to callback() outputs: nout = # of output datums (function return) - outbuf = list of output datums - outsize = size in bytes of each output datum + outbuf = vector of output datums + outsize = byte size of each output datum + callback inputs: + nrvous = # of rvous decomp datums in inbuf_rvous + inbuf_rvous = vector of rvous decomp input datums + ptr = pointer to caller class + callback outputs: + nrvous_out = # of rvous decomp output datums (function return) + flag = 0 for no second comm, 1 for outbuf_rvous = inbuf_rvous, + 2 for second comm with new outbuf_rvous + procs_rvous = outorder 0 = proc to send each datum to, 1 = # of datums/proc + allocated + outbuf_rvous = vector of rvous decomp output datums + NOTE: could use MPI_INT or MPI_DOUBLE insead of MPI_CHAR + to avoid checked-for overflow in MPI_Alltoallv? ------------------------------------------------------------------------- */ -int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, - int (*callback)(int, char *, int &, int *&, char *&, void *), - char *&outbuf, int outsize, void *ptr) +int Comm:: +rendezvous(int which, int n, char *inbuf, int insize, + int inorder, int *procs, + int (*callback)(int, char *, int &, int *&, char *&, void *), + int outorder, char *&outbuf, int outsize, void *ptr) { - // comm inbuf from caller decomposition to rendezvous decomposition + int nout; + if (which == 0) + nout = rendezvous_irregular(n,inbuf,insize,inorder,procs,callback, + outorder,outbuf,outsize,ptr); + else + nout = rendezvous_all2all(n,inbuf,insize,inorder,procs,callback, + outorder,outbuf,outsize,ptr); + + return nout; +} + +/* ---------------------------------------------------------------------- */ + +int Comm:: +rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, + int (*callback)(int, char *, int &, int *&, char *&, void *), + int outorder, char *&outbuf, + int outsize, void *ptr) +{ + // irregular comm of inbuf from caller decomp to rendezvous decomp + Irregular *irregular = new Irregular(lmp); - int n_rvous = irregular->create_data(n,proclist); // add sort - char *inbuf_rvous = (char *) memory->smalloc((bigint) n_rvous*insize, - "rendezvous:inbuf_rvous"); + int nrvous; + if (inorder) nrvous = irregular->create_data_grouped(n,procs); + else nrvous = irregular->create_data(n,procs); + + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, + "rendezvous:inbuf"); irregular->exchange_data(inbuf,insize,inbuf_rvous); + bigint irregular1_bytes = 0; //irregular->irregular_bytes; irregular->destroy_data(); delete irregular; @@ -764,29 +808,253 @@ int Comm::rendezvous(int n, int *proclist, char *inbuf, int insize, // callback() allocates/populates proclist_rvous and outbuf_rvous int flag; - int *proclist_rvous; + int *procs_rvous; char *outbuf_rvous; - - int nout_rvous = - callback(n_rvous,inbuf_rvous,flag,proclist_rvous,outbuf_rvous,ptr); + int nrvous_out = callback(nrvous,inbuf_rvous,flag, + procs_rvous,outbuf_rvous,ptr); if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous - if (flag == 0) return 0; // all nout_rvous are 0, no 2nd irregular + if (flag == 0) return 0; // all nout_rvous are 0, no 2nd comm stage - // comm outbuf from rendezvous decomposition back to caller + // irregular comm of outbuf from rendezvous decomp back to caller decomp // caller will free outbuf irregular = new Irregular(lmp); - int nout = irregular->create_data(nout_rvous,proclist_rvous); - outbuf = (char *) memory->smalloc((bigint) nout*outsize,"rendezvous:outbuf"); + int nout; + if (outorder) + nout = irregular->create_data_grouped(nrvous_out,procs_rvous); + else nout = irregular->create_data(nrvous_out,procs_rvous); + + outbuf = (char *) memory->smalloc((bigint) nout*outsize, + "rendezvous:outbuf"); irregular->exchange_data(outbuf_rvous,outsize,outbuf); - + + bigint irregular2_bytes = 0; //irregular->irregular_bytes; irregular->destroy_data(); delete irregular; - memory->destroy(proclist_rvous); + + memory->destroy(procs_rvous); memory->sfree(outbuf_rvous); + // approximate memory tally + + bigint rvous_bytes = 0; + rvous_bytes += n*insize; // inbuf + rvous_bytes += nout*outsize; // outbuf + rvous_bytes += nrvous*insize; // inbuf_rvous + rvous_bytes += nrvous_out*outsize; // outbuf_rvous + rvous_bytes += nrvous_out*sizeof(int); // procs_rvous + rvous_bytes += MAX(irregular1_bytes,irregular2_bytes); // max of 2 comms + + // return number of output datums + + return nout; +} + +/* ---------------------------------------------------------------------- */ + +int Comm:: +rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, + int (*callback)(int, char *, int &, int *&, char *&, void *), + int outorder, char *&outbuf, int outsize, void *ptr) +{ + int iproc; + bigint all2all1_bytes,all2all2_bytes; + int *sendcount,*sdispls,*recvcount,*rdispls; + int *procs_a2a; + bigint *offsets; + char *inbuf_a2a,*outbuf_a2a; + + // create procs and inbuf for All2all if necesary + + if (!inorder) { + memory->create(procs_a2a,nprocs,"rendezvous:procs"); + inbuf_a2a = (char *) memory->smalloc((bigint) n*insize, + "rendezvous:inbuf"); + memory->create(offsets,nprocs,"rendezvous:offsets"); + + for (int i = 0; i < nprocs; i++) procs_a2a[i] = 0; + for (int i = 0; i < n; i++) procs_a2a[procs[i]]++; + + offsets[0] = 0; + for (int i = 1; i < nprocs; i++) + offsets[i] = offsets[i-1] + insize*procs_a2a[i-1]; + + bigint offset = 0; + for (int i = 0; i < n; i++) { + iproc = procs[i]; + memcpy(&inbuf_a2a[offsets[iproc]],&inbuf[offset],insize); + offsets[iproc] += insize; + offset += insize; + } + + all2all1_bytes = nprocs*sizeof(int) + nprocs*sizeof(bigint) + n*insize; + + } else { + procs_a2a = procs; + inbuf_a2a = inbuf; + all2all1_bytes = 0; + } + + // create args for MPI_Alltoallv() on input data + + memory->create(sendcount,nprocs,"rendezvous:sendcount"); + memcpy(sendcount,procs_a2a,nprocs*sizeof(int)); + + memory->create(recvcount,nprocs,"rendezvous:recvcount"); + MPI_Alltoall(sendcount,1,MPI_INT,recvcount,1,MPI_INT,world); + + memory->create(sdispls,nprocs,"rendezvous:sdispls"); + memory->create(rdispls,nprocs,"rendezvous:rdispls"); + sdispls[0] = rdispls[0] = 0; + for (int i = 1; i < nprocs; i++) { + sdispls[i] = sdispls[i-1] + sendcount[i-1]; + rdispls[i] = rdispls[i-1] + recvcount[i-1]; + } + int nrvous = rdispls[nprocs-1] + recvcount[nprocs-1]; + + // test for overflow of input data due to imbalance or insize + // means that individual sdispls or rdispls values overflow + + int overflow = 0; + if ((bigint) n*insize > MAXSMALLINT) overflow = 1; + if ((bigint) nrvous*insize > MAXSMALLINT) overflow = 1; + int overflowall; + MPI_Allreduce(&overflow,&overflowall,1,MPI_INT,MPI_MAX,world); + if (overflowall) error->all(FLERR,"Overflow input size in rendezvous_a2a"); + + for (int i = 0; i < nprocs; i++) { + sendcount[i] *= insize; + sdispls[i] *= insize; + recvcount[i] *= insize; + rdispls[i] *= insize; + } + + // all2all comm of inbuf from caller decomp to rendezvous decomp + + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, + "rendezvous:inbuf"); + + MPI_Alltoallv(inbuf_a2a,sendcount,sdispls,MPI_CHAR, + inbuf_rvous,recvcount,rdispls,MPI_CHAR,world); + + if (!inorder) { + memory->destroy(procs_a2a); + memory->sfree(inbuf_a2a); + memory->destroy(offsets); + } + + // peform rendezvous computation via callback() + // callback() allocates/populates proclist_rvous and outbuf_rvous + + int flag; + int *procs_rvous; + char *outbuf_rvous; + + int nrvous_out = callback(nrvous,inbuf_rvous,flag, + procs_rvous,outbuf_rvous,ptr); + + if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous + if (flag == 0) return 0; // all nout_rvous are 0, no 2nd irregular + + // create procs and outbuf for All2all if necesary + + if (!outorder) { + memory->create(procs_a2a,nprocs,"rendezvous_a2a:procs"); + + outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize, + "rendezvous:outbuf"); + memory->create(offsets,nprocs,"rendezvous:offsets"); + + for (int i = 0; i < nprocs; i++) procs_a2a[i] = 0; + for (int i = 0; i < nrvous_out; i++) procs_a2a[procs_rvous[i]]++; + + offsets[0] = 0; + for (int i = 1; i < nprocs; i++) + offsets[i] = offsets[i-1] + outsize*procs_a2a[i-1]; + + bigint offset = 0; + for (int i = 0; i < nrvous_out; i++) { + iproc = procs_rvous[i]; + memcpy(&outbuf_a2a[offsets[iproc]],&outbuf_rvous[offset],outsize); + offsets[iproc] += outsize; + offset += outsize; + } + + all2all2_bytes = nprocs*sizeof(int) + nprocs*sizeof(bigint) + + nrvous_out*outsize; + + } else { + procs_a2a = procs_rvous; + outbuf_a2a = outbuf_rvous; + all2all2_bytes = 0; + } + + // comm outbuf from rendezvous decomposition back to caller + + memcpy(sendcount,procs_a2a,nprocs*sizeof(int)); + + MPI_Alltoall(sendcount,1,MPI_INT,recvcount,1,MPI_INT,world); + + sdispls[0] = rdispls[0] = 0; + for (int i = 1; i < nprocs; i++) { + sdispls[i] = sdispls[i-1] + sendcount[i-1]; + rdispls[i] = rdispls[i-1] + recvcount[i-1]; + } + int nout = rdispls[nprocs-1] + recvcount[nprocs-1]; + + // test for overflow of outbuf due to imbalance or outsize + // means that individual sdispls or rdispls values overflow + + overflow = 0; + if ((bigint) nrvous*outsize > MAXSMALLINT) overflow = 1; + if ((bigint) nout*outsize > MAXSMALLINT) overflow = 1; + MPI_Allreduce(&overflow,&overflowall,1,MPI_INT,MPI_MAX,world); + if (overflowall) error->all(FLERR,"Overflow output in rendezvous_a2a"); + + for (int i = 0; i < nprocs; i++) { + sendcount[i] *= outsize; + sdispls[i] *= outsize; + recvcount[i] *= outsize; + rdispls[i] *= outsize; + } + + // all2all comm of outbuf from rendezvous decomp back to caller decomp + // caller will free outbuf + + outbuf = (char *) memory->smalloc((bigint) nout*outsize,"rendezvous:outbuf"); + + MPI_Alltoallv(outbuf_a2a,sendcount,sdispls,MPI_CHAR, + outbuf,recvcount,rdispls,MPI_CHAR,world); + + memory->destroy(procs_rvous); + memory->sfree(outbuf_rvous); + + if (!outorder) { + memory->destroy(procs_a2a); + memory->sfree(outbuf_a2a); + memory->destroy(offsets); + } + + // clean up + + memory->destroy(sendcount); + memory->destroy(recvcount); + memory->destroy(sdispls); + memory->destroy(rdispls); + + // approximate memory tally + + bigint rvous_bytes = 0; + rvous_bytes += n*insize; // inbuf + rvous_bytes += nout*outsize; // outbuf + rvous_bytes += nrvous*insize; // inbuf_rvous + rvous_bytes += nrvous_out*outsize; // outbuf_rvous + rvous_bytes += nrvous_out*sizeof(int); // procs_rvous + rvous_bytes += 4*nprocs*sizeof(int); // all2all vectors + rvous_bytes += MAX(all2all1_bytes,all2all2_bytes); // reorder ops + // return number of datums return nout; diff --git a/src/comm.h b/src/comm.h index a1bac53ac8..807da9bf0d 100644 --- a/src/comm.h +++ b/src/comm.h @@ -109,9 +109,9 @@ class Comm : protected Pointers { void ring(int, int, void *, int, void (*)(int, char *, void *), void *, void *, int self = 1); - int rendezvous(int, int *, char *, int, + int rendezvous(int, int, char *, int, int, int *, int (*)(int, char *, int &, int *&, char *&, void *), - char *&, int, void *); + int, char *&, int, void *); int read_lines_from_file(FILE *, int, int, char *); int read_lines_from_file_universe(FILE *, int, int, char *); @@ -146,6 +146,14 @@ class Comm : protected Pointers { int ncores; // # of cores per node int coregrid[3]; // 3d grid of cores within a node int user_coregrid[3]; // user request for cores in each dim + + int rendezvous_irregular(int, char *, int, int, int *, + int (*)(int, char *, int &, int *&, char *&, void *), + int, char *&, int, void *); + int rendezvous_all2all(int, char *, int, int, int *, + int (*)(int, char *, int &, int *&, char *&, void *), + int, char *&, int, void *); + public: enum{MULTIPLE}; }; diff --git a/src/irregular.cpp b/src/irregular.cpp index 60025249cf..77278ec4c5 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -622,6 +622,7 @@ int Irregular::create_data(int n, int *proclist, int sortflag) num_send = new int[nsend_proc]; index_send = new int[n-work1[me]]; index_self = new int[work1[me]]; + maxindex = n; // proc_send = procs I send to // num_send = # of datums I send to each proc @@ -679,8 +680,182 @@ int Irregular::create_data(int n, int *proclist, int sortflag) // receive incoming messages // proc_recv = procs I recv from - // num_recv = total size of message each proc sends me - // nrecvdatum = total size of data I recv + // num_recv = # of datums each proc sends me + // nrecvdatum = total # of datums I recv + + int nrecvdatum = 0; + for (i = 0; i < nrecv_proc; i++) { + MPI_Recv(&num_recv[i],1,MPI_INT,MPI_ANY_SOURCE,0,world,status); + proc_recv[i] = status->MPI_SOURCE; + nrecvdatum += num_recv[i]; + } + nrecvdatum += num_self; + + // sort proc_recv and num_recv by proc ID if requested + // useful for debugging to insure reproducible ordering of received datums + + if (sortflag) { + int *order = new int[nrecv_proc]; + int *proc_recv_ordered = new int[nrecv_proc]; + int *num_recv_ordered = new int[nrecv_proc]; + + for (i = 0; i < nrecv_proc; i++) order[i] = i; + +#if defined(LMP_QSORT) + proc_recv_copy = proc_recv; + qsort(order,nrecv_proc,sizeof(int),compare_standalone); +#else + merge_sort(order,nrecv_proc,(void *)proc_recv,compare_standalone); +#endif + + int j; + for (i = 0; i < nrecv_proc; i++) { + j = order[i]; + proc_recv_ordered[i] = proc_recv[j]; + num_recv_ordered[i] = num_recv[j]; + } + + memcpy(proc_recv,proc_recv_ordered,nrecv_proc*sizeof(int)); + memcpy(num_recv,num_recv_ordered,nrecv_proc*sizeof(int)); + delete [] order; + delete [] proc_recv_ordered; + delete [] num_recv_ordered; + } + + // barrier to insure all MPI_ANY_SOURCE messages are received + // else another proc could proceed to exchange_data() and send to me + + MPI_Barrier(world); + + // return # of datums I will receive + + return nrecvdatum; +} + +/* ---------------------------------------------------------------------- + create communication plan based on list of datums of uniform size + n = # of datums to send + procs = how many datums to send to each proc, must include self + sort = flag for sorting order of received messages by proc ID + return total # of datums I will recv, including any to self +------------------------------------------------------------------------- */ + +int Irregular::create_data_grouped(int n, int *procs, int sortflag) +{ + int i,j,k,m; + + // setup for collective comm + // work1 = # of datums I send to each proc, set self to 0 + // work2 = 1 for all procs, used for ReduceScatter + + for (i = 0; i < nprocs; i++) { + work1[i] = procs[i]; + work2[i] = 1; + } + work1[me] = 0; + + // nrecv_proc = # of procs I receive messages from, not including self + // options for performing ReduceScatter operation + // some are more efficient on some machines at big sizes + +#ifdef LAMMPS_RS_ALLREDUCE_INPLACE + MPI_Allreduce(MPI_IN_PLACE,work1,nprocs,MPI_INT,MPI_SUM,world); + nrecv_proc = work1[me]; +#else +#ifdef LAMMPS_RS_ALLREDUCE + MPI_Allreduce(work1,work2,nprocs,MPI_INT,MPI_SUM,world); + nrecv_proc = work2[me]; +#else + MPI_Reduce_scatter(work1,&nrecv_proc,work2,MPI_INT,MPI_SUM,world); +#endif +#endif + + // allocate receive arrays + + proc_recv = new int[nrecv_proc]; + num_recv = new int[nrecv_proc]; + request = new MPI_Request[nrecv_proc]; + status = new MPI_Status[nrecv_proc]; + + // work1 = # of datums I send to each proc, including self + // nsend_proc = # of procs I send messages to, not including self + + for (i = 0; i < nprocs; i++) work1[i] = procs[i]; + + nsend_proc = 0; + for (i = 0; i < nprocs; i++) + if (work1[i]) nsend_proc++; + if (work1[me]) nsend_proc--; + + // allocate send and self arrays + + proc_send = new int[nsend_proc]; + num_send = new int[nsend_proc]; + index_send = new int[n-work1[me]]; + index_self = new int[work1[me]]; + maxindex = n; + + // proc_send = procs I send to + // num_send = # of datums I send to each proc + // num_self = # of datums I copy to self + // to balance pattern of send messages: + // each proc begins with iproc > me, continues until iproc = me + // reset work1 to store which send message each proc corresponds to + + int iproc = me; + int isend = 0; + for (i = 0; i < nprocs; i++) { + iproc++; + if (iproc == nprocs) iproc = 0; + if (iproc == me) { + num_self = work1[iproc]; + work1[iproc] = 0; + } else if (work1[iproc] > 0) { + proc_send[isend] = iproc; + num_send[isend] = work1[iproc]; + work1[iproc] = isend; + isend++; + } + } + + // work2 = offsets into index_send for each proc I send to + // m = ptr into index_self + // index_send = list of which datums to send to each proc + // 1st N1 values are datum indices for 1st proc, + // next N2 values are datum indices for 2nd proc, etc + // index_self = list of which datums to copy to self + + work2[0] = 0; + for (i = 1; i < nsend_proc; i++) work2[i] = work2[i-1] + num_send[i-1]; + + m = 0; + i = 0; + for (iproc = 0; iproc < nprocs; iproc++) { + k = procs[iproc]; + for (j = 0; j < k; j++) { + if (iproc == me) index_self[m++] = i++; + else { + isend = work1[iproc]; + index_send[work2[isend]++] = i++; + } + } + } + + // tell receivers how much data I send + // sendmax_proc = largest # of datums I send in a single message + + sendmax_proc = 0; + for (i = 0; i < nsend_proc; i++) { + MPI_Request tmpReq; // Use non-blocking send to avoid possible deadlock + MPI_Isend(&num_send[i],1,MPI_INT,proc_send[i],0,world,&tmpReq); + MPI_Request_free(&tmpReq); // the MPI_Barrier below marks completion + sendmax_proc = MAX(sendmax_proc,num_send[i]); + } + + // receive incoming messages + // proc_recv = procs I recv from + // num_recv = # of datums each proc sends me + // nrecvdatum = total # of datums I recv int nrecvdatum = 0; for (i = 0; i < nrecv_proc; i++) { @@ -789,6 +964,12 @@ void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf) // wait on all incoming messages if (nrecv_proc) MPI_Waitall(nrecv_proc,request,status); + + // approximate memory tally + + bigint irregular_bytes = 2*nprocs*sizeof(int); + irregular_bytes += maxindex*sizeof(int); + irregular_bytes += maxbuf; } /* ---------------------------------------------------------------------- diff --git a/src/irregular.h b/src/irregular.h index 1f74fe801b..d56bcb253d 100644 --- a/src/irregular.h +++ b/src/irregular.h @@ -33,6 +33,7 @@ class Irregular : protected Pointers { int *procassign = NULL); int migrate_check(); int create_data(int, int *, int sortflag = 0); + int create_data_grouped(int, int *, int sortflag = 0); void exchange_data(char *, int, char *); void destroy_data(); bigint memory_usage(); @@ -48,6 +49,7 @@ class Irregular : protected Pointers { double *dbuf; // double buf for largest single atom send int maxbuf; // size of char buf in bytes char *buf; // char buf for largest single data send + int maxindex; // combined size of index_send + index_self int *mproclist,*msizes; // persistent vectors in migrate_atoms int maxlocal; // allocated size of mproclist and msizes diff --git a/src/special.cpp b/src/special.cpp index b0d5bc7dca..34685d8c65 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -172,10 +172,9 @@ void Special::atom_owners() IDRvous *idbuf = (IDRvous *) memory->smalloc((bigint) nlocal*sizeof(IDRvous),"special:idbuf"); - // setup input buf to rendezvous comm - // input datums = pairs of bonded atoms - // owning proc for each datum = random hash of atomID + // setup input buf for rendezvous comm // one datum for each owned atom: datum = owning proc, atomID + // each proc assigned every 1/Pth atom for (int i = 0; i < nlocal; i++) { proclist[i] = tag[i] % nprocs; @@ -184,19 +183,18 @@ void Special::atom_owners() } // perform rendezvous operation - // each proc assigned every 1/Pth atom char *buf; - comm->rendezvous(nlocal,proclist, - (char *) idbuf,sizeof(IDRvous), - rendezvous_ids,buf,0,(void *) this); + comm->rendezvous(1,nlocal,(char *) idbuf,sizeof(IDRvous),0,proclist, + rendezvous_ids,0,buf,0,(void *) this); memory->destroy(proclist); memory->sfree(idbuf); } /* ---------------------------------------------------------------------- - onetwo build + onetwo build when newton_bond flag on + uses rendezvous comm ------------------------------------------------------------------------- */ void Special::onetwo_build_newton() @@ -225,9 +223,8 @@ void Special::onetwo_build_newton() memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm - // input datums = pairs of bonded atoms - // owning proc for each datum = atomID % nprocs - // one datum for each bond partner: bond partner ID, atomID + // one datum for each unowned bond partner: bond partner ID, atomID + // owning proc for each datum = bond partner ID % nprocs nsend = 0; for (i = 0; i < nlocal; i++) { @@ -242,19 +239,19 @@ void Special::onetwo_build_newton() } // perform rendezvous operation - // each proc owns random subset of atoms char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(PairRvous), - rendezvous_pairs,buf,sizeof(PairRvous), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + 0,proclist, + rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); - // set nspecial[0] and onetwo for all owned atoms based on output info + // set nspecial[0] and onetwo for all owned atoms + // based on owned info plus rendezvous output info // output datums = pairs of atoms that are 1-2 neighbors for (i = 0; i < nlocal; i++) { @@ -327,8 +324,8 @@ void Special::onetwo_build_newton_off() } /* ---------------------------------------------------------------------- - onetwo build with newton_bond flag off - no need for rendezvous comm + onethree build + uses rendezvous comm ------------------------------------------------------------------------- */ void Special::onethree_build() @@ -355,10 +352,10 @@ void Special::onethree_build() memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm - // input datums = all pairs of onetwo atoms (they are 1-3 neighbors) - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - // one datum for each onetwo pair: datum = atomID1, atomID2 + // datums = pairs of onetwo partners where either is unknown + // these pairs are onethree neighbors + // datum = onetwo ID, onetwo ID + // owning proc for each datum = onetwo ID % nprocs nsend = 0; for (i = 0; i < nlocal; i++) { @@ -377,20 +374,19 @@ void Special::onethree_build() } // perform rendezvous operation - // each proc owns random subset of atoms - // receives all info to form and return their onethree lists char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(PairRvous), - rendezvous_pairs,buf,sizeof(PairRvous), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + 0,proclist, + rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); - // set nspecial[1] and onethree for all owned atoms based on output info + // set nspecial[1] and onethree for all owned atoms + // based on owned info plus rendezvous output info // output datums = pairs of atoms that are 1-3 neighbors for (i = 0; i < nlocal; i++) { @@ -434,7 +430,8 @@ void Special::onethree_build() } /* ---------------------------------------------------------------------- - remove duplicates within each of onetwo, onethree, onefour individually + onefour build + uses rendezvous comm ------------------------------------------------------------------------- */ void Special::onefour_build() @@ -446,7 +443,6 @@ void Special::onefour_build() int nlocal = atom->nlocal; // nsend = # of my datums to send - // include nlocal datums with owner of each atom int nsend = 0; for (i = 0; i < nlocal; i++) { @@ -462,10 +458,10 @@ void Special::onefour_build() memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm - // input datums = all pairs of onethree and onetwo atoms (they're 1-4 neighbors) - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - // one datum for each onethree/onetwo pair: datum = atomID1, atomID2 + // datums = pairs of onethree and onetwo partners where onethree is unknown + // these pairs are onefour neighbors + // datum = onetwo ID, onetwo ID + // owning proc for each datum = onethree ID % nprocs nsend = 0; for (i = 0; i < nlocal; i++) { @@ -483,20 +479,19 @@ void Special::onefour_build() } // perform rendezvous operation - // each proc owns random subset of atoms - // receives all info to form and return their onefour lists char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(PairRvous), - rendezvous_pairs,buf,sizeof(PairRvous), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + 0,proclist, + rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); - // set nspecial[2] and onefour for all owned atoms based on output info + // set nspecial[2] and onefour for all owned atoms + // based on owned info plus rendezvous output info // output datums = pairs of atoms that are 1-4 neighbors for (i = 0; i < nlocal; i++) { @@ -780,6 +775,7 @@ void Special::combine() trim list of 1-3 neighbors by checking defined angles delete a 1-3 neigh if they are not end atoms of a defined angle and if they are not 1,3 or 2,4 atoms of a defined dihedral + uses rendezvous comm ------------------------------------------------------------------------- */ void Special::angle_trim() @@ -849,6 +845,10 @@ void Special::angle_trim() memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm + // datums = pairs of onetwo partners where either is unknown + // these pairs are onethree neighbors + // datum = onetwo ID, onetwo ID + // owning proc for each datum = onetwo ID % nprocs nsend = 0; for (i = 0; i < nlocal; i++) { @@ -902,14 +902,11 @@ void Special::angle_trim() } // perform rendezvous operation - // each proc owns random subset of atoms - // func = compute bbox of each body, flag atom closest to geometric center - // when done: each atom has atom ID of owning atom of its body char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(PairRvous), - rendezvous_pairs,buf,sizeof(PairRvous), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + 0,proclist, + rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; @@ -931,6 +928,8 @@ void Special::angle_trim() flag[i][j] = 0; // reset nspecial[1] and onethree for all owned atoms based on output info + // based on owned info plus rendezvous output info + // output datums = pairs of atoms that are 1-3 neighbors for (i = 0; i < nlocal; i++) { for (j = 0; j < num_angle[i]; j++) { @@ -1036,8 +1035,9 @@ void Special::angle_trim() } /* ---------------------------------------------------------------------- - trim list of 1-4 neighbors by checking defined dihedrals + trim list of 1-4 neighbors by checking all defined dihedrals delete a 1-4 neigh if they are not end atoms of a defined dihedral + uses rendezvous comm ------------------------------------------------------------------------- */ void Special::dihedral_trim() @@ -1068,12 +1068,11 @@ void Special::dihedral_trim() " %g = # of 1-4 neighbors before dihedral trim\n",allcount); } - // if dihedrals are defined, rendezvous dihedral 1-4 pairs + // if dihedrals are defined, rendezvous the dihedral 1-4 pairs if (num_dihedral && atom->ndihedrals) { // nsend = # of my datums to send - // latter is only for dihedrals where I own atom2 (newton bond off) int nsend = 0; for (i = 0; i < nlocal; i++) { @@ -1092,6 +1091,11 @@ void Special::dihedral_trim() memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); // setup input buf to rendezvous comm + // datums = pairs of onefour atom IDs in a dihedral defined for my atoms + // only dihedrals where I own atom2 (in case newton_bond off) + // datum = atom1 ID and atom4 ID + // send the datum twice, to owner of atom1 ID and atom4 ID + // owning procs for each datum = atom1 or atom4 ID % nprocs nsend = 0; for (i = 0; i < nlocal; i++) { @@ -1117,21 +1121,18 @@ void Special::dihedral_trim() } // perform rendezvous operation - // each proc owns random subset of atoms - // func = compute bbox of each body, flag atom closest to geometric center - // when done: each atom has atom ID of owning atom of its body char *buf; - int nreturn = comm->rendezvous(nsend,proclist, - (char *) inbuf,sizeof(PairRvous), - rendezvous_pairs,buf,sizeof(PairRvous), + int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + 0,proclist, + rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); memory->sfree(inbuf); - // flag all onefour atoms to keep + // flag all of my onefour IDs to keep int max = 0; for (i = 0; i < nlocal; i++) @@ -1145,8 +1146,6 @@ void Special::dihedral_trim() for (j = 0; j < nspecial[i][2]; j++) flag[i][j] = 0; - // reset nspecial[2] and onefour for all owned atoms based on output info - for (i = 0; i < nlocal; i++) { for (j = 0; j < num_dihedral[i]; j++) { if (tag[i] != dihedral_atom2[i][j]) continue; @@ -1251,7 +1250,7 @@ int Special::rendezvous_ids(int n, char *inbuf, sptr->procowner = procowner; sptr->atomIDs = atomIDs; - // flag = 0: no 2nd irregular comm needed in comm->rendezvous + // flag = 0: no second comm needed in rendezvous flag = 0; return 0; @@ -1272,7 +1271,7 @@ int Special::rendezvous_pairs(int n, char *inbuf, Atom *atom = sptr->atom; Memory *memory = sptr->memory; - // clear atom map so it can be here as a hash table + // clear atom map so it can be used here as a hash table // faster than an STL map for large atom counts atom->map_clear(); From 4ce68cf5fd776bd52a07befb93de7f197be49b69 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 23 Jan 2019 16:01:10 -0700 Subject: [PATCH 08/49] added diagnostic info for memory and balance info --- src/RIGID/fix_shake.cpp | 8 +- src/comm.cpp | 185 ++++++++++++++++++++++++++++++++++++---- src/comm.h | 6 +- src/irregular.cpp | 7 +- src/special.cpp | 12 +-- 5 files changed, 184 insertions(+), 34 deletions(-) diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 35153de839..46e478064c 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -1070,7 +1070,7 @@ void FixShake::atom_owners() char *buf; comm->rendezvous(1,nlocal,(char *) idbuf,sizeof(IDRvous), 0,proclist, - rendezvous_ids,0,buf,0,(void *) this); + rendezvous_ids,0,buf,0,(void *) this,1); memory->destroy(proclist); memory->sfree(idbuf); @@ -1178,7 +1178,7 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, 0,proclist, rendezvous_partners_info, 0,buf,sizeof(PartnerInfo), - (void *) this); + (void *) this,1); PartnerInfo *outbuf = (PartnerInfo *) buf; memory->destroy(proclist); @@ -1266,7 +1266,7 @@ void FixShake::nshake_info(int *npartner, tagint **partner_tag, int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(NShakeInfo), 0,proclist, rendezvous_nshake,0,buf,sizeof(NShakeInfo), - (void *) this); + (void *) this,1); NShakeInfo *outbuf = (NShakeInfo *) buf; memory->destroy(proclist); @@ -1359,7 +1359,7 @@ void FixShake::shake_info(int *npartner, tagint **partner_tag, int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(ShakeInfo), 0,proclist, rendezvous_shake,0,buf,sizeof(ShakeInfo), - (void *) this); + (void *) this,1); ShakeInfo *outbuf = (ShakeInfo *) buf; memory->destroy(proclist); diff --git a/src/comm.cpp b/src/comm.cpp index 39d4311aa2..54476078be 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -766,18 +766,14 @@ int Comm:: rendezvous(int which, int n, char *inbuf, int insize, int inorder, int *procs, int (*callback)(int, char *, int &, int *&, char *&, void *), - int outorder, char *&outbuf, int outsize, void *ptr) + int outorder, char *&outbuf, int outsize, void *ptr, int statflag) { - int nout; - if (which == 0) - nout = rendezvous_irregular(n,inbuf,insize,inorder,procs,callback, - outorder,outbuf,outsize,ptr); + return rendezvous_irregular(n,inbuf,insize,inorder,procs,callback, + outorder,outbuf,outsize,ptr,statflag); else - nout = rendezvous_all2all(n,inbuf,insize,inorder,procs,callback, - outorder,outbuf,outsize,ptr); - - return nout; + return rendezvous_all2all(n,inbuf,insize,inorder,procs,callback, + outorder,outbuf,outsize,ptr,statflag); } /* ---------------------------------------------------------------------- */ @@ -786,7 +782,7 @@ int Comm:: rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, int (*callback)(int, char *, int &, int *&, char *&, void *), int outorder, char *&outbuf, - int outsize, void *ptr) + int outsize, void *ptr, int statflag) { // irregular comm of inbuf from caller decomp to rendezvous decomp @@ -837,8 +833,82 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, memory->destroy(procs_rvous); memory->sfree(outbuf_rvous); - // approximate memory tally + // return number of output datums + if (!statflag) return nout; + + // memory info for caller and rendezvous decompositions + + bigint size_in_all,size_in_max,size_in_min; + bigint size_out_all,size_out_max,size_out_min; + bigint size_inrvous_all,size_inrvous_max,size_inrvous_min; + bigint size_outrvous_all,size_outrvous_max,size_outrvous_min; + + bigint size = (bigint) n*insize; + MPI_Allreduce(&size,&size_in_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_in_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_in_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + size = (bigint) nout*outsize; + MPI_Allreduce(&size,&size_out_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_out_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_out_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + size = (bigint) nrvous*insize; + MPI_Allreduce(&size,&size_inrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_inrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_inrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + size = (bigint) nrvous_out*insize; + MPI_Allreduce(&size,&size_outrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_outrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_outrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + int mbytes = 1024*1024; + + if (me == 0) { + if (screen) { + fprintf(screen,"Rendezvous balance and memory info:\n"); + fprintf(screen," input datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_in_all/insize,1.0*size_in_all/nprocs/insize, + size_in_max/insize,size_in_min/insize); + fprintf(screen," input data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_in_all/mbytes,1.0*size_in_all/nprocs/mbytes, + 1.0*size_in_max/mbytes,1.0*size_in_min/mbytes); + fprintf(screen," output datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_out_all/outsize,1.0*size_out_all/nprocs/outsize, + size_out_max/outsize,size_out_min/outsize); + fprintf(screen," output data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_out_all/mbytes,1.0*size_out_all/nprocs/mbytes, + 1.0*size_out_max/mbytes,1.0*size_out_min/mbytes); + fprintf(screen," input rvous datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_inrvous_all/insize,1.0*size_inrvous_all/nprocs/insize, + size_inrvous_max/insize,size_inrvous_min/insize); + fprintf(screen," input rvous data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_inrvous_all/mbytes,1.0*size_inrvous_all/nprocs/mbytes, + 1.0*size_inrvous_max/mbytes,1.0*size_inrvous_min/mbytes); + fprintf(screen," output rvous datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, + size_outrvous_max/outsize,size_outrvous_min/outsize); + fprintf(screen," output rvous data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_outrvous_all/mbytes,1.0*size_outrvous_all/nprocs/mbytes, + 1.0*size_outrvous_max/mbytes,1.0*size_outrvous_min/mbytes); + } + } + + /* bigint rvous_bytes = 0; rvous_bytes += n*insize; // inbuf rvous_bytes += nout*outsize; // outbuf @@ -846,8 +916,7 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, rvous_bytes += nrvous_out*outsize; // outbuf_rvous rvous_bytes += nrvous_out*sizeof(int); // procs_rvous rvous_bytes += MAX(irregular1_bytes,irregular2_bytes); // max of 2 comms - - // return number of output datums + */ return nout; } @@ -857,7 +926,8 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, int Comm:: rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, int (*callback)(int, char *, int &, int *&, char *&, void *), - int outorder, char *&outbuf, int outsize, void *ptr) + int outorder, char *&outbuf, int outsize, void *ptr, + int statflag) { int iproc; bigint all2all1_bytes,all2all2_bytes; @@ -956,7 +1026,13 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, procs_rvous,outbuf_rvous,ptr); if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous - if (flag == 0) return 0; // all nout_rvous are 0, no 2nd irregular + if (flag == 0) { + memory->destroy(sendcount); + memory->destroy(recvcount); + memory->destroy(sdispls); + memory->destroy(rdispls); + return 0; // all nout_rvous are 0, no 2nd irregular + } // create procs and outbuf for All2all if necesary @@ -1044,8 +1120,82 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, memory->destroy(sdispls); memory->destroy(rdispls); - // approximate memory tally + // return number of output datums + if (!statflag) return nout; + + // memory info for caller and rendezvous decompositions + + bigint size_in_all,size_in_max,size_in_min; + bigint size_out_all,size_out_max,size_out_min; + bigint size_inrvous_all,size_inrvous_max,size_inrvous_min; + bigint size_outrvous_all,size_outrvous_max,size_outrvous_min; + + bigint size = (bigint) n*insize; + MPI_Allreduce(&size,&size_in_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_in_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_in_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + size = (bigint) nout*outsize; + MPI_Allreduce(&size,&size_out_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_out_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_out_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + size = (bigint) nrvous*insize; + MPI_Allreduce(&size,&size_inrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_inrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_inrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + size = (bigint) nrvous_out*insize; + MPI_Allreduce(&size,&size_outrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_outrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_outrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + + int mbytes = 1024*1024; + + if (me == 0) { + if (screen) { + fprintf(screen,"Rendezvous balance and memory info:\n"); + fprintf(screen," input datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_in_all/insize,1.0*size_in_all/nprocs/insize, + size_in_max/insize,size_in_min/insize); + fprintf(screen," input data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_in_all/mbytes,1.0*size_in_all/nprocs/mbytes, + 1.0*size_in_max/mbytes,1.0*size_in_min/mbytes); + fprintf(screen," output datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_out_all/outsize,1.0*size_out_all/nprocs/outsize, + size_out_max/outsize,size_out_min/outsize); + fprintf(screen," output data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_out_all/mbytes,1.0*size_out_all/nprocs/mbytes, + 1.0*size_out_max/mbytes,1.0*size_out_min/mbytes); + fprintf(screen," input rvous datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_inrvous_all/insize,1.0*size_inrvous_all/nprocs/insize, + size_inrvous_max/insize,size_inrvous_min/insize); + fprintf(screen," input rvous data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_inrvous_all/mbytes,1.0*size_inrvous_all/nprocs/mbytes, + 1.0*size_inrvous_max/mbytes,1.0*size_inrvous_min/mbytes); + fprintf(screen," output rvous datum count " + "(tot,ave,max,min): " BIGINT_FORMAT " %g " + BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, + size_outrvous_max/outsize,size_outrvous_min/outsize); + fprintf(screen," output rvous data (MB) " + "(tot,ave,max,min): %g %g %g %g\n", + 1.0*size_outrvous_all/mbytes,1.0*size_outrvous_all/nprocs/mbytes, + 1.0*size_outrvous_max/mbytes,1.0*size_outrvous_min/mbytes); + } + } + + /* bigint rvous_bytes = 0; rvous_bytes += n*insize; // inbuf rvous_bytes += nout*outsize; // outbuf @@ -1054,8 +1204,7 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, rvous_bytes += nrvous_out*sizeof(int); // procs_rvous rvous_bytes += 4*nprocs*sizeof(int); // all2all vectors rvous_bytes += MAX(all2all1_bytes,all2all2_bytes); // reorder ops - - // return number of datums + */ return nout; } diff --git a/src/comm.h b/src/comm.h index 807da9bf0d..89889e3ebe 100644 --- a/src/comm.h +++ b/src/comm.h @@ -111,7 +111,7 @@ class Comm : protected Pointers { void *, void *, int self = 1); int rendezvous(int, int, char *, int, int, int *, int (*)(int, char *, int &, int *&, char *&, void *), - int, char *&, int, void *); + int, char *&, int, void *, int statflag=0); int read_lines_from_file(FILE *, int, int, char *); int read_lines_from_file_universe(FILE *, int, int, char *); @@ -149,10 +149,10 @@ class Comm : protected Pointers { int rendezvous_irregular(int, char *, int, int, int *, int (*)(int, char *, int &, int *&, char *&, void *), - int, char *&, int, void *); + int, char *&, int, void *, int); int rendezvous_all2all(int, char *, int, int, int *, int (*)(int, char *, int &, int *&, char *&, void *), - int, char *&, int, void *); + int, char *&, int, void *, int); public: enum{MULTIPLE}; diff --git a/src/irregular.cpp b/src/irregular.cpp index 77278ec4c5..c27a8c8e18 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -966,10 +966,11 @@ void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf) if (nrecv_proc) MPI_Waitall(nrecv_proc,request,status); // approximate memory tally + // DEBUG lines - bigint irregular_bytes = 2*nprocs*sizeof(int); - irregular_bytes += maxindex*sizeof(int); - irregular_bytes += maxbuf; + //bigint irregular_bytes = 2*nprocs*sizeof(int); + //irregular_bytes += maxindex*sizeof(int); + //irregular_bytes += maxbuf; } /* ---------------------------------------------------------------------- diff --git a/src/special.cpp b/src/special.cpp index 34685d8c65..5e0f865488 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -186,7 +186,7 @@ void Special::atom_owners() char *buf; comm->rendezvous(1,nlocal,(char *) idbuf,sizeof(IDRvous),0,proclist, - rendezvous_ids,0,buf,0,(void *) this); + rendezvous_ids,0,buf,0,(void *) this,1); memory->destroy(proclist); memory->sfree(idbuf); @@ -244,7 +244,7 @@ void Special::onetwo_build_newton() int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); + (void *) this,1); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -379,7 +379,7 @@ void Special::onethree_build() int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); + (void *) this,1); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -484,7 +484,7 @@ void Special::onefour_build() int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); + (void *) this,1); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -907,7 +907,7 @@ void Special::angle_trim() int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); + (void *) this,1); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -1126,7 +1126,7 @@ void Special::dihedral_trim() int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); + (void *) this,1); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); From a278df586d72850c71a318b550d8f3f9de69e5f0 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 24 Jan 2019 09:56:21 -0700 Subject: [PATCH 09/49] cleanup up rendezvous diagnostic output --- src/RIGID/fix_rigid_small.cpp | 19 +++- src/RIGID/fix_shake.cpp | 10 ++- src/comm.cpp | 163 +++++++++------------------------- src/comm.h | 1 + src/special.cpp | 14 +-- 5 files changed, 73 insertions(+), 134 deletions(-) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 957438fc55..bee5570316 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -28,6 +28,7 @@ #include "modify.h" #include "group.h" #include "comm.h" +#include "neighbor.h" #include "force.h" #include "input.h" #include "output.h" @@ -44,6 +45,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; +#define RVOUS 1 // 0 for irregular, 1 for all2all + #define MAXLINE 1024 #define CHUNK 1024 #define ATTRIBUTE_PERBODY 20 @@ -585,12 +588,22 @@ void FixRigidSmall::init() if (rflag && (modify->fmask[i] & POST_FORCE) && !modify->fix[i]->rigid_flag) { char str[128]; - snprintf(str,128,"Fix %s alters forces after fix rigid",modify->fix[i]->id); + snprintf(str,128,"Fix %s alters forces after fix rigid", + modify->fix[i]->id); error->warning(FLERR,str); } } } + // error if maxextent > comm->cutghost + // NOTE: could just warn if an override flag set + // NOTE: this could fail for comm multi mode if user sets a wrong cutoff + // for atom types in rigid bodies - need a more careful test + + double cutghost = MAX(neighbor->cutneighmax,comm->cutghostuser); + if (maxextent > cutghost) + error->all(FLERR,"Rigid body extent > ghost cutoff - use comm_modify cutoff"); + // error if npt,nph fix comes before rigid fix for (i = 0; i < modify->nfix; i++) { @@ -1576,10 +1589,10 @@ void FixRigidSmall::create_bodies(tagint *bodyID) // func = compute bbox of each body, find atom closest to geometric center char *buf; - int nreturn = comm->rendezvous(1,ncount,(char *) inbuf,sizeof(InRvous), + int nreturn = comm->rendezvous(RVOUS,ncount,(char *) inbuf,sizeof(InRvous), 0,proclist, rendezvous_body,0,buf,sizeof(OutRvous), - (void *) this); + (void *) this,1); OutRvous *outbuf = (OutRvous *) buf; memory->destroy(proclist); diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 46e478064c..2d3244885d 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -39,6 +39,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; +#define RVOUS 1 // 0 for irregular, 1 for all2all + #define BIG 1.0e20 #define MASSDELTA 0.1 @@ -1068,7 +1070,7 @@ void FixShake::atom_owners() // each proc assigned every 1/Pth atom char *buf; - comm->rendezvous(1,nlocal,(char *) idbuf,sizeof(IDRvous), + comm->rendezvous(RVOUS,nlocal,(char *) idbuf,sizeof(IDRvous), 0,proclist, rendezvous_ids,0,buf,0,(void *) this,1); @@ -1174,7 +1176,7 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, // receives all data needed to populate un-owned partner 4 values char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PartnerInfo), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PartnerInfo), 0,proclist, rendezvous_partners_info, 0,buf,sizeof(PartnerInfo), @@ -1263,7 +1265,7 @@ void FixShake::nshake_info(int *npartner, tagint **partner_tag, // receives all data needed to populate un-owned partner nshake char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(NShakeInfo), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(NShakeInfo), 0,proclist, rendezvous_nshake,0,buf,sizeof(NShakeInfo), (void *) this,1); @@ -1356,7 +1358,7 @@ void FixShake::shake_info(int *npartner, tagint **partner_tag, // receives all data needed to populate un-owned shake info char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(ShakeInfo), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(ShakeInfo), 0,proclist, rendezvous_shake,0,buf,sizeof(ShakeInfo), (void *) this,1); diff --git a/src/comm.cpp b/src/comm.cpp index 54476078be..e8a796036c 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -796,7 +796,7 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, "rendezvous:inbuf"); irregular->exchange_data(inbuf,insize,inbuf_rvous); - bigint irregular1_bytes = 0; //irregular->irregular_bytes; + bigint irregular1_bytes = irregular->memory_usage(); irregular->destroy_data(); delete irregular; @@ -826,7 +826,7 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, "rendezvous:outbuf"); irregular->exchange_data(outbuf_rvous,outsize,outbuf); - bigint irregular2_bytes = 0; //irregular->irregular_bytes; + bigint irregular2_bytes = irregular->memory_usage(); irregular->destroy_data(); delete irregular; @@ -834,90 +834,11 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, memory->sfree(outbuf_rvous); // return number of output datums + // last arg to stats() = memory for procs_rvous + irregular comm - if (!statflag) return nout; - - // memory info for caller and rendezvous decompositions - - bigint size_in_all,size_in_max,size_in_min; - bigint size_out_all,size_out_max,size_out_min; - bigint size_inrvous_all,size_inrvous_max,size_inrvous_min; - bigint size_outrvous_all,size_outrvous_max,size_outrvous_min; - - bigint size = (bigint) n*insize; - MPI_Allreduce(&size,&size_in_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_in_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_in_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = (bigint) nout*outsize; - MPI_Allreduce(&size,&size_out_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_out_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_out_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = (bigint) nrvous*insize; - MPI_Allreduce(&size,&size_inrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_inrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_inrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = (bigint) nrvous_out*insize; - MPI_Allreduce(&size,&size_outrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_outrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_outrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - int mbytes = 1024*1024; - - if (me == 0) { - if (screen) { - fprintf(screen,"Rendezvous balance and memory info:\n"); - fprintf(screen," input datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_in_all/insize,1.0*size_in_all/nprocs/insize, - size_in_max/insize,size_in_min/insize); - fprintf(screen," input data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", - 1.0*size_in_all/mbytes,1.0*size_in_all/nprocs/mbytes, - 1.0*size_in_max/mbytes,1.0*size_in_min/mbytes); - fprintf(screen," output datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_out_all/outsize,1.0*size_out_all/nprocs/outsize, - size_out_max/outsize,size_out_min/outsize); - fprintf(screen," output data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", - 1.0*size_out_all/mbytes,1.0*size_out_all/nprocs/mbytes, - 1.0*size_out_max/mbytes,1.0*size_out_min/mbytes); - fprintf(screen," input rvous datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_inrvous_all/insize,1.0*size_inrvous_all/nprocs/insize, - size_inrvous_max/insize,size_inrvous_min/insize); - fprintf(screen," input rvous data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", - 1.0*size_inrvous_all/mbytes,1.0*size_inrvous_all/nprocs/mbytes, - 1.0*size_inrvous_max/mbytes,1.0*size_inrvous_min/mbytes); - fprintf(screen," output rvous datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, - size_outrvous_max/outsize,size_outrvous_min/outsize); - fprintf(screen," output rvous data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", - 1.0*size_outrvous_all/mbytes,1.0*size_outrvous_all/nprocs/mbytes, - 1.0*size_outrvous_max/mbytes,1.0*size_outrvous_min/mbytes); - } - } - - /* - bigint rvous_bytes = 0; - rvous_bytes += n*insize; // inbuf - rvous_bytes += nout*outsize; // outbuf - rvous_bytes += nrvous*insize; // inbuf_rvous - rvous_bytes += nrvous_out*outsize; // outbuf_rvous - rvous_bytes += nrvous_out*sizeof(int); // procs_rvous - rvous_bytes += MAX(irregular1_bytes,irregular2_bytes); // max of 2 comms - */ - + if (statflag) rendezvous_stats(n,nout,nrvous,nrvous_out,insize,outsize, + (bigint) nrvous_out*sizeof(int) + + MAX(irregular1_bytes,irregular2_bytes)); return nout; } @@ -1121,15 +1042,28 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, memory->destroy(rdispls); // return number of output datums + // last arg to stats() = mem for procs_rvous + per-proc vecs + reordering ops - if (!statflag) return nout; + if (statflag) rendezvous_stats(n,nout,nrvous,nrvous_out,insize,outsize, + (bigint) nrvous_out*sizeof(int) + + 4*nprocs*sizeof(int) + + MAX(all2all1_bytes,all2all2_bytes)); + return nout; +} - // memory info for caller and rendezvous decompositions +/* ---------------------------------------------------------------------- + print balance and memory info for rendezvous operation + useful for debugging +------------------------------------------------------------------------- */ +void Comm::rendezvous_stats(int n, int nout, int nrvous, int nrvous_out, + int insize, int outsize, bigint commsize) +{ bigint size_in_all,size_in_max,size_in_min; bigint size_out_all,size_out_max,size_out_min; bigint size_inrvous_all,size_inrvous_max,size_inrvous_min; bigint size_outrvous_all,size_outrvous_max,size_outrvous_min; + bigint size_comm_all,size_comm_max,size_comm_min; bigint size = (bigint) n*insize; MPI_Allreduce(&size,&size_in_all,1,MPI_LMP_BIGINT,MPI_SUM,world); @@ -1151,62 +1085,49 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, MPI_Allreduce(&size,&size_outrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); MPI_Allreduce(&size,&size_outrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + size = commsize; + MPI_Allreduce(&size,&size_comm_all,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&size,&size_comm_max,1,MPI_LMP_BIGINT,MPI_MAX,world); + MPI_Allreduce(&size,&size_comm_min,1,MPI_LMP_BIGINT,MPI_MIN,world); + int mbytes = 1024*1024; if (me == 0) { if (screen) { - fprintf(screen,"Rendezvous balance and memory info:\n"); - fprintf(screen," input datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", + fprintf(screen,"Rendezvous balance and memory info: (tot,ave,max,min) \n"); + fprintf(screen," input datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", size_in_all/insize,1.0*size_in_all/nprocs/insize, size_in_max/insize,size_in_min/insize); - fprintf(screen," input data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", + fprintf(screen," input data (MB): %g %g %g %g\n", 1.0*size_in_all/mbytes,1.0*size_in_all/nprocs/mbytes, 1.0*size_in_max/mbytes,1.0*size_in_min/mbytes); - fprintf(screen," output datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", + fprintf(screen," output datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", size_out_all/outsize,1.0*size_out_all/nprocs/outsize, size_out_max/outsize,size_out_min/outsize); - fprintf(screen," output data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", + fprintf(screen," output data (MB): %g %g %g %g\n", 1.0*size_out_all/mbytes,1.0*size_out_all/nprocs/mbytes, 1.0*size_out_max/mbytes,1.0*size_out_min/mbytes); - fprintf(screen," input rvous datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", + fprintf(screen," input rvous datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", size_inrvous_all/insize,1.0*size_inrvous_all/nprocs/insize, size_inrvous_max/insize,size_inrvous_min/insize); - fprintf(screen," input rvous data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", + fprintf(screen," input rvous data (MB): %g %g %g %g\n", 1.0*size_inrvous_all/mbytes,1.0*size_inrvous_all/nprocs/mbytes, 1.0*size_inrvous_max/mbytes,1.0*size_inrvous_min/mbytes); - fprintf(screen," output rvous datum count " - "(tot,ave,max,min): " BIGINT_FORMAT " %g " - BIGINT_FORMAT " " BIGINT_FORMAT "\n", + fprintf(screen," output rvous datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, size_outrvous_max/outsize,size_outrvous_min/outsize); - fprintf(screen," output rvous data (MB) " - "(tot,ave,max,min): %g %g %g %g\n", + fprintf(screen," output rvous data (MB): %g %g %g %g\n", 1.0*size_outrvous_all/mbytes,1.0*size_outrvous_all/nprocs/mbytes, 1.0*size_outrvous_max/mbytes,1.0*size_outrvous_min/mbytes); + fprintf(screen," rvous comm (MB): %g %g %g %g\n", + 1.0*size_comm_all/mbytes,1.0*size_comm_all/nprocs/mbytes, + 1.0*size_comm_max/mbytes,1.0*size_comm_min/mbytes); } } - - /* - bigint rvous_bytes = 0; - rvous_bytes += n*insize; // inbuf - rvous_bytes += nout*outsize; // outbuf - rvous_bytes += nrvous*insize; // inbuf_rvous - rvous_bytes += nrvous_out*outsize; // outbuf_rvous - rvous_bytes += nrvous_out*sizeof(int); // procs_rvous - rvous_bytes += 4*nprocs*sizeof(int); // all2all vectors - rvous_bytes += MAX(all2all1_bytes,all2all2_bytes); // reorder ops - */ - - return nout; } /* ---------------------------------------------------------------------- diff --git a/src/comm.h b/src/comm.h index 89889e3ebe..9c0112b4c4 100644 --- a/src/comm.h +++ b/src/comm.h @@ -153,6 +153,7 @@ class Comm : protected Pointers { int rendezvous_all2all(int, char *, int, int, int *, int (*)(int, char *, int &, int *&, char *&, void *), int, char *&, int, void *, int); + void rendezvous_stats(int, int, int, int, int, int, bigint); public: enum{MULTIPLE}; diff --git a/src/special.cpp b/src/special.cpp index 5e0f865488..a0739d6ccc 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -27,6 +27,8 @@ using namespace LAMMPS_NS; +#define RVOUS 1 // 0 for irregular, 1 for all2all + /* ---------------------------------------------------------------------- */ Special::Special(LAMMPS *lmp) : Pointers(lmp) @@ -185,7 +187,7 @@ void Special::atom_owners() // perform rendezvous operation char *buf; - comm->rendezvous(1,nlocal,(char *) idbuf,sizeof(IDRvous),0,proclist, + comm->rendezvous(RVOUS,nlocal,(char *) idbuf,sizeof(IDRvous),0,proclist, rendezvous_ids,0,buf,0,(void *) this,1); memory->destroy(proclist); @@ -241,7 +243,7 @@ void Special::onetwo_build_newton() // perform rendezvous operation char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this,1); @@ -376,7 +378,7 @@ void Special::onethree_build() // perform rendezvous operation char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this,1); @@ -481,7 +483,7 @@ void Special::onefour_build() // perform rendezvous operation char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this,1); @@ -904,7 +906,7 @@ void Special::angle_trim() // perform rendezvous operation char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this,1); @@ -1123,7 +1125,7 @@ void Special::dihedral_trim() // perform rendezvous operation char *buf; - int nreturn = comm->rendezvous(1,nsend,(char *) inbuf,sizeof(PairRvous), + int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), (void *) this,1); From 3b234c167ff723805ba30dd0e6b222782f39b676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 13:46:15 +0100 Subject: [PATCH 10/49] USER-MEAMC: fix incomplete clearing of ev variables --- src/USER-MEAMC/pair_meamc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/USER-MEAMC/pair_meamc.cpp b/src/USER-MEAMC/pair_meamc.cpp index b74416a46d..d0d97740b3 100644 --- a/src/USER-MEAMC/pair_meamc.cpp +++ b/src/USER-MEAMC/pair_meamc.cpp @@ -94,8 +94,7 @@ void PairMEAMC::compute(int eflag, int vflag) int *numneigh_full,**firstneigh_full; if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + else ev_unset(); // neighbor list info From 06a57dd6598cb648709a539da4ccc03cc01f72b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 16:34:15 +0100 Subject: [PATCH 11/49] use ev_unset for all pair styles --- src/ASPHERE/pair_gayberne.cpp | 3 +-- src/ASPHERE/pair_line_lj.cpp | 3 +-- src/ASPHERE/pair_resquared.cpp | 3 +-- src/ASPHERE/pair_tri_lj.cpp | 3 +-- src/BODY/pair_body_nparticle.cpp | 3 +-- src/BODY/pair_body_rounded_polygon.cpp | 3 +-- src/BODY/pair_body_rounded_polyhedron.cpp | 3 +-- src/CLASS2/pair_lj_class2.cpp | 3 +-- src/CLASS2/pair_lj_class2_coul_cut.cpp | 3 +-- src/CLASS2/pair_lj_class2_coul_long.cpp | 3 +-- src/COLLOID/pair_brownian.cpp | 3 +-- src/COLLOID/pair_brownian_poly.cpp | 3 +-- src/COLLOID/pair_colloid.cpp | 3 +-- src/COLLOID/pair_lubricate.cpp | 3 +-- src/COLLOID/pair_lubricateU.cpp | 3 +-- src/COLLOID/pair_lubricateU_poly.cpp | 3 +-- src/COLLOID/pair_lubricate_poly.cpp | 3 +-- src/COLLOID/pair_yukawa_colloid.cpp | 3 +-- src/CORESHELL/pair_born_coul_dsf_cs.cpp | 3 +-- src/CORESHELL/pair_born_coul_long_cs.cpp | 3 +-- src/CORESHELL/pair_born_coul_wolf_cs.cpp | 3 +-- src/CORESHELL/pair_buck_coul_long_cs.cpp | 3 +-- src/CORESHELL/pair_coul_long_cs.cpp | 3 +-- src/CORESHELL/pair_coul_wolf_cs.cpp | 3 +-- src/CORESHELL/pair_lj_cut_coul_long_cs.cpp | 6 ++---- src/DIPOLE/pair_lj_cut_dipole_cut.cpp | 3 +-- src/DIPOLE/pair_lj_cut_dipole_long.cpp | 3 +-- src/DIPOLE/pair_lj_long_dipole_long.cpp | 3 +-- src/GPU/pair_beck_gpu.cpp | 3 +-- src/GPU/pair_born_coul_long_cs_gpu.cpp | 3 +-- src/GPU/pair_born_coul_long_gpu.cpp | 3 +-- src/GPU/pair_born_coul_wolf_cs_gpu.cpp | 3 +-- src/GPU/pair_born_coul_wolf_gpu.cpp | 3 +-- src/GPU/pair_born_gpu.cpp | 3 +-- src/GPU/pair_buck_coul_cut_gpu.cpp | 3 +-- src/GPU/pair_buck_coul_long_gpu.cpp | 3 +-- src/GPU/pair_buck_gpu.cpp | 3 +-- src/GPU/pair_colloid_gpu.cpp | 3 +-- src/GPU/pair_coul_cut_gpu.cpp | 3 +-- src/GPU/pair_coul_debye_gpu.cpp | 3 +-- src/GPU/pair_coul_dsf_gpu.cpp | 3 +-- src/GPU/pair_coul_long_cs_gpu.cpp | 3 +-- src/GPU/pair_coul_long_gpu.cpp | 3 +-- src/GPU/pair_dpd_gpu.cpp | 3 +-- src/GPU/pair_dpd_tstat_gpu.cpp | 3 +-- src/GPU/pair_eam_alloy_gpu.cpp | 3 +-- src/GPU/pair_eam_fs_gpu.cpp | 3 +-- src/GPU/pair_eam_gpu.cpp | 3 +-- src/GPU/pair_gauss_gpu.cpp | 3 +-- src/GPU/pair_gayberne_gpu.cpp | 3 +-- src/GPU/pair_lj96_cut_gpu.cpp | 3 +-- src/GPU/pair_lj_charmm_coul_long_gpu.cpp | 3 +-- src/GPU/pair_lj_class2_coul_long_gpu.cpp | 3 +-- src/GPU/pair_lj_class2_gpu.cpp | 3 +-- src/GPU/pair_lj_cubic_gpu.cpp | 3 +-- src/GPU/pair_lj_cut_coul_cut_gpu.cpp | 3 +-- src/GPU/pair_lj_cut_coul_debye_gpu.cpp | 3 +-- src/GPU/pair_lj_cut_coul_dsf_gpu.cpp | 3 +-- src/GPU/pair_lj_cut_coul_long_gpu.cpp | 3 +-- src/GPU/pair_lj_cut_coul_msm_gpu.cpp | 3 +-- src/GPU/pair_lj_cut_dipole_cut_gpu.cpp | 6 ++---- src/GPU/pair_lj_cut_dipole_long_gpu.cpp | 6 ++---- src/GPU/pair_lj_cut_gpu.cpp | 3 +-- src/GPU/pair_lj_expand_coul_long_gpu.cpp | 3 +-- src/GPU/pair_lj_expand_gpu.cpp | 3 +-- src/GPU/pair_lj_gromacs_gpu.cpp | 3 +-- src/GPU/pair_lj_sdk_coul_long_gpu.cpp | 3 +-- src/GPU/pair_lj_sdk_gpu.cpp | 3 +-- src/GPU/pair_lj_sf_dipole_sf_gpu.cpp | 6 ++---- src/GPU/pair_mie_cut_gpu.cpp | 3 +-- src/GPU/pair_morse_gpu.cpp | 3 +-- src/GPU/pair_resquared_gpu.cpp | 3 +-- src/GPU/pair_soft_gpu.cpp | 3 +-- src/GPU/pair_sw_gpu.cpp | 3 +-- src/GPU/pair_table_gpu.cpp | 3 +-- src/GPU/pair_tersoff_gpu.cpp | 3 +-- src/GPU/pair_tersoff_mod_gpu.cpp | 3 +-- src/GPU/pair_tersoff_zbl_gpu.cpp | 3 +-- src/GPU/pair_ufm_gpu.cpp | 3 +-- src/GPU/pair_vashishta_gpu.cpp | 3 +-- src/GPU/pair_yukawa_colloid_gpu.cpp | 3 +-- src/GPU/pair_yukawa_gpu.cpp | 3 +-- src/GPU/pair_zbl_gpu.cpp | 3 +-- src/GRANULAR/pair_gran_hertz_history.cpp | 3 +-- src/GRANULAR/pair_gran_hooke.cpp | 3 +-- src/GRANULAR/pair_gran_hooke_history.cpp | 3 +-- src/KIM/pair_kim.cpp | 5 +---- src/KOKKOS/pair_buck_coul_cut_kokkos.cpp | 3 +-- src/KOKKOS/pair_buck_coul_long_kokkos.cpp | 3 +-- src/KOKKOS/pair_buck_kokkos.cpp | 3 +-- src/KOKKOS/pair_coul_cut_kokkos.cpp | 3 +-- src/KOKKOS/pair_coul_debye_kokkos.cpp | 3 +-- src/KOKKOS/pair_coul_dsf_kokkos.cpp | 3 +-- src/KOKKOS/pair_coul_long_kokkos.cpp | 3 +-- src/KOKKOS/pair_coul_wolf_kokkos.cpp | 3 +-- src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp | 3 +-- src/KOKKOS/pair_eam_alloy_kokkos.cpp | 3 +-- src/KOKKOS/pair_eam_fs_kokkos.cpp | 3 +-- src/KOKKOS/pair_eam_kokkos.cpp | 3 +-- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 3 +-- src/KOKKOS/pair_gran_hooke_history_kokkos.cpp | 3 +-- src/KOKKOS/pair_hybrid_kokkos.cpp | 4 +--- src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_class2_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_cut_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_expand_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 3 +-- src/KOKKOS/pair_lj_sdk_kokkos.cpp | 3 +-- src/KOKKOS/pair_morse_kokkos.cpp | 3 +-- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 3 +-- src/KOKKOS/pair_reaxc_kokkos.cpp | 3 +-- src/KOKKOS/pair_snap_kokkos_impl.h | 3 +-- src/KOKKOS/pair_sw_kokkos.cpp | 3 +-- src/KOKKOS/pair_table_kokkos.cpp | 3 +-- src/KOKKOS/pair_table_rx_kokkos.cpp | 3 +-- src/KOKKOS/pair_tersoff_kokkos.cpp | 3 +-- src/KOKKOS/pair_tersoff_mod_kokkos.cpp | 3 +-- src/KOKKOS/pair_tersoff_zbl_kokkos.cpp | 3 +-- src/KOKKOS/pair_vashishta_kokkos.cpp | 3 +-- src/KOKKOS/pair_yukawa_kokkos.cpp | 3 +-- src/KOKKOS/pair_zbl_kokkos.cpp | 3 +-- src/KSPACE/pair_born_coul_long.cpp | 3 +-- src/KSPACE/pair_born_coul_msm.cpp | 3 +-- src/KSPACE/pair_buck_coul_long.cpp | 3 +-- src/KSPACE/pair_buck_coul_msm.cpp | 3 +-- src/KSPACE/pair_buck_long_coul_long.cpp | 6 ++---- src/KSPACE/pair_coul_long.cpp | 3 +-- src/KSPACE/pair_coul_msm.cpp | 3 +-- src/KSPACE/pair_lj_charmm_coul_long.cpp | 6 ++---- src/KSPACE/pair_lj_charmm_coul_msm.cpp | 6 ++---- src/KSPACE/pair_lj_charmmfsw_coul_long.cpp | 6 ++---- src/KSPACE/pair_lj_cut_coul_long.cpp | 6 ++---- src/KSPACE/pair_lj_cut_coul_msm.cpp | 6 ++---- src/KSPACE/pair_lj_cut_tip4p_long.cpp | 3 +-- src/KSPACE/pair_lj_long_coul_long.cpp | 6 ++---- src/KSPACE/pair_lj_long_tip4p_long.cpp | 6 ++---- src/KSPACE/pair_tip4p_long.cpp | 3 +-- src/MANYBODY/pair_adp.cpp | 3 +-- src/MANYBODY/pair_airebo.cpp | 3 +-- src/MANYBODY/pair_atm.cpp | 3 +-- src/MANYBODY/pair_bop.cpp | 3 +-- src/MANYBODY/pair_comb.cpp | 3 +-- src/MANYBODY/pair_comb3.cpp | 3 +-- src/MANYBODY/pair_eam.cpp | 3 +-- src/MANYBODY/pair_eam_cd.cpp | 3 +-- src/MANYBODY/pair_eim.cpp | 3 +-- src/MANYBODY/pair_gw.cpp | 3 +-- src/MANYBODY/pair_lcbop.cpp | 3 +-- src/MANYBODY/pair_nb3b_harmonic.cpp | 3 +-- src/MANYBODY/pair_polymorphic.cpp | 3 +-- src/MANYBODY/pair_sw.cpp | 3 +-- src/MANYBODY/pair_tersoff.cpp | 3 +-- src/MANYBODY/pair_vashishta.cpp | 3 +-- src/MANYBODY/pair_vashishta_table.cpp | 3 +-- src/MISC/pair_nm_cut.cpp | 3 +-- src/MISC/pair_nm_cut_coul_cut.cpp | 3 +-- src/MISC/pair_nm_cut_coul_long.cpp | 3 +-- src/MOLECULE/pair_hbond_dreiding_lj.cpp | 3 +-- src/MOLECULE/pair_hbond_dreiding_morse.cpp | 3 +-- src/MOLECULE/pair_lj_charmm_coul_charmm.cpp | 3 +-- src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp | 3 +-- src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp | 3 +-- src/MOLECULE/pair_lj_cut_tip4p_cut.cpp | 3 +-- src/MOLECULE/pair_tip4p_cut.cpp | 3 +-- src/OPT/pair_eam_opt.cpp | 3 +-- src/OPT/pair_lj_charmm_coul_long_opt.cpp | 3 +-- src/OPT/pair_lj_cut_coul_long_opt.cpp | 3 +-- src/OPT/pair_lj_cut_opt.cpp | 3 +-- src/OPT/pair_lj_cut_tip4p_long_opt.cpp | 3 +-- src/OPT/pair_lj_long_coul_long_opt.cpp | 6 ++---- src/OPT/pair_morse_opt.cpp | 3 +-- src/OPT/pair_ufm_opt.cpp | 3 +-- src/PERI/pair_peri_eps.cpp | 3 +-- src/PERI/pair_peri_lps.cpp | 3 +-- src/PERI/pair_peri_pmb.cpp | 3 +-- src/PERI/pair_peri_ves.cpp | 3 +-- src/PYTHON/pair_python.cpp | 3 +-- src/SNAP/pair_snap.cpp | 6 ++---- src/SPIN/pair_spin_dmi.cpp | 3 +-- src/SPIN/pair_spin_exchange.cpp | 3 +-- src/SPIN/pair_spin_magelec.cpp | 3 +-- src/SPIN/pair_spin_neel.cpp | 3 +-- src/USER-AWPMD/pair_awpmd_cut.cpp | 5 +---- src/USER-CGDNA/pair_oxdna2_coaxstk.cpp | 3 +-- src/USER-CGDNA/pair_oxdna2_dh.cpp | 3 +-- src/USER-CGDNA/pair_oxdna_coaxstk.cpp | 3 +-- src/USER-CGDNA/pair_oxdna_excv.cpp | 3 +-- src/USER-CGDNA/pair_oxdna_hbond.cpp | 3 +-- src/USER-CGDNA/pair_oxdna_stk.cpp | 3 +-- src/USER-CGDNA/pair_oxdna_xstk.cpp | 3 +-- src/USER-CGSDK/pair_lj_sdk.cpp | 4 +--- src/USER-CGSDK/pair_lj_sdk_coul_long.cpp | 4 +--- src/USER-CGSDK/pair_lj_sdk_coul_msm.cpp | 4 +--- src/USER-DPD/pair_dpd_fdt.cpp | 3 +-- src/USER-DPD/pair_dpd_fdt_energy.cpp | 3 +-- src/USER-DPD/pair_exp6_rx.cpp | 3 +-- src/USER-DPD/pair_multi_lucy.cpp | 3 +-- src/USER-DPD/pair_multi_lucy_rx.cpp | 3 +-- src/USER-DPD/pair_table_rx.cpp | 3 +-- src/USER-DRUDE/pair_lj_cut_thole_long.cpp | 3 +-- src/USER-DRUDE/pair_thole.cpp | 3 +-- src/USER-EFF/pair_eff_cut.cpp | 3 +-- src/USER-FEP/pair_coul_cut_soft.cpp | 3 +-- src/USER-FEP/pair_coul_long_soft.cpp | 3 +-- src/USER-FEP/pair_lj_charmm_coul_long_soft.cpp | 6 ++---- src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp | 3 +-- src/USER-FEP/pair_lj_class2_coul_long_soft.cpp | 3 +-- src/USER-FEP/pair_lj_class2_soft.cpp | 3 +-- src/USER-FEP/pair_lj_cut_coul_cut_soft.cpp | 3 +-- src/USER-FEP/pair_lj_cut_coul_long_soft.cpp | 6 ++---- src/USER-FEP/pair_lj_cut_soft.cpp | 6 ++---- src/USER-FEP/pair_lj_cut_tip4p_long_soft.cpp | 3 +-- src/USER-FEP/pair_morse_soft.cpp | 3 +-- src/USER-FEP/pair_tip4p_long_soft.cpp | 3 +-- src/USER-INTEL/pair_airebo_intel.cpp | 3 +-- src/USER-INTEL/pair_buck_coul_cut_intel.cpp | 4 +--- src/USER-INTEL/pair_buck_coul_long_intel.cpp | 4 +--- src/USER-INTEL/pair_buck_intel.cpp | 4 +--- src/USER-INTEL/pair_dpd_intel.cpp | 4 +--- src/USER-INTEL/pair_eam_intel.cpp | 4 +--- src/USER-INTEL/pair_gayberne_intel.cpp | 4 +--- src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp | 4 +--- src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp | 4 +--- src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp | 4 +--- src/USER-INTEL/pair_lj_cut_intel.cpp | 4 +--- src/USER-INTEL/pair_sw_intel.cpp | 4 +--- src/USER-INTEL/pair_tersoff_intel.cpp | 4 +--- src/USER-MEAMC/pair_meamc.cpp | 3 +-- src/USER-MESO/pair_edpd.cpp | 3 +-- src/USER-MESO/pair_mdpd.cpp | 3 +-- src/USER-MESO/pair_mdpd_rhosum.cpp | 5 +---- src/USER-MESO/pair_tdpd.cpp | 3 +-- src/USER-MGPT/pair_mgpt.cpp | 3 +-- src/USER-MISC/pair_agni.cpp | 3 +-- src/USER-MISC/pair_buck_mdf.cpp | 3 +-- src/USER-MISC/pair_coul_diel.cpp | 3 +-- src/USER-MISC/pair_coul_shield.cpp | 3 +-- src/USER-MISC/pair_edip.cpp | 3 +-- src/USER-MISC/pair_edip_multi.cpp | 3 +-- src/USER-MISC/pair_extep.cpp | 3 +-- src/USER-MISC/pair_gauss_cut.cpp | 3 +-- src/USER-MISC/pair_ilp_graphene_hbn.cpp | 3 +-- src/USER-MISC/pair_kolmogorov_crespi_full.cpp | 3 +-- src/USER-MISC/pair_kolmogorov_crespi_z.cpp | 3 +-- src/USER-MISC/pair_lebedeva_z.cpp | 3 +-- src/USER-MISC/pair_lennard_mdf.cpp | 3 +-- src/USER-MISC/pair_list.cpp | 4 +--- src/USER-MISC/pair_lj_expand_coul_long.cpp | 6 ++---- src/USER-MISC/pair_lj_mdf.cpp | 3 +-- src/USER-MISC/pair_lj_sf_dipole_sf.cpp | 3 +-- src/USER-MISC/pair_meam_spline.cpp | 7 +------ src/USER-MISC/pair_meam_sw_spline.cpp | 4 +--- src/USER-MISC/pair_momb.cpp | 3 +-- src/USER-MISC/pair_morse_smooth_linear.cpp | 3 +-- src/USER-MISC/pair_srp.cpp | 5 +---- src/USER-MISC/pair_tersoff_table.cpp | 3 +-- src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp | 3 +-- src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp | 3 +-- src/USER-OMP/pair_adp_omp.cpp | 4 +--- src/USER-OMP/pair_agni_omp.cpp | 4 +--- src/USER-OMP/pair_airebo_omp.cpp | 4 +--- src/USER-OMP/pair_beck_omp.cpp | 4 +--- src/USER-OMP/pair_born_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_born_coul_msm_omp.cpp | 4 +--- src/USER-OMP/pair_born_coul_wolf_omp.cpp | 4 +--- src/USER-OMP/pair_born_omp.cpp | 4 +--- src/USER-OMP/pair_brownian_omp.cpp | 4 +--- src/USER-OMP/pair_brownian_poly_omp.cpp | 4 +--- src/USER-OMP/pair_buck_coul_cut_omp.cpp | 4 +--- src/USER-OMP/pair_buck_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_buck_coul_msm_omp.cpp | 4 +--- src/USER-OMP/pair_buck_long_coul_long_omp.cpp | 5 ++--- src/USER-OMP/pair_buck_omp.cpp | 4 +--- src/USER-OMP/pair_colloid_omp.cpp | 4 +--- src/USER-OMP/pair_comb_omp.cpp | 4 +--- src/USER-OMP/pair_coul_cut_omp.cpp | 4 +--- src/USER-OMP/pair_coul_cut_soft_omp.cpp | 4 +--- src/USER-OMP/pair_coul_debye_omp.cpp | 4 +--- src/USER-OMP/pair_coul_diel_omp.cpp | 4 +--- src/USER-OMP/pair_coul_dsf_omp.cpp | 4 +--- src/USER-OMP/pair_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_coul_long_soft_omp.cpp | 4 +--- src/USER-OMP/pair_coul_msm_omp.cpp | 4 +--- src/USER-OMP/pair_coul_wolf_omp.cpp | 4 +--- src/USER-OMP/pair_dpd_omp.cpp | 4 +--- src/USER-OMP/pair_dpd_tstat_omp.cpp | 4 +--- src/USER-OMP/pair_eam_cd_omp.cpp | 4 +--- src/USER-OMP/pair_eam_omp.cpp | 4 +--- src/USER-OMP/pair_edip_omp.cpp | 4 +--- src/USER-OMP/pair_eim_omp.cpp | 4 +--- src/USER-OMP/pair_gauss_cut_omp.cpp | 4 +--- src/USER-OMP/pair_gauss_omp.cpp | 4 +--- src/USER-OMP/pair_gayberne_omp.cpp | 4 +--- src/USER-OMP/pair_gran_hertz_history_omp.cpp | 4 +--- src/USER-OMP/pair_gran_hooke_history_omp.cpp | 4 +--- src/USER-OMP/pair_gran_hooke_omp.cpp | 4 +--- src/USER-OMP/pair_hbond_dreiding_lj_omp.cpp | 4 +--- src/USER-OMP/pair_hbond_dreiding_morse_omp.cpp | 4 +--- src/USER-OMP/pair_lj96_cut_omp.cpp | 4 +--- src/USER-OMP/pair_lj_charmm_coul_charmm_implicit_omp.cpp | 4 +--- src/USER-OMP/pair_lj_charmm_coul_charmm_omp.cpp | 4 +--- src/USER-OMP/pair_lj_charmm_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_lj_charmm_coul_long_soft_omp.cpp | 4 +--- src/USER-OMP/pair_lj_charmm_coul_msm_omp.cpp | 4 +--- src/USER-OMP/pair_lj_class2_coul_cut_omp.cpp | 4 +--- src/USER-OMP/pair_lj_class2_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_lj_class2_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cubic_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_cut_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_cut_soft_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_debye_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_dsf_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_long_soft_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_msm_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_coul_wolf_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_dipole_cut_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_soft_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_thole_long_omp.cpp | 4 +--- src/USER-OMP/pair_lj_cut_tip4p_cut_omp.cpp | 3 +-- src/USER-OMP/pair_lj_cut_tip4p_long_omp.cpp | 3 +-- src/USER-OMP/pair_lj_cut_tip4p_long_soft_omp.cpp | 3 +-- src/USER-OMP/pair_lj_expand_omp.cpp | 4 +--- src/USER-OMP/pair_lj_gromacs_coul_gromacs_omp.cpp | 4 +--- src/USER-OMP/pair_lj_gromacs_omp.cpp | 4 +--- src/USER-OMP/pair_lj_long_coul_long_omp.cpp | 5 ++--- src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp | 4 +--- src/USER-OMP/pair_lj_sdk_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_lj_sdk_coul_msm_omp.cpp | 4 +--- src/USER-OMP/pair_lj_sdk_omp.cpp | 4 +--- src/USER-OMP/pair_lj_sf_dipole_sf_omp.cpp | 4 +--- src/USER-OMP/pair_lj_smooth_linear_omp.cpp | 4 +--- src/USER-OMP/pair_lj_smooth_omp.cpp | 4 +--- src/USER-OMP/pair_lubricate_omp.cpp | 4 +--- src/USER-OMP/pair_lubricate_poly_omp.cpp | 4 +--- src/USER-OMP/pair_meam_spline_omp.cpp | 4 +--- src/USER-OMP/pair_morse_omp.cpp | 4 +--- src/USER-OMP/pair_morse_smooth_linear_omp.cpp | 4 +--- src/USER-OMP/pair_nm_cut_coul_cut_omp.cpp | 4 +--- src/USER-OMP/pair_nm_cut_coul_long_omp.cpp | 4 +--- src/USER-OMP/pair_nm_cut_omp.cpp | 4 +--- src/USER-OMP/pair_peri_lps_omp.cpp | 4 +--- src/USER-OMP/pair_peri_pmb_omp.cpp | 4 +--- src/USER-OMP/pair_reaxc_omp.cpp | 3 +-- src/USER-OMP/pair_resquared_omp.cpp | 4 +--- src/USER-OMP/pair_soft_omp.cpp | 4 +--- src/USER-OMP/pair_sw_omp.cpp | 4 +--- src/USER-OMP/pair_table_omp.cpp | 4 +--- src/USER-OMP/pair_tersoff_mod_c_omp.cpp | 4 +--- src/USER-OMP/pair_tersoff_mod_omp.cpp | 4 +--- src/USER-OMP/pair_tersoff_omp.cpp | 4 +--- src/USER-OMP/pair_tersoff_table_omp.cpp | 4 +--- src/USER-OMP/pair_tip4p_cut_omp.cpp | 3 +-- src/USER-OMP/pair_tip4p_long_omp.cpp | 3 +-- src/USER-OMP/pair_tip4p_long_soft_omp.cpp | 3 +-- src/USER-OMP/pair_ufm_omp.cpp | 4 +--- src/USER-OMP/pair_vashishta_omp.cpp | 4 +--- src/USER-OMP/pair_vashishta_table_omp.cpp | 4 +--- src/USER-OMP/pair_yukawa_colloid_omp.cpp | 4 +--- src/USER-OMP/pair_yukawa_omp.cpp | 4 +--- src/USER-OMP/pair_zbl_omp.cpp | 4 +--- src/USER-QUIP/pair_quip.cpp | 3 +-- src/USER-REAXC/pair_reaxc.cpp | 3 +-- src/USER-SDPD/pair_sdpd_taitwater_isothermal.cpp | 3 +-- src/USER-SMD/pair_smd_hertz.cpp | 5 +---- src/USER-SMD/pair_smd_tlsph.cpp | 5 +---- src/USER-SMD/pair_smd_triangulated_surface.cpp | 5 +---- src/USER-SMD/pair_smd_ulsph.cpp | 5 +---- src/USER-SMTBQ/pair_smtbq.cpp | 3 +-- src/USER-SPH/pair_sph_heatconduction.cpp | 5 +---- src/USER-SPH/pair_sph_idealgas.cpp | 5 +---- src/USER-SPH/pair_sph_lj.cpp | 5 +---- src/USER-SPH/pair_sph_rhosum.cpp | 5 +---- src/USER-SPH/pair_sph_taitwater.cpp | 5 +---- src/USER-SPH/pair_sph_taitwater_morris.cpp | 5 +---- src/USER-YAFF/pair_lj_switch3_coulgauss_long.cpp | 3 +-- src/USER-YAFF/pair_mm3_switch3_coulgauss_long.cpp | 3 +-- src/pair.cpp | 3 +-- src/pair.h | 4 ++++ src/pair_beck.cpp | 3 +-- src/pair_born.cpp | 3 +-- src/pair_born_coul_dsf.cpp | 3 +-- src/pair_born_coul_wolf.cpp | 3 +-- src/pair_buck.cpp | 3 +-- src/pair_buck_coul_cut.cpp | 3 +-- src/pair_coul_cut.cpp | 3 +-- src/pair_coul_debye.cpp | 3 +-- src/pair_coul_dsf.cpp | 3 +-- src/pair_coul_streitz.cpp | 3 +-- src/pair_coul_wolf.cpp | 3 +-- src/pair_dpd.cpp | 3 +-- src/pair_dpd_tstat.cpp | 3 +-- src/pair_gauss.cpp | 3 +-- src/pair_hybrid.cpp | 5 ++--- src/pair_lj96_cut.cpp | 6 ++---- src/pair_lj_cubic.cpp | 3 +-- src/pair_lj_cut.cpp | 6 ++---- src/pair_lj_cut_coul_cut.cpp | 3 +-- src/pair_lj_cut_coul_debye.cpp | 3 +-- src/pair_lj_cut_coul_dsf.cpp | 3 +-- src/pair_lj_cut_coul_wolf.cpp | 3 +-- src/pair_lj_expand.cpp | 3 +-- src/pair_lj_gromacs.cpp | 3 +-- src/pair_lj_gromacs_coul_gromacs.cpp | 3 +-- src/pair_lj_smooth.cpp | 3 +-- src/pair_lj_smooth_linear.cpp | 3 +-- src/pair_mie_cut.cpp | 6 ++---- src/pair_morse.cpp | 3 +-- src/pair_soft.cpp | 3 +-- src/pair_table.cpp | 3 +-- src/pair_ufm.cpp | 3 +-- src/pair_yukawa.cpp | 3 +-- src/pair_zbl.cpp | 3 +-- src/pair_zero.cpp | 3 +-- 424 files changed, 451 insertions(+), 1036 deletions(-) diff --git a/src/ASPHERE/pair_gayberne.cpp b/src/ASPHERE/pair_gayberne.cpp index 857541957e..3d4ed3f183 100644 --- a/src/ASPHERE/pair_gayberne.cpp +++ b/src/ASPHERE/pair_gayberne.cpp @@ -94,8 +94,7 @@ void PairGayBerne::compute(int eflag, int vflag) double *iquat,*jquat; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); AtomVecEllipsoid::Bonus *bonus = avec->bonus; int *ellipsoid = atom->ellipsoid; diff --git a/src/ASPHERE/pair_line_lj.cpp b/src/ASPHERE/pair_line_lj.cpp index 963ff985c4..4873b44dc4 100644 --- a/src/ASPHERE/pair_line_lj.cpp +++ b/src/ASPHERE/pair_line_lj.cpp @@ -77,8 +77,7 @@ void PairLineLJ::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/ASPHERE/pair_resquared.cpp b/src/ASPHERE/pair_resquared.cpp index c477b1b8cf..b100a5f184 100644 --- a/src/ASPHERE/pair_resquared.cpp +++ b/src/ASPHERE/pair_resquared.cpp @@ -85,8 +85,7 @@ void PairRESquared::compute(int eflag, int vflag) RE2Vars wi,wj; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/ASPHERE/pair_tri_lj.cpp b/src/ASPHERE/pair_tri_lj.cpp index 142caf3764..cefd73f976 100644 --- a/src/ASPHERE/pair_tri_lj.cpp +++ b/src/ASPHERE/pair_tri_lj.cpp @@ -77,8 +77,7 @@ void PairTriLJ::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); AtomVecTri::Bonus *bonus = avec->bonus; double **x = atom->x; diff --git a/src/BODY/pair_body_nparticle.cpp b/src/BODY/pair_body_nparticle.cpp index 80b45beb4e..f2eb2aa520 100644 --- a/src/BODY/pair_body_nparticle.cpp +++ b/src/BODY/pair_body_nparticle.cpp @@ -77,8 +77,7 @@ void PairBodyNparticle::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index b6dcab29ae..69495ea57f 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -111,8 +111,7 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/BODY/pair_body_rounded_polyhedron.cpp b/src/BODY/pair_body_rounded_polyhedron.cpp index 1a4653ce53..60f6df3582 100644 --- a/src/BODY/pair_body_rounded_polyhedron.cpp +++ b/src/BODY/pair_body_rounded_polyhedron.cpp @@ -127,8 +127,7 @@ void PairBodyRoundedPolyhedron::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/CLASS2/pair_lj_class2.cpp b/src/CLASS2/pair_lj_class2.cpp index e6546b1acc..b71c34d795 100644 --- a/src/CLASS2/pair_lj_class2.cpp +++ b/src/CLASS2/pair_lj_class2.cpp @@ -65,8 +65,7 @@ void PairLJClass2::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CLASS2/pair_lj_class2_coul_cut.cpp b/src/CLASS2/pair_lj_class2_coul_cut.cpp index 49242ecb43..7fabe3c7c7 100644 --- a/src/CLASS2/pair_lj_class2_coul_cut.cpp +++ b/src/CLASS2/pair_lj_class2_coul_cut.cpp @@ -70,8 +70,7 @@ void PairLJClass2CoulCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CLASS2/pair_lj_class2_coul_long.cpp b/src/CLASS2/pair_lj_class2_coul_long.cpp index bbea2ade6e..0171350443 100644 --- a/src/CLASS2/pair_lj_class2_coul_long.cpp +++ b/src/CLASS2/pair_lj_class2_coul_long.cpp @@ -82,8 +82,7 @@ void PairLJClass2CoulLong::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index e532c06c86..aefa96b1fb 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -80,8 +80,7 @@ void PairBrownian::compute(int eflag, int vflag) double rsq,r,h_sep,radi; int *ilist,*jlist,*numneigh,**firstneigh; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index c6d5def2fa..389ae084b7 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -66,8 +66,7 @@ void PairBrownianPoly::compute(int eflag, int vflag) double rsq,r,h_sep,beta0,beta1,radi,radj; int *ilist,*jlist,*numneigh,**firstneigh; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/COLLOID/pair_colloid.cpp b/src/COLLOID/pair_colloid.cpp index c16dbf41af..04c35a7c00 100644 --- a/src/COLLOID/pair_colloid.cpp +++ b/src/COLLOID/pair_colloid.cpp @@ -78,8 +78,7 @@ void PairColloid::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index de53d91818..4e629bd442 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -88,8 +88,7 @@ void PairLubricate::compute(int eflag, int vflag) double vxmu2f = force->vxmu2f; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index 35fe33c84e..3ea3d4fe4a 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -116,8 +116,7 @@ void PairLubricateU::compute(int eflag, int vflag) int nghost = atom->nghost; int nall = nlocal + nghost; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // skip compute() if called from integrate::setup() // this is b/c do not want compute() to update velocities twice on a restart diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 90ac848d26..4fec95dcd8 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -78,8 +78,7 @@ void PairLubricateUPoly::compute(int eflag, int vflag) double **f = atom->f; double **torque = atom->torque; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // grow per-atom arrays if necessary // need to be atom->nmax in length diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index 5e52933364..ffbe7fce3c 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -72,8 +72,7 @@ void PairLubricatePoly::compute(int eflag, int vflag) double vxmu2f = force->vxmu2f; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/COLLOID/pair_yukawa_colloid.cpp b/src/COLLOID/pair_yukawa_colloid.cpp index d21bc43524..ab7d088508 100644 --- a/src/COLLOID/pair_yukawa_colloid.cpp +++ b/src/COLLOID/pair_yukawa_colloid.cpp @@ -46,8 +46,7 @@ void PairYukawaColloid::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_born_coul_dsf_cs.cpp b/src/CORESHELL/pair_born_coul_dsf_cs.cpp index 549c7c0348..f4d7447ade 100644 --- a/src/CORESHELL/pair_born_coul_dsf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_dsf_cs.cpp @@ -57,8 +57,7 @@ void PairBornCoulDSFCS::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_born_coul_long_cs.cpp b/src/CORESHELL/pair_born_coul_long_cs.cpp index 76f6eb387d..a19f8c34a8 100644 --- a/src/CORESHELL/pair_born_coul_long_cs.cpp +++ b/src/CORESHELL/pair_born_coul_long_cs.cpp @@ -68,8 +68,7 @@ void PairBornCoulLongCS::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_born_coul_wolf_cs.cpp b/src/CORESHELL/pair_born_coul_wolf_cs.cpp index 84179ce50a..7b52c28664 100644 --- a/src/CORESHELL/pair_born_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_wolf_cs.cpp @@ -53,8 +53,7 @@ void PairBornCoulWolfCS::compute(int eflag, int vflag) double erfcc,erfcd,v_sh,dvdrr,e_self,e_shift,f_shift,qisq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_buck_coul_long_cs.cpp b/src/CORESHELL/pair_buck_coul_long_cs.cpp index ea072d44a1..8df91f39a3 100644 --- a/src/CORESHELL/pair_buck_coul_long_cs.cpp +++ b/src/CORESHELL/pair_buck_coul_long_cs.cpp @@ -68,8 +68,7 @@ void PairBuckCoulLongCS::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_coul_long_cs.cpp b/src/CORESHELL/pair_coul_long_cs.cpp index b214653841..c8c8387d6d 100644 --- a/src/CORESHELL/pair_coul_long_cs.cpp +++ b/src/CORESHELL/pair_coul_long_cs.cpp @@ -69,8 +69,7 @@ void PairCoulLongCS::compute(int eflag, int vflag) double rsq; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_coul_wolf_cs.cpp b/src/CORESHELL/pair_coul_wolf_cs.cpp index b50f14833e..36e037bfc8 100644 --- a/src/CORESHELL/pair_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_coul_wolf_cs.cpp @@ -53,8 +53,7 @@ void PairCoulWolfCS::compute(int eflag, int vflag) double erfcc,erfcd,v_sh,dvdrr,e_self,e_shift,f_shift,qisq; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp index 8caefc0e66..56c75f0f5d 100644 --- a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp @@ -74,8 +74,7 @@ void PairLJCutCoulLongCS::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -399,8 +398,7 @@ void PairLJCutCoulLongCS::compute_outer(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/DIPOLE/pair_lj_cut_dipole_cut.cpp b/src/DIPOLE/pair_lj_cut_dipole_cut.cpp index 6af9b45724..18b78c55e0 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_cut.cpp +++ b/src/DIPOLE/pair_lj_cut_dipole_cut.cpp @@ -69,8 +69,7 @@ void PairLJCutDipoleCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/DIPOLE/pair_lj_cut_dipole_long.cpp b/src/DIPOLE/pair_lj_cut_dipole_long.cpp index 817a120e3d..0806d1ee73 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_long.cpp +++ b/src/DIPOLE/pair_lj_cut_dipole_long.cpp @@ -90,8 +90,7 @@ void PairLJCutDipoleLong::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/DIPOLE/pair_lj_long_dipole_long.cpp b/src/DIPOLE/pair_lj_long_dipole_long.cpp index 21fc035854..fbdc47a15b 100644 --- a/src/DIPOLE/pair_lj_long_dipole_long.cpp +++ b/src/DIPOLE/pair_lj_long_dipole_long.cpp @@ -405,8 +405,7 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) double evdwl,ecoul,fpair; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x, *x0 = x[0]; double **mu = atom->mu, *mu0 = mu[0], *imu, *jmu; diff --git a/src/GPU/pair_beck_gpu.cpp b/src/GPU/pair_beck_gpu.cpp index e65c53d194..9f76975ef1 100644 --- a/src/GPU/pair_beck_gpu.cpp +++ b/src/GPU/pair_beck_gpu.cpp @@ -84,8 +84,7 @@ PairBeckGPU::~PairBeckGPU() void PairBeckGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_born_coul_long_cs_gpu.cpp b/src/GPU/pair_born_coul_long_cs_gpu.cpp index 587c7b5215..291ad8ad1f 100644 --- a/src/GPU/pair_born_coul_long_cs_gpu.cpp +++ b/src/GPU/pair_born_coul_long_cs_gpu.cpp @@ -106,8 +106,7 @@ PairBornCoulLongCSGPU::~PairBornCoulLongCSGPU() void PairBornCoulLongCSGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_born_coul_long_gpu.cpp b/src/GPU/pair_born_coul_long_gpu.cpp index 1549ed79af..eb204691c7 100644 --- a/src/GPU/pair_born_coul_long_gpu.cpp +++ b/src/GPU/pair_born_coul_long_gpu.cpp @@ -101,8 +101,7 @@ PairBornCoulLongGPU::~PairBornCoulLongGPU() void PairBornCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_born_coul_wolf_cs_gpu.cpp b/src/GPU/pair_born_coul_wolf_cs_gpu.cpp index bf23007bca..4877a442b5 100644 --- a/src/GPU/pair_born_coul_wolf_cs_gpu.cpp +++ b/src/GPU/pair_born_coul_wolf_cs_gpu.cpp @@ -94,8 +94,7 @@ PairBornCoulWolfCSGPU::~PairBornCoulWolfCSGPU() void PairBornCoulWolfCSGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_born_coul_wolf_gpu.cpp b/src/GPU/pair_born_coul_wolf_gpu.cpp index 06a2769e10..851174988b 100644 --- a/src/GPU/pair_born_coul_wolf_gpu.cpp +++ b/src/GPU/pair_born_coul_wolf_gpu.cpp @@ -92,8 +92,7 @@ PairBornCoulWolfGPU::~PairBornCoulWolfGPU() void PairBornCoulWolfGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_born_gpu.cpp b/src/GPU/pair_born_gpu.cpp index 01e91a9c0b..253d2d7282 100644 --- a/src/GPU/pair_born_gpu.cpp +++ b/src/GPU/pair_born_gpu.cpp @@ -87,8 +87,7 @@ PairBornGPU::~PairBornGPU() void PairBornGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_buck_coul_cut_gpu.cpp b/src/GPU/pair_buck_coul_cut_gpu.cpp index ce71e9ac41..ed602f9cab 100644 --- a/src/GPU/pair_buck_coul_cut_gpu.cpp +++ b/src/GPU/pair_buck_coul_cut_gpu.cpp @@ -88,8 +88,7 @@ PairBuckCoulCutGPU::~PairBuckCoulCutGPU() void PairBuckCoulCutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_buck_coul_long_gpu.cpp b/src/GPU/pair_buck_coul_long_gpu.cpp index a2d14ea25f..d6b9e53282 100644 --- a/src/GPU/pair_buck_coul_long_gpu.cpp +++ b/src/GPU/pair_buck_coul_long_gpu.cpp @@ -97,8 +97,7 @@ PairBuckCoulLongGPU::~PairBuckCoulLongGPU() void PairBuckCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_buck_gpu.cpp b/src/GPU/pair_buck_gpu.cpp index e6479e46e8..8c85407e6e 100644 --- a/src/GPU/pair_buck_gpu.cpp +++ b/src/GPU/pair_buck_gpu.cpp @@ -85,8 +85,7 @@ PairBuckGPU::~PairBuckGPU() void PairBuckGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_colloid_gpu.cpp b/src/GPU/pair_colloid_gpu.cpp index 03e5aac5d5..0ee8708b5b 100644 --- a/src/GPU/pair_colloid_gpu.cpp +++ b/src/GPU/pair_colloid_gpu.cpp @@ -85,8 +85,7 @@ PairColloidGPU::~PairColloidGPU() void PairColloidGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_coul_cut_gpu.cpp b/src/GPU/pair_coul_cut_gpu.cpp index 436d26fb54..fb50c446b1 100644 --- a/src/GPU/pair_coul_cut_gpu.cpp +++ b/src/GPU/pair_coul_cut_gpu.cpp @@ -85,8 +85,7 @@ PairCoulCutGPU::~PairCoulCutGPU() void PairCoulCutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_coul_debye_gpu.cpp b/src/GPU/pair_coul_debye_gpu.cpp index c17e21f41f..ec771a9935 100644 --- a/src/GPU/pair_coul_debye_gpu.cpp +++ b/src/GPU/pair_coul_debye_gpu.cpp @@ -86,8 +86,7 @@ PairCoulDebyeGPU::~PairCoulDebyeGPU() void PairCoulDebyeGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_coul_dsf_gpu.cpp b/src/GPU/pair_coul_dsf_gpu.cpp index 15a15660dd..1753b8a91c 100644 --- a/src/GPU/pair_coul_dsf_gpu.cpp +++ b/src/GPU/pair_coul_dsf_gpu.cpp @@ -97,8 +97,7 @@ PairCoulDSFGPU::~PairCoulDSFGPU() void PairCoulDSFGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_coul_long_cs_gpu.cpp b/src/GPU/pair_coul_long_cs_gpu.cpp index be2a090786..6ca00d6361 100644 --- a/src/GPU/pair_coul_long_cs_gpu.cpp +++ b/src/GPU/pair_coul_long_cs_gpu.cpp @@ -99,8 +99,7 @@ PairCoulLongCSGPU::~PairCoulLongCSGPU() void PairCoulLongCSGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_coul_long_gpu.cpp b/src/GPU/pair_coul_long_gpu.cpp index 684b0049c0..f75d10b6dd 100644 --- a/src/GPU/pair_coul_long_gpu.cpp +++ b/src/GPU/pair_coul_long_gpu.cpp @@ -94,8 +94,7 @@ PairCoulLongGPU::~PairCoulLongGPU() void PairCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_dpd_gpu.cpp b/src/GPU/pair_dpd_gpu.cpp index 7d56b47fe5..b1e45fbecd 100644 --- a/src/GPU/pair_dpd_gpu.cpp +++ b/src/GPU/pair_dpd_gpu.cpp @@ -225,8 +225,7 @@ PairDPDGPU::~PairDPDGPU() void PairDPDGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_dpd_tstat_gpu.cpp b/src/GPU/pair_dpd_tstat_gpu.cpp index f093c03a2d..0693a27344 100644 --- a/src/GPU/pair_dpd_tstat_gpu.cpp +++ b/src/GPU/pair_dpd_tstat_gpu.cpp @@ -228,8 +228,7 @@ PairDPDTstatGPU::~PairDPDTstatGPU() void PairDPDTstatGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // adjust sigma if target T is changing diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index c472b91fc8..9b3412d3d1 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -94,8 +94,7 @@ double PairEAMAlloyGPU::memory_usage() void PairEAMAlloyGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); // compute density on each atom on GPU diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index 821bb1af1c..11ef28af3e 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -92,8 +92,7 @@ double PairEAMFSGPU::memory_usage() void PairEAMFSGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); // compute density on each atom on GPU diff --git a/src/GPU/pair_eam_gpu.cpp b/src/GPU/pair_eam_gpu.cpp index 515a349ad2..4788a72417 100644 --- a/src/GPU/pair_eam_gpu.cpp +++ b/src/GPU/pair_eam_gpu.cpp @@ -95,8 +95,7 @@ double PairEAMGPU::memory_usage() void PairEAMGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); // compute density on each atom on GPU diff --git a/src/GPU/pair_gauss_gpu.cpp b/src/GPU/pair_gauss_gpu.cpp index 71fb55f4d0..c596a9d644 100644 --- a/src/GPU/pair_gauss_gpu.cpp +++ b/src/GPU/pair_gauss_gpu.cpp @@ -82,8 +82,7 @@ PairGaussGPU::~PairGaussGPU() void PairGaussGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_gayberne_gpu.cpp b/src/GPU/pair_gayberne_gpu.cpp index 32b8b979cd..4ed2750e57 100644 --- a/src/GPU/pair_gayberne_gpu.cpp +++ b/src/GPU/pair_gayberne_gpu.cpp @@ -92,8 +92,7 @@ PairGayBerneGPU::~PairGayBerneGPU() void PairGayBerneGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj96_cut_gpu.cpp b/src/GPU/pair_lj96_cut_gpu.cpp index 707d632d9a..5bc30c809d 100644 --- a/src/GPU/pair_lj96_cut_gpu.cpp +++ b/src/GPU/pair_lj96_cut_gpu.cpp @@ -82,8 +82,7 @@ PairLJ96CutGPU::~PairLJ96CutGPU() void PairLJ96CutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_charmm_coul_long_gpu.cpp b/src/GPU/pair_lj_charmm_coul_long_gpu.cpp index ebc9f88943..134295c69f 100644 --- a/src/GPU/pair_lj_charmm_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_charmm_coul_long_gpu.cpp @@ -99,8 +99,7 @@ PairLJCharmmCoulLongGPU::~PairLJCharmmCoulLongGPU() void PairLJCharmmCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_class2_coul_long_gpu.cpp b/src/GPU/pair_lj_class2_coul_long_gpu.cpp index 797680c032..fdffb06a8d 100644 --- a/src/GPU/pair_lj_class2_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_class2_coul_long_gpu.cpp @@ -96,8 +96,7 @@ PairLJClass2CoulLongGPU::~PairLJClass2CoulLongGPU() void PairLJClass2CoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_class2_gpu.cpp b/src/GPU/pair_lj_class2_gpu.cpp index 8a9b2b31e8..bbb9168169 100644 --- a/src/GPU/pair_lj_class2_gpu.cpp +++ b/src/GPU/pair_lj_class2_gpu.cpp @@ -81,8 +81,7 @@ PairLJClass2GPU::~PairLJClass2GPU() void PairLJClass2GPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cubic_gpu.cpp b/src/GPU/pair_lj_cubic_gpu.cpp index 669eae4ee4..95eee6ae8f 100644 --- a/src/GPU/pair_lj_cubic_gpu.cpp +++ b/src/GPU/pair_lj_cubic_gpu.cpp @@ -86,8 +86,7 @@ PairLJCubicGPU::~PairLJCubicGPU() void PairLJCubicGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cut_coul_cut_gpu.cpp b/src/GPU/pair_lj_cut_coul_cut_gpu.cpp index 99c7bb1c66..69fefbcdea 100644 --- a/src/GPU/pair_lj_cut_coul_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_cut_gpu.cpp @@ -87,8 +87,7 @@ PairLJCutCoulCutGPU::~PairLJCutCoulCutGPU() void PairLJCutCoulCutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cut_coul_debye_gpu.cpp b/src/GPU/pair_lj_cut_coul_debye_gpu.cpp index 450eca5c47..de86c58647 100644 --- a/src/GPU/pair_lj_cut_coul_debye_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_debye_gpu.cpp @@ -89,8 +89,7 @@ ljcd_gpu_clear(); void PairLJCutCoulDebyeGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp index abe7394a8c..87eac52749 100644 --- a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp @@ -98,8 +98,7 @@ PairLJCutCoulDSFGPU::~PairLJCutCoulDSFGPU() void PairLJCutCoulDSFGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cut_coul_long_gpu.cpp b/src/GPU/pair_lj_cut_coul_long_gpu.cpp index 943d12b0fe..c854dab83d 100644 --- a/src/GPU/pair_lj_cut_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_long_gpu.cpp @@ -99,8 +99,7 @@ PairLJCutCoulLongGPU::~PairLJCutCoulLongGPU() void PairLJCutCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cut_coul_msm_gpu.cpp b/src/GPU/pair_lj_cut_coul_msm_gpu.cpp index 46cf6f19bc..f87dc0ec91 100644 --- a/src/GPU/pair_lj_cut_coul_msm_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_msm_gpu.cpp @@ -88,8 +88,7 @@ PairLJCutCoulMSMGPU::~PairLJCutCoulMSMGPU() void PairLJCutCoulMSMGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp b/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp index 1f4528cb88..d2c925d950 100644 --- a/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp @@ -89,8 +89,7 @@ PairLJCutDipoleCutGPU::~PairLJCutDipoleCutGPU() void PairLJCutDipoleCutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; @@ -199,8 +198,7 @@ void PairLJCutDipoleCutGPU::cpu_compute(int start, int inum, int eflag, int vfla int *jlist; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/GPU/pair_lj_cut_dipole_long_gpu.cpp b/src/GPU/pair_lj_cut_dipole_long_gpu.cpp index b209fa0ee7..774ff2fae4 100644 --- a/src/GPU/pair_lj_cut_dipole_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_dipole_long_gpu.cpp @@ -100,8 +100,7 @@ PairLJCutDipoleLongGPU::~PairLJCutDipoleLongGPU() void PairLJCutDipoleLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; @@ -228,8 +227,7 @@ void PairLJCutDipoleLongGPU::cpu_compute(int start, int inum, int eflag, int vfl int *jlist; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/GPU/pair_lj_cut_gpu.cpp b/src/GPU/pair_lj_cut_gpu.cpp index 9a6be3aab9..6dde9689f7 100644 --- a/src/GPU/pair_lj_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_gpu.cpp @@ -86,8 +86,7 @@ PairLJCutGPU::~PairLJCutGPU() void PairLJCutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_expand_coul_long_gpu.cpp b/src/GPU/pair_lj_expand_coul_long_gpu.cpp index 4161155980..31f4fd651c 100644 --- a/src/GPU/pair_lj_expand_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_expand_coul_long_gpu.cpp @@ -99,8 +99,7 @@ PairLJExpandCoulLongGPU::~PairLJExpandCoulLongGPU() void PairLJExpandCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_expand_gpu.cpp b/src/GPU/pair_lj_expand_gpu.cpp index 36378bf10e..a2e1cf54e3 100644 --- a/src/GPU/pair_lj_expand_gpu.cpp +++ b/src/GPU/pair_lj_expand_gpu.cpp @@ -85,8 +85,7 @@ PairLJExpandGPU::~PairLJExpandGPU() void PairLJExpandGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_gromacs_gpu.cpp b/src/GPU/pair_lj_gromacs_gpu.cpp index cc7010b295..e03f4b2e50 100644 --- a/src/GPU/pair_lj_gromacs_gpu.cpp +++ b/src/GPU/pair_lj_gromacs_gpu.cpp @@ -87,8 +87,7 @@ PairLJGromacsGPU::~PairLJGromacsGPU() void PairLJGromacsGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_sdk_coul_long_gpu.cpp b/src/GPU/pair_lj_sdk_coul_long_gpu.cpp index 4dbd8874d6..f5029df5dc 100644 --- a/src/GPU/pair_lj_sdk_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_sdk_coul_long_gpu.cpp @@ -102,8 +102,7 @@ PairLJSDKCoulLongGPU::~PairLJSDKCoulLongGPU() void PairLJSDKCoulLongGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_sdk_gpu.cpp b/src/GPU/pair_lj_sdk_gpu.cpp index 84d224a8c4..4797a34408 100644 --- a/src/GPU/pair_lj_sdk_gpu.cpp +++ b/src/GPU/pair_lj_sdk_gpu.cpp @@ -87,8 +87,7 @@ PairLJSDKGPU::~PairLJSDKGPU() void PairLJSDKGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp b/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp index a5ebb1dbc1..dd25a70eee 100644 --- a/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp +++ b/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp @@ -88,8 +88,7 @@ PairLJSFDipoleSFGPU::~PairLJSFDipoleSFGPU() void PairLJSFDipoleSFGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; @@ -202,8 +201,7 @@ void PairLJSFDipoleSFGPU::cpu_compute(int start, int inum, int eflag, int vflag, int *jlist; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/GPU/pair_mie_cut_gpu.cpp b/src/GPU/pair_mie_cut_gpu.cpp index e52577ee4c..838d28033f 100644 --- a/src/GPU/pair_mie_cut_gpu.cpp +++ b/src/GPU/pair_mie_cut_gpu.cpp @@ -83,8 +83,7 @@ PairMIECutGPU::~PairMIECutGPU() void PairMIECutGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_morse_gpu.cpp b/src/GPU/pair_morse_gpu.cpp index 7abf78ff30..1f94643e3a 100644 --- a/src/GPU/pair_morse_gpu.cpp +++ b/src/GPU/pair_morse_gpu.cpp @@ -81,8 +81,7 @@ PairMorseGPU::~PairMorseGPU() void PairMorseGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_resquared_gpu.cpp b/src/GPU/pair_resquared_gpu.cpp index b6fada0897..5e90f788bf 100644 --- a/src/GPU/pair_resquared_gpu.cpp +++ b/src/GPU/pair_resquared_gpu.cpp @@ -94,8 +94,7 @@ PairRESquaredGPU::~PairRESquaredGPU() void PairRESquaredGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_soft_gpu.cpp b/src/GPU/pair_soft_gpu.cpp index eed1bd5db3..42adb02553 100644 --- a/src/GPU/pair_soft_gpu.cpp +++ b/src/GPU/pair_soft_gpu.cpp @@ -86,8 +86,7 @@ PairSoftGPU::~PairSoftGPU() void PairSoftGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_sw_gpu.cpp b/src/GPU/pair_sw_gpu.cpp index 5368bee959..0cc858e57d 100644 --- a/src/GPU/pair_sw_gpu.cpp +++ b/src/GPU/pair_sw_gpu.cpp @@ -93,8 +93,7 @@ PairSWGPU::~PairSWGPU() void PairSWGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_table_gpu.cpp b/src/GPU/pair_table_gpu.cpp index d0185b85e8..a0b6562e5e 100644 --- a/src/GPU/pair_table_gpu.cpp +++ b/src/GPU/pair_table_gpu.cpp @@ -89,8 +89,7 @@ PairTableGPU::~PairTableGPU() void PairTableGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_tersoff_gpu.cpp b/src/GPU/pair_tersoff_gpu.cpp index 535b56163e..cd0c5e6693 100644 --- a/src/GPU/pair_tersoff_gpu.cpp +++ b/src/GPU/pair_tersoff_gpu.cpp @@ -97,8 +97,7 @@ PairTersoffGPU::~PairTersoffGPU() void PairTersoffGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_tersoff_mod_gpu.cpp b/src/GPU/pair_tersoff_mod_gpu.cpp index f8b6c50db5..fd55ddc6e6 100644 --- a/src/GPU/pair_tersoff_mod_gpu.cpp +++ b/src/GPU/pair_tersoff_mod_gpu.cpp @@ -90,8 +90,7 @@ PairTersoffMODGPU::~PairTersoffMODGPU() void PairTersoffMODGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_tersoff_zbl_gpu.cpp b/src/GPU/pair_tersoff_zbl_gpu.cpp index b45503d759..d3828962e2 100644 --- a/src/GPU/pair_tersoff_zbl_gpu.cpp +++ b/src/GPU/pair_tersoff_zbl_gpu.cpp @@ -98,8 +98,7 @@ PairTersoffZBLGPU::~PairTersoffZBLGPU() void PairTersoffZBLGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_ufm_gpu.cpp b/src/GPU/pair_ufm_gpu.cpp index 688e3ef4dc..31422b0f4d 100644 --- a/src/GPU/pair_ufm_gpu.cpp +++ b/src/GPU/pair_ufm_gpu.cpp @@ -88,8 +88,7 @@ PairUFMGPU::~PairUFMGPU() void PairUFMGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_vashishta_gpu.cpp b/src/GPU/pair_vashishta_gpu.cpp index 84936f2c26..b496359b8a 100644 --- a/src/GPU/pair_vashishta_gpu.cpp +++ b/src/GPU/pair_vashishta_gpu.cpp @@ -94,8 +94,7 @@ PairVashishtaGPU::~PairVashishtaGPU() void PairVashishtaGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_yukawa_colloid_gpu.cpp b/src/GPU/pair_yukawa_colloid_gpu.cpp index 556dece7f8..3645f392a2 100644 --- a/src/GPU/pair_yukawa_colloid_gpu.cpp +++ b/src/GPU/pair_yukawa_colloid_gpu.cpp @@ -84,8 +84,7 @@ PairYukawaColloidGPU::~PairYukawaColloidGPU() void PairYukawaColloidGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_yukawa_gpu.cpp b/src/GPU/pair_yukawa_gpu.cpp index 9d3ea6f5a7..90317fea34 100644 --- a/src/GPU/pair_yukawa_gpu.cpp +++ b/src/GPU/pair_yukawa_gpu.cpp @@ -83,8 +83,7 @@ PairYukawaGPU::~PairYukawaGPU() void PairYukawaGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GPU/pair_zbl_gpu.cpp b/src/GPU/pair_zbl_gpu.cpp index c9b8dd75a1..99471cbe90 100644 --- a/src/GPU/pair_zbl_gpu.cpp +++ b/src/GPU/pair_zbl_gpu.cpp @@ -86,8 +86,7 @@ PairZBLGPU::~PairZBLGPU() void PairZBLGPU::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int nall = atom->nlocal + atom->nghost; int inum, host_start; diff --git a/src/GRANULAR/pair_gran_hertz_history.cpp b/src/GRANULAR/pair_gran_hertz_history.cpp index d1f3c7bbe1..728491c17a 100644 --- a/src/GRANULAR/pair_gran_hertz_history.cpp +++ b/src/GRANULAR/pair_gran_hertz_history.cpp @@ -55,8 +55,7 @@ void PairGranHertzHistory::compute(int eflag, int vflag) int *touch,**firsttouch; double *shear,*allshear,**firstshear; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int shearupdate = 1; if (update->setupflag) shearupdate = 0; diff --git a/src/GRANULAR/pair_gran_hooke.cpp b/src/GRANULAR/pair_gran_hooke.cpp index 5244396ead..cfcc2743ba 100644 --- a/src/GRANULAR/pair_gran_hooke.cpp +++ b/src/GRANULAR/pair_gran_hooke.cpp @@ -51,8 +51,7 @@ void PairGranHooke::compute(int eflag, int vflag) double fn,fs,ft,fs1,fs2,fs3; int *ilist,*jlist,*numneigh,**firstneigh; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // update rigid body info for owned & ghost atoms if using FixRigid masses // body[i] = which body atom I is in, -1 if none diff --git a/src/GRANULAR/pair_gran_hooke_history.cpp b/src/GRANULAR/pair_gran_hooke_history.cpp index 83f75c221d..cec825316c 100644 --- a/src/GRANULAR/pair_gran_hooke_history.cpp +++ b/src/GRANULAR/pair_gran_hooke_history.cpp @@ -98,8 +98,7 @@ void PairGranHookeHistory::compute(int eflag, int vflag) int *touch,**firsttouch; double *shear,*allshear,**firstshear; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int shearupdate = 1; if (update->setupflag) shearupdate = 0; diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index a4517b848c..84842f87cc 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -191,10 +191,7 @@ void PairKIM::compute(int eflag , int vflag) { int kimerror; - if (eflag || vflag) - ev_setup(eflag,vflag); - else - ev_unset(); + ev_init(eflag,vflag); // grow kim_particleSpecies and kim_particleContributing array if necessary // needs to be atom->nmax in length diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index 18d09965be..57ac3a9c57 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -92,8 +92,7 @@ void PairBuckCoulCutKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp index 0b44a83ebb..349c4c0601 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp @@ -111,8 +111,7 @@ void PairBuckCoulLongKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_buck_kokkos.cpp b/src/KOKKOS/pair_buck_kokkos.cpp index 999aefe4c3..02c02c986e 100644 --- a/src/KOKKOS/pair_buck_kokkos.cpp +++ b/src/KOKKOS/pair_buck_kokkos.cpp @@ -81,8 +81,7 @@ void PairBuckKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_coul_cut_kokkos.cpp b/src/KOKKOS/pair_coul_cut_kokkos.cpp index 7d29adc625..54ba0b63ce 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_coul_cut_kokkos.cpp @@ -80,8 +80,7 @@ void PairCoulCutKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index 3de83b5bc4..8966e30394 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -87,8 +87,7 @@ void PairCoulDebyeKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_coul_dsf_kokkos.cpp index 7d03ee4968..748fed71a7 100644 --- a/src/KOKKOS/pair_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_dsf_kokkos.cpp @@ -80,8 +80,7 @@ void PairCoulDSFKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_coul_long_kokkos.cpp b/src/KOKKOS/pair_coul_long_kokkos.cpp index 73b9521da0..a21cb050ff 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_coul_long_kokkos.cpp @@ -104,8 +104,7 @@ void PairCoulLongKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_coul_wolf_kokkos.cpp index fe9c581cc1..20391d9530 100644 --- a/src/KOKKOS/pair_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_wolf_kokkos.cpp @@ -75,8 +75,7 @@ void PairCoulWolfKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp index d2fcc81ea4..a44ef1790e 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp @@ -165,8 +165,7 @@ void PairDPDfdtEnergyKokkos::compute(int eflag_in, int vflag_in) vflag = vflag_in; if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index 6039282141..b580f00ed0 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -74,8 +74,7 @@ void PairEAMAlloyKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 81d9ba8326..1b1ec5c31e 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -74,8 +74,7 @@ void PairEAMFSKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index 22383f57c5..d423f2c927 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -68,8 +68,7 @@ void PairEAMKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index df24a5f4c7..fa10c6d30f 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -147,8 +147,7 @@ void PairExp6rxKokkos::compute(int eflag_in, int vflag_in) vflag = vflag_in; if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp index 189407b541..068580b525 100644 --- a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp +++ b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp @@ -111,8 +111,7 @@ void PairGranHookeHistoryKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); int shearupdate = 1; if (update->setupflag) shearupdate = 0; diff --git a/src/KOKKOS/pair_hybrid_kokkos.cpp b/src/KOKKOS/pair_hybrid_kokkos.cpp index 03ad77c34a..00df4a8f3c 100644 --- a/src/KOKKOS/pair_hybrid_kokkos.cpp +++ b/src/KOKKOS/pair_hybrid_kokkos.cpp @@ -78,9 +78,7 @@ void PairHybridKokkos::compute(int eflag, int vflag) if (no_virial_fdotr_compute && vflag % 4 == 2) vflag = 1 + vflag/4 * 4; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); // check if global component of incoming vflag = 2 // if so, reset vflag passed to substyle as if it were 0 diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index ce7df2bec1..510740112a 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -112,8 +112,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::compute(int eflag_in, int if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp index b31282e595..51c96354f9 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp @@ -112,8 +112,7 @@ void PairLJCharmmCoulCharmmKokkos::compute(int eflag_in, int vflag_i if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp index 5d8a202aa4..22faa98935 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp @@ -112,8 +112,7 @@ void PairLJCharmmCoulLongKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp index 6eb3028101..60d480188b 100644 --- a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp @@ -89,8 +89,7 @@ void PairLJClass2CoulCutKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp index a388694876..4c8aea8e92 100644 --- a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp @@ -97,8 +97,7 @@ void PairLJClass2CoulLongKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_class2_kokkos.cpp b/src/KOKKOS/pair_lj_class2_kokkos.cpp index 33d1477443..dd42baa4e0 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_kokkos.cpp @@ -89,8 +89,7 @@ void PairLJClass2Kokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp index 6001fabbed..cb5ab96871 100644 --- a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp @@ -89,8 +89,7 @@ void PairLJCutCoulCutKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp index 10923bc5da..800092a09b 100644 --- a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp @@ -93,8 +93,7 @@ void PairLJCutCoulDebyeKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index 47aa2ea7cc..f793485b47 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -101,8 +101,7 @@ void PairLJCutCoulDSFKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp index fa36cb1866..02150586f4 100644 --- a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp @@ -101,8 +101,7 @@ void PairLJCutCoulLongKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_kokkos.cpp index 9b0ff902af..4ba8c00f88 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_kokkos.cpp @@ -89,8 +89,7 @@ void PairLJCutKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_expand_kokkos.cpp b/src/KOKKOS/pair_lj_expand_kokkos.cpp index 3b8b9343d8..5ea6c9e438 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_kokkos.cpp @@ -88,8 +88,7 @@ void PairLJExpandKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp index d06ad9b44e..2421d059da 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp @@ -103,8 +103,7 @@ void PairLJGromacsCoulGromacsKokkos::compute(int eflag_in, int vflag if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp index d447846333..09a0261ae1 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp @@ -100,8 +100,7 @@ void PairLJGromacsKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.cpp b/src/KOKKOS/pair_lj_sdk_kokkos.cpp index 990e464341..c2375fa7a8 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.cpp +++ b/src/KOKKOS/pair_lj_sdk_kokkos.cpp @@ -88,8 +88,7 @@ void PairLJSDKKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_morse_kokkos.cpp b/src/KOKKOS/pair_morse_kokkos.cpp index ab5eb817a1..b308330ead 100644 --- a/src/KOKKOS/pair_morse_kokkos.cpp +++ b/src/KOKKOS/pair_morse_kokkos.cpp @@ -93,8 +93,7 @@ void PairMorseKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 5f19d73dfa..7d17ac3f43 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -148,8 +148,7 @@ void PairMultiLucyRXKokkos::compute_style(int eflag_in, int vflag_in vflag = vflag_in; if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index 56d2ebd8aa..c6ee50c6ac 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -677,8 +677,7 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); atomKK->sync(execution_space,datamask_read); k_params_sing.template sync(); diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index 998e75fabe..569783f926 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -137,8 +137,7 @@ void PairSNAPKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 24022475ab..da4737a2c1 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -80,8 +80,7 @@ void PairSWKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_table_kokkos.cpp b/src/KOKKOS/pair_table_kokkos.cpp index 9522e94706..737d600d1e 100644 --- a/src/KOKKOS/pair_table_kokkos.cpp +++ b/src/KOKKOS/pair_table_kokkos.cpp @@ -86,8 +86,7 @@ void PairTableKokkos::compute_style(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index 376984afa2..ec7a2ffb94 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -619,8 +619,7 @@ void PairTableRXKokkos::compute_style(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); if (eflag_atom) { memoryKK->destroy_kokkos(k_eatom,eatom); diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index a6668ca064..9252e3de52 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -164,8 +164,7 @@ void PairTersoffKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index 303d2bdfda..585074b128 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -164,8 +164,7 @@ void PairTersoffMODKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index ad4a2d444e..e1e2211ab5 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -178,8 +178,7 @@ void PairTersoffZBLKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 78ab8bfc85..4a1f291b17 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -79,8 +79,7 @@ void PairVashishtaKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_yukawa_kokkos.cpp b/src/KOKKOS/pair_yukawa_kokkos.cpp index 951613a33e..27e18533a2 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.cpp +++ b/src/KOKKOS/pair_yukawa_kokkos.cpp @@ -177,8 +177,7 @@ void PairYukawaKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index bcf33b405d..06c84e5189 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -129,8 +129,7 @@ void PairZBLKokkos::compute(int eflag_in, int vflag_in) if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KSPACE/pair_born_coul_long.cpp b/src/KSPACE/pair_born_coul_long.cpp index d55a5a3afe..f12f5779d9 100644 --- a/src/KSPACE/pair_born_coul_long.cpp +++ b/src/KSPACE/pair_born_coul_long.cpp @@ -87,8 +87,7 @@ void PairBornCoulLong::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_born_coul_msm.cpp b/src/KSPACE/pair_born_coul_msm.cpp index 775d26df95..eaa1c116c1 100644 --- a/src/KSPACE/pair_born_coul_msm.cpp +++ b/src/KSPACE/pair_born_coul_msm.cpp @@ -82,8 +82,7 @@ void PairBornCoulMSM::compute(int eflag, int vflag) } evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_buck_coul_long.cpp b/src/KSPACE/pair_buck_coul_long.cpp index a37e4ab4e9..0d24ff2497 100644 --- a/src/KSPACE/pair_buck_coul_long.cpp +++ b/src/KSPACE/pair_buck_coul_long.cpp @@ -82,8 +82,7 @@ void PairBuckCoulLong::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_buck_coul_msm.cpp b/src/KSPACE/pair_buck_coul_msm.cpp index fc72f1a4d6..257d1b661f 100644 --- a/src/KSPACE/pair_buck_coul_msm.cpp +++ b/src/KSPACE/pair_buck_coul_msm.cpp @@ -79,8 +79,7 @@ void PairBuckCoulMSM::compute(int eflag, int vflag) } evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_buck_long_coul_long.cpp b/src/KSPACE/pair_buck_long_coul_long.cpp index d5bb7b6c5b..c7a4a4b2f6 100644 --- a/src/KSPACE/pair_buck_long_coul_long.cpp +++ b/src/KSPACE/pair_buck_long_coul_long.cpp @@ -445,8 +445,7 @@ void PairBuckLongCoulLong::compute(int eflag, int vflag) double evdwl,ecoul,fpair; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x, *x0 = x[0]; double **f = atom->f, *f0 = f[0], *fi = f0; @@ -785,8 +784,7 @@ void PairBuckLongCoulLong::compute_outer(int eflag, int vflag) { double evdwl,ecoul,fpair,fvirial; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x, *x0 = x[0]; double **f = atom->f, *f0 = f[0], *fi = f0; diff --git a/src/KSPACE/pair_coul_long.cpp b/src/KSPACE/pair_coul_long.cpp index 8db5979b39..7d519eee0a 100644 --- a/src/KSPACE/pair_coul_long.cpp +++ b/src/KSPACE/pair_coul_long.cpp @@ -79,8 +79,7 @@ void PairCoulLong::compute(int eflag, int vflag) double rsq; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_coul_msm.cpp b/src/KSPACE/pair_coul_msm.cpp index ab59dfa4c1..960505142c 100644 --- a/src/KSPACE/pair_coul_msm.cpp +++ b/src/KSPACE/pair_coul_msm.cpp @@ -67,8 +67,7 @@ void PairCoulMSM::compute(int eflag, int vflag) } ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_lj_charmm_coul_long.cpp b/src/KSPACE/pair_lj_charmm_coul_long.cpp index 749d9657aa..df2b943af2 100644 --- a/src/KSPACE/pair_lj_charmm_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmm_coul_long.cpp @@ -96,8 +96,7 @@ void PairLJCharmmCoulLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -404,8 +403,7 @@ void PairLJCharmmCoulLong::compute_outer(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_lj_charmm_coul_msm.cpp b/src/KSPACE/pair_lj_charmm_coul_msm.cpp index aecadcf127..72a8e340bc 100644 --- a/src/KSPACE/pair_lj_charmm_coul_msm.cpp +++ b/src/KSPACE/pair_lj_charmm_coul_msm.cpp @@ -87,8 +87,7 @@ void PairLJCharmmCoulMSM::compute(int eflag, int vflag) } evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -265,8 +264,7 @@ void PairLJCharmmCoulMSM::compute_outer(int eflag, int vflag) "for rRESPA with kspace_style MSM"); evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp index 614980117e..0057197064 100644 --- a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp @@ -121,8 +121,7 @@ void PairLJCharmmfswCoulLong::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -452,8 +451,7 @@ void PairLJCharmmfswCoulLong::compute_outer(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_lj_cut_coul_long.cpp b/src/KSPACE/pair_lj_cut_coul_long.cpp index c9530fe157..fde7fa8e35 100644 --- a/src/KSPACE/pair_lj_cut_coul_long.cpp +++ b/src/KSPACE/pair_lj_cut_coul_long.cpp @@ -90,8 +90,7 @@ void PairLJCutCoulLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -397,8 +396,7 @@ void PairLJCutCoulLong::compute_outer(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_lj_cut_coul_msm.cpp b/src/KSPACE/pair_lj_cut_coul_msm.cpp index 78c364bd6a..c2e566a117 100644 --- a/src/KSPACE/pair_lj_cut_coul_msm.cpp +++ b/src/KSPACE/pair_lj_cut_coul_msm.cpp @@ -87,8 +87,7 @@ void PairLJCutCoulMSM::compute(int eflag, int vflag) } evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -252,8 +251,7 @@ void PairLJCutCoulMSM::compute_outer(int eflag, int vflag) "for rRESPA with kspace_style MSM"); evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KSPACE/pair_lj_cut_tip4p_long.cpp b/src/KSPACE/pair_lj_cut_tip4p_long.cpp index d622a83b39..f5889fd520 100644 --- a/src/KSPACE/pair_lj_cut_tip4p_long.cpp +++ b/src/KSPACE/pair_lj_cut_tip4p_long.cpp @@ -94,8 +94,7 @@ void PairLJCutTIP4PLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/KSPACE/pair_lj_long_coul_long.cpp b/src/KSPACE/pair_lj_long_coul_long.cpp index 2de527ab39..493866a895 100644 --- a/src/KSPACE/pair_lj_long_coul_long.cpp +++ b/src/KSPACE/pair_lj_long_coul_long.cpp @@ -441,8 +441,7 @@ void PairLJLongCoulLong::compute(int eflag, int vflag) { double evdwl,ecoul,fpair; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x, *x0 = x[0]; double **f = atom->f, *f0 = f[0], *fi = f0; @@ -778,8 +777,7 @@ void PairLJLongCoulLong::compute_outer(int eflag, int vflag) { double evdwl,ecoul,fvirial,fpair; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x, *x0 = x[0]; double **f = atom->f, *f0 = f[0], *fi = f0; diff --git a/src/KSPACE/pair_lj_long_tip4p_long.cpp b/src/KSPACE/pair_lj_long_tip4p_long.cpp index a571e30fc3..3137b9d79a 100644 --- a/src/KSPACE/pair_lj_long_tip4p_long.cpp +++ b/src/KSPACE/pair_lj_long_tip4p_long.cpp @@ -92,8 +92,7 @@ void PairLJLongTIP4PLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred @@ -1004,8 +1003,7 @@ void PairLJLongTIP4PLong::compute_outer(int eflag, int vflag) int respa_flag; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/KSPACE/pair_tip4p_long.cpp b/src/KSPACE/pair_tip4p_long.cpp index ac428d483a..9419fdf196 100644 --- a/src/KSPACE/pair_tip4p_long.cpp +++ b/src/KSPACE/pair_tip4p_long.cpp @@ -90,8 +90,7 @@ void PairTIP4PLong::compute(int eflag, int vflag) double rsq; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index 4fd19a36c4..68511b8709 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -133,8 +133,7 @@ void PairADP::compute(int eflag, int vflag) double sumlamxx,sumlamyy,sumlamzz,sumlamyz,sumlamxz,sumlamxy; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // grow local arrays if necessary // need to be atom->nmax in length diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index f8221e6381..4502bd9a82 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -108,8 +108,7 @@ PairAIREBO::~PairAIREBO() void PairAIREBO::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); pvector[0] = pvector[1] = pvector[2] = 0.0; REBO_neigh(); diff --git a/src/MANYBODY/pair_atm.cpp b/src/MANYBODY/pair_atm.cpp index e3be72443e..c157e0763c 100644 --- a/src/MANYBODY/pair_atm.cpp +++ b/src/MANYBODY/pair_atm.cpp @@ -82,8 +82,7 @@ void PairATM::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index 6540dedf98..ac157e071c 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -297,8 +297,7 @@ void PairBOP::compute(int eflag, int vflag) ilist = list->ilist; firstneigh = list->firstneigh; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // BOP Neighbor lists must be updated every timestep maxnall=nall; diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 85ea4812bf..980aa84b2a 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -144,8 +144,7 @@ void PairComb::compute(int eflag, int vflag) int sht_jnum, *sht_jlist, nj; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); // Build short range neighbor list diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index d82f6dfed0..097f235ff2 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -987,8 +987,7 @@ void PairComb3::compute(int eflag, int vflag) evdwl = eng_tmp = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); // Build short range neighbor list Short_neigh(); diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index f4b4901075..b7957349b6 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -142,8 +142,7 @@ void PairEAM::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); // grow energy and fp arrays if necessary // need to be atom->nmax in length diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index 8db1b6dd9a..c111c6d950 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -73,8 +73,7 @@ void PairEAMCD::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); // Grow per-atom arrays if necessary diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index b0fa1b1eef..f1c028ef38 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -113,8 +113,7 @@ void PairEIM::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); // grow energy array if necessary diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 7649090a99..e4b74f7a29 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -87,8 +87,7 @@ void PairGW::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index 0c8b3ef2a6..05cdea8055 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -87,8 +87,7 @@ PairLCBOP::~PairLCBOP() void PairLCBOP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); SR_neigh(); FSR(eflag,vflag); diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index ce449e4890..a61b403459 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -87,8 +87,7 @@ void PairNb3bHarmonic::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index 41c5892d4e..d3aca4e889 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -117,8 +117,7 @@ void PairPolymorphic::compute(int eflag, int vflag) double emb; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index 91e11b3d26..5a148fb152 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -91,8 +91,7 @@ void PairSW::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index 54101aef9e..213b1037bb 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -93,8 +93,7 @@ void PairTersoff::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index b4c3086ca8..3d4b1d900e 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -93,8 +93,7 @@ void PairVashishta::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MANYBODY/pair_vashishta_table.cpp b/src/MANYBODY/pair_vashishta_table.cpp index 1055db99fa..d4eaa59f1a 100644 --- a/src/MANYBODY/pair_vashishta_table.cpp +++ b/src/MANYBODY/pair_vashishta_table.cpp @@ -64,8 +64,7 @@ void PairVashishtaTable::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MISC/pair_nm_cut.cpp b/src/MISC/pair_nm_cut.cpp index 4b1611b137..124832b63e 100644 --- a/src/MISC/pair_nm_cut.cpp +++ b/src/MISC/pair_nm_cut.cpp @@ -70,8 +70,7 @@ void PairNMCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MISC/pair_nm_cut_coul_cut.cpp b/src/MISC/pair_nm_cut_coul_cut.cpp index 999fab1d6e..6a09d579b7 100644 --- a/src/MISC/pair_nm_cut_coul_cut.cpp +++ b/src/MISC/pair_nm_cut_coul_cut.cpp @@ -74,8 +74,7 @@ void PairNMCutCoulCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MISC/pair_nm_cut_coul_long.cpp b/src/MISC/pair_nm_cut_coul_long.cpp index fb82436dba..af21f02881 100644 --- a/src/MISC/pair_nm_cut_coul_long.cpp +++ b/src/MISC/pair_nm_cut_coul_long.cpp @@ -90,8 +90,7 @@ void PairNMCutCoulLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/pair_hbond_dreiding_lj.cpp b/src/MOLECULE/pair_hbond_dreiding_lj.cpp index c0c885d4d4..ddc1110081 100644 --- a/src/MOLECULE/pair_hbond_dreiding_lj.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_lj.cpp @@ -91,8 +91,7 @@ void PairHbondDreidingLJ::compute(int eflag, int vflag) tagint *klist; evdwl = ehbond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/pair_hbond_dreiding_morse.cpp b/src/MOLECULE/pair_hbond_dreiding_morse.cpp index f464d2c621..055f0ed46b 100644 --- a/src/MOLECULE/pair_hbond_dreiding_morse.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_morse.cpp @@ -61,8 +61,7 @@ void PairHbondDreidingMorse::compute(int eflag, int vflag) tagint *klist; evdwl = ehbond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp b/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp index 688c675815..98e272d99a 100644 --- a/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp +++ b/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp @@ -75,8 +75,7 @@ void PairLJCharmmCoulCharmm::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp b/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp index 6c083a49b0..d68d5e8f6d 100644 --- a/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp +++ b/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp @@ -39,8 +39,7 @@ void PairLJCharmmCoulCharmmImplicit::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp index 4b9147c169..7ce2417716 100644 --- a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp +++ b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp @@ -103,8 +103,7 @@ void PairLJCharmmfswCoulCharmmfsh::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/pair_lj_cut_tip4p_cut.cpp b/src/MOLECULE/pair_lj_cut_tip4p_cut.cpp index 92dead8435..2b3d2c60f5 100644 --- a/src/MOLECULE/pair_lj_cut_tip4p_cut.cpp +++ b/src/MOLECULE/pair_lj_cut_tip4p_cut.cpp @@ -91,8 +91,7 @@ void PairLJCutTIP4PCut::compute(int eflag, int vflag) double *x1,*x2,*xH1,*xH2; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/MOLECULE/pair_tip4p_cut.cpp b/src/MOLECULE/pair_tip4p_cut.cpp index 79dd79b180..e6fb9aab99 100644 --- a/src/MOLECULE/pair_tip4p_cut.cpp +++ b/src/MOLECULE/pair_tip4p_cut.cpp @@ -79,8 +79,7 @@ void PairTIP4PCut::compute(int eflag, int vflag) double *x1,*x2,*xH1,*xH2; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp index 5345d7f8d6..fc2b6731ee 100644 --- a/src/OPT/pair_eam_opt.cpp +++ b/src/OPT/pair_eam_opt.cpp @@ -38,8 +38,7 @@ PairEAMOpt::PairEAMOpt(LAMMPS *lmp) : PairEAM(lmp) {} void PairEAMOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/OPT/pair_lj_charmm_coul_long_opt.cpp b/src/OPT/pair_lj_charmm_coul_long_opt.cpp index 43f4ba7f5a..d80d3d1ec4 100644 --- a/src/OPT/pair_lj_charmm_coul_long_opt.cpp +++ b/src/OPT/pair_lj_charmm_coul_long_opt.cpp @@ -44,8 +44,7 @@ PairLJCharmmCoulLongOpt::PairLJCharmmCoulLongOpt(LAMMPS *lmp) : void PairLJCharmmCoulLongOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/OPT/pair_lj_cut_coul_long_opt.cpp b/src/OPT/pair_lj_cut_coul_long_opt.cpp index 98683a67a4..a25010cf1f 100644 --- a/src/OPT/pair_lj_cut_coul_long_opt.cpp +++ b/src/OPT/pair_lj_cut_coul_long_opt.cpp @@ -38,8 +38,7 @@ PairLJCutCoulLongOpt::PairLJCutCoulLongOpt(LAMMPS *lmp) : PairLJCutCoulLong(lmp) void PairLJCutCoulLongOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (!ncoultablebits) { if (evflag) { diff --git a/src/OPT/pair_lj_cut_opt.cpp b/src/OPT/pair_lj_cut_opt.cpp index ed35178c1f..c6684461be 100644 --- a/src/OPT/pair_lj_cut_opt.cpp +++ b/src/OPT/pair_lj_cut_opt.cpp @@ -34,8 +34,7 @@ PairLJCutOpt::PairLJCutOpt(LAMMPS *lmp) : PairLJCut(lmp) {} void PairLJCutOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/OPT/pair_lj_cut_tip4p_long_opt.cpp b/src/OPT/pair_lj_cut_tip4p_long_opt.cpp index 4842cc4fc0..92facca43e 100644 --- a/src/OPT/pair_lj_cut_tip4p_long_opt.cpp +++ b/src/OPT/pair_lj_cut_tip4p_long_opt.cpp @@ -53,8 +53,7 @@ PairLJCutTIP4PLongOpt::PairLJCutTIP4PLongOpt(LAMMPS *lmp) : void PairLJCutTIP4PLongOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/OPT/pair_lj_long_coul_long_opt.cpp b/src/OPT/pair_lj_long_coul_long_opt.cpp index 6bd1e8cb96..243b64391f 100644 --- a/src/OPT/pair_lj_long_coul_long_opt.cpp +++ b/src/OPT/pair_lj_long_coul_long_opt.cpp @@ -44,8 +44,7 @@ PairLJLongCoulLongOpt::PairLJLongCoulLongOpt(LAMMPS *lmp) : PairLJLongCoulLong(l void PairLJLongCoulLongOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int order1 = ewald_order&(1<<1), order6 = ewald_order&(1<<6); if (order6) { @@ -290,8 +289,7 @@ void PairLJLongCoulLongOpt::compute(int eflag, int vflag) void PairLJLongCoulLongOpt::compute_outer(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int order1 = ewald_order&(1<<1), order6 = ewald_order&(1<<6); if (order6) { diff --git a/src/OPT/pair_morse_opt.cpp b/src/OPT/pair_morse_opt.cpp index 6299136f46..c9c6bba355 100644 --- a/src/OPT/pair_morse_opt.cpp +++ b/src/OPT/pair_morse_opt.cpp @@ -35,8 +35,7 @@ PairMorseOpt::PairMorseOpt(LAMMPS *lmp) : PairMorse(lmp) {} void PairMorseOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/OPT/pair_ufm_opt.cpp b/src/OPT/pair_ufm_opt.cpp index 85c76d624d..f463dac3f1 100644 --- a/src/OPT/pair_ufm_opt.cpp +++ b/src/OPT/pair_ufm_opt.cpp @@ -34,8 +34,7 @@ PairUFMOpt::PairUFMOpt(LAMMPS *lmp) : PairUFM(lmp) {} void PairUFMOpt::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/PERI/pair_peri_eps.cpp b/src/PERI/pair_peri_eps.cpp index 76267426c6..c00495ba4d 100644 --- a/src/PERI/pair_peri_eps.cpp +++ b/src/PERI/pair_peri_eps.cpp @@ -96,8 +96,7 @@ void PairPeriEPS::compute(int eflag, int vflag) double d_ij,delta,stretch; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); double **f = atom->f; double **x = atom->x; diff --git a/src/PERI/pair_peri_lps.cpp b/src/PERI/pair_peri_lps.cpp index 383b91c6f5..f0418c8c8d 100644 --- a/src/PERI/pair_peri_lps.cpp +++ b/src/PERI/pair_peri_lps.cpp @@ -93,8 +93,7 @@ void PairPeriLPS::compute(int eflag, int vflag) double d_ij,delta,stretch; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); double **f = atom->f; double **x = atom->x; diff --git a/src/PERI/pair_peri_pmb.cpp b/src/PERI/pair_peri_pmb.cpp index 772e47f2d6..ad2f3fb7c7 100644 --- a/src/PERI/pair_peri_pmb.cpp +++ b/src/PERI/pair_peri_pmb.cpp @@ -84,8 +84,7 @@ void PairPeriPMB::compute(int eflag, int vflag) double d_ij,delta,stretch; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **f = atom->f; double **x = atom->x; diff --git a/src/PERI/pair_peri_ves.cpp b/src/PERI/pair_peri_ves.cpp index 7590077f0e..24a9f92a97 100644 --- a/src/PERI/pair_peri_ves.cpp +++ b/src/PERI/pair_peri_ves.cpp @@ -98,8 +98,7 @@ void PairPeriVES::compute(int eflag, int vflag) double d_ij,delta,stretch; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); double **f = atom->f; double **x = atom->x; diff --git a/src/PYTHON/pair_python.cpp b/src/PYTHON/pair_python.cpp index 4899e5e2ef..2148fc67b8 100644 --- a/src/PYTHON/pair_python.cpp +++ b/src/PYTHON/pair_python.cpp @@ -82,8 +82,7 @@ void PairPython::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 81c5e9f6d1..8b547e6e73 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -176,8 +176,7 @@ void PairSNAP::compute_regular(int eflag, int vflag) int *jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -486,8 +485,7 @@ void PairSNAP::compute_optimized(int eflag, int vflag) #pragma omp master #endif { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); } #if defined(_OPENMP) diff --git a/src/SPIN/pair_spin_dmi.cpp b/src/SPIN/pair_spin_dmi.cpp index 8496e40f99..200cafb999 100644 --- a/src/SPIN/pair_spin_dmi.cpp +++ b/src/SPIN/pair_spin_dmi.cpp @@ -233,8 +233,7 @@ void PairSpinDmi::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/SPIN/pair_spin_exchange.cpp b/src/SPIN/pair_spin_exchange.cpp index b2955aafb2..5b8ec60cd6 100644 --- a/src/SPIN/pair_spin_exchange.cpp +++ b/src/SPIN/pair_spin_exchange.cpp @@ -218,8 +218,7 @@ void PairSpinExchange::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/SPIN/pair_spin_magelec.cpp b/src/SPIN/pair_spin_magelec.cpp index a7357f61e3..95c29b233d 100644 --- a/src/SPIN/pair_spin_magelec.cpp +++ b/src/SPIN/pair_spin_magelec.cpp @@ -225,8 +225,7 @@ void PairSpinMagelec::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/SPIN/pair_spin_neel.cpp b/src/SPIN/pair_spin_neel.cpp index bd12832a8d..64fca23b7a 100644 --- a/src/SPIN/pair_spin_neel.cpp +++ b/src/SPIN/pair_spin_neel.cpp @@ -232,8 +232,7 @@ void PairSpinNeel::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-AWPMD/pair_awpmd_cut.cpp b/src/USER-AWPMD/pair_awpmd_cut.cpp index 806e4f3a14..1b7bf35c28 100644 --- a/src/USER-AWPMD/pair_awpmd_cut.cpp +++ b/src/USER-AWPMD/pair_awpmd_cut.cpp @@ -108,10 +108,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) // pvector = [KE, Pauli, ecoul, radial_restraint] for (int i=0; i<4; i++) pvector[i] = 0.0; - if (eflag || vflag) - ev_setup(eflag,vflag); - else - evflag = vflag_fdotr = 0; //?? + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp b/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp index 0b220a3275..f54197aea7 100644 --- a/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp +++ b/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp @@ -144,8 +144,7 @@ void PairOxdna2Coaxstk::compute(int eflag, int vflag) double df2,df4f6t1,df4t4,df4t5,df4t6,rsint; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); anum = list->inum; alist = list->ilist; diff --git a/src/USER-CGDNA/pair_oxdna2_dh.cpp b/src/USER-CGDNA/pair_oxdna2_dh.cpp index da6e1f8bbd..10e7121427 100644 --- a/src/USER-CGDNA/pair_oxdna2_dh.cpp +++ b/src/USER-CGDNA/pair_oxdna2_dh.cpp @@ -114,8 +114,7 @@ void PairOxdna2Dh::compute(int eflag, int vflag) int a,b,ia,ib,anum,bnum,atype,btype; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); anum = list->inum; alist = list->ilist; diff --git a/src/USER-CGDNA/pair_oxdna_coaxstk.cpp b/src/USER-CGDNA/pair_oxdna_coaxstk.cpp index ef0ff16150..6d3061620d 100644 --- a/src/USER-CGDNA/pair_oxdna_coaxstk.cpp +++ b/src/USER-CGDNA/pair_oxdna_coaxstk.cpp @@ -156,8 +156,7 @@ void PairOxdnaCoaxstk::compute(int eflag, int vflag) double df2,df4t1,df4t4,df4t5,df4t6,df5c3,rsint; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); anum = list->inum; alist = list->ilist; diff --git a/src/USER-CGDNA/pair_oxdna_excv.cpp b/src/USER-CGDNA/pair_oxdna_excv.cpp index 719a63b5f4..82af5ed1c7 100644 --- a/src/USER-CGDNA/pair_oxdna_excv.cpp +++ b/src/USER-CGDNA/pair_oxdna_excv.cpp @@ -144,8 +144,7 @@ void PairOxdnaExcv::compute(int eflag, int vflag) int a,b,ia,ib,anum,bnum,atype,btype; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); anum = list->inum; alist = list->ilist; diff --git a/src/USER-CGDNA/pair_oxdna_hbond.cpp b/src/USER-CGDNA/pair_oxdna_hbond.cpp index d8305e30de..d2aa236a05 100644 --- a/src/USER-CGDNA/pair_oxdna_hbond.cpp +++ b/src/USER-CGDNA/pair_oxdna_hbond.cpp @@ -161,8 +161,7 @@ void PairOxdnaHbond::compute(int eflag, int vflag) double df1,df4t1,df4t4,df4t2,df4t3,df4t7,df4t8; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); anum = list->inum; alist = list->ilist; diff --git a/src/USER-CGDNA/pair_oxdna_stk.cpp b/src/USER-CGDNA/pair_oxdna_stk.cpp index f713e4d27c..4cbc0317dd 100644 --- a/src/USER-CGDNA/pair_oxdna_stk.cpp +++ b/src/USER-CGDNA/pair_oxdna_stk.cpp @@ -154,8 +154,7 @@ void PairOxdnaStk::compute(int eflag, int vflag) double tptofp; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // loop over stacking interaction neighours using bond topology diff --git a/src/USER-CGDNA/pair_oxdna_xstk.cpp b/src/USER-CGDNA/pair_oxdna_xstk.cpp index a354a604fd..071886556c 100644 --- a/src/USER-CGDNA/pair_oxdna_xstk.cpp +++ b/src/USER-CGDNA/pair_oxdna_xstk.cpp @@ -153,8 +153,7 @@ void PairOxdnaXstk::compute(int eflag, int vflag) double df2,df4t1,df4t4,df4t2,df4t3,df4t7,df4t8,rsint; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); anum = list->inum; alist = list->ilist; diff --git a/src/USER-CGSDK/pair_lj_sdk.cpp b/src/USER-CGSDK/pair_lj_sdk.cpp index 3404beb58a..7dd6c04436 100644 --- a/src/USER-CGSDK/pair_lj_sdk.cpp +++ b/src/USER-CGSDK/pair_lj_sdk.cpp @@ -78,9 +78,7 @@ PairLJSDK::~PairLJSDK() void PairLJSDK::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/USER-CGSDK/pair_lj_sdk_coul_long.cpp b/src/USER-CGSDK/pair_lj_sdk_coul_long.cpp index c51235518b..33a1659df9 100644 --- a/src/USER-CGSDK/pair_lj_sdk_coul_long.cpp +++ b/src/USER-CGSDK/pair_lj_sdk_coul_long.cpp @@ -90,9 +90,7 @@ PairLJSDKCoulLong::~PairLJSDKCoulLong() void PairLJSDKCoulLong::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/USER-CGSDK/pair_lj_sdk_coul_msm.cpp b/src/USER-CGSDK/pair_lj_sdk_coul_msm.cpp index c4882fdbdb..d26f8efcdc 100644 --- a/src/USER-CGSDK/pair_lj_sdk_coul_msm.cpp +++ b/src/USER-CGSDK/pair_lj_sdk_coul_msm.cpp @@ -57,9 +57,7 @@ void PairLJSDKCoulMSM::compute(int eflag, int vflag) if (force->kspace->scalar_pressure_flag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' with Pair style"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (evflag) { if (eflag) { diff --git a/src/USER-DPD/pair_dpd_fdt.cpp b/src/USER-DPD/pair_dpd_fdt.cpp index 12e6d9f257..07ef8190f0 100644 --- a/src/USER-DPD/pair_dpd_fdt.cpp +++ b/src/USER-DPD/pair_dpd_fdt.cpp @@ -76,8 +76,7 @@ void PairDPDfdt::compute(int eflag, int vflag) double gamma_ij; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/USER-DPD/pair_dpd_fdt_energy.cpp b/src/USER-DPD/pair_dpd_fdt_energy.cpp index 42c23e3ad2..12e6989c00 100644 --- a/src/USER-DPD/pair_dpd_fdt_energy.cpp +++ b/src/USER-DPD/pair_dpd_fdt_energy.cpp @@ -85,8 +85,7 @@ void PairDPDfdtEnergy::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/USER-DPD/pair_exp6_rx.cpp b/src/USER-DPD/pair_exp6_rx.cpp index 0251f019c5..13521b52b1 100644 --- a/src/USER-DPD/pair_exp6_rx.cpp +++ b/src/USER-DPD/pair_exp6_rx.cpp @@ -121,8 +121,7 @@ void PairExp6rx::compute(int eflag, int vflag) evdwlOld = 0.0; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-DPD/pair_multi_lucy.cpp b/src/USER-DPD/pair_multi_lucy.cpp index 19a4a02f0b..ffc1562f88 100644 --- a/src/USER-DPD/pair_multi_lucy.cpp +++ b/src/USER-DPD/pair_multi_lucy.cpp @@ -95,8 +95,7 @@ void PairMultiLucy::compute(int eflag, int vflag) int tlm1 = tablength - 1; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-DPD/pair_multi_lucy_rx.cpp b/src/USER-DPD/pair_multi_lucy_rx.cpp index f3ad86eb2f..801e8ff039 100644 --- a/src/USER-DPD/pair_multi_lucy_rx.cpp +++ b/src/USER-DPD/pair_multi_lucy_rx.cpp @@ -111,8 +111,7 @@ void PairMultiLucyRX::compute(int eflag, int vflag) evdwlOld = 0.0; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-DPD/pair_table_rx.cpp b/src/USER-DPD/pair_table_rx.cpp index 1e7bc440d1..f2d0d7b1fb 100644 --- a/src/USER-DPD/pair_table_rx.cpp +++ b/src/USER-DPD/pair_table_rx.cpp @@ -78,8 +78,7 @@ void PairTableRX::compute(int eflag, int vflag) evdwlOld = 0.0; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp index f9da40dfb9..1ebe4a4c2d 100644 --- a/src/USER-DRUDE/pair_lj_cut_thole_long.cpp +++ b/src/USER-DRUDE/pair_lj_cut_thole_long.cpp @@ -98,8 +98,7 @@ void PairLJCutTholeLong::compute(int eflag, int vflag) int di_closest; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-DRUDE/pair_thole.cpp b/src/USER-DRUDE/pair_thole.cpp index 5a518d819b..1bb75af825 100644 --- a/src/USER-DRUDE/pair_thole.cpp +++ b/src/USER-DRUDE/pair_thole.cpp @@ -64,8 +64,7 @@ void PairThole::compute(int eflag, int vflag) double dcoul,asr,exp_asr; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-EFF/pair_eff_cut.cpp b/src/USER-EFF/pair_eff_cut.cpp index b4e9011e33..f566922ef7 100644 --- a/src/USER-EFF/pair_eff_cut.cpp +++ b/src/USER-EFF/pair_eff_cut.cpp @@ -81,8 +81,7 @@ void PairEffCut::compute(int eflag, int vflag) // pvector = [KE, Pauli, ecoul, radial_restraint] for (i=0; i<4; i++) pvector[i] = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_coul_cut_soft.cpp b/src/USER-FEP/pair_coul_cut_soft.cpp index 529ffe6b09..86a6d02819 100644 --- a/src/USER-FEP/pair_coul_cut_soft.cpp +++ b/src/USER-FEP/pair_coul_cut_soft.cpp @@ -60,8 +60,7 @@ void PairCoulCutSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_coul_long_soft.cpp b/src/USER-FEP/pair_coul_long_soft.cpp index e45dbe72d6..9d3ffc0da1 100644 --- a/src/USER-FEP/pair_coul_long_soft.cpp +++ b/src/USER-FEP/pair_coul_long_soft.cpp @@ -78,8 +78,7 @@ void PairCoulLongSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_charmm_coul_long_soft.cpp b/src/USER-FEP/pair_lj_charmm_coul_long_soft.cpp index 34758b159b..ac6f1e6384 100644 --- a/src/USER-FEP/pair_lj_charmm_coul_long_soft.cpp +++ b/src/USER-FEP/pair_lj_charmm_coul_long_soft.cpp @@ -92,8 +92,7 @@ void PairLJCharmmCoulLongSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -415,8 +414,7 @@ void PairLJCharmmCoulLongSoft::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp b/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp index 7970097cfe..54643f7305 100644 --- a/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp +++ b/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp @@ -72,8 +72,7 @@ void PairLJClass2CoulCutSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp b/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp index 13096a64c6..4dfafbb268 100644 --- a/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp +++ b/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp @@ -82,8 +82,7 @@ void PairLJClass2CoulLongSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_class2_soft.cpp b/src/USER-FEP/pair_lj_class2_soft.cpp index b7f21fc59c..858e5a727e 100644 --- a/src/USER-FEP/pair_lj_class2_soft.cpp +++ b/src/USER-FEP/pair_lj_class2_soft.cpp @@ -68,8 +68,7 @@ void PairLJClass2Soft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_cut_coul_cut_soft.cpp b/src/USER-FEP/pair_lj_cut_coul_cut_soft.cpp index fc887fbec5..35c9162dbc 100644 --- a/src/USER-FEP/pair_lj_cut_coul_cut_soft.cpp +++ b/src/USER-FEP/pair_lj_cut_coul_cut_soft.cpp @@ -73,8 +73,7 @@ void PairLJCutCoulCutSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_cut_coul_long_soft.cpp b/src/USER-FEP/pair_lj_cut_coul_long_soft.cpp index a9032ab4d7..79253d2b9c 100644 --- a/src/USER-FEP/pair_lj_cut_coul_long_soft.cpp +++ b/src/USER-FEP/pair_lj_cut_coul_long_soft.cpp @@ -89,8 +89,7 @@ void PairLJCutCoulLongSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -390,8 +389,7 @@ void PairLJCutCoulLongSoft::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_cut_soft.cpp b/src/USER-FEP/pair_lj_cut_soft.cpp index 1322565473..4192d6546b 100644 --- a/src/USER-FEP/pair_lj_cut_soft.cpp +++ b/src/USER-FEP/pair_lj_cut_soft.cpp @@ -77,8 +77,7 @@ void PairLJCutSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -323,8 +322,7 @@ void PairLJCutSoft::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_lj_cut_tip4p_long_soft.cpp b/src/USER-FEP/pair_lj_cut_tip4p_long_soft.cpp index 8653800ee6..8ac28f9fa9 100644 --- a/src/USER-FEP/pair_lj_cut_tip4p_long_soft.cpp +++ b/src/USER-FEP/pair_lj_cut_tip4p_long_soft.cpp @@ -92,8 +92,7 @@ void PairLJCutTIP4PLongSoft::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/USER-FEP/pair_morse_soft.cpp b/src/USER-FEP/pair_morse_soft.cpp index f4c5a4b910..21f616a082 100644 --- a/src/USER-FEP/pair_morse_soft.cpp +++ b/src/USER-FEP/pair_morse_soft.cpp @@ -53,8 +53,7 @@ void PairMorseSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-FEP/pair_tip4p_long_soft.cpp b/src/USER-FEP/pair_tip4p_long_soft.cpp index 5e8c5000f8..9b6a6841fe 100644 --- a/src/USER-FEP/pair_tip4p_long_soft.cpp +++ b/src/USER-FEP/pair_tip4p_long_soft.cpp @@ -91,8 +91,7 @@ void PairTIP4PLongSoft::compute(int eflag, int vflag) double rsq; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh & newsite if necessary // initialize hneigh[0] to -1 on steps when reneighboring occurred diff --git a/src/USER-INTEL/pair_airebo_intel.cpp b/src/USER-INTEL/pair_airebo_intel.cpp index 198f8798fa..f330e3ec86 100644 --- a/src/USER-INTEL/pair_airebo_intel.cpp +++ b/src/USER-INTEL/pair_airebo_intel.cpp @@ -292,8 +292,7 @@ template void PairAIREBOIntel::compute( int eflag, int vflag, IntelBuffers * buffers ) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); pvector[0] = pvector[1] = pvector[2] = 0.0; const int inum = list->inum; diff --git a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp index f82f4c1c7a..3f2d64fb93 100644 --- a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp @@ -73,9 +73,7 @@ void PairBuckCoulCutIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_buck_coul_long_intel.cpp b/src/USER-INTEL/pair_buck_coul_long_intel.cpp index 059413c3d9..2ddcd55663 100644 --- a/src/USER-INTEL/pair_buck_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_long_intel.cpp @@ -73,9 +73,7 @@ void PairBuckCoulLongIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_buck_intel.cpp b/src/USER-INTEL/pair_buck_intel.cpp index 0e0bd0f56f..34af3462e2 100644 --- a/src/USER-INTEL/pair_buck_intel.cpp +++ b/src/USER-INTEL/pair_buck_intel.cpp @@ -66,9 +66,7 @@ void PairBuckIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_dpd_intel.cpp b/src/USER-INTEL/pair_dpd_intel.cpp index 5d67a60c4b..016f3b5ca0 100644 --- a/src/USER-INTEL/pair_dpd_intel.cpp +++ b/src/USER-INTEL/pair_dpd_intel.cpp @@ -82,9 +82,7 @@ void PairDPDIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag, vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_eam_intel.cpp b/src/USER-INTEL/pair_eam_intel.cpp index 95d0272d33..7f4806c87c 100644 --- a/src/USER-INTEL/pair_eam_intel.cpp +++ b/src/USER-INTEL/pair_eam_intel.cpp @@ -78,9 +78,7 @@ void PairEAMIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag, vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_gayberne_intel.cpp b/src/USER-INTEL/pair_gayberne_intel.cpp index 51524355d5..1d9ee7d4cd 100644 --- a/src/USER-INTEL/pair_gayberne_intel.cpp +++ b/src/USER-INTEL/pair_gayberne_intel.cpp @@ -72,9 +72,7 @@ void PairGayBerneIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag, vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); const int inum = list->inum; const int nall = atom->nlocal + atom->nghost; diff --git a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp index 0b6ac3ffa5..9689c0bf50 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -66,9 +66,7 @@ void PairLJCharmmCoulCharmmIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp index 753a9afdd9..8de4ced549 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -70,9 +70,7 @@ void PairLJCharmmCoulLongIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp index 35ed9061ce..8ad1823d97 100644 --- a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp @@ -71,9 +71,7 @@ void PairLJCutCoulLongIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_lj_cut_intel.cpp b/src/USER-INTEL/pair_lj_cut_intel.cpp index 94133a7f47..74dae7e096 100644 --- a/src/USER-INTEL/pair_lj_cut_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_intel.cpp @@ -62,9 +62,7 @@ void PairLJCutIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag, vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_sw_intel.cpp b/src/USER-INTEL/pair_sw_intel.cpp index 9e00516087..8482895fb6 100644 --- a/src/USER-INTEL/pair_sw_intel.cpp +++ b/src/USER-INTEL/pair_sw_intel.cpp @@ -95,9 +95,7 @@ void PairSWIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag, vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-INTEL/pair_tersoff_intel.cpp b/src/USER-INTEL/pair_tersoff_intel.cpp index 5d4c5f2cb6..668cb0cf33 100644 --- a/src/USER-INTEL/pair_tersoff_intel.cpp +++ b/src/USER-INTEL/pair_tersoff_intel.cpp @@ -107,9 +107,7 @@ void PairTersoffIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int inum = list->inum; const int nthreads = comm->nthreads; diff --git a/src/USER-MEAMC/pair_meamc.cpp b/src/USER-MEAMC/pair_meamc.cpp index d0d97740b3..3a934694bf 100644 --- a/src/USER-MEAMC/pair_meamc.cpp +++ b/src/USER-MEAMC/pair_meamc.cpp @@ -93,8 +93,7 @@ void PairMEAMC::compute(int eflag, int vflag) int *ilist_half,*numneigh_half,**firstneigh_half; int *numneigh_full,**firstneigh_full; - if (eflag || vflag) ev_setup(eflag,vflag); - else ev_unset(); + ev_init(eflag,vflag); // neighbor list info diff --git a/src/USER-MESO/pair_edpd.cpp b/src/USER-MESO/pair_edpd.cpp index 1f6222944a..e428b02822 100644 --- a/src/USER-MESO/pair_edpd.cpp +++ b/src/USER-MESO/pair_edpd.cpp @@ -99,8 +99,7 @@ PairEDPD::~PairEDPD() void PairEDPD::compute(int eflag, int vflag) { double evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/USER-MESO/pair_mdpd.cpp b/src/USER-MESO/pair_mdpd.cpp index f9acd3dbe1..4102499d46 100644 --- a/src/USER-MESO/pair_mdpd.cpp +++ b/src/USER-MESO/pair_mdpd.cpp @@ -88,8 +88,7 @@ void PairMDPD::compute(int eflag, int vflag) double rhoi, rhoj; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/USER-MESO/pair_mdpd_rhosum.cpp b/src/USER-MESO/pair_mdpd_rhosum.cpp index 806a63f898..2fd238088c 100644 --- a/src/USER-MESO/pair_mdpd_rhosum.cpp +++ b/src/USER-MESO/pair_mdpd_rhosum.cpp @@ -84,10 +84,7 @@ void PairMDPDRhoSum::compute(int eflag, int vflag) { // neighbor list variables int inum, *ilist, *numneigh, **firstneigh; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **x = atom->x; double *rho = atom->rho; diff --git a/src/USER-MESO/pair_tdpd.cpp b/src/USER-MESO/pair_tdpd.cpp index a41282c0d8..7df9d6d163 100644 --- a/src/USER-MESO/pair_tdpd.cpp +++ b/src/USER-MESO/pair_tdpd.cpp @@ -91,8 +91,7 @@ PairTDPD::~PairTDPD() void PairTDPD::compute(int eflag, int vflag) { double evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index 347bc9cc69..91c624eec5 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -1673,8 +1673,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, void PairMGPT::compute(int eflag, int vflag) { - if(eflag || vflag) ev_setup(eflag, vflag); - else evflag = vflag_fdotr = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag, vflag); int newton_pair = force->newton_pair; double e_s,e_p,e_t,e_q; diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index 0277969d15..21a6f1deee 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -136,8 +136,7 @@ void PairAGNI::compute(int eflag, int vflag) double rsq; int *ilist,*jlist,*numneigh,**firstneigh; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_buck_mdf.cpp b/src/USER-MISC/pair_buck_mdf.cpp index 38de1c7c50..b5e81417ee 100644 --- a/src/USER-MISC/pair_buck_mdf.cpp +++ b/src/USER-MISC/pair_buck_mdf.cpp @@ -68,8 +68,7 @@ void PairBuckMDF::compute(int eflag, int vflag) double dp, d, tt, dt, dd; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_coul_diel.cpp b/src/USER-MISC/pair_coul_diel.cpp index 0154e89731..a86921d296 100644 --- a/src/USER-MISC/pair_coul_diel.cpp +++ b/src/USER-MISC/pair_coul_diel.cpp @@ -58,8 +58,7 @@ void PairCoulDiel::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_coul_shield.cpp b/src/USER-MISC/pair_coul_shield.cpp index 11df975c19..f74dcfe7d8 100644 --- a/src/USER-MISC/pair_coul_shield.cpp +++ b/src/USER-MISC/pair_coul_shield.cpp @@ -64,8 +64,7 @@ void PairCoulShield::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index 491268567f..0b5220fdfd 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -149,8 +149,7 @@ void PairEDIP::compute(int eflag, int vflag) double potential2B_factor; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index f56650d2f6..ab48fbaa73 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -118,8 +118,7 @@ void PairEDIPMulti::compute(int eflag, int vflag) // vflag != 0 means compute virial contributions in this step evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index 364fd45016..132b857dde 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -190,8 +190,7 @@ void PairExTeP::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); SR_neigh(); diff --git a/src/USER-MISC/pair_gauss_cut.cpp b/src/USER-MISC/pair_gauss_cut.cpp index a000eff028..24d0b191d8 100644 --- a/src/USER-MISC/pair_gauss_cut.cpp +++ b/src/USER-MISC/pair_gauss_cut.cpp @@ -69,8 +69,7 @@ void PairGaussCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index 6257c1d72b..d1b8a3be38 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -117,8 +117,7 @@ void PairILPGrapheneHBN::compute(int eflag, int vflag) int *ILP_neighs_i,*ILP_neighs_j; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index cbcf6c7934..289ed19bd3 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -115,8 +115,7 @@ void PairKolmogorovCrespiFull::compute(int eflag, int vflag) int *KC_neighs_i,*KC_neighs_j; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index e9583032fe..dcea990a3b 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -87,8 +87,7 @@ void PairKolmogorovCrespiZ::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index 5153857c2f..0ab22e04c1 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -87,8 +87,7 @@ void PairLebedevaZ::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_lennard_mdf.cpp b/src/USER-MISC/pair_lennard_mdf.cpp index 4bc2da23f8..b51639e80e 100644 --- a/src/USER-MISC/pair_lennard_mdf.cpp +++ b/src/USER-MISC/pair_lennard_mdf.cpp @@ -65,8 +65,7 @@ void PairLJ_AB_MDF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_list.cpp b/src/USER-MISC/pair_list.cpp index aaeb586c1d..562a60aa99 100644 --- a/src/USER-MISC/pair_list.cpp +++ b/src/USER-MISC/pair_list.cpp @@ -80,9 +80,7 @@ PairList::~PairList() void PairList::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = - vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int newton_pair = force->newton_pair; diff --git a/src/USER-MISC/pair_lj_expand_coul_long.cpp b/src/USER-MISC/pair_lj_expand_coul_long.cpp index 79a3c2a497..fe21538f2d 100644 --- a/src/USER-MISC/pair_lj_expand_coul_long.cpp +++ b/src/USER-MISC/pair_lj_expand_coul_long.cpp @@ -91,8 +91,7 @@ void PairLJExpandCoulLong::compute(int eflag, int vflag) double rsq,rshift,rshiftsq,rshift2inv; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -412,8 +411,7 @@ void PairLJExpandCoulLong::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_lj_mdf.cpp b/src/USER-MISC/pair_lj_mdf.cpp index 4cd21b1dbe..ca0118ffb0 100644 --- a/src/USER-MISC/pair_lj_mdf.cpp +++ b/src/USER-MISC/pair_lj_mdf.cpp @@ -65,8 +65,7 @@ void PairLJMDF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_lj_sf_dipole_sf.cpp b/src/USER-MISC/pair_lj_sf_dipole_sf.cpp index 523b2ca71a..af7d23370d 100644 --- a/src/USER-MISC/pair_lj_sf_dipole_sf.cpp +++ b/src/USER-MISC/pair_lj_sf_dipole_sf.cpp @@ -79,8 +79,7 @@ void PairLJSFDipoleSF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index 0300e2c7a2..f09919ce0f 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -103,12 +103,7 @@ void PairMEAMSpline::compute(int eflag, int vflag) double* const * const forces = atom->f; const int ntypes = atom->ntypes; - if (eflag || vflag) { - ev_setup(eflag, vflag); - } else { - evflag = vflag_fdotr = eflag_global = 0; - vflag_global = eflag_atom = vflag_atom = 0; - } + ev_init(eflag, vflag); // Grow per-atom array if necessary diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index e17c13865d..af1e8788bd 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -85,9 +85,7 @@ PairMEAMSWSpline::~PairMEAMSWSpline() void PairMEAMSWSpline::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag, vflag); - else evflag = vflag_fdotr = - eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag, vflag); double cutforcesq = cutoff*cutoff; diff --git a/src/USER-MISC/pair_momb.cpp b/src/USER-MISC/pair_momb.cpp index 927181ebf6..1716149a98 100644 --- a/src/USER-MISC/pair_momb.cpp +++ b/src/USER-MISC/pair_momb.cpp @@ -81,8 +81,7 @@ void PairMomb::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_morse_smooth_linear.cpp b/src/USER-MISC/pair_morse_smooth_linear.cpp index a88e7a1a27..7c7973f830 100644 --- a/src/USER-MISC/pair_morse_smooth_linear.cpp +++ b/src/USER-MISC/pair_morse_smooth_linear.cpp @@ -60,8 +60,7 @@ void PairMorseSmoothLinear::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_srp.cpp b/src/USER-MISC/pair_srp.cpp index 8f34e846c5..01deaf0fbe 100644 --- a/src/USER-MISC/pair_srp.cpp +++ b/src/USER-MISC/pair_srp.cpp @@ -143,10 +143,7 @@ void PairSRP::compute(int eflag, int vflag) { // setup energy and virial - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index d1044cc336..e0985d1dce 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -117,8 +117,7 @@ void PairTersoffTable::compute(int eflag, int vflag) double evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp b/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp index 1fc4644420..bb025e4e1e 100644 --- a/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp +++ b/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp @@ -87,8 +87,7 @@ void PairBuck6dCoulGaussDSF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp b/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp index 1ca42d864e..df54925f4e 100644 --- a/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp +++ b/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp @@ -89,8 +89,7 @@ void PairBuck6dCoulGaussLong::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-OMP/pair_adp_omp.cpp b/src/USER-OMP/pair_adp_omp.cpp index 264169773b..645d697994 100644 --- a/src/USER-OMP/pair_adp_omp.cpp +++ b/src/USER-OMP/pair_adp_omp.cpp @@ -39,9 +39,7 @@ PairADPOMP::PairADPOMP(LAMMPS *lmp) : void PairADPOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_agni_omp.cpp b/src/USER-OMP/pair_agni_omp.cpp index e8f003ea88..854bcbebf3 100644 --- a/src/USER-OMP/pair_agni_omp.cpp +++ b/src/USER-OMP/pair_agni_omp.cpp @@ -42,9 +42,7 @@ PairAGNIOMP::PairAGNIOMP(LAMMPS *lmp) : void PairAGNIOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_airebo_omp.cpp b/src/USER-OMP/pair_airebo_omp.cpp index ec5c02d727..bed6c81ee4 100644 --- a/src/USER-OMP/pair_airebo_omp.cpp +++ b/src/USER-OMP/pair_airebo_omp.cpp @@ -49,9 +49,7 @@ void PairAIREBOOMP::compute(int eflag, int vflag) { double pv0=0.0,pv1=0.0,pv2=0.0; - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); REBO_neigh_thr(); diff --git a/src/USER-OMP/pair_beck_omp.cpp b/src/USER-OMP/pair_beck_omp.cpp index 1494ec2987..90c3777932 100644 --- a/src/USER-OMP/pair_beck_omp.cpp +++ b/src/USER-OMP/pair_beck_omp.cpp @@ -38,9 +38,7 @@ PairBeckOMP::PairBeckOMP(LAMMPS *lmp) : void PairBeckOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_born_coul_long_omp.cpp b/src/USER-OMP/pair_born_coul_long_omp.cpp index f198184406..a5df8f8182 100644 --- a/src/USER-OMP/pair_born_coul_long_omp.cpp +++ b/src/USER-OMP/pair_born_coul_long_omp.cpp @@ -44,9 +44,7 @@ PairBornCoulLongOMP::PairBornCoulLongOMP(LAMMPS *lmp) : void PairBornCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_born_coul_msm_omp.cpp b/src/USER-OMP/pair_born_coul_msm_omp.cpp index 1b4757359f..ad1e5e63cd 100644 --- a/src/USER-OMP/pair_born_coul_msm_omp.cpp +++ b/src/USER-OMP/pair_born_coul_msm_omp.cpp @@ -41,9 +41,7 @@ void PairBornCoulMSMOMP::compute(int eflag, int vflag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' " "with OMP MSM Pair styles"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_born_coul_wolf_omp.cpp b/src/USER-OMP/pair_born_coul_wolf_omp.cpp index 7904181ba5..567eddc9cb 100644 --- a/src/USER-OMP/pair_born_coul_wolf_omp.cpp +++ b/src/USER-OMP/pair_born_coul_wolf_omp.cpp @@ -38,9 +38,7 @@ PairBornCoulWolfOMP::PairBornCoulWolfOMP(LAMMPS *lmp) : void PairBornCoulWolfOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_born_omp.cpp b/src/USER-OMP/pair_born_omp.cpp index f75d4b9f35..fce2013745 100644 --- a/src/USER-OMP/pair_born_omp.cpp +++ b/src/USER-OMP/pair_born_omp.cpp @@ -36,9 +36,7 @@ PairBornOMP::PairBornOMP(LAMMPS *lmp) : void PairBornOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_brownian_omp.cpp b/src/USER-OMP/pair_brownian_omp.cpp index b1af821bba..cef9fb0955 100644 --- a/src/USER-OMP/pair_brownian_omp.cpp +++ b/src/USER-OMP/pair_brownian_omp.cpp @@ -68,9 +68,7 @@ PairBrownianOMP::~PairBrownianOMP() void PairBrownianOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int inum = list->inum; diff --git a/src/USER-OMP/pair_brownian_poly_omp.cpp b/src/USER-OMP/pair_brownian_poly_omp.cpp index 2e677ed535..239a820242 100644 --- a/src/USER-OMP/pair_brownian_poly_omp.cpp +++ b/src/USER-OMP/pair_brownian_poly_omp.cpp @@ -68,9 +68,7 @@ PairBrownianPolyOMP::~PairBrownianPolyOMP() void PairBrownianPolyOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int inum = list->inum; diff --git a/src/USER-OMP/pair_buck_coul_cut_omp.cpp b/src/USER-OMP/pair_buck_coul_cut_omp.cpp index 8fa6be06b2..b9b77dc2b6 100644 --- a/src/USER-OMP/pair_buck_coul_cut_omp.cpp +++ b/src/USER-OMP/pair_buck_coul_cut_omp.cpp @@ -36,9 +36,7 @@ PairBuckCoulCutOMP::PairBuckCoulCutOMP(LAMMPS *lmp) : void PairBuckCoulCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_buck_coul_long_omp.cpp b/src/USER-OMP/pair_buck_coul_long_omp.cpp index 4d30eb3e82..951ba0688c 100644 --- a/src/USER-OMP/pair_buck_coul_long_omp.cpp +++ b/src/USER-OMP/pair_buck_coul_long_omp.cpp @@ -44,9 +44,7 @@ PairBuckCoulLongOMP::PairBuckCoulLongOMP(LAMMPS *lmp) : void PairBuckCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_buck_coul_msm_omp.cpp b/src/USER-OMP/pair_buck_coul_msm_omp.cpp index a8bca36394..6226191627 100644 --- a/src/USER-OMP/pair_buck_coul_msm_omp.cpp +++ b/src/USER-OMP/pair_buck_coul_msm_omp.cpp @@ -41,9 +41,7 @@ void PairBuckCoulMSMOMP::compute(int eflag, int vflag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' " "with OMP MSM Pair styles"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_buck_long_coul_long_omp.cpp b/src/USER-OMP/pair_buck_long_coul_long_omp.cpp index acb95ab76c..20d380a464 100644 --- a/src/USER-OMP/pair_buck_long_coul_long_omp.cpp +++ b/src/USER-OMP/pair_buck_long_coul_long_omp.cpp @@ -46,9 +46,8 @@ PairBuckLongCoulLongOMP::PairBuckLongCoulLongOMP(LAMMPS *lmp) : void PairBuckLongCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); + const int order1 = ewald_order&(1<<1); const int order6 = ewald_order&(1<<6); diff --git a/src/USER-OMP/pair_buck_omp.cpp b/src/USER-OMP/pair_buck_omp.cpp index f3fa32a5ea..cc7e81b9c5 100644 --- a/src/USER-OMP/pair_buck_omp.cpp +++ b/src/USER-OMP/pair_buck_omp.cpp @@ -36,9 +36,7 @@ PairBuckOMP::PairBuckOMP(LAMMPS *lmp) : void PairBuckOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_colloid_omp.cpp b/src/USER-OMP/pair_colloid_omp.cpp index 536b7644bd..64613cb31d 100644 --- a/src/USER-OMP/pair_colloid_omp.cpp +++ b/src/USER-OMP/pair_colloid_omp.cpp @@ -39,9 +39,7 @@ PairColloidOMP::PairColloidOMP(LAMMPS *lmp) : void PairColloidOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_comb_omp.cpp b/src/USER-OMP/pair_comb_omp.cpp index 8a77ab955f..be641dd0b9 100644 --- a/src/USER-OMP/pair_comb_omp.cpp +++ b/src/USER-OMP/pair_comb_omp.cpp @@ -41,9 +41,7 @@ PairCombOMP::PairCombOMP(LAMMPS *lmp) : void PairCombOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_cut_omp.cpp b/src/USER-OMP/pair_coul_cut_omp.cpp index b9ac72421e..056daf210a 100644 --- a/src/USER-OMP/pair_coul_cut_omp.cpp +++ b/src/USER-OMP/pair_coul_cut_omp.cpp @@ -36,9 +36,7 @@ PairCoulCutOMP::PairCoulCutOMP(LAMMPS *lmp) : void PairCoulCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_cut_soft_omp.cpp b/src/USER-OMP/pair_coul_cut_soft_omp.cpp index c7e8c5e560..70997da62b 100644 --- a/src/USER-OMP/pair_coul_cut_soft_omp.cpp +++ b/src/USER-OMP/pair_coul_cut_soft_omp.cpp @@ -36,9 +36,7 @@ PairCoulCutSoftOMP::PairCoulCutSoftOMP(LAMMPS *lmp) : void PairCoulCutSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_debye_omp.cpp b/src/USER-OMP/pair_coul_debye_omp.cpp index cb7a9025ce..d202e314bf 100644 --- a/src/USER-OMP/pair_coul_debye_omp.cpp +++ b/src/USER-OMP/pair_coul_debye_omp.cpp @@ -36,9 +36,7 @@ PairCoulDebyeOMP::PairCoulDebyeOMP(LAMMPS *lmp) : void PairCoulDebyeOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_diel_omp.cpp b/src/USER-OMP/pair_coul_diel_omp.cpp index c75e36b55e..f2bb6a46bf 100644 --- a/src/USER-OMP/pair_coul_diel_omp.cpp +++ b/src/USER-OMP/pair_coul_diel_omp.cpp @@ -36,9 +36,7 @@ PairCoulDielOMP::PairCoulDielOMP(LAMMPS *lmp) : void PairCoulDielOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_dsf_omp.cpp b/src/USER-OMP/pair_coul_dsf_omp.cpp index 740e3242ad..217fb844c3 100644 --- a/src/USER-OMP/pair_coul_dsf_omp.cpp +++ b/src/USER-OMP/pair_coul_dsf_omp.cpp @@ -46,9 +46,7 @@ PairCoulDSFOMP::PairCoulDSFOMP(LAMMPS *lmp) : void PairCoulDSFOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_long_omp.cpp b/src/USER-OMP/pair_coul_long_omp.cpp index eb74bb9615..1e3170c73c 100644 --- a/src/USER-OMP/pair_coul_long_omp.cpp +++ b/src/USER-OMP/pair_coul_long_omp.cpp @@ -45,9 +45,7 @@ PairCoulLongOMP::PairCoulLongOMP(LAMMPS *lmp) : void PairCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_long_soft_omp.cpp b/src/USER-OMP/pair_coul_long_soft_omp.cpp index 4e65483a17..dd1fc1030d 100644 --- a/src/USER-OMP/pair_coul_long_soft_omp.cpp +++ b/src/USER-OMP/pair_coul_long_soft_omp.cpp @@ -44,9 +44,7 @@ PairCoulLongSoftOMP::PairCoulLongSoftOMP(LAMMPS *lmp) : void PairCoulLongSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_msm_omp.cpp b/src/USER-OMP/pair_coul_msm_omp.cpp index f4bc279532..9b50b86954 100644 --- a/src/USER-OMP/pair_coul_msm_omp.cpp +++ b/src/USER-OMP/pair_coul_msm_omp.cpp @@ -42,9 +42,7 @@ void PairCoulMSMOMP::compute(int eflag, int vflag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' with " "OMP MSM Pair styles"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_coul_wolf_omp.cpp b/src/USER-OMP/pair_coul_wolf_omp.cpp index bc86cdbf5d..0913a2b188 100644 --- a/src/USER-OMP/pair_coul_wolf_omp.cpp +++ b/src/USER-OMP/pair_coul_wolf_omp.cpp @@ -38,9 +38,7 @@ PairCoulWolfOMP::PairCoulWolfOMP(LAMMPS *lmp) : void PairCoulWolfOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_dpd_omp.cpp b/src/USER-OMP/pair_dpd_omp.cpp index 29b5568def..77db3d9183 100644 --- a/src/USER-OMP/pair_dpd_omp.cpp +++ b/src/USER-OMP/pair_dpd_omp.cpp @@ -55,9 +55,7 @@ PairDPDOMP::~PairDPDOMP() void PairDPDOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int inum = list->inum; diff --git a/src/USER-OMP/pair_dpd_tstat_omp.cpp b/src/USER-OMP/pair_dpd_tstat_omp.cpp index 0a9e96fa0c..d7233a16c5 100644 --- a/src/USER-OMP/pair_dpd_tstat_omp.cpp +++ b/src/USER-OMP/pair_dpd_tstat_omp.cpp @@ -55,9 +55,7 @@ PairDPDTstatOMP::~PairDPDTstatOMP() void PairDPDTstatOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int inum = list->inum; diff --git a/src/USER-OMP/pair_eam_cd_omp.cpp b/src/USER-OMP/pair_eam_cd_omp.cpp index 68c01c83d2..51b83f3bf5 100644 --- a/src/USER-OMP/pair_eam_cd_omp.cpp +++ b/src/USER-OMP/pair_eam_cd_omp.cpp @@ -55,9 +55,7 @@ PairEAMCDOMP::PairEAMCDOMP(LAMMPS *lmp, int _cdeamVersion) : void PairEAMCDOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_eam_omp.cpp b/src/USER-OMP/pair_eam_omp.cpp index 492ff79769..99417f27da 100644 --- a/src/USER-OMP/pair_eam_omp.cpp +++ b/src/USER-OMP/pair_eam_omp.cpp @@ -39,9 +39,7 @@ PairEAMOMP::PairEAMOMP(LAMMPS *lmp) : void PairEAMOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_edip_omp.cpp b/src/USER-OMP/pair_edip_omp.cpp index 3392160d92..144d893c1c 100644 --- a/src/USER-OMP/pair_edip_omp.cpp +++ b/src/USER-OMP/pair_edip_omp.cpp @@ -43,9 +43,7 @@ PairEDIPOMP::PairEDIPOMP(LAMMPS *lmp) : void PairEDIPOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_eim_omp.cpp b/src/USER-OMP/pair_eim_omp.cpp index 6a3e0bc529..2ecd6f8ec7 100644 --- a/src/USER-OMP/pair_eim_omp.cpp +++ b/src/USER-OMP/pair_eim_omp.cpp @@ -39,9 +39,7 @@ PairEIMOMP::PairEIMOMP(LAMMPS *lmp) : void PairEIMOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_gauss_cut_omp.cpp b/src/USER-OMP/pair_gauss_cut_omp.cpp index 9a41dcc87e..928312240b 100644 --- a/src/USER-OMP/pair_gauss_cut_omp.cpp +++ b/src/USER-OMP/pair_gauss_cut_omp.cpp @@ -36,9 +36,7 @@ PairGaussCutOMP::PairGaussCutOMP(LAMMPS *lmp) : void PairGaussCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_gauss_omp.cpp b/src/USER-OMP/pair_gauss_omp.cpp index 059c77c677..159f1c3e31 100644 --- a/src/USER-OMP/pair_gauss_omp.cpp +++ b/src/USER-OMP/pair_gauss_omp.cpp @@ -37,9 +37,7 @@ PairGaussOMP::PairGaussOMP(LAMMPS *lmp) : void PairGaussOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_gayberne_omp.cpp b/src/USER-OMP/pair_gayberne_omp.cpp index 5b0ff67afe..cfa05745ff 100644 --- a/src/USER-OMP/pair_gayberne_omp.cpp +++ b/src/USER-OMP/pair_gayberne_omp.cpp @@ -38,9 +38,7 @@ PairGayBerneOMP::PairGayBerneOMP(LAMMPS *lmp) : void PairGayBerneOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_gran_hertz_history_omp.cpp b/src/USER-OMP/pair_gran_hertz_history_omp.cpp index 9854b8f9ff..271c70e9b9 100644 --- a/src/USER-OMP/pair_gran_hertz_history_omp.cpp +++ b/src/USER-OMP/pair_gran_hertz_history_omp.cpp @@ -40,9 +40,7 @@ PairGranHertzHistoryOMP::PairGranHertzHistoryOMP(LAMMPS *lmp) : void PairGranHertzHistoryOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_gran_hooke_history_omp.cpp b/src/USER-OMP/pair_gran_hooke_history_omp.cpp index 2327fc815a..9a0e8aab76 100644 --- a/src/USER-OMP/pair_gran_hooke_history_omp.cpp +++ b/src/USER-OMP/pair_gran_hooke_history_omp.cpp @@ -41,9 +41,7 @@ PairGranHookeHistoryOMP::PairGranHookeHistoryOMP(LAMMPS *lmp) : void PairGranHookeHistoryOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int shearupdate = (update->setupflag) ? 0 : 1; diff --git a/src/USER-OMP/pair_gran_hooke_omp.cpp b/src/USER-OMP/pair_gran_hooke_omp.cpp index 876fe9c4de..d226ceaa14 100644 --- a/src/USER-OMP/pair_gran_hooke_omp.cpp +++ b/src/USER-OMP/pair_gran_hooke_omp.cpp @@ -38,9 +38,7 @@ PairGranHookeOMP::PairGranHookeOMP(LAMMPS *lmp) : void PairGranHookeOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_hbond_dreiding_lj_omp.cpp b/src/USER-OMP/pair_hbond_dreiding_lj_omp.cpp index ec9da78b16..ea56ff51b5 100644 --- a/src/USER-OMP/pair_hbond_dreiding_lj_omp.cpp +++ b/src/USER-OMP/pair_hbond_dreiding_lj_omp.cpp @@ -57,9 +57,7 @@ PairHbondDreidingLJOMP::~PairHbondDreidingLJOMP() void PairHbondDreidingLJOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_hbond_dreiding_morse_omp.cpp b/src/USER-OMP/pair_hbond_dreiding_morse_omp.cpp index 4965be43b8..1cff2de3b2 100644 --- a/src/USER-OMP/pair_hbond_dreiding_morse_omp.cpp +++ b/src/USER-OMP/pair_hbond_dreiding_morse_omp.cpp @@ -57,9 +57,7 @@ PairHbondDreidingMorseOMP::~PairHbondDreidingMorseOMP() void PairHbondDreidingMorseOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj96_cut_omp.cpp b/src/USER-OMP/pair_lj96_cut_omp.cpp index 1cca674369..9ba8e09a54 100644 --- a/src/USER-OMP/pair_lj96_cut_omp.cpp +++ b/src/USER-OMP/pair_lj96_cut_omp.cpp @@ -37,9 +37,7 @@ PairLJ96CutOMP::PairLJ96CutOMP(LAMMPS *lmp) : void PairLJ96CutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_charmm_coul_charmm_implicit_omp.cpp b/src/USER-OMP/pair_lj_charmm_coul_charmm_implicit_omp.cpp index 2f72f3851e..3dc9b77c0f 100644 --- a/src/USER-OMP/pair_lj_charmm_coul_charmm_implicit_omp.cpp +++ b/src/USER-OMP/pair_lj_charmm_coul_charmm_implicit_omp.cpp @@ -36,9 +36,7 @@ PairLJCharmmCoulCharmmImplicitOMP::PairLJCharmmCoulCharmmImplicitOMP(LAMMPS *lmp void PairLJCharmmCoulCharmmImplicitOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_charmm_coul_charmm_omp.cpp b/src/USER-OMP/pair_lj_charmm_coul_charmm_omp.cpp index b61a80a178..f9230996f0 100644 --- a/src/USER-OMP/pair_lj_charmm_coul_charmm_omp.cpp +++ b/src/USER-OMP/pair_lj_charmm_coul_charmm_omp.cpp @@ -36,9 +36,7 @@ PairLJCharmmCoulCharmmOMP::PairLJCharmmCoulCharmmOMP(LAMMPS *lmp) : void PairLJCharmmCoulCharmmOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_charmm_coul_long_omp.cpp b/src/USER-OMP/pair_lj_charmm_coul_long_omp.cpp index 5351ab9aea..4bdaa3519f 100644 --- a/src/USER-OMP/pair_lj_charmm_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_charmm_coul_long_omp.cpp @@ -37,9 +37,7 @@ PairLJCharmmCoulLongOMP::PairLJCharmmCoulLongOMP(LAMMPS *lmp) : void PairLJCharmmCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_charmm_coul_long_soft_omp.cpp b/src/USER-OMP/pair_lj_charmm_coul_long_soft_omp.cpp index ea5d739e49..1f6daf052c 100644 --- a/src/USER-OMP/pair_lj_charmm_coul_long_soft_omp.cpp +++ b/src/USER-OMP/pair_lj_charmm_coul_long_soft_omp.cpp @@ -37,9 +37,7 @@ PairLJCharmmCoulLongSoftOMP::PairLJCharmmCoulLongSoftOMP(LAMMPS *lmp) : void PairLJCharmmCoulLongSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_charmm_coul_msm_omp.cpp b/src/USER-OMP/pair_lj_charmm_coul_msm_omp.cpp index 3baa9597a8..eab62d919e 100644 --- a/src/USER-OMP/pair_lj_charmm_coul_msm_omp.cpp +++ b/src/USER-OMP/pair_lj_charmm_coul_msm_omp.cpp @@ -42,9 +42,7 @@ void PairLJCharmmCoulMSMOMP::compute(int eflag, int vflag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' " "with OMP MSM Pair styles"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_class2_coul_cut_omp.cpp b/src/USER-OMP/pair_lj_class2_coul_cut_omp.cpp index 38390918c7..b9ffad134b 100644 --- a/src/USER-OMP/pair_lj_class2_coul_cut_omp.cpp +++ b/src/USER-OMP/pair_lj_class2_coul_cut_omp.cpp @@ -36,9 +36,7 @@ PairLJClass2CoulCutOMP::PairLJClass2CoulCutOMP(LAMMPS *lmp) : void PairLJClass2CoulCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_class2_coul_long_omp.cpp b/src/USER-OMP/pair_lj_class2_coul_long_omp.cpp index f47672c9bc..e5995363ad 100644 --- a/src/USER-OMP/pair_lj_class2_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_class2_coul_long_omp.cpp @@ -44,9 +44,7 @@ PairLJClass2CoulLongOMP::PairLJClass2CoulLongOMP(LAMMPS *lmp) : void PairLJClass2CoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_class2_omp.cpp b/src/USER-OMP/pair_lj_class2_omp.cpp index 7ab4626c3e..67715572ae 100644 --- a/src/USER-OMP/pair_lj_class2_omp.cpp +++ b/src/USER-OMP/pair_lj_class2_omp.cpp @@ -36,9 +36,7 @@ PairLJClass2OMP::PairLJClass2OMP(LAMMPS *lmp) : void PairLJClass2OMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cubic_omp.cpp b/src/USER-OMP/pair_lj_cubic_omp.cpp index 3e8adb33b8..5fa4f92f45 100644 --- a/src/USER-OMP/pair_lj_cubic_omp.cpp +++ b/src/USER-OMP/pair_lj_cubic_omp.cpp @@ -37,9 +37,7 @@ PairLJCubicOMP::PairLJCubicOMP(LAMMPS *lmp) : void PairLJCubicOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_cut_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_cut_omp.cpp index ea560a09bf..69cc2d3042 100644 --- a/src/USER-OMP/pair_lj_cut_coul_cut_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_cut_omp.cpp @@ -36,9 +36,7 @@ PairLJCutCoulCutOMP::PairLJCutCoulCutOMP(LAMMPS *lmp) : void PairLJCutCoulCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_cut_soft_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_cut_soft_omp.cpp index 4ef12bb1bb..5dfa414bd4 100644 --- a/src/USER-OMP/pair_lj_cut_coul_cut_soft_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_cut_soft_omp.cpp @@ -36,9 +36,7 @@ PairLJCutCoulCutSoftOMP::PairLJCutCoulCutSoftOMP(LAMMPS *lmp) : void PairLJCutCoulCutSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_debye_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_debye_omp.cpp index 9163e98edd..4644e565a7 100644 --- a/src/USER-OMP/pair_lj_cut_coul_debye_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_debye_omp.cpp @@ -36,9 +36,7 @@ PairLJCutCoulDebyeOMP::PairLJCutCoulDebyeOMP(LAMMPS *lmp) : void PairLJCutCoulDebyeOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_dsf_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_dsf_omp.cpp index 9d9c098f87..13d877ec07 100644 --- a/src/USER-OMP/pair_lj_cut_coul_dsf_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_dsf_omp.cpp @@ -46,9 +46,7 @@ PairLJCutCoulDSFOMP::PairLJCutCoulDSFOMP(LAMMPS *lmp) : void PairLJCutCoulDSFOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_long_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_long_omp.cpp index d2eaae4ca4..d4fe5fd2a7 100644 --- a/src/USER-OMP/pair_lj_cut_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_long_omp.cpp @@ -45,9 +45,7 @@ PairLJCutCoulLongOMP::PairLJCutCoulLongOMP(LAMMPS *lmp) : void PairLJCutCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_long_soft_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_long_soft_omp.cpp index 725bfe4724..4a0ef73f60 100644 --- a/src/USER-OMP/pair_lj_cut_coul_long_soft_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_long_soft_omp.cpp @@ -45,9 +45,7 @@ PairLJCutCoulLongSoftOMP::PairLJCutCoulLongSoftOMP(LAMMPS *lmp) : void PairLJCutCoulLongSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_msm_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_msm_omp.cpp index 234204af93..4c34b73622 100644 --- a/src/USER-OMP/pair_lj_cut_coul_msm_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_msm_omp.cpp @@ -42,9 +42,7 @@ void PairLJCutCoulMSMOMP::compute(int eflag, int vflag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' " "with OMP MSM Pair styles"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_coul_wolf_omp.cpp b/src/USER-OMP/pair_lj_cut_coul_wolf_omp.cpp index 36ef9d54f9..052be0a2fa 100644 --- a/src/USER-OMP/pair_lj_cut_coul_wolf_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_coul_wolf_omp.cpp @@ -38,9 +38,7 @@ PairLJCutCoulWolfOMP::PairLJCutCoulWolfOMP(LAMMPS *lmp) : void PairLJCutCoulWolfOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_dipole_cut_omp.cpp b/src/USER-OMP/pair_lj_cut_dipole_cut_omp.cpp index d4145d9835..55359db3be 100644 --- a/src/USER-OMP/pair_lj_cut_dipole_cut_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_dipole_cut_omp.cpp @@ -36,9 +36,7 @@ PairLJCutDipoleCutOMP::PairLJCutDipoleCutOMP(LAMMPS *lmp) : void PairLJCutDipoleCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_omp.cpp b/src/USER-OMP/pair_lj_cut_omp.cpp index 319257b56b..34068185d2 100644 --- a/src/USER-OMP/pair_lj_cut_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_omp.cpp @@ -37,9 +37,7 @@ PairLJCutOMP::PairLJCutOMP(LAMMPS *lmp) : void PairLJCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_soft_omp.cpp b/src/USER-OMP/pair_lj_cut_soft_omp.cpp index 7698f19b95..9bbe58146c 100644 --- a/src/USER-OMP/pair_lj_cut_soft_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_soft_omp.cpp @@ -37,9 +37,7 @@ PairLJCutSoftOMP::PairLJCutSoftOMP(LAMMPS *lmp) : void PairLJCutSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp b/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp index 536d5bcb86..85cab4fe7b 100644 --- a/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_thole_long_omp.cpp @@ -57,9 +57,7 @@ PairLJCutTholeLongOMP::PairLJCutTholeLongOMP(LAMMPS *lmp) : void PairLJCutTholeLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_cut_tip4p_cut_omp.cpp b/src/USER-OMP/pair_lj_cut_tip4p_cut_omp.cpp index 619e970bb0..288724cd77 100644 --- a/src/USER-OMP/pair_lj_cut_tip4p_cut_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_tip4p_cut_omp.cpp @@ -62,8 +62,7 @@ PairLJCutTIP4PCutOMP::~PairLJCutTIP4PCutOMP() void PairLJCutTIP4PCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_lj_cut_tip4p_long_omp.cpp b/src/USER-OMP/pair_lj_cut_tip4p_long_omp.cpp index ca8f450dc6..e2c1da1a89 100644 --- a/src/USER-OMP/pair_lj_cut_tip4p_long_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_tip4p_long_omp.cpp @@ -62,8 +62,7 @@ PairLJCutTIP4PLongOMP::~PairLJCutTIP4PLongOMP() void PairLJCutTIP4PLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_lj_cut_tip4p_long_soft_omp.cpp b/src/USER-OMP/pair_lj_cut_tip4p_long_soft_omp.cpp index 80b17fba96..6baba8aec4 100644 --- a/src/USER-OMP/pair_lj_cut_tip4p_long_soft_omp.cpp +++ b/src/USER-OMP/pair_lj_cut_tip4p_long_soft_omp.cpp @@ -62,8 +62,7 @@ PairLJCutTIP4PLongSoftOMP::~PairLJCutTIP4PLongSoftOMP() void PairLJCutTIP4PLongSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_lj_expand_omp.cpp b/src/USER-OMP/pair_lj_expand_omp.cpp index 064ea97809..6c6ddb045e 100644 --- a/src/USER-OMP/pair_lj_expand_omp.cpp +++ b/src/USER-OMP/pair_lj_expand_omp.cpp @@ -36,9 +36,7 @@ PairLJExpandOMP::PairLJExpandOMP(LAMMPS *lmp) : void PairLJExpandOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_gromacs_coul_gromacs_omp.cpp b/src/USER-OMP/pair_lj_gromacs_coul_gromacs_omp.cpp index c87f369d11..77c5bc0da0 100644 --- a/src/USER-OMP/pair_lj_gromacs_coul_gromacs_omp.cpp +++ b/src/USER-OMP/pair_lj_gromacs_coul_gromacs_omp.cpp @@ -36,9 +36,7 @@ PairLJGromacsCoulGromacsOMP::PairLJGromacsCoulGromacsOMP(LAMMPS *lmp) : void PairLJGromacsCoulGromacsOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_gromacs_omp.cpp b/src/USER-OMP/pair_lj_gromacs_omp.cpp index 1d7cec5eef..15bcb08eed 100644 --- a/src/USER-OMP/pair_lj_gromacs_omp.cpp +++ b/src/USER-OMP/pair_lj_gromacs_omp.cpp @@ -36,9 +36,7 @@ PairLJGromacsOMP::PairLJGromacsOMP(LAMMPS *lmp) : void PairLJGromacsOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp index 391840285b..c9edc087b6 100644 --- a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp @@ -46,9 +46,8 @@ PairLJLongCoulLongOMP::PairLJLongCoulLongOMP(LAMMPS *lmp) : void PairLJLongCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); + const int order1 = ewald_order&(1<<1); const int order6 = ewald_order&(1<<6); diff --git a/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp b/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp index 19278d19bb..6d7c5b5638 100644 --- a/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_tip4p_long_omp.cpp @@ -63,9 +63,7 @@ PairLJLongTIP4PLongOMP::~PairLJLongTIP4PLongOMP() void PairLJLongTIP4PLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // reallocate hneigh_thr & newsite_thr if necessary // initialize hneigh_thr[0] to -1 on steps when reneighboring occured diff --git a/src/USER-OMP/pair_lj_sdk_coul_long_omp.cpp b/src/USER-OMP/pair_lj_sdk_coul_long_omp.cpp index c87f26204e..16c87d5ed4 100644 --- a/src/USER-OMP/pair_lj_sdk_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_sdk_coul_long_omp.cpp @@ -38,9 +38,7 @@ PairLJSDKCoulLongOMP::PairLJSDKCoulLongOMP(LAMMPS *lmp) : void PairLJSDKCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_sdk_coul_msm_omp.cpp b/src/USER-OMP/pair_lj_sdk_coul_msm_omp.cpp index 8ff0cfe921..1002cc193e 100644 --- a/src/USER-OMP/pair_lj_sdk_coul_msm_omp.cpp +++ b/src/USER-OMP/pair_lj_sdk_coul_msm_omp.cpp @@ -44,9 +44,7 @@ void PairLJSDKCoulMSMOMP::compute(int eflag, int vflag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' " "with OMP MSM Pair styles"); - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_sdk_omp.cpp b/src/USER-OMP/pair_lj_sdk_omp.cpp index e107399316..1e64973cbb 100644 --- a/src/USER-OMP/pair_lj_sdk_omp.cpp +++ b/src/USER-OMP/pair_lj_sdk_omp.cpp @@ -40,9 +40,7 @@ PairLJSDKOMP::PairLJSDKOMP(LAMMPS *lmp) : void PairLJSDKOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_sf_dipole_sf_omp.cpp b/src/USER-OMP/pair_lj_sf_dipole_sf_omp.cpp index 250f6ff272..aea22fc4df 100644 --- a/src/USER-OMP/pair_lj_sf_dipole_sf_omp.cpp +++ b/src/USER-OMP/pair_lj_sf_dipole_sf_omp.cpp @@ -36,9 +36,7 @@ PairLJSFDipoleSFOMP::PairLJSFDipoleSFOMP(LAMMPS *lmp) : void PairLJSFDipoleSFOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_smooth_linear_omp.cpp b/src/USER-OMP/pair_lj_smooth_linear_omp.cpp index b06de641f5..420c55b0ed 100644 --- a/src/USER-OMP/pair_lj_smooth_linear_omp.cpp +++ b/src/USER-OMP/pair_lj_smooth_linear_omp.cpp @@ -36,9 +36,7 @@ PairLJSmoothLinearOMP::PairLJSmoothLinearOMP(LAMMPS *lmp) : void PairLJSmoothLinearOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lj_smooth_omp.cpp b/src/USER-OMP/pair_lj_smooth_omp.cpp index 36935616bf..d61dc19ff1 100644 --- a/src/USER-OMP/pair_lj_smooth_omp.cpp +++ b/src/USER-OMP/pair_lj_smooth_omp.cpp @@ -36,9 +36,7 @@ PairLJSmoothOMP::PairLJSmoothOMP(LAMMPS *lmp) : void PairLJSmoothOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lubricate_omp.cpp b/src/USER-OMP/pair_lubricate_omp.cpp index a7f9fc65b5..132dbc575e 100644 --- a/src/USER-OMP/pair_lubricate_omp.cpp +++ b/src/USER-OMP/pair_lubricate_omp.cpp @@ -54,9 +54,7 @@ PairLubricateOMP::~PairLubricateOMP() void PairLubricateOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_lubricate_poly_omp.cpp b/src/USER-OMP/pair_lubricate_poly_omp.cpp index 3f0ef1dba6..3a5f03364d 100644 --- a/src/USER-OMP/pair_lubricate_poly_omp.cpp +++ b/src/USER-OMP/pair_lubricate_poly_omp.cpp @@ -54,9 +54,7 @@ PairLubricatePolyOMP::~PairLubricatePolyOMP() void PairLubricatePolyOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_meam_spline_omp.cpp b/src/USER-OMP/pair_meam_spline_omp.cpp index dfc3b978a2..e9307c8666 100644 --- a/src/USER-OMP/pair_meam_spline_omp.cpp +++ b/src/USER-OMP/pair_meam_spline_omp.cpp @@ -39,9 +39,7 @@ PairMEAMSplineOMP::PairMEAMSplineOMP(LAMMPS *lmp) : void PairMEAMSplineOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_morse_omp.cpp b/src/USER-OMP/pair_morse_omp.cpp index 922b67b463..bf57019f11 100644 --- a/src/USER-OMP/pair_morse_omp.cpp +++ b/src/USER-OMP/pair_morse_omp.cpp @@ -36,9 +36,7 @@ PairMorseOMP::PairMorseOMP(LAMMPS *lmp) : void PairMorseOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_morse_smooth_linear_omp.cpp b/src/USER-OMP/pair_morse_smooth_linear_omp.cpp index 61cef69c37..5ba6acb439 100644 --- a/src/USER-OMP/pair_morse_smooth_linear_omp.cpp +++ b/src/USER-OMP/pair_morse_smooth_linear_omp.cpp @@ -40,9 +40,7 @@ PairMorseSmoothLinearOMP::PairMorseSmoothLinearOMP(LAMMPS *lmp) : void PairMorseSmoothLinearOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_nm_cut_coul_cut_omp.cpp b/src/USER-OMP/pair_nm_cut_coul_cut_omp.cpp index fcbf5dbabb..d62b4e5c62 100644 --- a/src/USER-OMP/pair_nm_cut_coul_cut_omp.cpp +++ b/src/USER-OMP/pair_nm_cut_coul_cut_omp.cpp @@ -36,9 +36,7 @@ PairNMCutCoulCutOMP::PairNMCutCoulCutOMP(LAMMPS *lmp) : void PairNMCutCoulCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_nm_cut_coul_long_omp.cpp b/src/USER-OMP/pair_nm_cut_coul_long_omp.cpp index b31387dbfe..a8696c74a1 100644 --- a/src/USER-OMP/pair_nm_cut_coul_long_omp.cpp +++ b/src/USER-OMP/pair_nm_cut_coul_long_omp.cpp @@ -44,9 +44,7 @@ PairNMCutCoulLongOMP::PairNMCutCoulLongOMP(LAMMPS *lmp) : void PairNMCutCoulLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_nm_cut_omp.cpp b/src/USER-OMP/pair_nm_cut_omp.cpp index 79cd046311..9304b10ef0 100644 --- a/src/USER-OMP/pair_nm_cut_omp.cpp +++ b/src/USER-OMP/pair_nm_cut_omp.cpp @@ -36,9 +36,7 @@ PairNMCutOMP::PairNMCutOMP(LAMMPS *lmp) : void PairNMCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_peri_lps_omp.cpp b/src/USER-OMP/pair_peri_lps_omp.cpp index 7b174face7..61db45363e 100644 --- a/src/USER-OMP/pair_peri_lps_omp.cpp +++ b/src/USER-OMP/pair_peri_lps_omp.cpp @@ -45,9 +45,7 @@ PairPeriLPSOMP::PairPeriLPSOMP(LAMMPS *lmp) : void PairPeriLPSOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_peri_pmb_omp.cpp b/src/USER-OMP/pair_peri_pmb_omp.cpp index 8199d8aa47..b1816e4052 100644 --- a/src/USER-OMP/pair_peri_pmb_omp.cpp +++ b/src/USER-OMP/pair_peri_pmb_omp.cpp @@ -43,9 +43,7 @@ PairPeriPMBOMP::PairPeriPMBOMP(LAMMPS *lmp) : void PairPeriPMBOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index 63beb61be6..7f2db420bf 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -191,8 +191,7 @@ void PairReaxCOMP::compute(int eflag, int vflag) int *num_hbonds = fix_reax->num_hbonds; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else ev_unset(); + ev_init(eflag,vflag); if (vflag_global) control->virial = 1; else control->virial = 0; diff --git a/src/USER-OMP/pair_resquared_omp.cpp b/src/USER-OMP/pair_resquared_omp.cpp index 1736e794f5..d9e0059a9f 100644 --- a/src/USER-OMP/pair_resquared_omp.cpp +++ b/src/USER-OMP/pair_resquared_omp.cpp @@ -38,9 +38,7 @@ PairRESquaredOMP::PairRESquaredOMP(LAMMPS *lmp) : void PairRESquaredOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_soft_omp.cpp b/src/USER-OMP/pair_soft_omp.cpp index a860ad97d9..eb151bc0df 100644 --- a/src/USER-OMP/pair_soft_omp.cpp +++ b/src/USER-OMP/pair_soft_omp.cpp @@ -40,9 +40,7 @@ PairSoftOMP::PairSoftOMP(LAMMPS *lmp) : void PairSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_sw_omp.cpp b/src/USER-OMP/pair_sw_omp.cpp index e323fc4c37..745b3a1f04 100644 --- a/src/USER-OMP/pair_sw_omp.cpp +++ b/src/USER-OMP/pair_sw_omp.cpp @@ -37,9 +37,7 @@ PairSWOMP::PairSWOMP(LAMMPS *lmp) : void PairSWOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_table_omp.cpp b/src/USER-OMP/pair_table_omp.cpp index d27456e1b5..b55817e75c 100644 --- a/src/USER-OMP/pair_table_omp.cpp +++ b/src/USER-OMP/pair_table_omp.cpp @@ -37,9 +37,7 @@ PairTableOMP::PairTableOMP(LAMMPS *lmp) : void PairTableOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_tersoff_mod_c_omp.cpp b/src/USER-OMP/pair_tersoff_mod_c_omp.cpp index fad077ca12..a11bd87640 100644 --- a/src/USER-OMP/pair_tersoff_mod_c_omp.cpp +++ b/src/USER-OMP/pair_tersoff_mod_c_omp.cpp @@ -36,9 +36,7 @@ PairTersoffMODCOMP::PairTersoffMODCOMP(LAMMPS *lmp) : void PairTersoffMODCOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_tersoff_mod_omp.cpp b/src/USER-OMP/pair_tersoff_mod_omp.cpp index 04e54c6e69..da22110c1c 100644 --- a/src/USER-OMP/pair_tersoff_mod_omp.cpp +++ b/src/USER-OMP/pair_tersoff_mod_omp.cpp @@ -36,9 +36,7 @@ PairTersoffMODOMP::PairTersoffMODOMP(LAMMPS *lmp) : void PairTersoffMODOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_tersoff_omp.cpp b/src/USER-OMP/pair_tersoff_omp.cpp index a5afdc7509..661f15d64d 100644 --- a/src/USER-OMP/pair_tersoff_omp.cpp +++ b/src/USER-OMP/pair_tersoff_omp.cpp @@ -37,9 +37,7 @@ PairTersoffOMP::PairTersoffOMP(LAMMPS *lmp) : void PairTersoffOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_tersoff_table_omp.cpp b/src/USER-OMP/pair_tersoff_table_omp.cpp index de045f9c62..7e83814f95 100644 --- a/src/USER-OMP/pair_tersoff_table_omp.cpp +++ b/src/USER-OMP/pair_tersoff_table_omp.cpp @@ -61,9 +61,7 @@ PairTersoffTableOMP::~PairTersoffTableOMP() void PairTersoffTableOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_tip4p_cut_omp.cpp b/src/USER-OMP/pair_tip4p_cut_omp.cpp index 85589cf043..1900ed4394 100644 --- a/src/USER-OMP/pair_tip4p_cut_omp.cpp +++ b/src/USER-OMP/pair_tip4p_cut_omp.cpp @@ -62,8 +62,7 @@ PairTIP4PCutOMP::~PairTIP4PCutOMP() void PairTIP4PCutOMP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_tip4p_long_omp.cpp b/src/USER-OMP/pair_tip4p_long_omp.cpp index c6c4bfe5fc..ee65937c46 100644 --- a/src/USER-OMP/pair_tip4p_long_omp.cpp +++ b/src/USER-OMP/pair_tip4p_long_omp.cpp @@ -62,8 +62,7 @@ PairTIP4PLongOMP::~PairTIP4PLongOMP() void PairTIP4PLongOMP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_tip4p_long_soft_omp.cpp b/src/USER-OMP/pair_tip4p_long_soft_omp.cpp index 7e9d3b6dff..adb984a2cd 100644 --- a/src/USER-OMP/pair_tip4p_long_soft_omp.cpp +++ b/src/USER-OMP/pair_tip4p_long_soft_omp.cpp @@ -62,8 +62,7 @@ PairTIP4PLongSoftOMP::~PairTIP4PLongSoftOMP() void PairTIP4PLongSoftOMP::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; diff --git a/src/USER-OMP/pair_ufm_omp.cpp b/src/USER-OMP/pair_ufm_omp.cpp index ff258b5b3b..08d8cc15f9 100644 --- a/src/USER-OMP/pair_ufm_omp.cpp +++ b/src/USER-OMP/pair_ufm_omp.cpp @@ -38,9 +38,7 @@ PairUFMOMP::PairUFMOMP(LAMMPS *lmp) : void PairUFMOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_vashishta_omp.cpp b/src/USER-OMP/pair_vashishta_omp.cpp index 194a3e2d86..28104013f0 100644 --- a/src/USER-OMP/pair_vashishta_omp.cpp +++ b/src/USER-OMP/pair_vashishta_omp.cpp @@ -37,9 +37,7 @@ PairVashishtaOMP::PairVashishtaOMP(LAMMPS *lmp) : void PairVashishtaOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_vashishta_table_omp.cpp b/src/USER-OMP/pair_vashishta_table_omp.cpp index e0d96d8bb6..b044902ebe 100644 --- a/src/USER-OMP/pair_vashishta_table_omp.cpp +++ b/src/USER-OMP/pair_vashishta_table_omp.cpp @@ -37,9 +37,7 @@ PairVashishtaTableOMP::PairVashishtaTableOMP(LAMMPS *lmp) : void PairVashishtaTableOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_yukawa_colloid_omp.cpp b/src/USER-OMP/pair_yukawa_colloid_omp.cpp index c1d2133a1c..86314ce7b8 100644 --- a/src/USER-OMP/pair_yukawa_colloid_omp.cpp +++ b/src/USER-OMP/pair_yukawa_colloid_omp.cpp @@ -36,9 +36,7 @@ PairYukawaColloidOMP::PairYukawaColloidOMP(LAMMPS *lmp) : void PairYukawaColloidOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_yukawa_omp.cpp b/src/USER-OMP/pair_yukawa_omp.cpp index cbfd627f97..add81e9b04 100644 --- a/src/USER-OMP/pair_yukawa_omp.cpp +++ b/src/USER-OMP/pair_yukawa_omp.cpp @@ -36,9 +36,7 @@ PairYukawaOMP::PairYukawaOMP(LAMMPS *lmp) : void PairYukawaOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/pair_zbl_omp.cpp b/src/USER-OMP/pair_zbl_omp.cpp index 788679434b..f6856c4fa0 100644 --- a/src/USER-OMP/pair_zbl_omp.cpp +++ b/src/USER-OMP/pair_zbl_omp.cpp @@ -37,9 +37,7 @@ PairZBLOMP::PairZBLOMP(LAMMPS *lmp) : void PairZBLOMP::compute(int eflag, int vflag) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index fce6313754..c3b03bc5e0 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -75,8 +75,7 @@ void PairQUIP::compute(int eflag, int vflag) double *quip_local_e, *quip_force, *quip_local_virial, *quip_virial, quip_energy, *lattice; - if (eflag || vflag) ev_setup(eflag,vflag); - else ev_unset(); + ev_init(eflag,vflag); inum = list->inum; ilist = list->ilist; diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index b68e0d0779..b9d488d8cf 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -497,8 +497,7 @@ void PairReaxC::compute(int eflag, int vflag) int *num_hbonds = fix_reax->num_hbonds; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else ev_unset(); + ev_init(eflag,vflag); if (vflag_global) control->virial = 1; else control->virial = 0; diff --git a/src/USER-SDPD/pair_sdpd_taitwater_isothermal.cpp b/src/USER-SDPD/pair_sdpd_taitwater_isothermal.cpp index 7cfc950eff..db80debe51 100644 --- a/src/USER-SDPD/pair_sdpd_taitwater_isothermal.cpp +++ b/src/USER-SDPD/pair_sdpd_taitwater_isothermal.cpp @@ -71,8 +71,7 @@ void PairSDPDTaitwaterIsothermal::compute (int eflag, int vflag) { double rsq, tmp, wfd, delVdotDelR; double prefactor, wiener[3][3], f_random[3]; - if (eflag || vflag) ev_setup (eflag, vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **v = atom->vest; double **x = atom->x; diff --git a/src/USER-SMD/pair_smd_hertz.cpp b/src/USER-SMD/pair_smd_hertz.cpp index 13f48e995e..541be9f05c 100644 --- a/src/USER-SMD/pair_smd_hertz.cpp +++ b/src/USER-SMD/pair_smd_hertz.cpp @@ -87,10 +87,7 @@ void PairHertz::compute(int eflag, int vflag) { double *rmass = atom->rmass; evdwl = 0.0; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **f = atom->f; double **x = atom->x; diff --git a/src/USER-SMD/pair_smd_tlsph.cpp b/src/USER-SMD/pair_smd_tlsph.cpp index ab6b7d2785..ac67a3279a 100644 --- a/src/USER-SMD/pair_smd_tlsph.cpp +++ b/src/USER-SMD/pair_smd_tlsph.cpp @@ -448,10 +448,7 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { Matrix3d eye; eye.setIdentity(); - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); /* * iterate over pairs of particles i, j and assign forces using PK1 stress tensor diff --git a/src/USER-SMD/pair_smd_triangulated_surface.cpp b/src/USER-SMD/pair_smd_triangulated_surface.cpp index e40c876ec3..d3a4983379 100644 --- a/src/USER-SMD/pair_smd_triangulated_surface.cpp +++ b/src/USER-SMD/pair_smd_triangulated_surface.cpp @@ -96,10 +96,7 @@ void PairTriSurf::compute(int eflag, int vflag) { Vector2d w2d, rhs; evdwl = 0.0; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); tagint *mol = atom->molecule; double **f = atom->f; diff --git a/src/USER-SMD/pair_smd_ulsph.cpp b/src/USER-SMD/pair_smd_ulsph.cpp index 50af6e2356..2c4a2de989 100644 --- a/src/USER-SMD/pair_smd_ulsph.cpp +++ b/src/USER-SMD/pair_smd_ulsph.cpp @@ -386,10 +386,7 @@ void PairULSPH::compute(int eflag, int vflag) { int k; SelfAdjointEigenSolver < Matrix3d > es; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); if (atom->nmax > nmax) { //printf("... allocating in compute with nmax = %d\n", atom->nmax); diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index 5c3189fc31..ba7f8eb88c 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -899,8 +899,7 @@ void PairSMTBQ::compute(int eflag, int vflag) evdwl = ecoul = ecovtot = ErepOO = ErepMO = Eion = 0.0; Eself = 0.0; - if (eflag || vflag) { ev_setup(eflag,vflag); } - else { evflag = vflag_fdotr = vflag_atom = 0; } + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-SPH/pair_sph_heatconduction.cpp b/src/USER-SPH/pair_sph_heatconduction.cpp index c93e8040b2..bafa26be89 100644 --- a/src/USER-SPH/pair_sph_heatconduction.cpp +++ b/src/USER-SPH/pair_sph_heatconduction.cpp @@ -52,10 +52,7 @@ void PairSPHHeatConduction::compute(int eflag, int vflag) { double imass, jmass, h, ih, ihsq; double rsq, wfd, D, deltaE; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **x = atom->x; double *e = atom->e; diff --git a/src/USER-SPH/pair_sph_idealgas.cpp b/src/USER-SPH/pair_sph_idealgas.cpp index d12ee06736..db5ec964bc 100644 --- a/src/USER-SPH/pair_sph_idealgas.cpp +++ b/src/USER-SPH/pair_sph_idealgas.cpp @@ -53,10 +53,7 @@ void PairSPHIdealGas::compute(int eflag, int vflag) { double vxtmp, vytmp, vztmp, imass, jmass, fi, fj, fvisc, h, ih, ihsq; double rsq, wfd, delVdotDelR, mu, deltaE, ci, cj; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **v = atom->vest; double **x = atom->x; diff --git a/src/USER-SPH/pair_sph_lj.cpp b/src/USER-SPH/pair_sph_lj.cpp index 3a30ecb5fa..7d315c975c 100644 --- a/src/USER-SPH/pair_sph_lj.cpp +++ b/src/USER-SPH/pair_sph_lj.cpp @@ -53,10 +53,7 @@ void PairSPHLJ::compute(int eflag, int vflag) { double vxtmp, vytmp, vztmp, imass, jmass, fi, fj, fvisc, h, ih, ihsq, ihcub; double rsq, wfd, delVdotDelR, mu, deltaE, ci, cj, lrc; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **v = atom->vest; double **x = atom->x; diff --git a/src/USER-SPH/pair_sph_rhosum.cpp b/src/USER-SPH/pair_sph_rhosum.cpp index 896a422782..842dddc744 100644 --- a/src/USER-SPH/pair_sph_rhosum.cpp +++ b/src/USER-SPH/pair_sph_rhosum.cpp @@ -72,10 +72,7 @@ void PairSPHRhoSum::compute(int eflag, int vflag) { // neighbor list variables int inum, *ilist, *numneigh, **firstneigh; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **x = atom->x; double *rho = atom->rho; diff --git a/src/USER-SPH/pair_sph_taitwater.cpp b/src/USER-SPH/pair_sph_taitwater.cpp index 9d5a417e5b..cf3c0e914b 100644 --- a/src/USER-SPH/pair_sph_taitwater.cpp +++ b/src/USER-SPH/pair_sph_taitwater.cpp @@ -58,10 +58,7 @@ void PairSPHTaitwater::compute(int eflag, int vflag) { double vxtmp, vytmp, vztmp, imass, jmass, fi, fj, fvisc, h, ih, ihsq; double rsq, tmp, wfd, delVdotDelR, mu, deltaE; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **v = atom->vest; double **x = atom->x; diff --git a/src/USER-SPH/pair_sph_taitwater_morris.cpp b/src/USER-SPH/pair_sph_taitwater_morris.cpp index fb745ac7da..5cbaa5959f 100644 --- a/src/USER-SPH/pair_sph_taitwater_morris.cpp +++ b/src/USER-SPH/pair_sph_taitwater_morris.cpp @@ -58,10 +58,7 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) { double vxtmp, vytmp, vztmp, imass, jmass, fi, fj, fvisc, h, ih, ihsq, velx, vely, velz; double rsq, tmp, wfd, delVdotDelR, deltaE; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; + ev_init(eflag, vflag); double **v = atom->vest; double **x = atom->x; diff --git a/src/USER-YAFF/pair_lj_switch3_coulgauss_long.cpp b/src/USER-YAFF/pair_lj_switch3_coulgauss_long.cpp index 91c75d6945..f37dcc3ed1 100644 --- a/src/USER-YAFF/pair_lj_switch3_coulgauss_long.cpp +++ b/src/USER-YAFF/pair_lj_switch3_coulgauss_long.cpp @@ -91,8 +91,7 @@ void PairLJSwitch3CoulGaussLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-YAFF/pair_mm3_switch3_coulgauss_long.cpp b/src/USER-YAFF/pair_mm3_switch3_coulgauss_long.cpp index aa656e5b2d..931ed1d116 100644 --- a/src/USER-YAFF/pair_mm3_switch3_coulgauss_long.cpp +++ b/src/USER-YAFF/pair_mm3_switch3_coulgauss_long.cpp @@ -91,8 +91,7 @@ void PairMM3Switch3CoulGaussLong::compute(int eflag, int vflag) double rsq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair.cpp b/src/pair.cpp index 44cf3a43ea..79b94ef597 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -688,8 +688,7 @@ double Pair::mix_distance(double sig1, double sig2) void Pair::compute_dummy(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); } /* ---------------------------------------------------------------------- */ diff --git a/src/pair.h b/src/pair.h index 27b6d41eef..37606ed595 100644 --- a/src/pair.h +++ b/src/pair.h @@ -220,6 +220,10 @@ class Pair : protected Pointers { virtual void ev_setup(int, int, int alloc = 1); void ev_unset(); + void ev_init(int eflag, int vflag, int alloc = 1) { + if (eflag||vflag) ev_setup(eflag, vflag, alloc); + else ev_unset(); + } void ev_tally_full(int, double, double, double, double, double, double); void ev_tally_xyz_full(int, double, double, double, double, double, double, double, double); diff --git a/src/pair_beck.cpp b/src/pair_beck.cpp index d9c0fb902c..17731ebf0b 100644 --- a/src/pair_beck.cpp +++ b/src/pair_beck.cpp @@ -63,8 +63,7 @@ void PairBeck::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_born.cpp b/src/pair_born.cpp index 1a1db9dd90..78434c91f8 100644 --- a/src/pair_born.cpp +++ b/src/pair_born.cpp @@ -71,8 +71,7 @@ void PairBorn::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_born_coul_dsf.cpp b/src/pair_born_coul_dsf.cpp index be7f41ca2b..2e565897b5 100644 --- a/src/pair_born_coul_dsf.cpp +++ b/src/pair_born_coul_dsf.cpp @@ -77,8 +77,7 @@ void PairBornCoulDSF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_born_coul_wolf.cpp b/src/pair_born_coul_wolf.cpp index 22dcfa9f2d..3bb0e39e57 100644 --- a/src/pair_born_coul_wolf.cpp +++ b/src/pair_born_coul_wolf.cpp @@ -76,8 +76,7 @@ void PairBornCoulWolf::compute(int eflag, int vflag) double erfcc,erfcd,v_sh,dvdrr,e_self,e_shift,f_shift,qisq; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_buck.cpp b/src/pair_buck.cpp index 8b6d79234b..a3cf1a38d6 100644 --- a/src/pair_buck.cpp +++ b/src/pair_buck.cpp @@ -66,8 +66,7 @@ void PairBuck::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_buck_coul_cut.cpp b/src/pair_buck_coul_cut.cpp index 7eecb62121..c472ab456f 100644 --- a/src/pair_buck_coul_cut.cpp +++ b/src/pair_buck_coul_cut.cpp @@ -71,8 +71,7 @@ void PairBuckCoulCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_coul_cut.cpp b/src/pair_coul_cut.cpp index 8741abdb89..e7c0e0aabb 100644 --- a/src/pair_coul_cut.cpp +++ b/src/pair_coul_cut.cpp @@ -53,8 +53,7 @@ void PairCoulCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_coul_debye.cpp b/src/pair_coul_debye.cpp index 432a015598..c8afdabb93 100644 --- a/src/pair_coul_debye.cpp +++ b/src/pair_coul_debye.cpp @@ -40,8 +40,7 @@ void PairCoulDebye::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_coul_dsf.cpp b/src/pair_coul_dsf.cpp index 8cd5f7fece..e487ff171c 100644 --- a/src/pair_coul_dsf.cpp +++ b/src/pair_coul_dsf.cpp @@ -68,8 +68,7 @@ void PairCoulDSF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 920770ed7f..244dccda12 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -412,8 +412,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) ci_jfi = ci_fifj = dci_jfi = dci_fifj = 0.0; forcecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; + ev_init(eflag,vflag); inum = list->inum; ilist = list->ilist; diff --git a/src/pair_coul_wolf.cpp b/src/pair_coul_wolf.cpp index 762491166e..dbf21b8bee 100644 --- a/src/pair_coul_wolf.cpp +++ b/src/pair_coul_wolf.cpp @@ -64,8 +64,7 @@ void PairCoulWolf::compute(int eflag, int vflag) double erfcc,erfcd,v_sh,dvdrr,e_self,e_shift,f_shift,qisq; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_dpd.cpp b/src/pair_dpd.cpp index 5c5fc4254b..914b4aee17 100644 --- a/src/pair_dpd.cpp +++ b/src/pair_dpd.cpp @@ -70,8 +70,7 @@ void PairDPD::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **v = atom->v; diff --git a/src/pair_dpd_tstat.cpp b/src/pair_dpd_tstat.cpp index f2c0b157ea..1207c954eb 100644 --- a/src/pair_dpd_tstat.cpp +++ b/src/pair_dpd_tstat.cpp @@ -43,8 +43,7 @@ void PairDPDTstat::compute(int eflag, int vflag) double rsq,r,rinv,dot,wd,randnum,factor_dpd; int *ilist,*jlist,*numneigh,**firstneigh; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); // adjust sigma if target T is changing diff --git a/src/pair_gauss.cpp b/src/pair_gauss.cpp index 426389753b..2d157d6cac 100644 --- a/src/pair_gauss.cpp +++ b/src/pair_gauss.cpp @@ -68,8 +68,7 @@ void PairGauss::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); int occ = 0; double **x = atom->x; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 2b2304718c..4961ce35c6 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -1,3 +1,4 @@ + /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories @@ -95,9 +96,7 @@ void PairHybrid::compute(int eflag, int vflag) if (no_virial_fdotr_compute && vflag % 4 == 2) vflag = 1 + vflag/4 * 4; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); // check if global component of incoming vflag = 2 // if so, reset vflag passed to substyle as if it were 0 diff --git a/src/pair_lj96_cut.cpp b/src/pair_lj96_cut.cpp index 457eba0e79..cefe9b87e0 100644 --- a/src/pair_lj96_cut.cpp +++ b/src/pair_lj96_cut.cpp @@ -73,8 +73,7 @@ void PairLJ96Cut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -308,8 +307,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_cubic.cpp b/src/pair_lj_cubic.cpp index 770caa6359..fdbfca608f 100644 --- a/src/pair_lj_cubic.cpp +++ b/src/pair_lj_cubic.cpp @@ -67,8 +67,7 @@ void PairLJCubic::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_cut.cpp b/src/pair_lj_cut.cpp index 13a546f5a5..2a0fcde3a5 100644 --- a/src/pair_lj_cut.cpp +++ b/src/pair_lj_cut.cpp @@ -73,8 +73,7 @@ void PairLJCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -305,8 +304,7 @@ void PairLJCut::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_cut_coul_cut.cpp b/src/pair_lj_cut_coul_cut.cpp index 15c06ab36a..6f2ba75309 100644 --- a/src/pair_lj_cut_coul_cut.cpp +++ b/src/pair_lj_cut_coul_cut.cpp @@ -67,8 +67,7 @@ void PairLJCutCoulCut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_cut_coul_debye.cpp b/src/pair_lj_cut_coul_debye.cpp index dfd866ca7a..cc6e92b2e3 100644 --- a/src/pair_lj_cut_coul_debye.cpp +++ b/src/pair_lj_cut_coul_debye.cpp @@ -37,8 +37,7 @@ void PairLJCutCoulDebye::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_cut_coul_dsf.cpp b/src/pair_lj_cut_coul_dsf.cpp index a49af13fb2..a0f9824b7f 100644 --- a/src/pair_lj_cut_coul_dsf.cpp +++ b/src/pair_lj_cut_coul_dsf.cpp @@ -81,8 +81,7 @@ void PairLJCutCoulDSF::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_cut_coul_wolf.cpp b/src/pair_lj_cut_coul_wolf.cpp index fc8a858ce1..2f796ded12 100644 --- a/src/pair_lj_cut_coul_wolf.cpp +++ b/src/pair_lj_cut_coul_wolf.cpp @@ -77,8 +77,7 @@ void PairLJCutCoulWolf::compute(int eflag, int vflag) evdwl = 0.0; ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_expand.cpp b/src/pair_lj_expand.cpp index 9aa58b3b88..662a1f8bd2 100644 --- a/src/pair_lj_expand.cpp +++ b/src/pair_lj_expand.cpp @@ -67,8 +67,7 @@ void PairLJExpand::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_gromacs.cpp b/src/pair_lj_gromacs.cpp index 495e96c368..bd19966ea3 100644 --- a/src/pair_lj_gromacs.cpp +++ b/src/pair_lj_gromacs.cpp @@ -75,8 +75,7 @@ void PairLJGromacs::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_gromacs_coul_gromacs.cpp b/src/pair_lj_gromacs_coul_gromacs.cpp index 414bfea92a..5821f26c81 100644 --- a/src/pair_lj_gromacs_coul_gromacs.cpp +++ b/src/pair_lj_gromacs_coul_gromacs.cpp @@ -72,8 +72,7 @@ void PairLJGromacsCoulGromacs::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_smooth.cpp b/src/pair_lj_smooth.cpp index a12046bb3b..ecacadbffa 100644 --- a/src/pair_lj_smooth.cpp +++ b/src/pair_lj_smooth.cpp @@ -72,8 +72,7 @@ void PairLJSmooth::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_lj_smooth_linear.cpp b/src/pair_lj_smooth_linear.cpp index 17c789bcee..265828c4cf 100644 --- a/src/pair_lj_smooth_linear.cpp +++ b/src/pair_lj_smooth_linear.cpp @@ -62,8 +62,7 @@ void PairLJSmoothLinear::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_mie_cut.cpp b/src/pair_mie_cut.cpp index c1e1c1ff50..231832dc48 100644 --- a/src/pair_mie_cut.cpp +++ b/src/pair_mie_cut.cpp @@ -75,8 +75,7 @@ void PairMIECut::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; @@ -310,8 +309,7 @@ void PairMIECut::compute_outer(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_morse.cpp b/src/pair_morse.cpp index c1031343e1..dca1834c14 100644 --- a/src/pair_morse.cpp +++ b/src/pair_morse.cpp @@ -59,8 +59,7 @@ void PairMorse::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_soft.cpp b/src/pair_soft.cpp index d1c51ac600..7602f7b925 100644 --- a/src/pair_soft.cpp +++ b/src/pair_soft.cpp @@ -58,8 +58,7 @@ void PairSoft::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_table.cpp b/src/pair_table.cpp index 04b1e4ceee..cf9e5c3bfb 100644 --- a/src/pair_table.cpp +++ b/src/pair_table.cpp @@ -74,8 +74,7 @@ void PairTable::compute(int eflag, int vflag) int tlm1 = tablength - 1; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_ufm.cpp b/src/pair_ufm.cpp index a9f076f504..226fb6e7d9 100644 --- a/src/pair_ufm.cpp +++ b/src/pair_ufm.cpp @@ -74,8 +74,7 @@ void PairUFM::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_yukawa.cpp b/src/pair_yukawa.cpp index af520fd3da..913afbd5a1 100644 --- a/src/pair_yukawa.cpp +++ b/src/pair_yukawa.cpp @@ -55,8 +55,7 @@ void PairYukawa::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_zbl.cpp b/src/pair_zbl.cpp index f23a1e5d56..254a82ea64 100644 --- a/src/pair_zbl.cpp +++ b/src/pair_zbl.cpp @@ -78,8 +78,7 @@ void PairZBL::compute(int eflag, int vflag) int *ilist,*jlist,*numneigh,**firstneigh; evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/pair_zero.cpp b/src/pair_zero.cpp index d423e196af..143808f598 100644 --- a/src/pair_zero.cpp +++ b/src/pair_zero.cpp @@ -50,8 +50,7 @@ PairZero::~PairZero() void PairZero::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = 0; + ev_init(eflag,vflag); if (vflag_fdotr) virial_fdotr_compute(); } From 17c81295c23f4df5aef2599216231310dcf82ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 17:50:10 +0100 Subject: [PATCH 12/49] use ev_init for fixes --- src/LATTE/fix_latte.cpp | 3 +-- src/MOLECULE/fix_cmap.cpp | 3 +-- src/fix.h | 4 ++++ src/fix_external.cpp | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index d1a96d32c6..645b298e09 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -239,8 +239,7 @@ void FixLatte::pre_reverse(int eflag, int /*vflag*/) void FixLatte::post_force(int vflag) { int eflag = eflag_caller; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); // compute Coulombic potential = pe[i]/q[i] // invoke compute pe/atom diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index ec2588e61b..3395c7ef14 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -341,8 +341,7 @@ void FixCMAP::post_force(int vflag) ecmap = 0.0; int eflag = eflag_caller; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); for (n = 0; n < ncrosstermlist; n++) { i1 = crosstermlist[n][0]; diff --git a/src/fix.h b/src/fix.h index 21dfc955a8..f5b3338aee 100644 --- a/src/fix.h +++ b/src/fix.h @@ -224,6 +224,10 @@ class Fix : protected Pointers { int dynamic; // recount atoms for temperature computes void ev_setup(int, int); + void ev_init(int eflag, int vflag) { + if (eflag||vflag) ev_setup(eflag, vflag); + else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; + } void ev_tally(int, int *, double, double, double *); void v_setup(int); void v_tally(int, int *, double, double *); diff --git a/src/fix_external.cpp b/src/fix_external.cpp index 5ac9206e7f..b1ffa65e49 100644 --- a/src/fix_external.cpp +++ b/src/fix_external.cpp @@ -141,8 +141,7 @@ void FixExternal::post_force(int vflag) bigint ntimestep = update->ntimestep; int eflag = eflag_caller; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); // invoke the callback in driver program // it will fill fexternal with forces From c7af948dfca45ecf0c1e8c367724bcdefea7acc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 17:50:50 +0100 Subject: [PATCH 13/49] use ev_init for impropers --- src/CLASS2/improper_class2.cpp | 3 +-- src/KOKKOS/improper_class2_kokkos.cpp | 3 +-- src/KOKKOS/improper_harmonic_kokkos.cpp | 3 +-- src/MOLECULE/improper_cvff.cpp | 3 +-- src/MOLECULE/improper_harmonic.cpp | 3 +-- src/MOLECULE/improper_umbrella.cpp | 3 +-- src/USER-INTEL/improper_cvff_intel.cpp | 3 +-- src/USER-INTEL/improper_harmonic_intel.cpp | 3 +-- src/USER-MISC/improper_cossq.cpp | 3 +-- src/USER-MISC/improper_distance.cpp | 3 +-- src/USER-MISC/improper_fourier.cpp | 3 +-- src/USER-MISC/improper_ring.cpp | 3 +-- src/USER-MOFFF/improper_inversion_harmonic.cpp | 3 +-- src/USER-OMP/improper_class2_omp.cpp | 5 +---- src/USER-OMP/improper_cossq_omp.cpp | 5 +---- src/USER-OMP/improper_cvff_omp.cpp | 5 +---- src/USER-OMP/improper_fourier_omp.cpp | 5 +---- src/USER-OMP/improper_harmonic_omp.cpp | 5 +---- src/USER-OMP/improper_ring_omp.cpp | 5 +---- src/USER-OMP/improper_umbrella_omp.cpp | 5 +---- src/USER-YAFF/improper_distharm.cpp | 3 +-- src/USER-YAFF/improper_sqdistharm.cpp | 3 +-- src/improper.h | 4 ++++ src/improper_hybrid.cpp | 3 +-- src/improper_zero.cpp | 3 +-- 25 files changed, 28 insertions(+), 62 deletions(-) diff --git a/src/CLASS2/improper_class2.cpp b/src/CLASS2/improper_class2.cpp index 77f594af9d..ccb81aebd9 100644 --- a/src/CLASS2/improper_class2.cpp +++ b/src/CLASS2/improper_class2.cpp @@ -90,8 +90,7 @@ void ImproperClass2::compute(int eflag, int vflag) double fabcd[4][3]; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) diff --git a/src/KOKKOS/improper_class2_kokkos.cpp b/src/KOKKOS/improper_class2_kokkos.cpp index e3af52b494..ad32e6da4e 100644 --- a/src/KOKKOS/improper_class2_kokkos.cpp +++ b/src/KOKKOS/improper_class2_kokkos.cpp @@ -71,8 +71,7 @@ void ImproperClass2Kokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/improper_harmonic_kokkos.cpp b/src/KOKKOS/improper_harmonic_kokkos.cpp index 4d41f3ef48..bb397a2c2f 100644 --- a/src/KOKKOS/improper_harmonic_kokkos.cpp +++ b/src/KOKKOS/improper_harmonic_kokkos.cpp @@ -71,8 +71,7 @@ void ImproperHarmonicKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/MOLECULE/improper_cvff.cpp b/src/MOLECULE/improper_cvff.cpp index 641eea74a8..01e9729e80 100644 --- a/src/MOLECULE/improper_cvff.cpp +++ b/src/MOLECULE/improper_cvff.cpp @@ -61,8 +61,7 @@ void ImproperCvff::compute(int eflag, int vflag) double a33,a12,a13,a23,sx2,sy2,sz2; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/improper_harmonic.cpp b/src/MOLECULE/improper_harmonic.cpp index 091bd46316..c5421fffdb 100644 --- a/src/MOLECULE/improper_harmonic.cpp +++ b/src/MOLECULE/improper_harmonic.cpp @@ -61,8 +61,7 @@ void ImproperHarmonic::compute(int eflag, int vflag) double sx2,sy2,sz2; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/improper_umbrella.cpp b/src/MOLECULE/improper_umbrella.cpp index 8ed3d3a84c..3de46df0f3 100644 --- a/src/MOLECULE/improper_umbrella.cpp +++ b/src/MOLECULE/improper_umbrella.cpp @@ -65,8 +65,7 @@ void ImproperUmbrella::compute(int eflag, int vflag) double ax,ay,az,ra2,rh2,ra,rh,rar,rhr,arx,ary,arz,hrx,hry,hrz; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-INTEL/improper_cvff_intel.cpp b/src/USER-INTEL/improper_cvff_intel.cpp index 03bd134b40..de316250c0 100644 --- a/src/USER-INTEL/improper_cvff_intel.cpp +++ b/src/USER-INTEL/improper_cvff_intel.cpp @@ -83,8 +83,7 @@ void ImproperCvffIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-INTEL/improper_harmonic_intel.cpp b/src/USER-INTEL/improper_harmonic_intel.cpp index 167095150e..846c3cfbf9 100644 --- a/src/USER-INTEL/improper_harmonic_intel.cpp +++ b/src/USER-INTEL/improper_harmonic_intel.cpp @@ -84,8 +84,7 @@ void ImproperHarmonicIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-MISC/improper_cossq.cpp b/src/USER-MISC/improper_cossq.cpp index 2483840e42..c8eb0808fb 100644 --- a/src/USER-MISC/improper_cossq.cpp +++ b/src/USER-MISC/improper_cossq.cpp @@ -63,8 +63,7 @@ void ImproperCossq::compute(int eflag, int vflag) eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/improper_distance.cpp b/src/USER-MISC/improper_distance.cpp index 2edf37ec5c..50babcc84e 100644 --- a/src/USER-MISC/improper_distance.cpp +++ b/src/USER-MISC/improper_distance.cpp @@ -67,8 +67,7 @@ void ImproperDistance::compute(int eflag, int vflag) double domega,a; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/improper_fourier.cpp b/src/USER-MISC/improper_fourier.cpp index 927478fa1a..288d888d12 100644 --- a/src/USER-MISC/improper_fourier.cpp +++ b/src/USER-MISC/improper_fourier.cpp @@ -59,8 +59,7 @@ void ImproperFourier::compute(int eflag, int vflag) int i1,i2,i3,i4,n,type; double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; int **improperlist = neighbor->improperlist; diff --git a/src/USER-MISC/improper_ring.cpp b/src/USER-MISC/improper_ring.cpp index 70124b2ed1..36ba73af0f 100644 --- a/src/USER-MISC/improper_ring.cpp +++ b/src/USER-MISC/improper_ring.cpp @@ -95,8 +95,7 @@ void ImproperRing::compute(int eflag, int vflag) double cjiji, ckjji, ckjkj, fix, fiy, fiz, fjx, fjy, fjz, fkx, fky, fkz; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); /* References to simulation data. */ double **x = atom->x; diff --git a/src/USER-MOFFF/improper_inversion_harmonic.cpp b/src/USER-MOFFF/improper_inversion_harmonic.cpp index 8404984b53..3f1e61e54a 100644 --- a/src/USER-MOFFF/improper_inversion_harmonic.cpp +++ b/src/USER-MOFFF/improper_inversion_harmonic.cpp @@ -66,8 +66,7 @@ void ImproperInversionHarmonic::compute(int eflag, int vflag) double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z; double rrvb1,rrvb2,rrvb3,rr2vb1,rr2vb2,rr2vb3; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; int **improperlist = neighbor->improperlist; diff --git a/src/USER-OMP/improper_class2_omp.cpp b/src/USER-OMP/improper_class2_omp.cpp index 7184cbeb69..c2b493f425 100644 --- a/src/USER-OMP/improper_class2_omp.cpp +++ b/src/USER-OMP/improper_class2_omp.cpp @@ -43,10 +43,7 @@ ImproperClass2OMP::ImproperClass2OMP(class LAMMPS *lmp) void ImproperClass2OMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/improper_cossq_omp.cpp b/src/USER-OMP/improper_cossq_omp.cpp index 022cfa6adf..3b328e5b78 100644 --- a/src/USER-OMP/improper_cossq_omp.cpp +++ b/src/USER-OMP/improper_cossq_omp.cpp @@ -43,10 +43,7 @@ ImproperCossqOMP::ImproperCossqOMP(class LAMMPS *lmp) void ImproperCossqOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/improper_cvff_omp.cpp b/src/USER-OMP/improper_cvff_omp.cpp index 78c5a55e05..fe1fc45bec 100644 --- a/src/USER-OMP/improper_cvff_omp.cpp +++ b/src/USER-OMP/improper_cvff_omp.cpp @@ -43,10 +43,7 @@ ImproperCvffOMP::ImproperCvffOMP(class LAMMPS *lmp) void ImproperCvffOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/improper_fourier_omp.cpp b/src/USER-OMP/improper_fourier_omp.cpp index 77dd36b64f..b5af428cb9 100644 --- a/src/USER-OMP/improper_fourier_omp.cpp +++ b/src/USER-OMP/improper_fourier_omp.cpp @@ -43,10 +43,7 @@ ImproperFourierOMP::ImproperFourierOMP(class LAMMPS *lmp) void ImproperFourierOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/improper_harmonic_omp.cpp b/src/USER-OMP/improper_harmonic_omp.cpp index 3f1895142d..6e02d0968e 100644 --- a/src/USER-OMP/improper_harmonic_omp.cpp +++ b/src/USER-OMP/improper_harmonic_omp.cpp @@ -43,10 +43,7 @@ ImproperHarmonicOMP::ImproperHarmonicOMP(class LAMMPS *lmp) void ImproperHarmonicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/improper_ring_omp.cpp b/src/USER-OMP/improper_ring_omp.cpp index 7970de3839..e198b99337 100644 --- a/src/USER-OMP/improper_ring_omp.cpp +++ b/src/USER-OMP/improper_ring_omp.cpp @@ -45,10 +45,7 @@ ImproperRingOMP::ImproperRingOMP(class LAMMPS *lmp) void ImproperRingOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/improper_umbrella_omp.cpp b/src/USER-OMP/improper_umbrella_omp.cpp index 69d41176c6..ceaca35074 100644 --- a/src/USER-OMP/improper_umbrella_omp.cpp +++ b/src/USER-OMP/improper_umbrella_omp.cpp @@ -43,10 +43,7 @@ ImproperUmbrellaOMP::ImproperUmbrellaOMP(class LAMMPS *lmp) void ImproperUmbrellaOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-YAFF/improper_distharm.cpp b/src/USER-YAFF/improper_distharm.cpp index 9a54afed9a..b45087a9ab 100644 --- a/src/USER-YAFF/improper_distharm.cpp +++ b/src/USER-YAFF/improper_distharm.cpp @@ -67,8 +67,7 @@ void ImproperDistHarm::compute(int eflag, int vflag) double domega,a; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-YAFF/improper_sqdistharm.cpp b/src/USER-YAFF/improper_sqdistharm.cpp index 763d82f1c5..ae702820cb 100644 --- a/src/USER-YAFF/improper_sqdistharm.cpp +++ b/src/USER-YAFF/improper_sqdistharm.cpp @@ -67,8 +67,7 @@ void ImproperSQDistHarm::compute(int eflag, int vflag) double domega,a; eimproper = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/improper.h b/src/improper.h index adcf6d29c8..8ee2c2996d 100644 --- a/src/improper.h +++ b/src/improper.h @@ -57,6 +57,10 @@ class Improper : protected Pointers { int maxeatom,maxvatom; void ev_setup(int, int, int alloc = 1); + void ev_init(int eflag, int vflag, int alloc = 1) { + if (eflag||vflag) ev_setup(eflag, vflag, alloc); + else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; + } void ev_tally(int, int, int, int, int, int, double, double *, double *, double *, double, double, double, double, double, double, double, double, double); diff --git a/src/improper_hybrid.cpp b/src/improper_hybrid.cpp index 3c17e42eaf..5fdcb42a96 100644 --- a/src/improper_hybrid.cpp +++ b/src/improper_hybrid.cpp @@ -104,8 +104,7 @@ void ImproperHybrid::compute(int eflag, int vflag) // set neighbor->improperlist to sub-style improperlist before call // accumulate sub-style global/peratom energy/virial in hybrid - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); for (m = 0; m < nstyles; m++) { neighbor->nimproperlist = nimproperlist[m]; diff --git a/src/improper_zero.cpp b/src/improper_zero.cpp index 8a1fa529c6..747dd57919 100644 --- a/src/improper_zero.cpp +++ b/src/improper_zero.cpp @@ -44,8 +44,7 @@ ImproperZero::~ImproperZero() void ImproperZero::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); } /* ---------------------------------------------------------------------- */ From 6e6f9038181acc6348f8e2f53057dbeb05660fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 17:51:41 +0100 Subject: [PATCH 14/49] use ev_init for angles --- src/CLASS2/angle_class2.cpp | 3 +-- src/KOKKOS/angle_charmm_kokkos.cpp | 3 +-- src/KOKKOS/angle_class2_kokkos.cpp | 3 +-- src/KOKKOS/angle_cosine_kokkos.cpp | 3 +-- src/KOKKOS/angle_harmonic_kokkos.cpp | 3 +-- src/MOLECULE/angle_charmm.cpp | 3 +-- src/MOLECULE/angle_cosine.cpp | 3 +-- src/MOLECULE/angle_cosine_delta.cpp | 3 +-- src/MOLECULE/angle_cosine_periodic.cpp | 3 +-- src/MOLECULE/angle_cosine_squared.cpp | 3 +-- src/MOLECULE/angle_harmonic.cpp | 3 +-- src/MOLECULE/angle_table.cpp | 3 +-- src/USER-CGSDK/angle_sdk.cpp | 3 +-- src/USER-INTEL/angle_charmm_intel.cpp | 3 +-- src/USER-INTEL/angle_harmonic_intel.cpp | 3 +-- src/USER-MISC/angle_cosine_shift.cpp | 3 +-- src/USER-MISC/angle_cosine_shift_exp.cpp | 3 +-- src/USER-MISC/angle_dipole.cpp | 3 +-- src/USER-MISC/angle_fourier.cpp | 3 +-- src/USER-MISC/angle_fourier_simple.cpp | 3 +-- src/USER-MISC/angle_quartic.cpp | 3 +-- src/USER-MOFFF/angle_class2_p6.cpp | 3 +-- src/USER-MOFFF/angle_cosine_buck6d.cpp | 3 +-- src/USER-OMP/angle_charmm_omp.cpp | 5 +---- src/USER-OMP/angle_class2_omp.cpp | 5 +---- src/USER-OMP/angle_cosine_delta_omp.cpp | 5 +---- src/USER-OMP/angle_cosine_omp.cpp | 5 +---- src/USER-OMP/angle_cosine_periodic_omp.cpp | 5 +---- src/USER-OMP/angle_cosine_shift_exp_omp.cpp | 5 +---- src/USER-OMP/angle_cosine_shift_omp.cpp | 5 +---- src/USER-OMP/angle_cosine_squared_omp.cpp | 5 +---- src/USER-OMP/angle_dipole_omp.cpp | 5 +---- src/USER-OMP/angle_fourier_omp.cpp | 5 +---- src/USER-OMP/angle_fourier_simple_omp.cpp | 5 +---- src/USER-OMP/angle_harmonic_omp.cpp | 5 +---- src/USER-OMP/angle_quartic_omp.cpp | 5 +---- src/USER-OMP/angle_sdk_omp.cpp | 5 +---- src/USER-OMP/angle_table_omp.cpp | 5 +---- src/USER-YAFF/angle_cross.cpp | 3 +-- src/USER-YAFF/angle_mm3.cpp | 3 +-- src/angle.h | 4 ++++ src/angle_hybrid.cpp | 3 +-- src/angle_zero.cpp | 3 +-- 43 files changed, 46 insertions(+), 114 deletions(-) diff --git a/src/CLASS2/angle_class2.cpp b/src/CLASS2/angle_class2.cpp index 24f41bfd58..d550767e5e 100644 --- a/src/CLASS2/angle_class2.cpp +++ b/src/CLASS2/angle_class2.cpp @@ -78,8 +78,7 @@ void AngleClass2::compute(int eflag, int vflag) double vx11,vx12,vy11,vy12,vz11,vz12,vx21,vx22,vy21,vy22,vz21,vz22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KOKKOS/angle_charmm_kokkos.cpp b/src/KOKKOS/angle_charmm_kokkos.cpp index ec2955b28d..0f46c958d6 100644 --- a/src/KOKKOS/angle_charmm_kokkos.cpp +++ b/src/KOKKOS/angle_charmm_kokkos.cpp @@ -64,8 +64,7 @@ void AngleCharmmKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/angle_class2_kokkos.cpp b/src/KOKKOS/angle_class2_kokkos.cpp index fe5b1895fe..836714764d 100644 --- a/src/KOKKOS/angle_class2_kokkos.cpp +++ b/src/KOKKOS/angle_class2_kokkos.cpp @@ -64,8 +64,7 @@ void AngleClass2Kokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/angle_cosine_kokkos.cpp b/src/KOKKOS/angle_cosine_kokkos.cpp index 08faa254f4..4a4866948f 100644 --- a/src/KOKKOS/angle_cosine_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_kokkos.cpp @@ -64,8 +64,7 @@ void AngleCosineKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/angle_harmonic_kokkos.cpp b/src/KOKKOS/angle_harmonic_kokkos.cpp index 8cdab2063a..dbe705800c 100644 --- a/src/KOKKOS/angle_harmonic_kokkos.cpp +++ b/src/KOKKOS/angle_harmonic_kokkos.cpp @@ -64,8 +64,7 @@ void AngleHarmonicKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/MOLECULE/angle_charmm.cpp b/src/MOLECULE/angle_charmm.cpp index 3608601c1f..efd1c682f7 100644 --- a/src/MOLECULE/angle_charmm.cpp +++ b/src/MOLECULE/angle_charmm.cpp @@ -61,8 +61,7 @@ void AngleCharmm::compute(int eflag, int vflag) double delxUB,delyUB,delzUB,rsqUB,rUB,dr,rk,forceUB; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/angle_cosine.cpp b/src/MOLECULE/angle_cosine.cpp index 18763e1b76..6e1b9fa2fb 100644 --- a/src/MOLECULE/angle_cosine.cpp +++ b/src/MOLECULE/angle_cosine.cpp @@ -52,8 +52,7 @@ void AngleCosine::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/angle_cosine_delta.cpp b/src/MOLECULE/angle_cosine_delta.cpp index 6f4f5c20d7..eca10970f2 100644 --- a/src/MOLECULE/angle_cosine_delta.cpp +++ b/src/MOLECULE/angle_cosine_delta.cpp @@ -44,8 +44,7 @@ void AngleCosineDelta::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,a,cot,a11,a12,a22,b11,b12,b22,c0,s0,s; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/angle_cosine_periodic.cpp b/src/MOLECULE/angle_cosine_periodic.cpp index e8dd970b3b..cb0a26871a 100644 --- a/src/MOLECULE/angle_cosine_periodic.cpp +++ b/src/MOLECULE/angle_cosine_periodic.cpp @@ -61,8 +61,7 @@ void AngleCosinePeriodic::compute(int eflag, int vflag) double tn,tn_1,tn_2,un,un_1,un_2; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/angle_cosine_squared.cpp b/src/MOLECULE/angle_cosine_squared.cpp index c83ba90a60..28d63344a4 100644 --- a/src/MOLECULE/angle_cosine_squared.cpp +++ b/src/MOLECULE/angle_cosine_squared.cpp @@ -62,8 +62,7 @@ void AngleCosineSquared::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/angle_harmonic.cpp b/src/MOLECULE/angle_harmonic.cpp index d28afd76d6..48b493d9b2 100644 --- a/src/MOLECULE/angle_harmonic.cpp +++ b/src/MOLECULE/angle_harmonic.cpp @@ -58,8 +58,7 @@ void AngleHarmonic::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,s,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index 6c1af54dcf..7dd56ffb76 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -72,8 +72,7 @@ void AngleTable::compute(int eflag, int vflag) double theta,u,mdu; //mdu: minus du, -du/dx=f eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-CGSDK/angle_sdk.cpp b/src/USER-CGSDK/angle_sdk.cpp index 6b8245b491..823c725e07 100644 --- a/src/USER-CGSDK/angle_sdk.cpp +++ b/src/USER-CGSDK/angle_sdk.cpp @@ -68,8 +68,7 @@ void AngleSDK::compute(int eflag, int vflag) double rsq1,rsq2,rsq3,r1,r2,c,s,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-INTEL/angle_charmm_intel.cpp b/src/USER-INTEL/angle_charmm_intel.cpp index f2542fc0c7..c5ada951a5 100644 --- a/src/USER-INTEL/angle_charmm_intel.cpp +++ b/src/USER-INTEL/angle_charmm_intel.cpp @@ -78,8 +78,7 @@ void AngleCharmmIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-INTEL/angle_harmonic_intel.cpp b/src/USER-INTEL/angle_harmonic_intel.cpp index 6d8901a5ee..aae6fcf0a2 100644 --- a/src/USER-INTEL/angle_harmonic_intel.cpp +++ b/src/USER-INTEL/angle_harmonic_intel.cpp @@ -78,8 +78,7 @@ void AngleHarmonicIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-MISC/angle_cosine_shift.cpp b/src/USER-MISC/angle_cosine_shift.cpp index a361db4970..18c87c81e3 100644 --- a/src/USER-MISC/angle_cosine_shift.cpp +++ b/src/USER-MISC/angle_cosine_shift.cpp @@ -62,8 +62,7 @@ void AngleCosineShift::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,s,cps,kcos,ksin,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/angle_cosine_shift_exp.cpp b/src/USER-MISC/angle_cosine_shift_exp.cpp index c87c73171a..8c6282de20 100644 --- a/src/USER-MISC/angle_cosine_shift_exp.cpp +++ b/src/USER-MISC/angle_cosine_shift_exp.cpp @@ -72,8 +72,7 @@ void AngleCosineShiftExp::compute(int eflag, int vflag) double exp2,aa,uumin,cccpsss,cssmscc; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/angle_dipole.cpp b/src/USER-MISC/angle_dipole.cpp index c4186da472..781da46869 100644 --- a/src/USER-MISC/angle_dipole.cpp +++ b/src/USER-MISC/angle_dipole.cpp @@ -59,8 +59,7 @@ void AngleDipole::compute(int eflag, int vflag) double r,cosGamma,deltaGamma,kdg,rmu; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; // position vector double **mu = atom->mu; // point-dipole components and moment magnitude diff --git a/src/USER-MISC/angle_fourier.cpp b/src/USER-MISC/angle_fourier.cpp index e6cc1f1a7e..8f5074ff5d 100644 --- a/src/USER-MISC/angle_fourier.cpp +++ b/src/USER-MISC/angle_fourier.cpp @@ -67,8 +67,7 @@ void AngleFourier::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,c2,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/angle_fourier_simple.cpp b/src/USER-MISC/angle_fourier_simple.cpp index 8464fe815c..615556bbe7 100644 --- a/src/USER-MISC/angle_fourier_simple.cpp +++ b/src/USER-MISC/angle_fourier_simple.cpp @@ -65,8 +65,7 @@ void AngleFourierSimple::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,cn,th,nth,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/angle_quartic.cpp b/src/USER-MISC/angle_quartic.cpp index 356f2df5d4..21a96100aa 100644 --- a/src/USER-MISC/angle_quartic.cpp +++ b/src/USER-MISC/angle_quartic.cpp @@ -61,8 +61,7 @@ void AngleQuartic::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,s,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MOFFF/angle_class2_p6.cpp b/src/USER-MOFFF/angle_class2_p6.cpp index d2a6e21e6b..e8e6f279de 100644 --- a/src/USER-MOFFF/angle_class2_p6.cpp +++ b/src/USER-MOFFF/angle_class2_p6.cpp @@ -79,8 +79,7 @@ void AngleClass2P6::compute(int eflag, int vflag) double vx11,vx12,vy11,vy12,vz11,vz12,vx21,vx22,vy21,vy22,vz21,vz22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MOFFF/angle_cosine_buck6d.cpp b/src/USER-MOFFF/angle_cosine_buck6d.cpp index f358097802..3829d2b8dc 100644 --- a/src/USER-MOFFF/angle_cosine_buck6d.cpp +++ b/src/USER-MOFFF/angle_cosine_buck6d.cpp @@ -69,8 +69,7 @@ void AngleCosineBuck6d::compute(int eflag, int vflag) double rcu,rqu,sme,smf; eangle = evdwl = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-3 virial contribution diff --git a/src/USER-OMP/angle_charmm_omp.cpp b/src/USER-OMP/angle_charmm_omp.cpp index 1f24438df3..118ba00226 100644 --- a/src/USER-OMP/angle_charmm_omp.cpp +++ b/src/USER-OMP/angle_charmm_omp.cpp @@ -44,10 +44,7 @@ using namespace MathConst; void AngleCharmmOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_class2_omp.cpp b/src/USER-OMP/angle_class2_omp.cpp index bd13e20bcc..e072d136e1 100644 --- a/src/USER-OMP/angle_class2_omp.cpp +++ b/src/USER-OMP/angle_class2_omp.cpp @@ -44,10 +44,7 @@ AngleClass2OMP::AngleClass2OMP(class LAMMPS *lmp) void AngleClass2OMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_cosine_delta_omp.cpp b/src/USER-OMP/angle_cosine_delta_omp.cpp index b3bb3e1f8a..a6dfb20433 100644 --- a/src/USER-OMP/angle_cosine_delta_omp.cpp +++ b/src/USER-OMP/angle_cosine_delta_omp.cpp @@ -44,10 +44,7 @@ AngleCosineDeltaOMP::AngleCosineDeltaOMP(class LAMMPS *lmp) void AngleCosineDeltaOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_cosine_omp.cpp b/src/USER-OMP/angle_cosine_omp.cpp index 04b3870bc4..9097c8569c 100644 --- a/src/USER-OMP/angle_cosine_omp.cpp +++ b/src/USER-OMP/angle_cosine_omp.cpp @@ -44,10 +44,7 @@ AngleCosineOMP::AngleCosineOMP(class LAMMPS *lmp) void AngleCosineOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_cosine_periodic_omp.cpp b/src/USER-OMP/angle_cosine_periodic_omp.cpp index 8060ebec7b..3fcea7ad1d 100644 --- a/src/USER-OMP/angle_cosine_periodic_omp.cpp +++ b/src/USER-OMP/angle_cosine_periodic_omp.cpp @@ -46,10 +46,7 @@ AngleCosinePeriodicOMP::AngleCosinePeriodicOMP(class LAMMPS *lmp) void AngleCosinePeriodicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_cosine_shift_exp_omp.cpp b/src/USER-OMP/angle_cosine_shift_exp_omp.cpp index 3e00681ec9..6bd2feb023 100644 --- a/src/USER-OMP/angle_cosine_shift_exp_omp.cpp +++ b/src/USER-OMP/angle_cosine_shift_exp_omp.cpp @@ -44,10 +44,7 @@ AngleCosineShiftExpOMP::AngleCosineShiftExpOMP(class LAMMPS *lmp) void AngleCosineShiftExpOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_cosine_shift_omp.cpp b/src/USER-OMP/angle_cosine_shift_omp.cpp index 0ab3df4359..56486faac1 100644 --- a/src/USER-OMP/angle_cosine_shift_omp.cpp +++ b/src/USER-OMP/angle_cosine_shift_omp.cpp @@ -44,10 +44,7 @@ AngleCosineShiftOMP::AngleCosineShiftOMP(class LAMMPS *lmp) void AngleCosineShiftOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_cosine_squared_omp.cpp b/src/USER-OMP/angle_cosine_squared_omp.cpp index a1b1ffdf1a..6dd2a3bb3b 100644 --- a/src/USER-OMP/angle_cosine_squared_omp.cpp +++ b/src/USER-OMP/angle_cosine_squared_omp.cpp @@ -44,10 +44,7 @@ AngleCosineSquaredOMP::AngleCosineSquaredOMP(class LAMMPS *lmp) void AngleCosineSquaredOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_dipole_omp.cpp b/src/USER-OMP/angle_dipole_omp.cpp index 92a5ba092e..da2e819ee2 100644 --- a/src/USER-OMP/angle_dipole_omp.cpp +++ b/src/USER-OMP/angle_dipole_omp.cpp @@ -45,10 +45,7 @@ AngleDipoleOMP::AngleDipoleOMP(class LAMMPS *lmp) void AngleDipoleOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); if (!force->newton_bond) error->all(FLERR,"'newton' flag for bonded interactions must be 'on'"); diff --git a/src/USER-OMP/angle_fourier_omp.cpp b/src/USER-OMP/angle_fourier_omp.cpp index dfc713c372..b2f9b47e05 100644 --- a/src/USER-OMP/angle_fourier_omp.cpp +++ b/src/USER-OMP/angle_fourier_omp.cpp @@ -44,10 +44,7 @@ AngleFourierOMP::AngleFourierOMP(class LAMMPS *lmp) void AngleFourierOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_fourier_simple_omp.cpp b/src/USER-OMP/angle_fourier_simple_omp.cpp index dea7a88723..93532a30e5 100644 --- a/src/USER-OMP/angle_fourier_simple_omp.cpp +++ b/src/USER-OMP/angle_fourier_simple_omp.cpp @@ -44,10 +44,7 @@ AngleFourierSimpleOMP::AngleFourierSimpleOMP(class LAMMPS *lmp) void AngleFourierSimpleOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_harmonic_omp.cpp b/src/USER-OMP/angle_harmonic_omp.cpp index 0a71e5c9dd..824b254287 100644 --- a/src/USER-OMP/angle_harmonic_omp.cpp +++ b/src/USER-OMP/angle_harmonic_omp.cpp @@ -44,10 +44,7 @@ AngleHarmonicOMP::AngleHarmonicOMP(class LAMMPS *lmp) void AngleHarmonicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_quartic_omp.cpp b/src/USER-OMP/angle_quartic_omp.cpp index 97a9b14f1d..fff08ddb39 100644 --- a/src/USER-OMP/angle_quartic_omp.cpp +++ b/src/USER-OMP/angle_quartic_omp.cpp @@ -44,10 +44,7 @@ AngleQuarticOMP::AngleQuarticOMP(class LAMMPS *lmp) void AngleQuarticOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_sdk_omp.cpp b/src/USER-OMP/angle_sdk_omp.cpp index 9383a9af83..e8c762092c 100644 --- a/src/USER-OMP/angle_sdk_omp.cpp +++ b/src/USER-OMP/angle_sdk_omp.cpp @@ -46,10 +46,7 @@ AngleSDKOMP::AngleSDKOMP(class LAMMPS *lmp) void AngleSDKOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/angle_table_omp.cpp b/src/USER-OMP/angle_table_omp.cpp index c3d2307489..d9d80b744d 100644 --- a/src/USER-OMP/angle_table_omp.cpp +++ b/src/USER-OMP/angle_table_omp.cpp @@ -44,10 +44,7 @@ AngleTableOMP::AngleTableOMP(class LAMMPS *lmp) void AngleTableOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-YAFF/angle_cross.cpp b/src/USER-YAFF/angle_cross.cpp index 6333c2f035..2e6731f494 100644 --- a/src/USER-YAFF/angle_cross.cpp +++ b/src/USER-YAFF/angle_cross.cpp @@ -67,8 +67,7 @@ void AngleCross::compute(int eflag, int vflag) double vx11,vx12,vy11,vy12,vz11,vz12,vx21,vx22,vy21,vy22,vz21,vz22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-YAFF/angle_mm3.cpp b/src/USER-YAFF/angle_mm3.cpp index 4e44f10408..53cb11b5df 100644 --- a/src/USER-YAFF/angle_mm3.cpp +++ b/src/USER-YAFF/angle_mm3.cpp @@ -61,8 +61,7 @@ void AngleMM3::compute(int eflag, int vflag) double rsq1,rsq2,r1,r2,c,s,a,a11,a12,a22; eangle = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/angle.h b/src/angle.h index 0247fa0ff8..196c2a44d1 100644 --- a/src/angle.h +++ b/src/angle.h @@ -59,6 +59,10 @@ class Angle : protected Pointers { int maxeatom,maxvatom; void ev_setup(int, int, int alloc = 1); + void ev_init(int eflag, int vflag, int alloc = 1) { + if (eflag||vflag) ev_setup(eflag, vflag, alloc); + else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; + } void ev_tally(int, int, int, int, int, double, double *, double *, double, double, double, double, double, double); }; diff --git a/src/angle_hybrid.cpp b/src/angle_hybrid.cpp index c29eaac2ae..6afa7413b2 100644 --- a/src/angle_hybrid.cpp +++ b/src/angle_hybrid.cpp @@ -103,8 +103,7 @@ void AngleHybrid::compute(int eflag, int vflag) // set neighbor->anglelist to sub-style anglelist before call // accumulate sub-style global/peratom energy/virial in hybrid - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); for (m = 0; m < nstyles; m++) { neighbor->nanglelist = nanglelist[m]; diff --git a/src/angle_zero.cpp b/src/angle_zero.cpp index d7b7c9cdb5..6eb127fa58 100644 --- a/src/angle_zero.cpp +++ b/src/angle_zero.cpp @@ -47,8 +47,7 @@ AngleZero::~AngleZero() void AngleZero::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); } /* ---------------------------------------------------------------------- */ From fbd600592b802cdcb3a45e0bbf3126ae5c1c702c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 17:53:22 +0100 Subject: [PATCH 15/49] use ev_init for dihedrals --- src/CLASS2/dihedral_class2.cpp | 3 +-- src/KOKKOS/dihedral_charmm_kokkos.cpp | 3 +-- src/KOKKOS/dihedral_class2_kokkos.cpp | 3 +-- src/KOKKOS/dihedral_opls_kokkos.cpp | 3 +-- src/MOLECULE/dihedral_charmm.cpp | 3 +-- src/MOLECULE/dihedral_charmmfsw.cpp | 3 +-- src/MOLECULE/dihedral_harmonic.cpp | 3 +-- src/MOLECULE/dihedral_helix.cpp | 3 +-- src/MOLECULE/dihedral_multi_harmonic.cpp | 3 +-- src/MOLECULE/dihedral_opls.cpp | 3 +-- src/USER-INTEL/dihedral_charmm_intel.cpp | 4 +--- src/USER-INTEL/dihedral_fourier_intel.cpp | 4 +--- src/USER-INTEL/dihedral_harmonic_intel.cpp | 4 +--- src/USER-INTEL/dihedral_opls_intel.cpp | 4 +--- src/USER-MISC/dihedral_cosine_shift_exp.cpp | 3 +-- src/USER-MISC/dihedral_fourier.cpp | 3 +-- src/USER-MISC/dihedral_nharmonic.cpp | 3 +-- src/USER-MISC/dihedral_quadratic.cpp | 3 +-- src/USER-MISC/dihedral_spherical.cpp | 3 +-- src/USER-MISC/dihedral_table.cpp | 3 +-- src/USER-MISC/dihedral_table_cut.cpp | 3 +-- src/USER-OMP/dihedral_charmm_omp.cpp | 5 +---- src/USER-OMP/dihedral_class2_omp.cpp | 5 +---- src/USER-OMP/dihedral_cosine_shift_exp_omp.cpp | 5 +---- src/USER-OMP/dihedral_fourier_omp.cpp | 5 +---- src/USER-OMP/dihedral_harmonic_omp.cpp | 5 +---- src/USER-OMP/dihedral_helix_omp.cpp | 5 +---- src/USER-OMP/dihedral_multi_harmonic_omp.cpp | 5 +---- src/USER-OMP/dihedral_nharmonic_omp.cpp | 5 +---- src/USER-OMP/dihedral_opls_omp.cpp | 5 +---- src/USER-OMP/dihedral_quadratic_omp.cpp | 5 +---- src/USER-OMP/dihedral_table_omp.cpp | 5 +---- src/dihedral.h | 4 ++++ src/dihedral_hybrid.cpp | 3 +-- src/dihedral_zero.cpp | 3 +-- 35 files changed, 38 insertions(+), 94 deletions(-) diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp index c6360dd846..c471b1f353 100644 --- a/src/CLASS2/dihedral_class2.cpp +++ b/src/CLASS2/dihedral_class2.cpp @@ -118,8 +118,7 @@ void DihedralClass2::compute(int eflag, int vflag) double fabcd[4][3]; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KOKKOS/dihedral_charmm_kokkos.cpp b/src/KOKKOS/dihedral_charmm_kokkos.cpp index 3931309dc1..61ddcc425a 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.cpp +++ b/src/KOKKOS/dihedral_charmm_kokkos.cpp @@ -69,8 +69,7 @@ void DihedralCharmmKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/KOKKOS/dihedral_class2_kokkos.cpp b/src/KOKKOS/dihedral_class2_kokkos.cpp index c7db07a6cb..98436bc696 100644 --- a/src/KOKKOS/dihedral_class2_kokkos.cpp +++ b/src/KOKKOS/dihedral_class2_kokkos.cpp @@ -69,8 +69,7 @@ void DihedralClass2Kokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/dihedral_opls_kokkos.cpp b/src/KOKKOS/dihedral_opls_kokkos.cpp index 9d01cf1a54..f50dea2c36 100644 --- a/src/KOKKOS/dihedral_opls_kokkos.cpp +++ b/src/KOKKOS/dihedral_opls_kokkos.cpp @@ -69,8 +69,7 @@ void DihedralOPLSKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp index 2372fae38b..68c62eb4fd 100644 --- a/src/MOLECULE/dihedral_charmm.cpp +++ b/src/MOLECULE/dihedral_charmm.cpp @@ -76,8 +76,7 @@ void DihedralCharmm::compute(int eflag, int vflag) double forcecoul,forcelj,fpair,ecoul,evdwl; edihedral = evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/MOLECULE/dihedral_charmmfsw.cpp b/src/MOLECULE/dihedral_charmmfsw.cpp index 99a5333620..f65d01e9ed 100644 --- a/src/MOLECULE/dihedral_charmmfsw.cpp +++ b/src/MOLECULE/dihedral_charmmfsw.cpp @@ -79,8 +79,7 @@ void DihedralCharmmfsw::compute(int eflag, int vflag) double forcecoul,forcelj,fpair,ecoul,evdwl; edihedral = evdwl = ecoul = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/MOLECULE/dihedral_harmonic.cpp b/src/MOLECULE/dihedral_harmonic.cpp index cb122f4bc2..ddb94dc571 100644 --- a/src/MOLECULE/dihedral_harmonic.cpp +++ b/src/MOLECULE/dihedral_harmonic.cpp @@ -67,8 +67,7 @@ void DihedralHarmonic::compute(int eflag, int vflag) double c,s,p,sx2,sy2,sz2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/dihedral_helix.cpp b/src/MOLECULE/dihedral_helix.cpp index ae23b77951..6b6d19ecdf 100644 --- a/src/MOLECULE/dihedral_helix.cpp +++ b/src/MOLECULE/dihedral_helix.cpp @@ -67,8 +67,7 @@ void DihedralHelix::compute(int eflag, int vflag) double s2,cx,cy,cz,cmag,dx,phi,si,siinv,sin2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/dihedral_multi_harmonic.cpp b/src/MOLECULE/dihedral_multi_harmonic.cpp index f6461abb6e..f0097342a8 100644 --- a/src/MOLECULE/dihedral_multi_harmonic.cpp +++ b/src/MOLECULE/dihedral_multi_harmonic.cpp @@ -64,8 +64,7 @@ void DihedralMultiHarmonic::compute(int eflag, int vflag) double s2,sin2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/dihedral_opls.cpp b/src/MOLECULE/dihedral_opls.cpp index b5103413b2..293245e411 100644 --- a/src/MOLECULE/dihedral_opls.cpp +++ b/src/MOLECULE/dihedral_opls.cpp @@ -67,8 +67,7 @@ void DihedralOPLS::compute(int eflag, int vflag) double s2,cx,cy,cz,cmag,dx,phi,si,siinv,sin2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-INTEL/dihedral_charmm_intel.cpp b/src/USER-INTEL/dihedral_charmm_intel.cpp index c9237e7309..4f4b091300 100644 --- a/src/USER-INTEL/dihedral_charmm_intel.cpp +++ b/src/USER-INTEL/dihedral_charmm_intel.cpp @@ -84,9 +84,7 @@ void DihedralCharmmIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/USER-INTEL/dihedral_fourier_intel.cpp b/src/USER-INTEL/dihedral_fourier_intel.cpp index 6ccc165c61..030d371e44 100644 --- a/src/USER-INTEL/dihedral_fourier_intel.cpp +++ b/src/USER-INTEL/dihedral_fourier_intel.cpp @@ -73,9 +73,7 @@ void DihedralFourierIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-INTEL/dihedral_harmonic_intel.cpp b/src/USER-INTEL/dihedral_harmonic_intel.cpp index ae5eb914e7..d84db4f4ac 100644 --- a/src/USER-INTEL/dihedral_harmonic_intel.cpp +++ b/src/USER-INTEL/dihedral_harmonic_intel.cpp @@ -73,9 +73,7 @@ void DihedralHarmonicIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-INTEL/dihedral_opls_intel.cpp b/src/USER-INTEL/dihedral_opls_intel.cpp index 7a60b62cae..eae796974b 100644 --- a/src/USER-INTEL/dihedral_opls_intel.cpp +++ b/src/USER-INTEL/dihedral_opls_intel.cpp @@ -77,9 +77,7 @@ void DihedralOPLSIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-MISC/dihedral_cosine_shift_exp.cpp b/src/USER-MISC/dihedral_cosine_shift_exp.cpp index 82da173f8e..c1396aba11 100644 --- a/src/USER-MISC/dihedral_cosine_shift_exp.cpp +++ b/src/USER-MISC/dihedral_cosine_shift_exp.cpp @@ -68,8 +68,7 @@ void DihedralCosineShiftExp::compute(int eflag, int vflag) double cccpsss,cssmscc,exp2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/dihedral_fourier.cpp b/src/USER-MISC/dihedral_fourier.cpp index 7c405ee28c..af86259c01 100644 --- a/src/USER-MISC/dihedral_fourier.cpp +++ b/src/USER-MISC/dihedral_fourier.cpp @@ -79,8 +79,7 @@ void DihedralFourier::compute(int eflag, int vflag) double dtfx,dtfy,dtfz,dtgx,dtgy,dtgz,dthx,dthy,dthz; double c,s,p_,sx2,sy2,sz2; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/dihedral_nharmonic.cpp b/src/USER-MISC/dihedral_nharmonic.cpp index f8e8850680..189555946b 100644 --- a/src/USER-MISC/dihedral_nharmonic.cpp +++ b/src/USER-MISC/dihedral_nharmonic.cpp @@ -66,8 +66,7 @@ void DihedralNHarmonic::compute(int eflag, int vflag) double s2,sin2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/dihedral_quadratic.cpp b/src/USER-MISC/dihedral_quadratic.cpp index 1b64b52faf..4c65f2fd70 100644 --- a/src/USER-MISC/dihedral_quadratic.cpp +++ b/src/USER-MISC/dihedral_quadratic.cpp @@ -65,8 +65,7 @@ void DihedralQuadratic::compute(int eflag, int vflag) double s2,cx,cy,cz,cmag,dx,phi,si,siinv,sin2; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/dihedral_spherical.cpp b/src/USER-MISC/dihedral_spherical.cpp index 77fa885b7a..97cdf13801 100644 --- a/src/USER-MISC/dihedral_spherical.cpp +++ b/src/USER-MISC/dihedral_spherical.cpp @@ -213,8 +213,7 @@ void DihedralSpherical::compute(int eflag, int vflag) // perp34on23[d] = v34[d] - proj34on23[d] edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); for (n = 0; n < ndihedrallist; n++) { diff --git a/src/USER-MISC/dihedral_table.cpp b/src/USER-MISC/dihedral_table.cpp index e221a54a82..a97ae3649f 100644 --- a/src/USER-MISC/dihedral_table.cpp +++ b/src/USER-MISC/dihedral_table.cpp @@ -549,8 +549,7 @@ void DihedralTable::compute(int eflag, int vflag) edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); for (n = 0; n < ndihedrallist; n++) { diff --git a/src/USER-MISC/dihedral_table_cut.cpp b/src/USER-MISC/dihedral_table_cut.cpp index 6ebe094e50..a11ad94969 100644 --- a/src/USER-MISC/dihedral_table_cut.cpp +++ b/src/USER-MISC/dihedral_table_cut.cpp @@ -472,8 +472,7 @@ void DihedralTableCut::compute(int eflag, int vflag) double fabcd[4][3]; edihedral = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-OMP/dihedral_charmm_omp.cpp b/src/USER-OMP/dihedral_charmm_omp.cpp index 1bed449774..b09863613e 100644 --- a/src/USER-OMP/dihedral_charmm_omp.cpp +++ b/src/USER-OMP/dihedral_charmm_omp.cpp @@ -45,10 +45,7 @@ DihedralCharmmOMP::DihedralCharmmOMP(class LAMMPS *lmp) void DihedralCharmmOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/USER-OMP/dihedral_class2_omp.cpp b/src/USER-OMP/dihedral_class2_omp.cpp index c7ae1572c7..03ac9d9bab 100644 --- a/src/USER-OMP/dihedral_class2_omp.cpp +++ b/src/USER-OMP/dihedral_class2_omp.cpp @@ -43,10 +43,7 @@ DihedralClass2OMP::DihedralClass2OMP(class LAMMPS *lmp) void DihedralClass2OMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_cosine_shift_exp_omp.cpp b/src/USER-OMP/dihedral_cosine_shift_exp_omp.cpp index c43b990028..c64cad9fc3 100644 --- a/src/USER-OMP/dihedral_cosine_shift_exp_omp.cpp +++ b/src/USER-OMP/dihedral_cosine_shift_exp_omp.cpp @@ -43,10 +43,7 @@ DihedralCosineShiftExpOMP::DihedralCosineShiftExpOMP(class LAMMPS *lmp) void DihedralCosineShiftExpOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_fourier_omp.cpp b/src/USER-OMP/dihedral_fourier_omp.cpp index 319acb0beb..94bdae3795 100644 --- a/src/USER-OMP/dihedral_fourier_omp.cpp +++ b/src/USER-OMP/dihedral_fourier_omp.cpp @@ -44,10 +44,7 @@ DihedralFourierOMP::DihedralFourierOMP(class LAMMPS *lmp) void DihedralFourierOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_harmonic_omp.cpp b/src/USER-OMP/dihedral_harmonic_omp.cpp index bb659cf262..10ccbd3d9f 100644 --- a/src/USER-OMP/dihedral_harmonic_omp.cpp +++ b/src/USER-OMP/dihedral_harmonic_omp.cpp @@ -43,10 +43,7 @@ DihedralHarmonicOMP::DihedralHarmonicOMP(class LAMMPS *lmp) void DihedralHarmonicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_helix_omp.cpp b/src/USER-OMP/dihedral_helix_omp.cpp index e40f084e54..8c8e29cac0 100644 --- a/src/USER-OMP/dihedral_helix_omp.cpp +++ b/src/USER-OMP/dihedral_helix_omp.cpp @@ -46,10 +46,7 @@ DihedralHelixOMP::DihedralHelixOMP(class LAMMPS *lmp) void DihedralHelixOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_multi_harmonic_omp.cpp b/src/USER-OMP/dihedral_multi_harmonic_omp.cpp index e10fc7b94a..38961e1746 100644 --- a/src/USER-OMP/dihedral_multi_harmonic_omp.cpp +++ b/src/USER-OMP/dihedral_multi_harmonic_omp.cpp @@ -43,10 +43,7 @@ DihedralMultiHarmonicOMP::DihedralMultiHarmonicOMP(class LAMMPS *lmp) void DihedralMultiHarmonicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_nharmonic_omp.cpp b/src/USER-OMP/dihedral_nharmonic_omp.cpp index ad758fc892..e74238265d 100644 --- a/src/USER-OMP/dihedral_nharmonic_omp.cpp +++ b/src/USER-OMP/dihedral_nharmonic_omp.cpp @@ -43,10 +43,7 @@ DihedralNHarmonicOMP::DihedralNHarmonicOMP(class LAMMPS *lmp) void DihedralNHarmonicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_opls_omp.cpp b/src/USER-OMP/dihedral_opls_omp.cpp index 53fddf51cb..64eaffe6fe 100644 --- a/src/USER-OMP/dihedral_opls_omp.cpp +++ b/src/USER-OMP/dihedral_opls_omp.cpp @@ -44,10 +44,7 @@ DihedralOPLSOMP::DihedralOPLSOMP(class LAMMPS *lmp) void DihedralOPLSOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_quadratic_omp.cpp b/src/USER-OMP/dihedral_quadratic_omp.cpp index f6110cd505..8df622b847 100644 --- a/src/USER-OMP/dihedral_quadratic_omp.cpp +++ b/src/USER-OMP/dihedral_quadratic_omp.cpp @@ -44,10 +44,7 @@ DihedralQuadraticOMP::DihedralQuadraticOMP(class LAMMPS *lmp) void DihedralQuadraticOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/dihedral_table_omp.cpp b/src/USER-OMP/dihedral_table_omp.cpp index 1457f7b2bf..792ee90c26 100644 --- a/src/USER-OMP/dihedral_table_omp.cpp +++ b/src/USER-OMP/dihedral_table_omp.cpp @@ -111,10 +111,7 @@ DihedralTableOMP::DihedralTableOMP(class LAMMPS *lmp) void DihedralTableOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/dihedral.h b/src/dihedral.h index 627104871b..0769d79163 100644 --- a/src/dihedral.h +++ b/src/dihedral.h @@ -57,6 +57,10 @@ class Dihedral : protected Pointers { int maxeatom,maxvatom; void ev_setup(int, int, int alloc = 1); + void ev_init(int eflag, int vflag, int alloc = 1) { + if (eflag||vflag) ev_setup(eflag, vflag, alloc); + else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; + } void ev_tally(int, int, int, int, int, int, double, double *, double *, double *, double, double, double, double, double, double, double, double, double); diff --git a/src/dihedral_hybrid.cpp b/src/dihedral_hybrid.cpp index b9107ac874..f3e4823d53 100644 --- a/src/dihedral_hybrid.cpp +++ b/src/dihedral_hybrid.cpp @@ -104,8 +104,7 @@ void DihedralHybrid::compute(int eflag, int vflag) // set neighbor->dihedrallist to sub-style dihedrallist before call // accumulate sub-style global/peratom energy/virial in hybrid - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); for (m = 0; m < nstyles; m++) { neighbor->ndihedrallist = ndihedrallist[m]; diff --git a/src/dihedral_zero.cpp b/src/dihedral_zero.cpp index 46facdb6db..8145d5f32d 100644 --- a/src/dihedral_zero.cpp +++ b/src/dihedral_zero.cpp @@ -44,8 +44,7 @@ DihedralZero::~DihedralZero() void DihedralZero::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); } /* ---------------------------------------------------------------------- */ From ff2d8e55c99dca2a55a537b12f6e3dcf30b87b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 17:54:10 +0100 Subject: [PATCH 16/49] use ev_init for bonds --- src/CLASS2/bond_class2.cpp | 3 +-- src/KOKKOS/bond_class2_kokkos.cpp | 3 +-- src/KOKKOS/bond_fene_kokkos.cpp | 3 +-- src/KOKKOS/bond_harmonic_kokkos.cpp | 3 +-- src/MOLECULE/bond_fene.cpp | 3 +-- src/MOLECULE/bond_fene_expand.cpp | 3 +-- src/MOLECULE/bond_gromos.cpp | 3 +-- src/MOLECULE/bond_harmonic.cpp | 3 +-- src/MOLECULE/bond_morse.cpp | 3 +-- src/MOLECULE/bond_nonlinear.cpp | 3 +-- src/MOLECULE/bond_quartic.cpp | 3 +-- src/MOLECULE/bond_table.cpp | 3 +-- src/USER-CGDNA/bond_oxdna_fene.cpp | 3 +-- src/USER-INTEL/bond_fene_intel.cpp | 3 +-- src/USER-INTEL/bond_harmonic_intel.cpp | 3 +-- src/USER-MISC/bond_harmonic_shift.cpp | 3 +-- src/USER-MISC/bond_harmonic_shift_cut.cpp | 3 +-- src/USER-OMP/bond_class2_omp.cpp | 5 +---- src/USER-OMP/bond_fene_expand_omp.cpp | 5 +---- src/USER-OMP/bond_fene_omp.cpp | 5 +---- src/USER-OMP/bond_gromos_omp.cpp | 5 +---- src/USER-OMP/bond_harmonic_omp.cpp | 5 +---- src/USER-OMP/bond_harmonic_shift_cut_omp.cpp | 5 +---- src/USER-OMP/bond_harmonic_shift_omp.cpp | 5 +---- src/USER-OMP/bond_morse_omp.cpp | 5 +---- src/USER-OMP/bond_nonlinear_omp.cpp | 5 +---- src/USER-OMP/bond_quartic_omp.cpp | 5 +---- src/USER-OMP/bond_table_omp.cpp | 5 +---- src/USER-YAFF/bond_mm3.cpp | 3 +-- src/bond.h | 4 ++++ src/bond_hybrid.cpp | 3 +-- src/bond_zero.cpp | 3 +-- 32 files changed, 35 insertions(+), 84 deletions(-) diff --git a/src/CLASS2/bond_class2.cpp b/src/CLASS2/bond_class2.cpp index af20313e0a..26c4e63a4d 100644 --- a/src/CLASS2/bond_class2.cpp +++ b/src/CLASS2/bond_class2.cpp @@ -56,8 +56,7 @@ void BondClass2::compute(int eflag, int vflag) double rsq,r,dr,dr2,dr3,dr4,de_bond; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/KOKKOS/bond_class2_kokkos.cpp b/src/KOKKOS/bond_class2_kokkos.cpp index d84b3d390c..798fb41c92 100644 --- a/src/KOKKOS/bond_class2_kokkos.cpp +++ b/src/KOKKOS/bond_class2_kokkos.cpp @@ -60,8 +60,7 @@ void BondClass2Kokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/bond_fene_kokkos.cpp b/src/KOKKOS/bond_fene_kokkos.cpp index d37943ba82..b5cdc1a05a 100644 --- a/src/KOKKOS/bond_fene_kokkos.cpp +++ b/src/KOKKOS/bond_fene_kokkos.cpp @@ -69,8 +69,7 @@ void BondFENEKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/KOKKOS/bond_harmonic_kokkos.cpp b/src/KOKKOS/bond_harmonic_kokkos.cpp index 6cdd4fe856..51a9fa4389 100644 --- a/src/KOKKOS/bond_harmonic_kokkos.cpp +++ b/src/KOKKOS/bond_harmonic_kokkos.cpp @@ -61,8 +61,7 @@ void BondHarmonicKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = 0; + ev_init(eflag,vflag,0); // reallocate per-atom arrays if necessary diff --git a/src/MOLECULE/bond_fene.cpp b/src/MOLECULE/bond_fene.cpp index 671290b0ad..c023a7e81e 100644 --- a/src/MOLECULE/bond_fene.cpp +++ b/src/MOLECULE/bond_fene.cpp @@ -54,8 +54,7 @@ void BondFENE::compute(int eflag, int vflag) double rsq,r0sq,rlogarg,sr2,sr6; ebond = sr6 = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/bond_fene_expand.cpp b/src/MOLECULE/bond_fene_expand.cpp index 3e191683fb..b1bfdc6a1b 100644 --- a/src/MOLECULE/bond_fene_expand.cpp +++ b/src/MOLECULE/bond_fene_expand.cpp @@ -56,8 +56,7 @@ void BondFENEExpand::compute(int eflag, int vflag) double r,rshift,rshiftsq; ebond = sr6 = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/bond_gromos.cpp b/src/MOLECULE/bond_gromos.cpp index 57091903af..f65adeb2cb 100644 --- a/src/MOLECULE/bond_gromos.cpp +++ b/src/MOLECULE/bond_gromos.cpp @@ -55,8 +55,7 @@ void BondGromos::compute(int eflag, int vflag) double delx,dely,delz,ebond,fbond; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/bond_harmonic.cpp b/src/MOLECULE/bond_harmonic.cpp index fb4581d0d6..cb8434ce6e 100644 --- a/src/MOLECULE/bond_harmonic.cpp +++ b/src/MOLECULE/bond_harmonic.cpp @@ -52,8 +52,7 @@ void BondHarmonic::compute(int eflag, int vflag) double rsq,r,dr,rk; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/bond_morse.cpp b/src/MOLECULE/bond_morse.cpp index 06af28f2b0..91dd2dbc49 100644 --- a/src/MOLECULE/bond_morse.cpp +++ b/src/MOLECULE/bond_morse.cpp @@ -53,8 +53,7 @@ void BondMorse::compute(int eflag, int vflag) double rsq,r,dr,ralpha; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/bond_nonlinear.cpp b/src/MOLECULE/bond_nonlinear.cpp index 645b081779..9999ead47f 100644 --- a/src/MOLECULE/bond_nonlinear.cpp +++ b/src/MOLECULE/bond_nonlinear.cpp @@ -49,8 +49,7 @@ void BondNonlinear::compute(int eflag, int vflag) double rsq,r,dr,drsq,lamdasq,denom,denomsq; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/MOLECULE/bond_quartic.cpp b/src/MOLECULE/bond_quartic.cpp index f200030d6c..895202ff00 100644 --- a/src/MOLECULE/bond_quartic.cpp +++ b/src/MOLECULE/bond_quartic.cpp @@ -60,8 +60,7 @@ void BondQuartic::compute(int eflag, int vflag) double r,rsq,dr,r2,ra,rb,sr2,sr6; ebond = evdwl = sr6 = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp index c75779922a..94e843eb65 100644 --- a/src/MOLECULE/bond_table.cpp +++ b/src/MOLECULE/bond_table.cpp @@ -68,8 +68,7 @@ void BondTable::compute(int eflag, int vflag) double u,mdu; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-CGDNA/bond_oxdna_fene.cpp b/src/USER-CGDNA/bond_oxdna_fene.cpp index 34a25a9b5a..8271668e3f 100644 --- a/src/USER-CGDNA/bond_oxdna_fene.cpp +++ b/src/USER-CGDNA/bond_oxdna_fene.cpp @@ -96,8 +96,7 @@ void BondOxdnaFene::compute(int eflag, int vflag) int newton_bond = force->newton_bond; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); // loop over FENE bonds diff --git a/src/USER-INTEL/bond_fene_intel.cpp b/src/USER-INTEL/bond_fene_intel.cpp index bff3722a44..bd8bc94c18 100644 --- a/src/USER-INTEL/bond_fene_intel.cpp +++ b/src/USER-INTEL/bond_fene_intel.cpp @@ -74,8 +74,7 @@ void BondFENEIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-INTEL/bond_harmonic_intel.cpp b/src/USER-INTEL/bond_harmonic_intel.cpp index 65894efa05..4424b868eb 100644 --- a/src/USER-INTEL/bond_harmonic_intel.cpp +++ b/src/USER-INTEL/bond_harmonic_intel.cpp @@ -74,8 +74,7 @@ void BondHarmonicIntel::compute(int eflag, int vflag, IntelBuffers *buffers, const ForceConst &fc) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); if (evflag) { if (vflag && !eflag) { diff --git a/src/USER-MISC/bond_harmonic_shift.cpp b/src/USER-MISC/bond_harmonic_shift.cpp index b34f71e888..c7e4444cce 100644 --- a/src/USER-MISC/bond_harmonic_shift.cpp +++ b/src/USER-MISC/bond_harmonic_shift.cpp @@ -53,8 +53,7 @@ void BondHarmonicShift::compute(int eflag, int vflag) double rsq,r,dr,rk; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-MISC/bond_harmonic_shift_cut.cpp b/src/USER-MISC/bond_harmonic_shift_cut.cpp index a58df70878..5b396f5d72 100644 --- a/src/USER-MISC/bond_harmonic_shift_cut.cpp +++ b/src/USER-MISC/bond_harmonic_shift_cut.cpp @@ -53,8 +53,7 @@ void BondHarmonicShiftCut::compute(int eflag, int vflag) double rsq,r,dr,rk; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/USER-OMP/bond_class2_omp.cpp b/src/USER-OMP/bond_class2_omp.cpp index 1f9bcaa320..fdd73c20b0 100644 --- a/src/USER-OMP/bond_class2_omp.cpp +++ b/src/USER-OMP/bond_class2_omp.cpp @@ -40,10 +40,7 @@ BondClass2OMP::BondClass2OMP(class LAMMPS *lmp) void BondClass2OMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_fene_expand_omp.cpp b/src/USER-OMP/bond_fene_expand_omp.cpp index d002d454dd..a8eec11760 100644 --- a/src/USER-OMP/bond_fene_expand_omp.cpp +++ b/src/USER-OMP/bond_fene_expand_omp.cpp @@ -41,10 +41,7 @@ BondFENEExpandOMP::BondFENEExpandOMP(class LAMMPS *lmp) void BondFENEExpandOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_fene_omp.cpp b/src/USER-OMP/bond_fene_omp.cpp index ba958e1d6f..be7dcd4b49 100644 --- a/src/USER-OMP/bond_fene_omp.cpp +++ b/src/USER-OMP/bond_fene_omp.cpp @@ -41,10 +41,7 @@ BondFENEOMP::BondFENEOMP(class LAMMPS *lmp) void BondFENEOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_gromos_omp.cpp b/src/USER-OMP/bond_gromos_omp.cpp index bcfde436d5..8f0926c0e9 100644 --- a/src/USER-OMP/bond_gromos_omp.cpp +++ b/src/USER-OMP/bond_gromos_omp.cpp @@ -39,10 +39,7 @@ BondGromosOMP::BondGromosOMP(class LAMMPS *lmp) void BondGromosOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_harmonic_omp.cpp b/src/USER-OMP/bond_harmonic_omp.cpp index 46a93cbbdd..a3bb69c53c 100644 --- a/src/USER-OMP/bond_harmonic_omp.cpp +++ b/src/USER-OMP/bond_harmonic_omp.cpp @@ -39,10 +39,7 @@ BondHarmonicOMP::BondHarmonicOMP(class LAMMPS *lmp) void BondHarmonicOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp b/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp index 5f39bb1b64..5c16e27a32 100644 --- a/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp +++ b/src/USER-OMP/bond_harmonic_shift_cut_omp.cpp @@ -39,10 +39,7 @@ BondHarmonicShiftCutOMP::BondHarmonicShiftCutOMP(class LAMMPS *lmp) void BondHarmonicShiftCutOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_harmonic_shift_omp.cpp b/src/USER-OMP/bond_harmonic_shift_omp.cpp index 8c260bfc9b..39e957c137 100644 --- a/src/USER-OMP/bond_harmonic_shift_omp.cpp +++ b/src/USER-OMP/bond_harmonic_shift_omp.cpp @@ -39,10 +39,7 @@ BondHarmonicShiftOMP::BondHarmonicShiftOMP(class LAMMPS *lmp) void BondHarmonicShiftOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_morse_omp.cpp b/src/USER-OMP/bond_morse_omp.cpp index 0c3cded71a..c0203de0d6 100644 --- a/src/USER-OMP/bond_morse_omp.cpp +++ b/src/USER-OMP/bond_morse_omp.cpp @@ -39,10 +39,7 @@ BondMorseOMP::BondMorseOMP(class LAMMPS *lmp) void BondMorseOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_nonlinear_omp.cpp b/src/USER-OMP/bond_nonlinear_omp.cpp index cdc70eac8d..8fa3daf8ab 100644 --- a/src/USER-OMP/bond_nonlinear_omp.cpp +++ b/src/USER-OMP/bond_nonlinear_omp.cpp @@ -39,10 +39,7 @@ BondNonlinearOMP::BondNonlinearOMP(class LAMMPS *lmp) void BondNonlinearOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-OMP/bond_quartic_omp.cpp b/src/USER-OMP/bond_quartic_omp.cpp index b2b1696bb4..fd0ccaf79d 100644 --- a/src/USER-OMP/bond_quartic_omp.cpp +++ b/src/USER-OMP/bond_quartic_omp.cpp @@ -40,10 +40,7 @@ BondQuarticOMP::BondQuarticOMP(class LAMMPS *lmp) void BondQuarticOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-4 virial contribution diff --git a/src/USER-OMP/bond_table_omp.cpp b/src/USER-OMP/bond_table_omp.cpp index 71dc237496..1616988385 100644 --- a/src/USER-OMP/bond_table_omp.cpp +++ b/src/USER-OMP/bond_table_omp.cpp @@ -39,10 +39,7 @@ BondTableOMP::BondTableOMP(class LAMMPS *lmp) void BondTableOMP::compute(int eflag, int vflag) { - - if (eflag || vflag) { - ev_setup(eflag,vflag); - } else evflag = 0; + ev_init(eflag,vflag); const int nall = atom->nlocal + atom->nghost; const int nthreads = comm->nthreads; diff --git a/src/USER-YAFF/bond_mm3.cpp b/src/USER-YAFF/bond_mm3.cpp index 1c464ff895..ee1ebcdd61 100644 --- a/src/USER-YAFF/bond_mm3.cpp +++ b/src/USER-YAFF/bond_mm3.cpp @@ -54,8 +54,7 @@ void BondMM3::compute(int eflag, int vflag) double rsq,r,dr,dr2,de_bond,K3,K4; ebond = 0.0; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); double **x = atom->x; double **f = atom->f; diff --git a/src/bond.h b/src/bond.h index 9c353a1a6d..1082748403 100644 --- a/src/bond.h +++ b/src/bond.h @@ -65,6 +65,10 @@ class Bond : protected Pointers { int maxeatom,maxvatom; void ev_setup(int, int, int alloc = 1); + void ev_init(int eflag, int vflag, int alloc = 1) { + if (eflag||vflag) ev_setup(eflag, vflag, alloc); + else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; + } void ev_tally(int, int, int, int, double, double, double, double, double); }; diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 4e5a26f731..65609b4b6e 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -103,8 +103,7 @@ void BondHybrid::compute(int eflag, int vflag) // set neighbor->bondlist to sub-style bondlist before call // accumulate sub-style global/peratom energy/virial in hybrid - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); for (m = 0; m < nstyles; m++) { neighbor->nbondlist = nbondlist[m]; diff --git a/src/bond_zero.cpp b/src/bond_zero.cpp index 9fcf300b21..0847cf9e6b 100644 --- a/src/bond_zero.cpp +++ b/src/bond_zero.cpp @@ -45,8 +45,7 @@ BondZero::~BondZero() void BondZero::compute(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + ev_init(eflag,vflag); } /* ---------------------------------------------------------------------- */ From 985fc86aa3f8e907c8dae04321db2b6464c007eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 13 Mar 2019 17:55:30 +0100 Subject: [PATCH 17/49] use ev_init for kspace --- src/GPU/pppm_gpu.cpp | 4 +--- src/KOKKOS/pppm_kokkos.cpp | 3 +-- src/KSPACE/ewald.cpp | 4 +--- src/KSPACE/ewald_disp.cpp | 3 +-- src/KSPACE/msm.cpp | 4 +--- src/KSPACE/msm_cg.cpp | 4 +--- src/KSPACE/pppm.cpp | 4 +--- src/KSPACE/pppm_cg.cpp | 4 +--- src/KSPACE/pppm_disp.cpp | 4 +--- src/KSPACE/pppm_stagger.cpp | 4 +--- src/USER-INTEL/pppm_disp_intel.cpp | 4 +--- src/USER-INTEL/pppm_intel.cpp | 4 +--- src/USER-OMP/ewald_omp.cpp | 4 +--- src/USER-OMP/msm_cg_omp.cpp | 4 +--- src/USER-SCAFACOS/scafacos.cpp | 7 +------ src/kspace.cpp | 4 +--- src/kspace.h | 4 ++++ 17 files changed, 20 insertions(+), 49 deletions(-) diff --git a/src/GPU/pppm_gpu.cpp b/src/GPU/pppm_gpu.cpp index 4b460b1280..1bb1a39703 100644 --- a/src/GPU/pppm_gpu.cpp +++ b/src/GPU/pppm_gpu.cpp @@ -199,9 +199,7 @@ void PPPMGPU::compute(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); // If need per-atom energies/virials, allocate per-atom arrays here // so that particle map on host can be done concurrently with GPU calculations diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index bcac29ba9b..c233ca6264 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -615,8 +615,7 @@ void PPPMKokkos::compute(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag,0); - else evflag = evflag_atom = eflag_global = vflag_global = + ev_init(eflag,vflag,0); eflag_atom = vflag_atom = 0; // reallocate per-atom arrays if necessary diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index 283c672bad..ccbb3ed708 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -365,9 +365,7 @@ void Ewald::compute(int eflag, int vflag) // set energy/virial flags - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); // if atom count has changed, update qsum and qsqsum diff --git a/src/KSPACE/ewald_disp.cpp b/src/KSPACE/ewald_disp.cpp index 4cbdf7b9cb..0603d68eb2 100644 --- a/src/KSPACE/ewald_disp.cpp +++ b/src/KSPACE/ewald_disp.cpp @@ -688,8 +688,7 @@ void EwaldDisp::compute(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (!peratom_allocate_flag && (eflag_atom || vflag_atom)) { allocate_peratom(); diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index d8964ffa67..d7cc3f6876 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -454,9 +454,7 @@ void MSM::compute(int eflag, int vflag) // set energy/virial flags - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = eflag_either = vflag_either = 0; + ev_init(eflag,vflag); if (scalar_pressure_flag && vflag_either) { if (vflag_atom) diff --git a/src/KSPACE/msm_cg.cpp b/src/KSPACE/msm_cg.cpp index 55435e5a6e..c7896db50c 100644 --- a/src/KSPACE/msm_cg.cpp +++ b/src/KSPACE/msm_cg.cpp @@ -90,9 +90,7 @@ void MSMCG::compute(int eflag, int vflag) // set energy/virial flags - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = eflag_either = vflag_either = 0; + ev_init(eflag,vflag); // invoke allocate_peratom() if needed for first time diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 8fd74d00dc..773305bb5e 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -630,9 +630,7 @@ void PPPM::compute(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); diff --git a/src/KSPACE/pppm_cg.cpp b/src/KSPACE/pppm_cg.cpp index fa73588363..3285dba21c 100644 --- a/src/KSPACE/pppm_cg.cpp +++ b/src/KSPACE/pppm_cg.cpp @@ -88,9 +88,7 @@ void PPPMCG::compute(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 687ea0b3f9..45dce0895b 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -928,9 +928,7 @@ void PPPMDisp::compute(int eflag, int vflag) int i; // convert atoms from box to lamda coords - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); diff --git a/src/KSPACE/pppm_stagger.cpp b/src/KSPACE/pppm_stagger.cpp index ca369cf260..a5ed6de626 100644 --- a/src/KSPACE/pppm_stagger.cpp +++ b/src/KSPACE/pppm_stagger.cpp @@ -124,9 +124,7 @@ void PPPMStagger::compute(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); diff --git a/src/USER-INTEL/pppm_disp_intel.cpp b/src/USER-INTEL/pppm_disp_intel.cpp index 795fe1a47d..9d075c78a1 100644 --- a/src/USER-INTEL/pppm_disp_intel.cpp +++ b/src/USER-INTEL/pppm_disp_intel.cpp @@ -174,9 +174,7 @@ void PPPMDispIntel::compute(int eflag, int vflag) int i; // convert atoms from box to lamda coords - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); diff --git a/src/USER-INTEL/pppm_intel.cpp b/src/USER-INTEL/pppm_intel.cpp index 59455bcf52..e3d1e7d4aa 100644 --- a/src/USER-INTEL/pppm_intel.cpp +++ b/src/USER-INTEL/pppm_intel.cpp @@ -161,9 +161,7 @@ void PPPMIntel::compute_first(int eflag, int vflag) // set energy/virial flags // invoke allocate_peratom() if needed for first time - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); diff --git a/src/USER-OMP/ewald_omp.cpp b/src/USER-OMP/ewald_omp.cpp index 1fece5c31b..b56fc25142 100644 --- a/src/USER-OMP/ewald_omp.cpp +++ b/src/USER-OMP/ewald_omp.cpp @@ -61,9 +61,7 @@ void EwaldOMP::compute(int eflag, int vflag) { // set energy/virial flags - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); // extend size of per-atom arrays if necessary diff --git a/src/USER-OMP/msm_cg_omp.cpp b/src/USER-OMP/msm_cg_omp.cpp index dee9fd85b6..8a920e05d5 100644 --- a/src/USER-OMP/msm_cg_omp.cpp +++ b/src/USER-OMP/msm_cg_omp.cpp @@ -90,9 +90,7 @@ void MSMCGOMP::compute(int eflag, int vflag) // set energy/virial flags - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = eflag_either = vflag_either = 0; + ev_init(eflag,vflag); // invoke allocate_peratom() if needed for first time diff --git a/src/USER-SCAFACOS/scafacos.cpp b/src/USER-SCAFACOS/scafacos.cpp index 4b8e10123c..497442fbe8 100644 --- a/src/USER-SCAFACOS/scafacos.cpp +++ b/src/USER-SCAFACOS/scafacos.cpp @@ -197,12 +197,7 @@ void Scafacos::compute(int eflag, int vflag) fcs_set_redistribute((FCS)fcs,0); } - if (eflag || vflag) ev_setup(eflag,vflag); - else - { - eflag_atom = 0; - vflag_global = 0; - } + ev_init(eflag,vflag); // grow xpbc, epot, efield if necessary diff --git a/src/kspace.cpp b/src/kspace.cpp index 25491cd964..0144ea59a3 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -168,9 +168,7 @@ void KSpace::triclinic_check() void KSpace::compute_dummy(int eflag, int vflag) { - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + ev_init(eflag,vflag); } /* ---------------------------------------------------------------------- diff --git a/src/kspace.h b/src/kspace.h index f29659d0e8..12cb16c929 100644 --- a/src/kspace.h +++ b/src/kspace.h @@ -195,6 +195,10 @@ class KSpace : protected Pointers { void pair_check(); void ev_setup(int, int, int alloc = 1); + void ev_init(int eflag, int vflag, int alloc = 1) { + if (eflag||vflag) ev_setup(eflag, vflag, alloc); + else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; + } double estimate_table_accuracy(double, double); }; From 02b800a3bbaf1b4ec1a5e023849ee66bf2cb47ad Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 19 Aug 2018 20:25:23 -0400 Subject: [PATCH 18/49] add template for new kim_query command --- src/.gitignore | 7 ++- src/KIM/kim_query.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++ src/KIM/kim_query.h | 85 +++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 src/KIM/kim_query.cpp create mode 100644 src/KIM/kim_query.h diff --git a/src/.gitignore b/src/.gitignore index d405cb209e..27f4f8a64c 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -26,6 +26,11 @@ /*_ssa.h /*_ssa.cpp +/kim_query.cpp +/kim_query.h +/pair_kim.cpp +/pair_kim.h + /kokkos.cpp /kokkos.h /kokkos_type.h @@ -818,8 +823,6 @@ /pair_hbond_dreiding_morse.h /pair_ilp_graphene_hbn.cpp /pair_ilp_graphene_hbn.h -/pair_kim.cpp -/pair_kim.h /pair_kolmogorov_crespi_full.cpp /pair_kolmogorov_crespi_full.h /pair_kolmogorov_crespi_z.cpp diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp new file mode 100644 index 0000000000..1755b61417 --- /dev/null +++ b/src/KIM/kim_query.cpp @@ -0,0 +1,116 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + + +/* ---------------------------------------------------------------------- + Contributing authors: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-v2.0.0-beta.1 (and newer) package +------------------------------------------------------------------------- */ + +#include +#include +#include "kim_query.h" +#include "comm.h" +#include "error.h" +#include "input.h" +#include "variable.h" + +using namespace LAMMPS_NS; + +static char *do_query(char *, char *, int, MPI_Comm); + +/* ---------------------------------------------------------------------- */ + +void KimQuery::command(int narg, char **arg) +{ + char *model, *property, *varname, *value; + + if (narg != 3) error->all(FLERR,"Illegal kim_query command"); + + model = arg[0]; + property = arg[1]; + varname = arg[2]; + + value = do_query(model, property, comm->me, world); + + if (comm->me == 0) + printf("property %s for model %s is %s\n",property,model,value); + + char **varcmd = new char*[3]; + varcmd[0] = varname; + varcmd[1] = (char *) "string"; + varcmd[2] = value; + + input->variable->set(3,varcmd); + + delete[] varcmd; + delete[] value; +} + + +char *do_query(char *model, char *property, int rank, MPI_Comm comm) +{ + char val[512], *retval; + int len; + + // only run query from rank 0 + if (rank == 0) { + + // fake query + strcpy(val,(const char*)"4.25"); + } + MPI_Bcast(val, 512, MPI_CHAR, 0, comm); + len = strlen(val) + 1; + retval = new char[len]; + strcpy(retval,val); + + return retval; +} diff --git a/src/KIM/kim_query.h b/src/KIM/kim_query.h new file mode 100644 index 0000000000..92972d804d --- /dev/null +++ b/src/KIM/kim_query.h @@ -0,0 +1,85 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Axel Kohlmeyer (Temple U), + Ryan S. Elliott (UMN) +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see . + + Linking LAMMPS statically or dynamically with other modules is making a + combined work based on LAMMPS. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + In addition, as a special exception, the copyright holders of LAMMPS give + you permission to combine LAMMPS with free software programs or libraries + that are released under the GNU LGPL and with code included in the standard + release of the "kim-api" under the CDDL (or modified versions of such code, + with unchanged license). You may copy and distribute such a system following + the terms of the GNU GPL for LAMMPS and the licenses of the other code + concerned, provided that you include the source code of that other code + when and as the GNU GPL requires distribution of source code. + + Note that people who make modified versions of LAMMPS are not obligated to + grant this special exception for their modified versions; it is their choice + whether to do so. The GNU General Public License gives permission to release + a modified version without this exception; this exception also makes it + possible to release a modified version which carries forward this exception. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Designed for use with the kim-api-v2.0.0-beta.1 (and newer) package +------------------------------------------------------------------------- */ + +#ifdef COMMAND_CLASS + +CommandStyle(kim_query,KimQuery) + +#else + +#ifndef LMP_KIM_QUERY_H +#define LMP_KIM_QUERY_H + +#include "pointers.h" + +namespace LAMMPS_NS { + +class KimQuery : protected Pointers { + public: + KimQuery(class LAMMPS *lmp) : Pointers(lmp) {}; + void command(int, char **); + +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + + +*/ From 7a8bb5baaf938f7534c9f0aee2231ff1a744a2f8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 19 Aug 2018 21:18:03 -0400 Subject: [PATCH 19/49] come code cleanup and refactoring --- src/KIM/kim_query.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 1755b61417..17f993c92d 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -81,8 +81,13 @@ void KimQuery::command(int narg, char **arg) value = do_query(model, property, comm->me, world); - if (comm->me == 0) - printf("property %s for model %s is %s\n",property,model,value); + // check for valid result + + int len = strlen(value) + 1; + if (len == 1) { + // TODO: store more detailed error message after \0 byte. + error->all(FLERR,"Query of OpenKIM database failed"); + } char **varcmd = new char*[3]; varcmd[0] = varname; @@ -98,19 +103,21 @@ void KimQuery::command(int narg, char **arg) char *do_query(char *model, char *property, int rank, MPI_Comm comm) { - char val[512], *retval; - int len; + char value[512], *retval; // only run query from rank 0 if (rank == 0) { // fake query - strcpy(val,(const char*)"4.25"); + strcpy(value,(const char*)"4.25"); } - MPI_Bcast(val, 512, MPI_CHAR, 0, comm); - len = strlen(val) + 1; + MPI_Bcast(value, 512, MPI_CHAR, 0, comm); + + // must make a proper copy of the query, as the stack allocation + // will go out of scope + + int len = strlen(value) + 1; retval = new char[len]; - strcpy(retval,val); - + strcpy(retval,value); return retval; } From 741a7fe630d5e445163115c897db5aba74455f7f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Aug 2018 18:56:40 -0400 Subject: [PATCH 20/49] final touches to support compiling with libcurl transparently --- examples/kim/in.query | 11 ++ examples/kim/log.16Aug2018.query.g++.1 | 34 ++++++ lib/kim/Makefile.lammps | 7 +- lib/kim/README | 6 + src/KIM/kim_query.cpp | 154 +++++++++++++++++++++---- 5 files changed, 190 insertions(+), 22 deletions(-) create mode 100644 examples/kim/in.query create mode 100644 examples/kim/log.16Aug2018.query.g++.1 diff --git a/examples/kim/in.query b/examples/kim/in.query new file mode 100644 index 0000000000..8538cac749 --- /dev/null +++ b/examples/kim/in.query @@ -0,0 +1,11 @@ + +# example for performing a query to the OpenKIM test database to retrieve +# a parameter to be used in the input. here it requests the aluminium +# lattice constant for a specific test used for a specific model and then +# assigns it to the variable 'latconst' + +units metal +info variables out log +kim_query latconst get_test_result test=TE_156715955670_004 species=["Al"] model=MO_800509458712_001 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] +info variables out log +lattice fcc ${latconst} diff --git a/examples/kim/log.16Aug2018.query.g++.1 b/examples/kim/log.16Aug2018.query.g++.1 new file mode 100644 index 0000000000..eb83dd84b1 --- /dev/null +++ b/examples/kim/log.16Aug2018.query.g++.1 @@ -0,0 +1,34 @@ +LAMMPS (16 Aug 2018) + +# example for performing a query to the OpenKIM test database to retrieve +# a parameter to be used in the input. here it requests the aluminium +# lattice constant for a specific test used for a specific model and then +# assigns it to the variable 'latconst' + +units metal +info variables out log + +Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info +Printed on Mon Aug 20 18:44:24 2018 + + +Variable information: + +Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info + +kim_query latconst get_test_result test=TE_156715955670_004 species=["Al"] model=MO_800509458712_001 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] +info variables out log + +Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info +Printed on Mon Aug 20 18:44:24 2018 + + +Variable information: +Variable[ 0]: latconst , style = string , def = 4.0320827961 + +Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info + +lattice fcc ${latconst} +lattice fcc 4.0320827961 +Lattice spacing in x,y,z = 4.03208 4.03208 4.03208 +Total wall time: 0:00:00 diff --git a/lib/kim/Makefile.lammps b/lib/kim/Makefile.lammps index 7c9fc7c5f7..492b9ddfc6 100644 --- a/lib/kim/Makefile.lammps +++ b/lib/kim/Makefile.lammps @@ -17,13 +17,18 @@ ifeq ($(strip $(shell pkg-config --version)),) $(error 'pkg-config' not found, but is required to configure the KIM API) endif - kim_PREFIX := $(shell cat ../../lib/kim/kim-prefix.txt 2> /dev/null) kim_PREFIX := $(if $(kim_PREFIX),$(kim_PREFIX)/lib/pkgconfig,) kim_PREFIX := $(if $(shell printf -- "$${PKG_CONFIG_PATH}"),$(kim_PREFIX):$(shell printf -- "$${PKG_CONFIG_PATH}"),$(kim_PREFIX)) +# there is no usable libcurl installation +ifeq ($(shell curl-config --version 2> /dev/null),) kim_SYSINC := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --cflags libkim-api-v2 2> /dev/null) kim_SYSLIB := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --libs libkim-api-v2 2> /dev/null) +else +kim_SYSINC := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --cflags libkim-api-v2 2> /dev/null) $(shell curl-config --cflags) -DLMP_KIM_CURL +kim_SYSLIB := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --libs libkim-api-v2 2> /dev/null) $(shell curl-config --libs) +endif ifeq ($(strip $(kim_SYSINC)),) $(error 'pkg-config' could not find an installed KIM API library.) diff --git a/lib/kim/README b/lib/kim/README index 0e51a30870..493758561d 100644 --- a/lib/kim/README +++ b/lib/kim/README @@ -13,6 +13,12 @@ do the same thing by typing "python Install.py" from within this directory, or you can do it manually by following the instructions below. +As of KIM API version 2, the KIM package also provides a LAMMPS command +to perform queries through the OpenKIM web API. This feature requires +that the CURL library (libcurl) development package and its configuration +query tool, curl-config, are installed. The provided Makefile.lammps +is set up to automatically detect this. + ----------------- Instructions: diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 17f993c92d..8d400ac333 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -57,36 +57,55 @@ #include #include +#include #include "kim_query.h" #include "comm.h" #include "error.h" #include "input.h" #include "variable.h" +#include +#include + using namespace LAMMPS_NS; -static char *do_query(char *, char *, int, MPI_Comm); +#if defined(LMP_KIM_CURL) + +struct WriteBuf { + char *dataptr; + size_t sizeleft; +}; + +static char *do_query(char *, int, char **, int, MPI_Comm); +static size_t write_callback(void *, size_t, size_t, void *); + +#endif /* ---------------------------------------------------------------------- */ void KimQuery::command(int narg, char **arg) { - char *model, *property, *varname, *value; + char *varname, *function, *value; - if (narg != 3) error->all(FLERR,"Illegal kim_query command"); + if (narg < 2) error->all(FLERR,"Illegal kim_query command"); - model = arg[0]; - property = arg[1]; - varname = arg[2]; + varname = arg[0]; + function = arg[1]; - value = do_query(model, property, comm->me, world); +#if defined(LMP_KIM_CURL) + + value = do_query(function, narg-2, arg+2, comm->me, world); // check for valid result + // on error the content of "value" is a '\0' byte + // as the first element, and then the error message + // that was returned by the web server - int len = strlen(value) + 1; - if (len == 1) { - // TODO: store more detailed error message after \0 byte. - error->all(FLERR,"Query of OpenKIM database failed"); + if (0 == strlen(value)) { + char errmsg[512]; + + sprintf(errmsg,"OpenKIM query failed: %s",value+1); + error->all(FLERR,errmsg); } char **varcmd = new char*[3]; @@ -98,26 +117,119 @@ void KimQuery::command(int narg, char **arg) delete[] varcmd; delete[] value; +#else + error->all(FLERR,"Cannot use 'kim_query' command when KIM package " + "is compiled without support for libcurl"); +#endif } +#if defined(LMP_KIM_CURL) -char *do_query(char *model, char *property, int rank, MPI_Comm comm) +// copy data to the user provided data structure, optionally in increments + +size_t write_callback(void *data, size_t size, size_t nmemb, void *userp) +{ + struct WriteBuf *buf = (struct WriteBuf *)userp; + size_t buffer_size = size*nmemb; + + // copy chunks into the buffer for as long as there is space left + if (buf->sizeleft) { + size_t copy_this_much = buf->sizeleft; + if (copy_this_much > buffer_size) + copy_this_much = buffer_size; + memcpy(buf->dataptr, data, copy_this_much); + + buf->dataptr += copy_this_much; + buf->sizeleft -= copy_this_much; + return copy_this_much; + } + return 0; // done +} + +char *do_query(char *qfunction, int narg, char **arg, int rank, MPI_Comm comm) { char value[512], *retval; - // only run query from rank 0 - if (rank == 0) { + // run the web query from rank 0 only - // fake query - strcpy(value,(const char*)"4.25"); + if (rank == 0) { + CURL *handle; + CURLcode res; + + // set up and clear receive buffer + + struct WriteBuf buf; + buf.dataptr = value; + buf.sizeleft = 511; + memset(value,0,512); + + // create curl web query instance + curl_global_init(CURL_GLOBAL_DEFAULT); + handle = curl_easy_init(); + + if (handle) { + std::string url("https://query.openkim.org/api/"); + url += qfunction; + + std::string query(arg[0]); + for (int i=1; i < narg; ++i) { + query += '&'; + query += arg[i]; + } + +#if LMP_DEBUG_CURL + curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L); +#endif + +#if defined(LMP_NO_SSL_CHECK) + // disable verifying SSL certificate and host name + curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L); +#endif + + curl_easy_setopt(handle, CURLOPT_URL, url.c_str()); + curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(handle, CURLOPT_POSTFIELDS, query.c_str()); + + curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION,write_callback); + curl_easy_setopt(handle, CURLOPT_WRITEDATA,&buf); + + // perform OpenKIM query and check for errors + res = curl_easy_perform(handle); + if (res != CURLE_OK) { + // on error we return an "empty" string but add error message after it + value[0]= '\0'; + strcpy(value+1,curl_easy_strerror(res)); + } + curl_easy_cleanup(handle); + } + curl_global_cleanup(); } MPI_Bcast(value, 512, MPI_CHAR, 0, comm); - // must make a proper copy of the query, as the stack allocation - // will go out of scope + // we must make a proper copy of the query, as the stack allocation + // for "value" will go out of scope. a valid query has a '[' as + // the first character. skip over it (and the last character ']', too) + // an error messages starts with a '\0' character. copy that and + // the remaining string, as that is the error message. - int len = strlen(value) + 1; - retval = new char[len]; - strcpy(retval,value); + if (value[0] == '[') { + int len = strlen(value)-1; + retval = new char[len]; + value[len] = '\0'; + strcpy(retval,value+1); + } else if (value[0] == '\0') { + int len = strlen(value+1)+2; + retval = new char[len]; + retval[0] = '\0'; + strcpy(retval+1,value+1); + } else { + // unknown response type. we should not get here. + // copy response without modifications. + int len = strlen(value)+1; + retval = new char[len]; + strcpy(retval,value); + } return retval; } +#endif From 38c373a0e41d4f4d07d0624187680eb55b46c5d7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Aug 2018 21:29:32 -0400 Subject: [PATCH 21/49] integrate new kim_query command into the documentation environment --- doc/src/Build_extras.txt | 4 +++- doc/src/Packages_details.txt | 2 ++ doc/src/commands_list.txt | 1 + doc/src/kim_query.txt | 46 ++++++++++++++++++++++++++++++++++++ doc/src/lammps.book | 1 + doc/src/pair_kim.txt | 9 +++---- 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 doc/src/kim_query.txt diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index cbbd9db2f3..c096b5901b 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -171,7 +171,9 @@ KIM package :h4,link(kim) To build with this package, the KIM library must be downloaded and built on your system. It must include the KIM models that you want to -use with LAMMPS. +use with LAMMPS. If you want to use the "kim_query"_kim_query.html +command, you also need to have libcurl installed with the matching +development headers and the curl-config tool. Note that in LAMMPS lingo, a KIM model driver is a pair style (e.g. EAM or Tersoff). A KIM model is a pair style for a particular diff --git a/doc/src/Packages_details.txt b/doc/src/Packages_details.txt index 3a362a23d0..0ab1b5e4fd 100644 --- a/doc/src/Packages_details.txt +++ b/doc/src/Packages_details.txt @@ -341,6 +341,8 @@ KIM package :link(PKG-KIM),h4 A "pair_style kim"_pair_kim.html command which is a wrapper on the Knowledge Base for Interatomic Models (KIM) repository of interatomic potentials, enabling any of them to be used in LAMMPS simulations. +Also a "kim_query"_kim_query.html command, which allows to query +the OpenKIM database for stored properties. To use this package you must have the KIM library available on your system. diff --git a/doc/src/commands_list.txt b/doc/src/commands_list.txt index 27e0906b5f..61221b26d8 100644 --- a/doc/src/commands_list.txt +++ b/doc/src/commands_list.txt @@ -53,6 +53,7 @@ Commands :h1 include info jump + kim_query kspace_modify kspace_style label diff --git a/doc/src/kim_query.txt b/doc/src/kim_query.txt new file mode 100644 index 0000000000..61f8bf12ae --- /dev/null +++ b/doc/src/kim_query.txt @@ -0,0 +1,46 @@ +"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c + +:link(lws,http://lammps.sandia.gov) +:link(ld,Manual.html) +:link(lc,Commands_all.html) + +:line + +kim_query command :h3 + +[Syntax:] + +kim_query variable query_function web_query_flags :pre + +variable = name of a (string style) variable where the result of the query is stored +query_function = name of the OpenKIM web API query function to be used +web_query_flags = a series of keyword=value pairs that represent the web query; supported keywords depend on query function :ul + +[Examples:] + +kim_query latconst get_test_result test=TE_156715955670_004 model=MO_800509458712_001 & + prop=structure-cubic-crystal-npt species=\["Al"\] keys=\["a"\] units=\["angstrom"\] :pre + +[Description:] + +The kim_query command allows to retrieve properties from the OpenKIM +through a web query. The result is stored in a string style +"variable"_variable.html, the name of which must be given as the first +argument of the kim_query command. The second required argument is the +name of the actual query function (e.g. {get_test_result}). All following +arguments are parameters handed over to the web query in the format +{keyword=value}. This list of supported keywords and the type of how +the value has to be encoded depends on the query function used. +For more details on this, please refer to the OpenKIM homepage. + +[Restrictions:] + +This command is part of the KIM package. It is only enabled if +LAMMPS was built with that package. Furthermore, its correct +functioning is dependend on compiling LAMMPS with libcurl support. +See the "Build package"_Build_package.html doc page for more info. + +[Related commands:] + +"pair_style kim"_pair_kim.html, "variable"_variable.html + diff --git a/doc/src/lammps.book b/doc/src/lammps.book index 198e234f0c..6b220ed241 100644 --- a/doc/src/lammps.book +++ b/doc/src/lammps.book @@ -167,6 +167,7 @@ if.html include.html info.html jump.html +kim_query.html label.html lattice.html log.html diff --git a/doc/src/pair_kim.txt b/doc/src/pair_kim.txt index c5d42403e3..a415ac606b 100644 --- a/doc/src/pair_kim.txt +++ b/doc/src/pair_kim.txt @@ -42,12 +42,9 @@ section of the "Packages details"_Packages_details.html doc page has instructions on how to do this with a simple make command, when building LAMMPS. -See the examples/kim dir for an input script that uses a KIM model (potential) -for Lennard-Jones. Note, for this example input script, the example models -shipped with with kim-api package must be installed. See the "Build -package"_Build_package.html section and the ./lib/kim/README for details -on how to build LAMMSPS with the kim-api and how to install the example models. - +See the examples/kim dir for an input script that uses a KIM model +(potential) for Lennard-Jones. + :line The argument {model} is the name of the KIM model for a specific From fed48427be9ee74c21cdf6fa5edc2b37bf4df95c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Aug 2018 22:15:02 -0400 Subject: [PATCH 22/49] update lib/kim/Install.py to support md5 checksum. update CMake support as needed --- cmake/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f6f822676e..601aa4b7c4 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -670,6 +670,12 @@ if(PKG_USER-VTK) endif() if(PKG_KIM) + find_package(CURL) + if(CURL_FOUND) + include_directories(${CURL_INCLUDE_DIRS}) + list(APPEND LAMMPS_LINK_LIBS ${CURL_LIBRARIES}) + add_definitions(-DLMP_KIM_CURL) + endif() option(DOWNLOAD_KIM "Download KIM-API v2 from OpenKIM instead of using an already installed one" OFF) if(DOWNLOAD_KIM) message(STATUS "KIM-API v2 download requested - we will build our own") From 1c3e3ce5481144b77bc438de5bb1cdcfceb0b055 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 19 Mar 2019 15:57:19 -0400 Subject: [PATCH 23/49] add kim_query command to commands list --- doc/src/Commands_all.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/Commands_all.txt b/doc/src/Commands_all.txt index 155b56ace8..ddb8e121cb 100644 --- a/doc/src/Commands_all.txt +++ b/doc/src/Commands_all.txt @@ -68,6 +68,7 @@ An alphabetic list of all general LAMMPS commands. "improper_style"_improper_style.html, "include"_include.html, "jump"_jump.html, +"kim_query"_kim_query.html, "kspace_modify"_kspace_modify.html, "kspace_style"_kspace_style.html, "label"_label.html, From 2dbc2c59169533d3fe2e8ad0897abf7288d8afd4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 19 Mar 2019 16:04:53 -0400 Subject: [PATCH 24/49] fix spelling issues in documentation and some minor clarification --- doc/src/Build_extras.txt | 10 +++++----- doc/src/kim_query.txt | 2 +- doc/utils/sphinx-config/false_positives.txt | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index c096b5901b..66f1c8fcbd 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -169,8 +169,8 @@ used to build the GPU library. KIM package :h4,link(kim) -To build with this package, the KIM library must be downloaded and -built on your system. It must include the KIM models that you want to +To build with this package, the KIM library with API v2 must be downloaded +and built on your system. It must include the KIM models that you want to use with LAMMPS. If you want to use the "kim_query"_kim_query.html command, you also need to have libcurl installed with the matching development headers and the curl-config tool. @@ -178,9 +178,9 @@ development headers and the curl-config tool. Note that in LAMMPS lingo, a KIM model driver is a pair style (e.g. EAM or Tersoff). A KIM model is a pair style for a particular element or alloy and set of parameters, e.g. EAM for Cu with a -specific EAM potential file. Also note that installing the KIM API -library with all its models, may take around 30 min to build. Of -course you only need to do that once. +specific EAM potential file. Also note that downloading and installing +the KIM API library with all its models, may take a long time (10s of +minutes to hours) to build. Of course you only need to do that once. See the list of KIM model drivers here: https://openkim.org/browse/model-drivers/alphabetical diff --git a/doc/src/kim_query.txt b/doc/src/kim_query.txt index 61f8bf12ae..ffebe698be 100644 --- a/doc/src/kim_query.txt +++ b/doc/src/kim_query.txt @@ -37,7 +37,7 @@ For more details on this, please refer to the OpenKIM homepage. This command is part of the KIM package. It is only enabled if LAMMPS was built with that package. Furthermore, its correct -functioning is dependend on compiling LAMMPS with libcurl support. +functioning depends on compiling LAMMPS with libcurl support. See the "Build package"_Build_package.html doc page for more info. [Related commands:] diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 5366a31d5d..6eb158396f 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1382,6 +1382,7 @@ libAtoms libawpmd libch libcolvars +libcurl libdir libdl libfftw From a508f1de6c8001b7c70cf75330663faf06996818 Mon Sep 17 00:00:00 2001 From: julient31 Date: Tue, 19 Mar 2019 22:30:44 -0600 Subject: [PATCH 25/49] Commit JT 031919 - correct. error in fix_prec_spin - added min_post_force in fix_prec_spin --- src/SPIN/fix_precession_spin.cpp | 17 +++++++++++++---- src/SPIN/fix_precession_spin.h | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/SPIN/fix_precession_spin.cpp b/src/SPIN/fix_precession_spin.cpp index d3edb3ae8a..433a260e83 100644 --- a/src/SPIN/fix_precession_spin.cpp +++ b/src/SPIN/fix_precession_spin.cpp @@ -115,6 +115,7 @@ int FixPrecessionSpin::setmask() { int mask = 0; mask |= POST_FORCE; + mask |= MIN_POST_FORCE; mask |= THERMO_ENERGY; mask |= POST_FORCE_RESPA; return mask; @@ -171,6 +172,7 @@ void FixPrecessionSpin::setup(int vflag) void FixPrecessionSpin::post_force(int /*vflag*/) { + // update mag field with time (potential improvement) if (varflag != CONSTANT) { @@ -200,7 +202,7 @@ void FixPrecessionSpin::post_force(int /*vflag*/) if (aniso_flag) { // compute magnetic anisotropy compute_anisotropy(spi,fmi); - emag -= (spi[0]*fmi[0] + spi[1]*fmi[1] + spi[2]*fmi[2]); + emag -= 0.5*(spi[0]*fmi[0] + spi[1]*fmi[1] + spi[2]*fmi[2]); } fm[i][0] += fmi[0]; @@ -228,9 +230,9 @@ void FixPrecessionSpin::compute_single_precession(int i, double spi[3], double f void FixPrecessionSpin::compute_zeeman(int i, double fmi[3]) { double **sp = atom->sp; - fmi[0] -= sp[i][3]*hx; - fmi[1] -= sp[i][3]*hy; - fmi[2] -= sp[i][3]*hz; + fmi[0] += sp[i][0]*hx; + fmi[1] += sp[i][1]*hy; + fmi[2] += sp[i][3]*hz; } /* ---------------------------------------------------------------------- */ @@ -280,3 +282,10 @@ double FixPrecessionSpin::compute_scalar() } return emag_all; } + +/* ---------------------------------------------------------------------- */ + +void FixPrecessionSpin::min_post_force(int vflag) +{ + post_force(vflag); +} diff --git a/src/SPIN/fix_precession_spin.h b/src/SPIN/fix_precession_spin.h index 53ae4ba124..2fe6b5a673 100644 --- a/src/SPIN/fix_precession_spin.h +++ b/src/SPIN/fix_precession_spin.h @@ -33,8 +33,9 @@ class FixPrecessionSpin : public Fix { int setmask(); void init(); void setup(int); - virtual void post_force(int); - virtual void post_force_respa(int, int, int); + void post_force(int); + void post_force_respa(int, int, int); + void min_post_force(int); double compute_scalar(); int zeeman_flag, aniso_flag; From 86810c2d7ccab32a9f0019e94d9197ae5d85bafc Mon Sep 17 00:00:00 2001 From: julient31 Date: Tue, 19 Mar 2019 22:44:26 -0600 Subject: [PATCH 26/49] Commit2 JT 031919 - correct error in fix_precession_spin - only the sign of the force needed a correction --- src/SPIN/fix_precession_spin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPIN/fix_precession_spin.cpp b/src/SPIN/fix_precession_spin.cpp index 433a260e83..6ccb692033 100644 --- a/src/SPIN/fix_precession_spin.cpp +++ b/src/SPIN/fix_precession_spin.cpp @@ -230,8 +230,8 @@ void FixPrecessionSpin::compute_single_precession(int i, double spi[3], double f void FixPrecessionSpin::compute_zeeman(int i, double fmi[3]) { double **sp = atom->sp; - fmi[0] += sp[i][0]*hx; - fmi[1] += sp[i][1]*hy; + fmi[0] += sp[i][3]*hx; + fmi[1] += sp[i][3]*hy; fmi[2] += sp[i][3]*hz; } From 1e8ccb17742f8cf72f06ca4780598a2e81999ff2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 04:54:06 -0400 Subject: [PATCH 27/49] initialize setflag and cutsq pointers to NULL, so they are not accessed uninitialized by accident --- src/pair.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pair.cpp b/src/pair.cpp index 44cf3a43ea..9fd3515a3d 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -72,6 +72,9 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp) single_extra = 0; svector = NULL; + setflag = NULL; + cutsq = NULL; + ewaldflag = pppmflag = msmflag = dispersionflag = tip4pflag = dipoleflag = 0; reinitflag = 1; From 8f90d6c6d00a8dd07edbd510b072f7f953a114ea Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 04:55:13 -0400 Subject: [PATCH 28/49] must bracket 'memory->destroy()' calls in destructor with 'if (allocated)' --- src/pair_buck_coul_cut.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pair_buck_coul_cut.cpp b/src/pair_buck_coul_cut.cpp index 7eecb62121..f9e7c94920 100644 --- a/src/pair_buck_coul_cut.cpp +++ b/src/pair_buck_coul_cut.cpp @@ -42,7 +42,9 @@ PairBuckCoulCut::PairBuckCoulCut(LAMMPS *lmp) : Pair(lmp) PairBuckCoulCut::~PairBuckCoulCut() { - if (!copymode) { + if (copymode) return; + + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); From b975d59d9f7956835ba93d8ba731d0fe1f9941f7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 04:55:58 -0400 Subject: [PATCH 29/49] make use of copymode flag in pair style destructors consistent --- src/CLASS2/pair_lj_class2.cpp | 26 +++++------ src/CLASS2/pair_lj_class2_coul_cut.cpp | 32 +++++++------- src/CLASS2/pair_lj_class2_coul_long.cpp | 28 ++++++------ src/KSPACE/pair_buck_coul_long.cpp | 30 ++++++------- src/KSPACE/pair_coul_long.cpp | 14 +++--- src/KSPACE/pair_lj_charmm_coul_long.cpp | 38 ++++++++-------- src/KSPACE/pair_lj_charmmfsw_coul_long.cpp | 42 +++++++++--------- src/MOLECULE/pair_lj_charmm_coul_charmm.cpp | 6 +-- .../pair_lj_charmmfsw_coul_charmmfsh.cpp | 40 ++++++++--------- src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp | 34 +++++++------- .../pair_lj_class2_coul_long_soft.cpp | 30 ++++++------- src/USER-FEP/pair_lj_class2_soft.cpp | 28 ++++++------ src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp | 44 +++++++++---------- .../pair_buck6d_coul_gauss_long.cpp | 40 ++++++++--------- src/pair_lj_cut_coul_dsf.cpp | 28 ++++++------ src/pair_lj_expand.cpp | 6 +-- src/pair_lj_gromacs.cpp | 6 +-- src/pair_lj_gromacs_coul_gromacs.cpp | 6 +-- 18 files changed, 238 insertions(+), 240 deletions(-) diff --git a/src/CLASS2/pair_lj_class2.cpp b/src/CLASS2/pair_lj_class2.cpp index e6546b1acc..015dc59d2f 100644 --- a/src/CLASS2/pair_lj_class2.cpp +++ b/src/CLASS2/pair_lj_class2.cpp @@ -38,20 +38,20 @@ PairLJClass2::PairLJClass2(LAMMPS *lmp) : Pair(lmp) PairLJClass2::~PairLJClass2() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); } } diff --git a/src/CLASS2/pair_lj_class2_coul_cut.cpp b/src/CLASS2/pair_lj_class2_coul_cut.cpp index 49242ecb43..7888591b51 100644 --- a/src/CLASS2/pair_lj_class2_coul_cut.cpp +++ b/src/CLASS2/pair_lj_class2_coul_cut.cpp @@ -39,23 +39,23 @@ PairLJClass2CoulCut::PairLJClass2CoulCut(LAMMPS *lmp) : Pair(lmp) PairLJClass2CoulCut::~PairLJClass2CoulCut() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(cut_coul); - memory->destroy(cut_coulsq); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(cut_coul); + memory->destroy(cut_coulsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); } } diff --git a/src/CLASS2/pair_lj_class2_coul_long.cpp b/src/CLASS2/pair_lj_class2_coul_long.cpp index bbea2ade6e..4ae448af30 100644 --- a/src/CLASS2/pair_lj_class2_coul_long.cpp +++ b/src/CLASS2/pair_lj_class2_coul_long.cpp @@ -50,21 +50,21 @@ PairLJClass2CoulLong::PairLJClass2CoulLong(LAMMPS *lmp) : Pair(lmp) PairLJClass2CoulLong::~PairLJClass2CoulLong() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); } if (ftable) free_tables(); } diff --git a/src/KSPACE/pair_buck_coul_long.cpp b/src/KSPACE/pair_buck_coul_long.cpp index a37e4ab4e9..c18b1f3481 100644 --- a/src/KSPACE/pair_buck_coul_long.cpp +++ b/src/KSPACE/pair_buck_coul_long.cpp @@ -50,23 +50,23 @@ PairBuckCoulLong::PairBuckCoulLong(LAMMPS *lmp) : Pair(lmp) PairBuckCoulLong::~PairBuckCoulLong() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(a); - memory->destroy(rho); - memory->destroy(c); - memory->destroy(rhoinv); - memory->destroy(buck1); - memory->destroy(buck2); - memory->destroy(offset); - } - if (ftable) free_tables(); + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(a); + memory->destroy(rho); + memory->destroy(c); + memory->destroy(rhoinv); + memory->destroy(buck1); + memory->destroy(buck2); + memory->destroy(offset); } + if (ftable) free_tables(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_coul_long.cpp b/src/KSPACE/pair_coul_long.cpp index 8db5979b39..98dac97db3 100644 --- a/src/KSPACE/pair_coul_long.cpp +++ b/src/KSPACE/pair_coul_long.cpp @@ -55,15 +55,15 @@ PairCoulLong::PairCoulLong(LAMMPS *lmp) : Pair(lmp) PairCoulLong::~PairCoulLong() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(scale); - } - if (ftable) free_tables(); + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(scale); } + if (ftable) free_tables(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_charmm_coul_long.cpp b/src/KSPACE/pair_lj_charmm_coul_long.cpp index 749d9657aa..78dfdc8dd9 100644 --- a/src/KSPACE/pair_lj_charmm_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmm_coul_long.cpp @@ -59,27 +59,27 @@ PairLJCharmmCoulLong::PairLJCharmmCoulLong(LAMMPS *lmp) : Pair(lmp) PairLJCharmmCoulLong::~PairLJCharmmCoulLong() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(eps14); - memory->destroy(sigma14); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(lj14_1); - memory->destroy(lj14_2); - memory->destroy(lj14_3); - memory->destroy(lj14_4); - memory->destroy(offset); - } - if (ftable) free_tables(); + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(eps14); + memory->destroy(sigma14); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(lj14_1); + memory->destroy(lj14_2); + memory->destroy(lj14_3); + memory->destroy(lj14_4); + memory->destroy(offset); } + if (ftable) free_tables(); } /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp index 614980117e..00c6d793e7 100644 --- a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp @@ -77,27 +77,6 @@ PairLJCharmmfswCoulLong::PairLJCharmmfswCoulLong(LAMMPS *lmp) : Pair(lmp) PairLJCharmmfswCoulLong::~PairLJCharmmfswCoulLong() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(eps14); - memory->destroy(sigma14); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(lj14_1); - memory->destroy(lj14_2); - memory->destroy(lj14_3); - memory->destroy(lj14_4); - } - if (ftable) free_tables(); - } - // switch qqr2e back from CHARMM value to LAMMPS value if (update && strcmp(update->unit_style,"real") == 0) { @@ -106,6 +85,27 @@ PairLJCharmmfswCoulLong::~PairLJCharmmfswCoulLong() " conversion constant"); force->qqr2e = force->qqr2e_lammps_real; } + + if (copymode) return; + + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(eps14); + memory->destroy(sigma14); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(lj14_1); + memory->destroy(lj14_2); + memory->destroy(lj14_3); + memory->destroy(lj14_4); + } + if (ftable) free_tables(); } /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp b/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp index 688c675815..ddca7f8b49 100644 --- a/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp +++ b/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp @@ -43,8 +43,9 @@ PairLJCharmmCoulCharmm::PairLJCharmmCoulCharmm(LAMMPS *lmp) : Pair(lmp) PairLJCharmmCoulCharmm::~PairLJCharmmCoulCharmm() { - if (!copymode) { - if (allocated) { + if (copymode) return; + + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); @@ -60,7 +61,6 @@ PairLJCharmmCoulCharmm::~PairLJCharmmCoulCharmm() memory->destroy(lj14_2); memory->destroy(lj14_3); memory->destroy(lj14_4); - } } } diff --git a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp index 4b9147c169..5ea1ce4fcf 100644 --- a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp +++ b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp @@ -62,26 +62,6 @@ PairLJCharmmfswCoulCharmmfsh::PairLJCharmmfswCoulCharmmfsh(LAMMPS *lmp) : PairLJCharmmfswCoulCharmmfsh::~PairLJCharmmfswCoulCharmmfsh() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(eps14); - memory->destroy(sigma14); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(lj14_1); - memory->destroy(lj14_2); - memory->destroy(lj14_3); - memory->destroy(lj14_4); - } - } - // switch qqr2e back from CHARMM value to LAMMPS value if (update && strcmp(update->unit_style,"real") == 0) { @@ -90,6 +70,26 @@ PairLJCharmmfswCoulCharmmfsh::~PairLJCharmmfswCoulCharmmfsh() " conversion constant"); force->qqr2e = force->qqr2e_lammps_real; } + + if (copymode) return; + + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(eps14); + memory->destroy(sigma14); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(lj14_1); + memory->destroy(lj14_2); + memory->destroy(lj14_3); + memory->destroy(lj14_4); + } } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp b/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp index 7970097cfe..8250f1da06 100644 --- a/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp +++ b/src/USER-FEP/pair_lj_class2_coul_cut_soft.cpp @@ -39,24 +39,24 @@ PairLJClass2CoulCutSoft::PairLJClass2CoulCutSoft(LAMMPS *lmp) : Pair(lmp) PairLJClass2CoulCutSoft::~PairLJClass2CoulCutSoft() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(cut_coul); - memory->destroy(cut_coulsq); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lambda); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(cut_coul); + memory->destroy(cut_coulsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lambda); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); } } diff --git a/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp b/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp index 13096a64c6..fe8f6a4f1b 100644 --- a/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp +++ b/src/USER-FEP/pair_lj_class2_coul_long_soft.cpp @@ -49,22 +49,22 @@ PairLJClass2CoulLongSoft::PairLJClass2CoulLongSoft(LAMMPS *lmp) : Pair(lmp) PairLJClass2CoulLongSoft::~PairLJClass2CoulLongSoft() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lambda); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lambda); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); } } diff --git a/src/USER-FEP/pair_lj_class2_soft.cpp b/src/USER-FEP/pair_lj_class2_soft.cpp index b7f21fc59c..88638d9ca0 100644 --- a/src/USER-FEP/pair_lj_class2_soft.cpp +++ b/src/USER-FEP/pair_lj_class2_soft.cpp @@ -32,28 +32,26 @@ using namespace MathConst; PairLJClass2Soft::PairLJClass2Soft(LAMMPS *lmp) : Pair(lmp) { writedata = 1; - allocated = 0; } /* ---------------------------------------------------------------------- */ PairLJClass2Soft::~PairLJClass2Soft() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lambda); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(offset); - allocated=0; - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lambda); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(offset); } } diff --git a/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp b/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp index 1fc4644420..94903f43fa 100644 --- a/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp +++ b/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp @@ -48,29 +48,29 @@ PairBuck6dCoulGaussDSF::PairBuck6dCoulGaussDSF(LAMMPS *lmp) : Pair(lmp) PairBuck6dCoulGaussDSF::~PairBuck6dCoulGaussDSF() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(alpha_ij); - memory->destroy(f_shift_ij); - memory->destroy(e_shift_ij); - memory->destroy(buck6d1); - memory->destroy(buck6d2); - memory->destroy(buck6d3); - memory->destroy(buck6d4); - memory->destroy(c0); - memory->destroy(c1); - memory->destroy(c2); - memory->destroy(c3); - memory->destroy(c4); - memory->destroy(c5); - memory->destroy(rsmooth_sq); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(alpha_ij); + memory->destroy(f_shift_ij); + memory->destroy(e_shift_ij); + memory->destroy(buck6d1); + memory->destroy(buck6d2); + memory->destroy(buck6d3); + memory->destroy(buck6d4); + memory->destroy(c0); + memory->destroy(c1); + memory->destroy(c2); + memory->destroy(c3); + memory->destroy(c4); + memory->destroy(c5); + memory->destroy(rsmooth_sq); + memory->destroy(offset); } } diff --git a/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp b/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp index 1ca42d864e..7df1ee4a1f 100644 --- a/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp +++ b/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp @@ -51,27 +51,27 @@ PairBuck6dCoulGaussLong::PairBuck6dCoulGaussLong(LAMMPS *lmp) : Pair(lmp) PairBuck6dCoulGaussLong::~PairBuck6dCoulGaussLong() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(alpha_ij); - memory->destroy(buck6d1); - memory->destroy(buck6d2); - memory->destroy(buck6d3); - memory->destroy(buck6d4); - memory->destroy(c0); - memory->destroy(c1); - memory->destroy(c2); - memory->destroy(c3); - memory->destroy(c4); - memory->destroy(c5); - memory->destroy(rsmooth_sq); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(alpha_ij); + memory->destroy(buck6d1); + memory->destroy(buck6d2); + memory->destroy(buck6d3); + memory->destroy(buck6d4); + memory->destroy(c0); + memory->destroy(c1); + memory->destroy(c2); + memory->destroy(c3); + memory->destroy(c4); + memory->destroy(c5); + memory->destroy(rsmooth_sq); + memory->destroy(offset); } } diff --git a/src/pair_lj_cut_coul_dsf.cpp b/src/pair_lj_cut_coul_dsf.cpp index a49af13fb2..ba4a9ef201 100644 --- a/src/pair_lj_cut_coul_dsf.cpp +++ b/src/pair_lj_cut_coul_dsf.cpp @@ -52,21 +52,21 @@ PairLJCutCoulDSF::PairLJCutCoulDSF(LAMMPS *lmp) : Pair(lmp) PairLJCutCoulDSF::~PairLJCutCoulDSF() { - if (!copymode) { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); + if (copymode) return; - memory->destroy(cut_lj); - memory->destroy(cut_ljsq); - memory->destroy(epsilon); - memory->destroy(sigma); - memory->destroy(lj1); - memory->destroy(lj2); - memory->destroy(lj3); - memory->destroy(lj4); - memory->destroy(offset); - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(cut_lj); + memory->destroy(cut_ljsq); + memory->destroy(epsilon); + memory->destroy(sigma); + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + memory->destroy(offset); } } diff --git a/src/pair_lj_expand.cpp b/src/pair_lj_expand.cpp index 9aa58b3b88..abb57534cd 100644 --- a/src/pair_lj_expand.cpp +++ b/src/pair_lj_expand.cpp @@ -38,8 +38,9 @@ PairLJExpand::PairLJExpand(LAMMPS *lmp) : Pair(lmp) PairLJExpand::~PairLJExpand() { - if (!copymode) { - if (allocated) { + if (copymode) return; + + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); @@ -52,7 +53,6 @@ PairLJExpand::~PairLJExpand() memory->destroy(lj3); memory->destroy(lj4); memory->destroy(offset); - } } } diff --git a/src/pair_lj_gromacs.cpp b/src/pair_lj_gromacs.cpp index 495e96c368..da0c8148e2 100644 --- a/src/pair_lj_gromacs.cpp +++ b/src/pair_lj_gromacs.cpp @@ -41,8 +41,9 @@ PairLJGromacs::PairLJGromacs(LAMMPS *lmp) : Pair(lmp) PairLJGromacs::~PairLJGromacs() { - if (!copymode) { - if (allocated) { + if (copymode) return; + + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); @@ -60,7 +61,6 @@ PairLJGromacs::~PairLJGromacs() memory->destroy(ljsw3); memory->destroy(ljsw4); memory->destroy(ljsw5); - } } } diff --git a/src/pair_lj_gromacs_coul_gromacs.cpp b/src/pair_lj_gromacs_coul_gromacs.cpp index 414bfea92a..b003d3c068 100644 --- a/src/pair_lj_gromacs_coul_gromacs.cpp +++ b/src/pair_lj_gromacs_coul_gromacs.cpp @@ -41,8 +41,9 @@ PairLJGromacsCoulGromacs::PairLJGromacsCoulGromacs(LAMMPS *lmp) : Pair(lmp) PairLJGromacsCoulGromacs::~PairLJGromacsCoulGromacs() { - if (!copymode) { - if (allocated) { + if (copymode) return; + + if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); @@ -57,7 +58,6 @@ PairLJGromacsCoulGromacs::~PairLJGromacsCoulGromacs() memory->destroy(ljsw3); memory->destroy(ljsw4); memory->destroy(ljsw5); - } } } From 8916aeb36daad1b02ae565baf8f72a4c2dafe640 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 05:25:14 -0400 Subject: [PATCH 30/49] update for README to USER-SMTBQ with up-to-date maintainer e-mails --- src/USER-SMTBQ/README | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/USER-SMTBQ/README b/src/USER-SMTBQ/README index 74b621eef1..e778c65be2 100644 --- a/src/USER-SMTBQ/README +++ b/src/USER-SMTBQ/README @@ -2,9 +2,11 @@ This package implements the Second Moment Tight Binding - QEq (SMTB-Q) potential for the description of ionocovalent bonds in oxides. Authors: Nicolas Salles, Emile Maras, Olivier Politano, Robert Tetot -at LAAS-CNRS in France. +at ICB, Universite de Bourgogne and ICMMO, Universite Paris-Sud. -Contact emails: lammps@u-bourgogne.fr, nsalles@laas.fr +Contact emails: lammps@u-bourgogne.fr, nsalles33@gmail.com + +This package is occasionally maintained. See the doc page for the pair_style smtbq command to get started. From 75d63df4e029a15a1780e3337b6ab0b806aeea68 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 05:41:32 -0400 Subject: [PATCH 31/49] fix small memory leak in pair style hybrid when reading restarts --- src/pair_hybrid.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 2b2304718c..2b6546aef3 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -45,7 +45,7 @@ PairHybrid::PairHybrid(LAMMPS *lmp) : Pair(lmp), PairHybrid::~PairHybrid() { - if (nstyles) { + if (nstyles > 0) { for (int m = 0; m < nstyles; m++) { delete styles[m]; delete [] keywords[m]; @@ -243,11 +243,18 @@ void PairHybrid::settings(int narg, char **arg) // delete old lists, since cannot just change settings - if (nstyles) { - for (int m = 0; m < nstyles; m++) delete styles[m]; - delete [] styles; - for (int m = 0; m < nstyles; m++) delete [] keywords[m]; - delete [] keywords; + if (nstyles > 0) { + for (int m = 0; m < nstyles; m++) { + delete styles[m]; + delete [] keywords[m]; + if (special_lj[m]) delete [] special_lj[m]; + if (special_coul[m]) delete [] special_coul[m]; + } + delete[] styles; + delete[] keywords; + delete[] multiple; + delete[] special_lj; + delete[] special_coul; } if (allocated) { @@ -670,6 +677,12 @@ void PairHybrid::read_restart(FILE *fp) // allocate list of sub-styles + delete[] styles; + delete[] keywords; + delete[] multiple; + delete[] special_lj; + delete[] special_coul; + styles = new Pair*[nstyles]; keywords = new char*[nstyles]; multiple = new int[nstyles]; From cd6b23d1041501543889050f8d6b8396cc3645c4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 09:50:31 -0400 Subject: [PATCH 32/49] explicitly request OpenCL version 1.2 compatibility when compiling GPU package kernels for OpenCL --- lib/gpu/lal_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index 6b4d0ab2a5..9397f3c6c5 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -237,7 +237,7 @@ int DeviceT::set_ocl_params(char *ocl_vendor) { " -DBLOCK_CELL_ID="+params[11]+ " -DMAX_BIO_SHARED_TYPES="+params[12]; } - _ocl_compile_string="-cl-fast-relaxed-math -cl-mad-enable "+std::string(OCL_INT_TYPE)+" "+ + _ocl_compile_string="-cl-std=CL1.2 -cl-fast-relaxed-math -cl-mad-enable "+std::string(OCL_INT_TYPE)+" "+ std::string(OCL_PRECISION_COMPILE)+" "+_ocl_vendor_string; #endif return 0; From 52f9e4a960ef477a54750f7b36740693c5018e75 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Mar 2019 14:11:02 -0400 Subject: [PATCH 33/49] allow overriding the location of the molfile plugin headers with CMake --- cmake/CMakeLists.txt | 4 ++-- doc/src/Build_extras.txt | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f6f822676e..327a94237b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -613,8 +613,9 @@ if(PKG_USER-PLUMED) endif() if(PKG_USER-MOLFILE) + set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers") add_library(molfile INTERFACE) - target_include_directories(molfile INTERFACE ${LAMMPS_LIB_SOURCE_DIR}/molfile) + target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS}) target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS}) list(APPEND LAMMPS_LINK_LIBS molfile) endif() @@ -626,7 +627,6 @@ if(PKG_USER-NETCDF) add_definitions(-DLMP_HAS_NETCDF -DNC_64BIT_DATA=0x0020) endif() - if(PKG_USER-SMD) option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" OFF) if(DOWNLOAD_EIGEN3) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index cbbd9db2f3..3ee8d06b8e 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -893,7 +893,17 @@ USER-MOLFILE package :h4,link(user-molfile) [CMake build]: -No additional settings are needed besides "-D PKG_USER-MOLFILE=yes". +-D MOLFILE_INCLUDE_DIRS=path # (optional) path where VMD molfile plugin headers are installed +-D PKG_USER-MOLFILE=yes :pre + + +Using "-D PKG_USER-MOLFILE=yes" enables the package, and setting +"-D MOLFILE_INCLUDE DIRS" allows to provide a custom location for +the molfile plugin header files. These should match the ABI of the +plugin files used, and thus one typically sets them to include +folder of the local VMD installation in use. LAMMPS ships with a +couple of default header files that correspond to a popular VMD +version, usually the latest release. [Traditional make]: @@ -902,7 +912,11 @@ loading library libdl.a that is typically present on all systems. It is required for LAMMPS to link with this package. If the setting is not valid for your system, you will need to edit the Makefile.lammps file. See lib/molfile/README and lib/molfile/Makefile.lammps for -details. +details. It is also possible to configure a different folder with +the VMD molfile plugin header files. LAMMPS ships with a couple of +default headers, but these are not compatible with all VMD versions, +so it is often best to change this setting to the location of the +same include files of the local VMD installation in use. :line From 3464464ea925918a5bf8e4fd71171c6790bcc8fe Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Fri, 22 Mar 2019 20:20:47 -0500 Subject: [PATCH 34/49] Update kim example query and log files --- doc/src/kim_query.txt | 3 +-- examples/kim/in.query | 2 +- ...Aug2018.query.g++.1 => log.22Mar2019.query.g++.1} | 12 ++++++------ src/KIM/kim_query.cpp | 4 ++-- src/KIM/kim_query.h | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) rename examples/kim/{log.16Aug2018.query.g++.1 => log.22Mar2019.query.g++.1} (72%) diff --git a/doc/src/kim_query.txt b/doc/src/kim_query.txt index ffebe698be..be46783d82 100644 --- a/doc/src/kim_query.txt +++ b/doc/src/kim_query.txt @@ -18,7 +18,7 @@ web_query_flags = a series of keyword=value pairs that represent the web query; [Examples:] -kim_query latconst get_test_result test=TE_156715955670_004 model=MO_800509458712_001 & +kim_query latconst get_test_result test=TE_156715955670 model=MO_800509458712 & prop=structure-cubic-crystal-npt species=\["Al"\] keys=\["a"\] units=\["angstrom"\] :pre [Description:] @@ -43,4 +43,3 @@ See the "Build package"_Build_package.html doc page for more info. [Related commands:] "pair_style kim"_pair_kim.html, "variable"_variable.html - diff --git a/examples/kim/in.query b/examples/kim/in.query index 8538cac749..33272dc298 100644 --- a/examples/kim/in.query +++ b/examples/kim/in.query @@ -6,6 +6,6 @@ units metal info variables out log -kim_query latconst get_test_result test=TE_156715955670_004 species=["Al"] model=MO_800509458712_001 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] +kim_query latconst get_test_result test=TE_156715955670 species=["Al"] model=MO_800509458712 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] info variables out log lattice fcc ${latconst} diff --git a/examples/kim/log.16Aug2018.query.g++.1 b/examples/kim/log.22Mar2019.query.g++.1 similarity index 72% rename from examples/kim/log.16Aug2018.query.g++.1 rename to examples/kim/log.22Mar2019.query.g++.1 index eb83dd84b1..034bb13bba 100644 --- a/examples/kim/log.16Aug2018.query.g++.1 +++ b/examples/kim/log.22Mar2019.query.g++.1 @@ -1,4 +1,4 @@ -LAMMPS (16 Aug 2018) +LAMMPS (28 Feb 2019) # example for performing a query to the OpenKIM test database to retrieve # a parameter to be used in the input. here it requests the aluminium @@ -9,26 +9,26 @@ units metal info variables out log Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info -Printed on Mon Aug 20 18:44:24 2018 +Printed on Fri Mar 22 20:00:56 2019 Variable information: Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info -kim_query latconst get_test_result test=TE_156715955670_004 species=["Al"] model=MO_800509458712_001 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] +kim_query latconst get_test_result test=TE_156715955670 species=["Al"] model=MO_800509458712 prop=structure-cubic-crystal-npt keys=["a"] units=["angstrom"] info variables out log Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info -Printed on Mon Aug 20 18:44:24 2018 +Printed on Fri Mar 22 20:00:57 2019 Variable information: -Variable[ 0]: latconst , style = string , def = 4.0320827961 +Variable[ 0]: latconst , style = string , def = 4.03208274841 Info-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info lattice fcc ${latconst} -lattice fcc 4.0320827961 +lattice fcc 4.03208274841 Lattice spacing in x,y,z = 4.03208 4.03208 4.03208 Total wall time: 0:00:00 diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index 8d400ac333..2e1f752dc1 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -52,7 +52,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the kim-api-v2.0.0-beta.1 (and newer) package + Designed for use with the kim-api-v2-2.0.0 (and newer) package ------------------------------------------------------------------------- */ #include @@ -114,7 +114,7 @@ void KimQuery::command(int narg, char **arg) varcmd[2] = value; input->variable->set(3,varcmd); - + delete[] varcmd; delete[] value; #else diff --git a/src/KIM/kim_query.h b/src/KIM/kim_query.h index 92972d804d..ed5a7c88f3 100644 --- a/src/KIM/kim_query.h +++ b/src/KIM/kim_query.h @@ -51,7 +51,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Designed for use with the kim-api-v2.0.0-beta.1 (and newer) package + Designed for use with the kim-api-v2-2.0.0 (and newer) package ------------------------------------------------------------------------- */ #ifdef COMMAND_CLASS From 414f9b25d15c583763f7cd0e7d0c3fcf02a8b80b Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sat, 23 Mar 2019 08:01:41 -0600 Subject: [PATCH 35/49] cmake: move lmpgitversion generation to build phase --- cmake/CMakeLists.txt | 38 +++++----------------- cmake/Modules/generate_lmpgitversion.cmake | 30 +++++++++++++++++ 2 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 cmake/Modules/generate_lmpgitversion.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f6f822676e..088b712856 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1331,36 +1331,14 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HE ###################################### # Generate lmpgitversion.h ###################################### -set(temp "#ifndef LMP_GIT_VERSION_H\n#define LMP_GIT_VERSION_H\n") -set(temp_git_commit "(unknown)") -set(temp_git_branch "(unknown)") -set(temp_git_describe "(unknown)") -set(temp_git_info "false") -if(GIT_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git) - set(temp_git_info "true") - execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/../.git rev-parse HEAD - OUTPUT_VARIABLE temp_git_commit - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/../.git rev-parse --abbrev-ref HEAD - OUTPUT_VARIABLE temp_git_branch - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/../.git describe --dirty=-modified - OUTPUT_VARIABLE temp_git_describe - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - -set(temp "${temp}const bool LAMMPS_NS::LAMMPS::has_git_info = ${temp_git_info};\n") -set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_commit[] = \"${temp_git_commit}\";\n") -set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_branch[] = \"${temp_git_branch}\";\n") -set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_descriptor[] = \"${temp_git_describe}\";\n") -set(temp "${temp}#endif\n\n") - -message(STATUS "Generating lmpgitversion.h...") -file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${temp}" ) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h") +add_custom_target(gitversion COMMAND ${CMAKE_COMMAND} + -DCMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + -DGIT_EXECUTABLE="${GIT_EXECUTABLE}" + -DGIT_FOUND="${GIT_FOUND}" + -DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h) +list(APPEND LAMMPS_DEPS gitversion) ########################################### # Actually add executable and lib to build diff --git a/cmake/Modules/generate_lmpgitversion.cmake b/cmake/Modules/generate_lmpgitversion.cmake new file mode 100644 index 0000000000..8aead88f5f --- /dev/null +++ b/cmake/Modules/generate_lmpgitversion.cmake @@ -0,0 +1,30 @@ +set(temp "#ifndef LMP_GIT_VERSION_H\n#define LMP_GIT_VERSION_H\n") +set(temp_git_commit "(unknown)") +set(temp_git_branch "(unknown)") +set(temp_git_describe "(unknown)") +set(temp_git_info "false") +if(GIT_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git) + set(temp_git_info "true") + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/../.git rev-parse HEAD + OUTPUT_VARIABLE temp_git_commit + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/../.git rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE temp_git_branch + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR}/../.git describe --dirty=-modified + OUTPUT_VARIABLE temp_git_describe + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +set(temp "${temp}const bool LAMMPS_NS::LAMMPS::has_git_info = ${temp_git_info};\n") +set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_commit[] = \"${temp_git_commit}\";\n") +set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_branch[] = \"${temp_git_branch}\";\n") +set(temp "${temp}const char LAMMPS_NS::LAMMPS::git_descriptor[] = \"${temp_git_describe}\";\n") +set(temp "${temp}#endif\n\n") + +message(STATUS "Generating lmpgitversion.h...") +file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${temp}" ) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h") From b2a7205abe96f328b7e08e756bac3df6b48176c0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 11:31:23 -0400 Subject: [PATCH 36/49] re-order ev_init() and ev_setup() so that 'init' comes before 'setup' as requested by @sjplimp --- src/angle.h | 2 +- src/bond.h | 2 +- src/dihedral.h | 2 +- src/fix.h | 2 +- src/improper.h | 2 +- src/kspace.h | 2 +- src/pair.h | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/angle.h b/src/angle.h index 196c2a44d1..3d8371242e 100644 --- a/src/angle.h +++ b/src/angle.h @@ -58,11 +58,11 @@ class Angle : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int, int alloc = 1); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, int, double, double *, double *, double, double, double, double, double, double); }; diff --git a/src/bond.h b/src/bond.h index 1082748403..8fb7040832 100644 --- a/src/bond.h +++ b/src/bond.h @@ -64,11 +64,11 @@ class Bond : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int, int alloc = 1); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, double, double, double, double, double); }; diff --git a/src/dihedral.h b/src/dihedral.h index 0769d79163..f1b42008bf 100644 --- a/src/dihedral.h +++ b/src/dihedral.h @@ -56,11 +56,11 @@ class Dihedral : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int, int alloc = 1); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, int, int, double, double *, double *, double *, double, double, double, double, double, double, double, double, double); diff --git a/src/fix.h b/src/fix.h index f5b3338aee..7eaff38bd3 100644 --- a/src/fix.h +++ b/src/fix.h @@ -223,11 +223,11 @@ class Fix : protected Pointers { int dynamic; // recount atoms for temperature computes - void ev_setup(int, int); void ev_init(int eflag, int vflag) { if (eflag||vflag) ev_setup(eflag, vflag); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } + void ev_setup(int, int); void ev_tally(int, int *, double, double, double *); void v_setup(int); void v_tally(int, int *, double, double *); diff --git a/src/improper.h b/src/improper.h index 8ee2c2996d..d940b43a13 100644 --- a/src/improper.h +++ b/src/improper.h @@ -56,11 +56,11 @@ class Improper : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int, int alloc = 1); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, int, int, double, double *, double *, double *, double, double, double, double, double, double, double, double, double); diff --git a/src/kspace.h b/src/kspace.h index 12cb16c929..2345cebf24 100644 --- a/src/kspace.h +++ b/src/kspace.h @@ -194,11 +194,11 @@ class KSpace : protected Pointers { int kx_ewald,ky_ewald,kz_ewald; // kspace settings for Ewald sum void pair_check(); - void ev_setup(int, int, int alloc = 1); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else evflag = eflag_either = eflag_global = eflag_atom = vflag_either = vflag_global = vflag_atom = 0; } + void ev_setup(int, int, int alloc = 1); double estimate_table_accuracy(double, double); }; diff --git a/src/pair.h b/src/pair.h index 37606ed595..5ce62f1b35 100644 --- a/src/pair.h +++ b/src/pair.h @@ -218,12 +218,12 @@ class Pair : protected Pointers { int copymode; // if set, do not deallocate during destruction // required when classes are used as functors by Kokkos - virtual void ev_setup(int, int, int alloc = 1); - void ev_unset(); void ev_init(int eflag, int vflag, int alloc = 1) { if (eflag||vflag) ev_setup(eflag, vflag, alloc); else ev_unset(); } + virtual void ev_setup(int, int, int alloc = 1); + void ev_unset(); void ev_tally_full(int, double, double, double, double, double, double); void ev_tally_xyz_full(int, double, double, double, double, double, double, double, double); From e04ab5197032679d563d3f15cc7931bdf5b98960 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 25 Mar 2019 10:20:32 -0600 Subject: [PATCH 37/49] bug fix for new fix shake redezvous comm --- src/RIGID/fix_shake.h | 2 +- src/comm.cpp | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/RIGID/fix_shake.h b/src/RIGID/fix_shake.h index 2baea90a4a..b99a35f958 100644 --- a/src/RIGID/fix_shake.h +++ b/src/RIGID/fix_shake.h @@ -159,8 +159,8 @@ class FixShake : public Fix { struct ShakeInfo { tagint atomID; + tagint shake_atom[4]; int shake_flag; - int shake_atom[4]; int shake_type[3]; }; diff --git a/src/comm.cpp b/src/comm.cpp index e8a796036c..729f96581a 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -810,7 +810,12 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, procs_rvous,outbuf_rvous,ptr); if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous - if (flag == 0) return 0; // all nout_rvous are 0, no 2nd comm stage + if (flag == 0) { + if (statflag) rendezvous_stats(n,0,nrvous,nrvous_out,insize,outsize, + (bigint) nrvous_out*sizeof(int) + + irregular1_bytes); + return 0; // all nout_rvous are 0, no 2nd comm stage + } // irregular comm of outbuf from rendezvous decomp back to caller decomp // caller will free outbuf @@ -952,9 +957,17 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, memory->destroy(recvcount); memory->destroy(sdispls); memory->destroy(rdispls); + if (statflag) rendezvous_stats(n,0,nrvous,nrvous_out,insize,outsize, + (bigint) nrvous_out*sizeof(int) + + 4*nprocs*sizeof(int) + all2all1_bytes); return 0; // all nout_rvous are 0, no 2nd irregular } + + + + + // create procs and outbuf for All2all if necesary if (!outorder) { @@ -1102,10 +1115,15 @@ void Comm::rendezvous_stats(int n, int nout, int nrvous, int nrvous_out, fprintf(screen," input data (MB): %g %g %g %g\n", 1.0*size_in_all/mbytes,1.0*size_in_all/nprocs/mbytes, 1.0*size_in_max/mbytes,1.0*size_in_min/mbytes); - fprintf(screen," output datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_out_all/outsize,1.0*size_out_all/nprocs/outsize, - size_out_max/outsize,size_out_min/outsize); + if (outsize) + fprintf(screen," output datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_out_all/outsize,1.0*size_out_all/nprocs/outsize, + size_out_max/outsize,size_out_min/outsize); + else + fprintf(screen," output datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", + 0,0.0,0,0); fprintf(screen," output data (MB): %g %g %g %g\n", 1.0*size_out_all/mbytes,1.0*size_out_all/nprocs/mbytes, 1.0*size_out_max/mbytes,1.0*size_out_min/mbytes); @@ -1116,10 +1134,15 @@ void Comm::rendezvous_stats(int n, int nout, int nrvous, int nrvous_out, fprintf(screen," input rvous data (MB): %g %g %g %g\n", 1.0*size_inrvous_all/mbytes,1.0*size_inrvous_all/nprocs/mbytes, 1.0*size_inrvous_max/mbytes,1.0*size_inrvous_min/mbytes); - fprintf(screen," output rvous datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, - size_outrvous_max/outsize,size_outrvous_min/outsize); + if (outsize) + fprintf(screen," output rvous datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", + size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, + size_outrvous_max/outsize,size_outrvous_min/outsize); + else + fprintf(screen," output rvous datum count: " + BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", + 0,0.0,0,0); fprintf(screen," output rvous data (MB): %g %g %g %g\n", 1.0*size_outrvous_all/mbytes,1.0*size_outrvous_all/nprocs/mbytes, 1.0*size_outrvous_max/mbytes,1.0*size_outrvous_min/mbytes); From a20d58312daf5679e386f7c0a5d4f07e23558732 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 12:25:50 -0400 Subject: [PATCH 38/49] add missing convesion to fractional coordinates and back for enforced PBC dumps of triclinic cells --- src/dump.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dump.cpp b/src/dump.cpp index 7cd80dcf71..8fa07a9cb2 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -423,7 +423,12 @@ void Dump::write() atom->x = xpbc; atom->v = vpbc; atom->image = imagepbc; + + // for triclinic, PBC is applied in lamda coordinates + + if (domain->triclinic) domain->x2lamda(nlocal); domain->pbc(); + if (domain->triclinic) domain->lamda2x(nlocal); } // pack my data into buf From ab748ffe488ddefdb34f4ebc2f988f36df3c42eb Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 25 Mar 2019 10:29:06 -0600 Subject: [PATCH 39/49] turn off diagnostic output for rendezvous op --- src/RIGID/fix_rigid_small.cpp | 2 +- src/RIGID/fix_shake.cpp | 8 ++++---- src/special.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index bee5570316..9a30fdf911 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -1592,7 +1592,7 @@ void FixRigidSmall::create_bodies(tagint *bodyID) int nreturn = comm->rendezvous(RVOUS,ncount,(char *) inbuf,sizeof(InRvous), 0,proclist, rendezvous_body,0,buf,sizeof(OutRvous), - (void *) this,1); + (void *) this); OutRvous *outbuf = (OutRvous *) buf; memory->destroy(proclist); diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 2d3244885d..dcdb190d45 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -1072,7 +1072,7 @@ void FixShake::atom_owners() char *buf; comm->rendezvous(RVOUS,nlocal,(char *) idbuf,sizeof(IDRvous), 0,proclist, - rendezvous_ids,0,buf,0,(void *) this,1); + rendezvous_ids,0,buf,0,(void *) this); memory->destroy(proclist); memory->sfree(idbuf); @@ -1180,7 +1180,7 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, 0,proclist, rendezvous_partners_info, 0,buf,sizeof(PartnerInfo), - (void *) this,1); + (void *) this); PartnerInfo *outbuf = (PartnerInfo *) buf; memory->destroy(proclist); @@ -1268,7 +1268,7 @@ void FixShake::nshake_info(int *npartner, tagint **partner_tag, int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(NShakeInfo), 0,proclist, rendezvous_nshake,0,buf,sizeof(NShakeInfo), - (void *) this,1); + (void *) this); NShakeInfo *outbuf = (NShakeInfo *) buf; memory->destroy(proclist); @@ -1361,7 +1361,7 @@ void FixShake::shake_info(int *npartner, tagint **partner_tag, int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(ShakeInfo), 0,proclist, rendezvous_shake,0,buf,sizeof(ShakeInfo), - (void *) this,1); + (void *) this); ShakeInfo *outbuf = (ShakeInfo *) buf; memory->destroy(proclist); diff --git a/src/special.cpp b/src/special.cpp index a0739d6ccc..b9287df472 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -188,7 +188,7 @@ void Special::atom_owners() char *buf; comm->rendezvous(RVOUS,nlocal,(char *) idbuf,sizeof(IDRvous),0,proclist, - rendezvous_ids,0,buf,0,(void *) this,1); + rendezvous_ids,0,buf,0,(void *) this); memory->destroy(proclist); memory->sfree(idbuf); @@ -246,7 +246,7 @@ void Special::onetwo_build_newton() int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this,1); + (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -381,7 +381,7 @@ void Special::onethree_build() int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this,1); + (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -486,7 +486,7 @@ void Special::onefour_build() int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this,1); + (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -909,7 +909,7 @@ void Special::angle_trim() int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this,1); + (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); @@ -1128,7 +1128,7 @@ void Special::dihedral_trim() int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), 0,proclist, rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this,1); + (void *) this); PairRvous *outbuf = (PairRvous *) buf; memory->destroy(proclist); From 3e8c1c801bc50822dff13447dd1b902495638510 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 14:03:29 -0400 Subject: [PATCH 40/49] add some degree of endian detection to hashlittle.cpp --- src/hashlittle.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/hashlittle.cpp b/src/hashlittle.cpp index be930217a1..f1d4e61142 100644 --- a/src/hashlittle.cpp +++ b/src/hashlittle.cpp @@ -2,10 +2,26 @@ // from lookup3.c, by Bob Jenkins, May 2006, Public Domain // bob_jenkins@burtleburtle.net -#include "stddef.h" -#include "stdint.h" +#include +#include +#include -#define HASH_LITTLE_ENDIAN 1 // Intel and AMD are little endian +// if the system defines the __BYTE_ORDER__ define, +// we use it instead of guessing the platform + +#if defined(__BYTE_ORDER__) +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define HASH_LITTLE_ENDIAN 1 +# else +# define HASH_LITTLE_ENDIAN 0 +# endif +#else // heuristic platform guess +# if defined(__bg__) +# define HASH_LITTLE_ENDIAN 0 // IBM BlueGene is big endian +# else +# define HASH_LITTLE_ENDIAN 1 // Intel and AMD x86 are little endian +# endif +#endif #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) From a726362888c430734faf9d499ccb03ca3b383146 Mon Sep 17 00:00:00 2001 From: julient31 Date: Mon, 25 Mar 2019 12:57:42 -0600 Subject: [PATCH 41/49] Commit JT 032519 - adding all min files into new branch - preparing branch for pull request of spin minimizer --- doc/src/min_modify.txt | 19 +- doc/src/min_spin.txt | 63 +++++ doc/src/min_style.txt | 7 +- doc/src/minimize.txt | 7 + examples/SPIN/spinmin/in.spinmin.bfo | 57 +++++ examples/SPIN/spinmin/in.spinmin.iron | 57 +++++ src/SPIN/fix_precession_spin.cpp | 9 +- src/SPIN/fix_precession_spin.h | 1 + src/SPIN/min_spin.cpp | 339 ++++++++++++++++++++++++++ src/SPIN/min_spin.h | 59 +++++ src/min.cpp | 6 +- src/min.h | 1 + 12 files changed, 620 insertions(+), 5 deletions(-) create mode 100644 doc/src/min_spin.txt create mode 100644 examples/SPIN/spinmin/in.spinmin.bfo create mode 100644 examples/SPIN/spinmin/in.spinmin.iron create mode 100644 src/SPIN/min_spin.cpp create mode 100644 src/SPIN/min_spin.h diff --git a/doc/src/min_modify.txt b/doc/src/min_modify.txt index 9408eea167..525d6716d8 100644 --- a/doc/src/min_modify.txt +++ b/doc/src/min_modify.txt @@ -13,11 +13,15 @@ min_modify command :h3 min_modify keyword values ... :pre one or more keyword/value pairs may be listed :ulb,l -keyword = {dmax} or {line} +keyword = {dmax} or {line} or {alpha_damp} or {discret_factor} {dmax} value = max max = maximum distance for line search to move (distance units) {line} value = {backtrack} or {quadratic} or {forcezero} - backtrack,quadratic,forcezero = style of linesearch to use :pre + backtrack,quadratic,forcezero = style of linesearch to use + {alpha_damp} value = damping + damping = fictitious Gilbert damping for spin minimization (adim) + {discret_factor} value = factor + factor = discretization factor for adaptive spin timestep (adim) :pre :ule [Examples:] @@ -65,6 +69,17 @@ difference of two large values (energy before and energy after) and that difference may be smaller than machine epsilon even if atoms could move in the gradient direction to reduce forces further. +Keywords {alpha_damp} and {discret_factor} only make sense when +a "min_spin"_min_spin.html command is declared. +Keyword {alpha_damp} defines an analog of a magnetic Gilbert +damping. It defines a relaxation rate toward an equilibrium for +a given magnetic system. +Keyword {discret_factor} defines a discretization factor for the +adaptive timestep used in the {spin} minimization. +See "min_spin"_min_spin.html for more information about those +quantities. +Default values are alpha_damp = 1.0 and discret_factor = 10.0. + [Restrictions:] none [Related commands:] diff --git a/doc/src/min_spin.txt b/doc/src/min_spin.txt new file mode 100644 index 0000000000..468cde0fec --- /dev/null +++ b/doc/src/min_spin.txt @@ -0,0 +1,63 @@ +"LAMMPS WWW Page"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c + +:link(lws,http://lammps.sandia.gov) +:link(ld,Manual.html) +:link(lc,Commands_all.html) + +:line + +min_style spin command :h3 + +[Syntax:] + +min_style spin :pre + +[Examples:] + +min_style spin +min_modify alpha_damp 1.0 discret_factor 10.0 :pre + +[Description:] + +Apply a minimization algorithm to use when a "minimize"_minimize.html +command is performed. + +Style {spin} defines a damped spin dynamics with an adaptive +timestep, according to: + +:c,image(Eqs/min_spin_damping.jpg) + +with lambda a damping coefficient (similar to a Gilbert damping) +Lambda can be defined by setting the {alpha_damp} keyword with the +"min_modify"_min_modify.html command. + +The minimization procedure solves this equation using an +adaptive timestep. The value of this timestep is conditionned +by the largest precession frequency that has to be solved in the +system: + +:c,image(Eqs/min_spin_timestep.jpg) + +with |omega|_{max} the norm of the largest precession frequency +in the system (across all processes, and across all replicas if a +spin/neb calculation is performed). + +Kappa defines a discretization factor {discret_factor} for the +definition of this timestep. +{discret_factor} can be defined with the "min_modify"_min_modify.html +command. + +NOTE: The {spin} style replaces the force tolerance by a torque +tolerance. See "minimize"_minimize.html for more explanation. + +[Restrictions:] none + +[Related commands:] + +"min_style"_min_style.html, "minimize"_minimize.html, +"min_modify"_min_modify.html + +[Default:] + +The option defaults are alpha_damp = 1.0 and discret_factor = +10.0. diff --git a/doc/src/min_style.txt b/doc/src/min_style.txt index 4948a34864..c46c1492b4 100644 --- a/doc/src/min_style.txt +++ b/doc/src/min_style.txt @@ -11,11 +11,12 @@ min_style command :h3 min_style style :pre -style = {cg} or {hftn} or {sd} or {quickmin} or {fire} :ul +style = {cg} or {hftn} or {sd} or {quickmin} or {fire} or {spin} :ul [Examples:] min_style cg +min_style spin min_style fire :pre [Description:] @@ -61,6 +62,10 @@ the velocity non-parallel to the current force vector. The velocity of each atom is initialized to 0.0 by this style, at the beginning of a minimization. +Style {spin} is a damped spin dynamics with an adaptive +timestep. +See the "min/spin"_min_spin.html doc page for more information. + Either the {quickmin} and {fire} styles are useful in the context of nudged elastic band (NEB) calculations via the "neb"_neb.html command. diff --git a/doc/src/minimize.txt b/doc/src/minimize.txt index 00de86c5f5..ecf1ad0fcf 100644 --- a/doc/src/minimize.txt +++ b/doc/src/minimize.txt @@ -103,6 +103,13 @@ the line search fails because the step distance backtracks to 0.0 the number of outer iterations or timesteps exceeds {maxiter} the number of total force evaluations exceeds {maxeval} :ul +NOTE: the "minimization style"_min_style.html {spin} replaces +the force tolerance {ftol} by a torque tolerance. +The minimization procedure stops if the 2-norm (length) of the +global torque vector (defined as the cross product between the +spins and their precession vectors omega) is less than {ftol}, +or if any of the other criteria are met. + NOTE: You can also use the "fix halt"_fix_halt.html command to specify a general criterion for exiting a minimization, that is a calculation performed on the state of the current system, as defined by an diff --git a/examples/SPIN/spinmin/in.spinmin.bfo b/examples/SPIN/spinmin/in.spinmin.bfo new file mode 100644 index 0000000000..5b678c8a4d --- /dev/null +++ b/examples/SPIN/spinmin/in.spinmin.bfo @@ -0,0 +1,57 @@ +# bfo in a 3d periodic box + +units metal +dimension 3 +boundary p p f +atom_style spin + +# necessary for the serial algorithm (sametag) +atom_modify map array + +lattice sc 3.96 +region box block 0.0 34.0 0.0 34.0 0.0 1.0 +create_box 1 box +create_atoms 1 box + +# setting mass, mag. moments, and interactions for bcc iron + +mass 1 1.0 +set group all spin/random 11 2.50 + +pair_style hybrid/overlay spin/exchange 6.0 spin/magelec 4.5 spin/dmi 4.5 +pair_coeff * * spin/exchange exchange 6.0 -0.01575 0.0 1.965 +#pair_coeff * * spin/magelec magelec 4.5 0.000109 1.0 1.0 1.0 +pair_coeff * * spin/magelec magelec 4.5 0.00109 1.0 1.0 1.0 +pair_coeff * * spin/dmi dmi 4.5 0.00005 1.0 1.0 1.0 + +neighbor 0.1 bin +neigh_modify every 10 check yes delay 20 + +#fix 1 all precession/spin zeeman 0.001 0.0 0.0 1.0 anisotropy 0.01 1.0 0.0 0.0 +fix 1 all precession/spin anisotropy 0.0000033 0.0 0.0 1.0 +fix_modify 1 energy yes +fix 2 all langevin/spin 0.0 0.1 21 +fix 3 all nve/spin lattice no + +timestep 0.0001 + +compute out_mag all spin +compute out_pe all pe +compute out_ke all ke +compute out_temp all temp + +variable magz equal c_out_mag[3] +variable magnorm equal c_out_mag[4] +variable emag equal c_out_mag[5] +variable tmag equal c_out_mag[6] + +thermo 50 +thermo_style custom step time v_magnorm v_emag v_tmag temp etotal +thermo_modify format float %20.15g + +compute outsp all property/atom spx spy spz sp fmx fmy fmz +dump 1 all custom 50 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7] + +min_style spin +min_modify alpha_damp 1.0 discret_factor 10.0 +minimize 0.0 0.0 10000 1000 diff --git a/examples/SPIN/spinmin/in.spinmin.iron b/examples/SPIN/spinmin/in.spinmin.iron new file mode 100644 index 0000000000..b87a811cc7 --- /dev/null +++ b/examples/SPIN/spinmin/in.spinmin.iron @@ -0,0 +1,57 @@ +# bcc iron in a 3d periodic box + +units metal +dimension 3 +boundary p p f +atom_style spin + +# necessary for the serial algorithm (sametag) +atom_modify map array + +lattice bcc 2.8665 +region box block 0.0 4.0 0.0 4.0 0.0 4.0 +create_box 1 box +create_atoms 1 box + +# setting mass, mag. moments, and interactions for bcc iron + +mass 1 55.845 +set group all spin/random 31 2.2 +#set group all spin 2.2 1.0 1.0 -1.0 + +pair_style spin/exchange 3.5 +pair_coeff * * exchange 3.4 0.02726 0.2171 1.841 + +neighbor 0.1 bin +neigh_modify every 10 check yes delay 20 + +#fix 1 all precession/spin zeeman 0.001 0.0 0.0 1.0 anisotropy 0.01 1.0 0.0 0.0 +fix 1 all precession/spin anisotropy 0.0001 0.0 0.0 1.0 +fix_modify 1 energy yes +fix 2 all langevin/spin 0.0 0.1 21 +fix 3 all nve/spin lattice no + +timestep 0.0001 + +compute out_mag all spin +compute out_pe all pe +compute out_ke all ke +compute out_temp all temp + +variable magx equal c_out_mag[1] +variable magy equal c_out_mag[2] +variable magz equal c_out_mag[3] +variable magnorm equal c_out_mag[4] +variable emag equal c_out_mag[5] +variable tmag equal c_out_mag[6] + +thermo 100 +thermo_style custom step time v_magx v_magz v_magnorm v_tmag etotal +thermo_modify format float %20.15g + +compute outsp all property/atom spx spy spz sp fmx fmy fmz +dump 1 all custom 100 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7] + +min_style spin +min_modify alpha_damp 1.0 discret_factor 10.0 +minimize 1.0e-10 1.0e-10 100000 1000 diff --git a/src/SPIN/fix_precession_spin.cpp b/src/SPIN/fix_precession_spin.cpp index 6ccb692033..d065f38d16 100644 --- a/src/SPIN/fix_precession_spin.cpp +++ b/src/SPIN/fix_precession_spin.cpp @@ -170,7 +170,14 @@ void FixPrecessionSpin::setup(int vflag) /* ---------------------------------------------------------------------- */ -void FixPrecessionSpin::post_force(int /*vflag*/) +void FixPrecessionSpin::min_setup(int vflag) +{ + post_force(vflag); +} + +/* ---------------------------------------------------------------------- */ + +void FixPrecessionSpin::post_force(int vflag) { // update mag field with time (potential improvement) diff --git a/src/SPIN/fix_precession_spin.h b/src/SPIN/fix_precession_spin.h index 2fe6b5a673..1db4d32ae9 100644 --- a/src/SPIN/fix_precession_spin.h +++ b/src/SPIN/fix_precession_spin.h @@ -33,6 +33,7 @@ class FixPrecessionSpin : public Fix { int setmask(); void init(); void setup(int); + void min_setup(int); void post_force(int); void post_force_respa(int, int, int); void min_post_force(int); diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp new file mode 100644 index 0000000000..99aa4ac3b7 --- /dev/null +++ b/src/SPIN/min_spin.cpp @@ -0,0 +1,339 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------------ + Contributing authors: Julien Tranchida (SNL) + + Please cite the related publication: +------------------------------------------------------------------------- */ + +#include +#include +#include "min_spin.h" +#include "universe.h" +#include "atom.h" +#include "force.h" +#include "update.h" +#include "output.h" +#include "timer.h" +#include "error.h" +#include +#include +#include "modify.h" +#include "math_special.h" +#include "math_const.h" +#include "fix_neb_spin.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +// EPS_ENERGY = minimum normalization for energy tolerance + +#define EPS_ENERGY 1.0e-8 + +#define DELAYSTEP 5 + +/* ---------------------------------------------------------------------- */ + +MinSpin::MinSpin(LAMMPS *lmp) : Min(lmp) {} + +/* ---------------------------------------------------------------------- */ + +void MinSpin::init() +{ + alpha_damp = 1.0; + discret_factor = 10.0; + + Min::init(); + + dts = dt = update->dt; + last_negative = update->ntimestep; +} + +/* ---------------------------------------------------------------------- */ + +void MinSpin::setup_style() +{ + double **v = atom->v; + int nlocal = atom->nlocal; + + // check if the atom/spin style is defined + + if (!atom->sp_flag) + error->all(FLERR,"min/spin requires atom/spin style"); + + for (int i = 0; i < nlocal; i++) + v[i][0] = v[i][1] = v[i][2] = 0.0; +} + +/* ---------------------------------------------------------------------- */ + +int MinSpin::modify_param(int narg, char **arg) +{ + if (strcmp(arg[0],"alpha_damp") == 0) { + if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + alpha_damp = force->numeric(FLERR,arg[1]); + return 2; + } + if (strcmp(arg[0],"discret_factor") == 0) { + if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + discret_factor = force->numeric(FLERR,arg[1]); + return 2; + } + return 0; +} + +/* ---------------------------------------------------------------------- + set current vector lengths and pointers + called after atoms have migrated +------------------------------------------------------------------------- */ + +void MinSpin::reset_vectors() +{ + // atomic dof + + // size sp is 4N vector + nvec = 4 * atom->nlocal; + if (nvec) spvec = atom->sp[0]; + + nvec = 3 * atom->nlocal; + if (nvec) fmvec = atom->fm[0]; + + if (nvec) xvec = atom->x[0]; + if (nvec) fvec = atom->f[0]; +} + +/* ---------------------------------------------------------------------- + minimization via damped spin dynamics +------------------------------------------------------------------------- */ + +int MinSpin::iterate(int maxiter) +{ + bigint ntimestep; + double fmdotfm,fmdotfmall; + int flag,flagall; + + for (int iter = 0; iter < maxiter; iter++) { + + if (timer->check_timeout(niter)) + return TIMEOUT; + + ntimestep = ++update->ntimestep; + niter++; + + // optimize timestep accross processes / replicas + // need a force calculation for timestep optimization + + energy_force(0); + dts = evaluate_dt(); + + // apply damped precessional dynamics to the spins + + advance_spins(dts); + + eprevious = ecurrent; + ecurrent = energy_force(0); + neval++; + + //// energy tolerance criterion + //// only check after DELAYSTEP elapsed since velocties reset to 0 + //// sync across replicas if running multi-replica minimization + + if (update->etol > 0.0 && ntimestep-last_negative > DELAYSTEP) { + if (update->multireplica == 0) { + if (fabs(ecurrent-eprevious) < + update->etol * 0.5*(fabs(ecurrent) + fabs(eprevious) + EPS_ENERGY)) + return ETOL; + } else { + if (fabs(ecurrent-eprevious) < + update->etol * 0.5*(fabs(ecurrent) + fabs(eprevious) + EPS_ENERGY)) + flag = 0; + else flag = 1; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,universe->uworld); + if (flagall == 0) return ETOL; + } + } + + // magnetic torque tolerance criterion + // sync across replicas if running multi-replica minimization + + if (update->ftol > 0.0) { + fmdotfm = fmnorm_sqr(); + if (update->multireplica == 0) { + if (fmdotfm < update->ftol*update->ftol) return FTOL; + } else { + if (fmdotfm < update->ftol*update->ftol) flag = 0; + else flag = 1; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,universe->uworld); + if (flagall == 0) return FTOL; + } + } + + // output for thermo, dump, restart files + + if (output->next == ntimestep) { + timer->stamp(); + output->write(ntimestep); + timer->stamp(Timer::OUTPUT); + } + } + + return MAXITER; +} + +/* ---------------------------------------------------------------------- + evaluate max timestep +---------------------------------------------------------------------- */ + +double MinSpin::evaluate_dt() +{ + double dtmax; + double fmsq; + double fmaxsqone,fmaxsqloc,fmaxsqall; + int nlocal = atom->nlocal; + int *mask = atom->mask; + double **fm = atom->fm; + + // finding max fm on this proc. + + fmsq = fmaxsqone = fmaxsqloc = fmaxsqall = 0.0; + for (int i = 0; i < nlocal; i++) { + fmsq = fm[i][0]*fm[i][0]+fm[i][1]*fm[i][1]+fm[i][2]*fm[i][2]; + fmaxsqone = MAX(fmaxsqone,fmsq); + } + + // finding max fm on this replica + + fmaxsqloc = fmaxsqone; + MPI_Allreduce(&fmaxsqone,&fmaxsqloc,1,MPI_DOUBLE,MPI_MAX,world); + + // finding max fm over all replicas, if necessary + // this communicator would be invalid for multiprocess replicas + + fmaxsqall = fmaxsqloc; + if (update->multireplica == 1) { + fmaxsqall = fmaxsqloc; + MPI_Allreduce(&fmaxsqloc,&fmaxsqall,1,MPI_DOUBLE,MPI_MAX,universe->uworld); + } + + if (fmaxsqall == 0.0) + error->all(FLERR,"Incorrect fmaxsqall calculation"); + + // define max timestep by dividing by the + // inverse of max frequency by discret_factor + + dtmax = MY_2PI/(discret_factor*sqrt(fmaxsqall)); + + return dtmax; +} + +/* ---------------------------------------------------------------------- + geometric damped advance of spins +---------------------------------------------------------------------- */ + +void MinSpin::advance_spins(double dts) +{ + int nlocal = atom->nlocal; + int *mask = atom->mask; + double **sp = atom->sp; + double **fm = atom->fm; + double tdampx,tdampy,tdampz; + double msq,scale,fm2,energy,dts2; + double cp[3],g[3]; + + dts2 = dts*dts; + + // loop on all spins on proc. + + for (int i = 0; i < nlocal; i++) { + + // calc. damping torque + + tdampx = -alpha_damp*(fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1]); + tdampy = -alpha_damp*(fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2]); + tdampz = -alpha_damp*(fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0]); + + // apply advance algorithm (geometric, norm preserving) + + fm2 = (tdampx*tdampx+tdampy*tdampy+tdampz*tdampz); + energy = (sp[i][0]*tdampx)+(sp[i][1]*tdampy)+(sp[i][2]*tdampz); + + cp[0] = tdampy*sp[i][2]-tdampz*sp[i][1]; + cp[1] = tdampz*sp[i][0]-tdampx*sp[i][2]; + cp[2] = tdampx*sp[i][1]-tdampy*sp[i][0]; + + g[0] = sp[i][0]+cp[0]*dts; + g[1] = sp[i][1]+cp[1]*dts; + g[2] = sp[i][2]+cp[2]*dts; + + g[0] += (tdampx*energy-0.5*sp[i][0]*fm2)*0.5*dts2; + g[1] += (tdampy*energy-0.5*sp[i][1]*fm2)*0.5*dts2; + g[2] += (tdampz*energy-0.5*sp[i][2]*fm2)*0.5*dts2; + + g[0] /= (1+0.25*fm2*dts2); + g[1] /= (1+0.25*fm2*dts2); + g[2] /= (1+0.25*fm2*dts2); + + sp[i][0] = g[0]; + sp[i][1] = g[1]; + sp[i][2] = g[2]; + + // renormalization (check if necessary) + + msq = g[0]*g[0] + g[1]*g[1] + g[2]*g[2]; + scale = 1.0/sqrt(msq); + sp[i][0] *= scale; + sp[i][1] *= scale; + sp[i][2] *= scale; + + // no comm. to atoms with same tag + // because no need for simplecticity + } +} + +/* ---------------------------------------------------------------------- + compute and return ||mag. torque||_2^2 +------------------------------------------------------------------------- */ + +double MinSpin::fmnorm_sqr() +{ + int i,n; + double *fmatom; + + int nlocal = atom->nlocal; + double tx,ty,tz; + double **sp = atom->sp; + double **fm = atom->fm; + + // calc. magnetic torques + + double local_norm2_sqr = 0.0; + for (int i = 0; i < nlocal; i++) { + tx = (fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1]); + ty = (fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2]); + tz = (fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0]); + + local_norm2_sqr += tx*tx + ty*ty + tz*tz; + } + + // no extra atom calc. for spins + + if (nextra_atom) + error->all(FLERR,"extra atom option not available yet"); + + double norm2_sqr = 0.0; + MPI_Allreduce(&local_norm2_sqr,&norm2_sqr,1,MPI_DOUBLE,MPI_SUM,world); + + return norm2_sqr; +} + diff --git a/src/SPIN/min_spin.h b/src/SPIN/min_spin.h new file mode 100644 index 0000000000..569bcbaab2 --- /dev/null +++ b/src/SPIN/min_spin.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef MINIMIZE_CLASS + +MinimizeStyle(spin,MinSpin) + +#else + +#ifndef LMP_MIN_SPIN_H +#define LMP_MIN_SPIN_H + +#include "min.h" + +namespace LAMMPS_NS { + +class MinSpin : public Min { + public: + MinSpin(class LAMMPS *); + ~MinSpin() {} + void init(); + void setup_style(); + int modify_param(int, char **); + void reset_vectors(); + int iterate(int); + double evaluate_dt(); + void advance_spins(double); + double fmnorm_sqr(); + + private: + + // global and spin timesteps + + double dt; + double dts; + + double alpha_damp; // damping for spin minimization + double discret_factor; // factor for spin timestep evaluation + + double *spvec; // variables for atomic dof, as 1d vector + double *fmvec; // variables for atomic dof, as 1d vector + + bigint last_negative; +}; + +} + +#endif +#endif diff --git a/src/min.cpp b/src/min.cpp index cd9253f8d3..2a42a444a0 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -655,7 +655,11 @@ void Min::modify_params(int narg, char **arg) else if (strcmp(arg[iarg+1],"forcezero") == 0) linestyle = 2; else error->all(FLERR,"Illegal min_modify command"); iarg += 2; - } else error->all(FLERR,"Illegal min_modify command"); + } else { + int n = modify_param(narg-iarg,&arg[iarg]); + if (n == 0) error->all(FLERR,"Illegal fix_modify command"); + iarg += n; + } } } diff --git a/src/min.h b/src/min.h index 92da97c664..a63254231c 100644 --- a/src/min.h +++ b/src/min.h @@ -38,6 +38,7 @@ class Min : protected Pointers { int request(class Pair *, int, double); virtual bigint memory_usage() {return 0;} void modify_params(int, char **); + virtual int modify_param(int, char **) {return 0;} double fnorm_sqr(); double fnorm_inf(); From 7a00997a14687f049cd3f9a3124d4143a8010d5b Mon Sep 17 00:00:00 2001 From: julient31 Date: Mon, 25 Mar 2019 14:03:28 -0600 Subject: [PATCH 42/49] Commit2 JT 032519 - added equations for documentation - updated examples (not calling fix nve/spin) - replaced error message by warning in all pair/spin --- doc/src/Eqs/min_spin_damping.jpg | Bin 0 -> 7035 bytes doc/src/Eqs/min_spin_damping.tex | 13 +++++++++++++ doc/src/Eqs/min_spin_timestep.jpg | Bin 0 -> 5984 bytes doc/src/Eqs/min_spin_timestep.tex | 14 ++++++++++++++ doc/src/min_spin.txt | 8 ++++++-- examples/SPIN/spinmin/in.spinmin.bfo | 2 -- examples/SPIN/spinmin/in.spinmin.iron | 2 -- src/SPIN/min_spin.cpp | 1 - src/SPIN/pair_spin_dmi.cpp | 2 +- src/SPIN/pair_spin_exchange.cpp | 2 +- src/SPIN/pair_spin_magelec.cpp | 2 +- src/SPIN/pair_spin_neel.cpp | 2 +- 12 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 doc/src/Eqs/min_spin_damping.jpg create mode 100644 doc/src/Eqs/min_spin_damping.tex create mode 100644 doc/src/Eqs/min_spin_timestep.jpg create mode 100644 doc/src/Eqs/min_spin_timestep.tex diff --git a/doc/src/Eqs/min_spin_damping.jpg b/doc/src/Eqs/min_spin_damping.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0c700cc67863762a99f9b9e3df0cb945612a2e38 GIT binary patch literal 7035 zcmb7o2UJu`v+kaOVMqfrFhoHKLk=Pm1tf<7B}vXXgMcIhl0l-wkb_9hQKAHqFhoH> zGJ@m`5*39b5B>jh|9j6{>%R4B)!JQMRlRrb)m>Hn_2u;CA^=xaLMs8FE8+$50>I@Q zAP?Yy!N2*6@UIv`2!Y_^Lx`bJ0zy(^Qc@CP5)v301sq0(AR{4xQ^OIINGd8SQgRwv zY9uWMk_!3zB_O=3G58Q72!sd;BY`3Rzv;3QKo9~(pa?t=0stdGcnHvCH^2aZfUBv2 zfd3Ey6dwY{Bm8Yeg8sYVkIUsOKzij4hU38j0CcLt8e#cHAWmuVKjZ&McuTqoltvEd zw{8D0K*2FW5&0UD)Ld+$+5fObA*@)`hf#hD$qs*8+@S)0#4U*+G6^D34hn}fmjM8= z#2~*A19?KwrX~PTmDnP3B^9DS006$jO9aa?Pi}_<05GV_;8?OL5_pkZK6E{yFDXM> z!S!rC)hVfK78!W{@3Ak9B_}5Ve~TF96_U;%RLdz%KR-s)6rsg5U7m z9?SQ`1~ci{=XNl%hIfBO;cI?mW7?8zdh%=la#x9D^Sx*ozbQbUps6MU#WMocND!yi zsk%20#LQAyQ5XYN{f>ET8)&^7D%Jepdj4t|^bCj>{$TxNG?@+~r^X59R3=>V3;g|; z1cBXbG62XVnYj<#z>5I@FzrK?$5yXp71OnkIq}8_u737kL>@8nM>z9`YAG@*Mk%Vf z_x)}AyS=U^%C`Ub#?wTd-ue<@%drA<_=mpjiXLx1q3~-j zMY-Qz5Nout3=Tn`E=H|2QdZP$MmjS@D|aw|VXNM3Su^@*>^Py2hE0AM_}@CQhMw8# z4a=qvkG`$UccuY#`NP|&29Dkp@1?ibh3H~2VR`IyM5K{hITnq(X5vw1nu2zu zN>GBf;D@Z**Y7!;+l5uWvB||Fiz}kJp(~*ukk+3|S$6zMIIJ74>Kc_G{K%e^%$}87-DQDt2c$wt%sbA4di`(nZF(82TTC#+tsJy2Y1`ak(^Ia@9Lduk0*zFd?P5OgDqXdC(i|={Yz{v$Gd{#;)2V0t@f&KDf&DqyUfq~mdFAHCM(Ee@gM6akgi<1Ry@o!gsF~iEXz!MTVEv5pH{E{dzOXci3ROaq4L$ z@Fi|oM7FM6SLYgU_w+#b zr;;jt+4I{H_qCBk7(AlF3uAxXIzq49bX#Wgq4p`;*3%iXQeo}Hpaxv37K^-5U)h!o z1!X(={R9e1qe3Nr)S7ik?NN~K5Y>>5LqzIwt8nc3o2~i|A4L_%60&dd zha;SE%Kqv?-9lzj?Tog!wbFQNjR~h;Gp(;*KV`k`-4an_6kUDx8RAM`laIdH zN(TzH>N4F3Jm)`E6Xs7H)`YdrnXU<~tr)#jXLX)DBq5Fl3pm#A?`&_(N^Pc+_-{d& zoBHPlX0~fRzmnA5x;5FEtX<9{TiB^I>ox0Vyf)ZYqV97$YGL|obNjh-Ax{je?qfD* zd8_6gEJQA8s>@en5?No&#zn;~0SU&+VHIVs{mO17Q9WSb?)14%uNOYHOPH$ zGOsOZWF_z0&TpxHclGJ9V|YIJQlC*?5SdRfk#h5<=*U~&y%x6%Zmj5?t@XTO*Sq&& z7sk{=L0@(jIEzZ>KeV)QneA24Ofc5?@T|`pnQ|-Du)G#EHy>#{bTJr%22}awW|jF0 z?w=GqZD=*u@xe`3Wq3P!mC$!bJ)8G`LixN}oNtuUSYwa=p!w5ZWi}O13M4n-m!m^X ztCfO>@0Ja1!KFq+K%@84FV6ow-rR`UzG3@p>Y6b0{`_<08`8e-i0*PpuV+2I#g(U* zCF3EbtkgDAge(ZpaAeq^_CXm8x3VfY2|nJsht<1Nn$CG*Y!oPN!C<1?N8^96UXwEQ z6ZKP*=gfJr>Z>gpTgqXjojG3brmA#oU$Edb!S$1RsmPjW$#i=qr#ETHl})+dZOB)& z=CiO#8nsRyk4jmfzB@S2TUw4)5 zOW#!50ykW_)_M+mk%x`8P>i)@Zw0QutEb`KBvG`du;w(^n%Z3&IX}mk0V6>>RXqaM z{7=+J&P`+@F%Q|78$Rt5gcls?AfFH`Di&iX#9-t-k5Z3FoVHn#U!=fH;&d6!$2?E9 z`)MBS_CBR{dfaMF{b<$zuPpN|KK`qQjaGb( ztYxW%u@ACK6xdh=@8`c67{~Qs@}c2MYOk&{-F+(UBb}J>c5D>=S$ctab(D5~jN-%D zLn7F+IHiNHeHTeuij|5N8+njcv`1gORRKH{Wv4D3H1aQKA7 znC@AuE_XqhyT<+OvL%ta5|s{Lv7=7R=mFJ*>H{g!LdLeJy}MiW6B_g9_bdBKhe&h! z6A#0YMVEm6kmK0&Ur!K9M^&8ZD;34HDUN1-eJ?1 zxK8WgbYAg^ZN%2B;+?F0k#wKWF=qAsR51C*RQ^KaJF0$J79lVCM#j4n*F}6#4Iv-I zIJI3)(3O!|v#d4w3CB?ykdrux6TbTOq!{+$`O06-U$Lv+3oAEpMUFgzG#U&KZfdmcCL{(e151hm~H-@uuyW<^0ob+}sokCH!RWTRZh@ zT!G0(5I~Y_Ct5 zBfYNE+pk0mT93WzDIw%C(r?Jv7WrCdJZ8-p^#N6^WT`-v#N(87FWk67tfZwA`<2k%br)0uD$c}l|p@SBd)aC zp|)c_Bab6SxX)ZsU0BTL)%-_}L%#jhCkAjQvd+88)}<;wv{+kwi`>cPaVz2Btd0|X zuTaTrPe^80p_GxtJ8uqe8XcES-dW>{G{-=({ms|**e7YkhkDY&n}>hlRgTla1eYMi zCcZxE1q81!8+gmBo}2aaWME3f*4M&28Mb2D%TJVLyEbYySC!>Q=L(TGy&;gQAC+>B zeO5|^cepTkM;XlF*I+_H3ON$cNe96jnuDqbHqEw5F3Rvm2oj_l{xn8_@ zDNaQ!@62VZ2o&#$Kdc{Kl^&&;RxhGt2vOBbGc2rkoS@CNDAeidoU-O`Dl&A8K!#5` zC1Og!(3#g)M<6cv6*l+{Yav%~_YaP^f|krzCmTz+M-Wqdj*Mna$AQ4;;omSqntAiN zAXz_mvSjPnM|oeB)D*4!{gJ@e!hF;AqhUwO!81K{X00Lidw~Oi1E18GJ<-TDPKw>v zX(c~Oyvi%6GHk9bhcj|Q8x#hP(#!qJMavU`K_hM;cR!DmDsC{flT1zv5+*(gYgQ~c zVeW$Er#UIOIgJW_z_Q7Bp}}bCb3ll;i+S zF4;wQ)H=g=5}bx*2)g?~Zj-oD={Emdev~C#q5FaGIUDQ^8Kv@1#o+e@#8HoSQxhMF zY|gmk(R@6k=mRI3QBvi#xD85v(mL{%s$e(Bm~N&Lmdr-7%UOB4MqdIkz>gP$Z>J|h z#xxB2!}9U6!Yug$+YZ4#LDXqqE>Nd2sYWv5n|c(}Bwyeh4hY9rTS@mG@K8VMJJ4j~ zVPLrXPEau=u7)zGcVOx`p!wIs@8(0lHdPZt0;tuMD=#43x1ra*A~GZT6N?F4c$4ED`*L-$L|hDeBi~}D^`43(W~L3 zbzMk&P8BdJX!;q>Eo^@S7R}E1M1j8Qg?>JK@Y&C6;`PX@knc}$BHm&!D6(RCBU_q7 zfz{~$$Y_>?W~ZR0`Vw}x{nU;yrf{>*(U6>1!0qG~sut5ORGxetbg1cV``Dr%XkF{A zB&8Lw=s4~q+)ujWm68uYJr`mdrqQQq=xD`SDe}I4nQQgo@0rS_B3E66rNn2si>eRq z5G5G|#V(Cw`RGTI3q^fVkKDtlXLUx-nxM;hC{CMOj#l2=7QJ}vy@QfUw+l$Dr?}k$ zH8^hJNy*YZi%J;#xbS_*%u6}UKeG+@6s0qHTH_@89v~qynn`E#F`+!W%Q>&|QUPH$ z6|_Bw&4xD*C$65c7!{I*f3?vDI{K9+9Vh$9@G1Q=?in(~xhg;9>f^$0^&677HnqgK zY!`V`z3cLIp38ol^cToZ_4p^Lu~2>2i_Yj4DfZE9PY$PFUrx>EewCdEOc)GlM#M$G zM@kBJ1zb>8jWQV!XS{>QcH9oi3fV!r3}AxbFbpjYJwEUvSVvsX(1XC~`zLI|Qxe!W zE|<@8Y#?Y*7NcI4!&=r(cU1>iH7+twxlyep!!#iw=ju2d3A-gan%eNqqmX+jUg~Xx zyjVV0t}|nei|e6t$Riow_g{s{&qDgll*yv^hj%Bltb!hjNuK(CzhUE|!R{b~M<_7M zZT_6qDr@f*4~O=8&f+x`#a6gUf%wX?7l&pb$k!UF>elW!LuJMdL%*@O1bhkwkQ%H= z5~hI<-6ycA=bSNjx6P`>*_5TrX_?i|&wm9^q&j-XILBzyODdayvHA9Ld;un{(JUuF zL)IKd2!wJKPRu!e$e6yjm}a}rdlooEEq1jpJ5{ge3Qm8IQs}9i?STu94fmdDVk)s+RFrfrBiBegfU} zbHyN)^-Wx{dC2a{FXbV7YW3T+e&4kU41bnn-b6fvkG`uM?yDz+Z8ap>NI*5c&mEIU zEKHes^x9%gR1*2PdxcuQ-5N4;h;o=%cY%Z=69O6nu5#g@`!nG8#S0t*ps?tFF#bO@ z81z3iSXlu4_o(1M0!9TtkO+k(VxmB!FoeJT!GF4d3hGM65Hev2QNc1-7j{elA$}kT zg_XspkVRpxe9$NgG}CVx4P1TbH~(`=_!LCImD?X?`j#7(hcS4P`^=9kDZ*+eqPp8Bm=w+;v}rf+ex|;rpB`t;yv<|4)FHv7 z$(FJTC1Y33$p-1Jz&z8bG#wF$3j)3|Z3tq7&5a`~a|NcCIY;D1_ogLKgN_6QcFOqT zen(F;6lZAxl0}fR+&)ON{|?$0BVaFqTL1w4?MO0ZpU+B!-c|##LZ8nGh?Wp6+4`Xh zdr{@dJT_T66|zVvLKXpmdLt^Lb`FKX)0k*R4JwxD#pgX$BLUrG;-Lx%Ld!?0>{!*% z`Ui1$*jYQb#Y$3?Yn!`vqtms7usUp|nI5CJuG47Y?lnujnq;JUAjo{@qI#XnkX7x) zmK?bU;^!q0cP)MJLtFE{ZzYQ^pmXBr(@))k!8v^t#JzZSx-YA>-C2q6>td#a|l^y^_O|5#<8F+fp|^}(HlCx z1o#!v{6zdRs8Y;P>CY;8+6!brH#JvLmsdN{Geco_4TEM>!xH6_pXCNMR=AMwYP94J zCT-%^Pt0#EWzA`6etDfUW%@u-4y!*4%4B&odW_V>X^jA-OL^N`AAQKxKQG!U(v>{9 z1l}_eO*RFo+7Pm^aiT`O5QI}C?^UuN+(*FYbOXsQXk~RpWiv-gOWURHIV5q6>;}2# zS*YxfloH{|%y8pxyK>2FMEqJNOlbenQtP(1_m;z7I`jzMi*S+`>y|54Qa?kVSos?Exv%{h#TMBwvJPI>IIjb*{Z@%&RuzqTU2gjQ4!6iH8(_kFby#aSx!aalVgw zWh;=U214d{fIIobzXynGo*Ct-)7DyO(lSYgJo8A2N~5W+fLh!Egc8@ zK5>XHIAbPoA@^1!Cls~uvOv# zr|hOgAdApI8%~;cGPAh|xH6)YNqy0p(-a&mCFQ}xdjmH-m)>_%kGM(R#3Jlts1k9D zCU*zEnO!E4w(p`ygMg(Z@#E3>Tv>A;2-68qY%|&ZTdYlLL=`zg+e~k5TPrK+Brwyd zx)gx&gFsAT=#uUpLVI<79`BP(xmWtQj&mbD9I+gNmwo#sp}bFShosYYL;k4E;aWgk4M`ba|!}QyEo2>TY)_SV+6mfG>(EZGGF}?kh8qa3wl9Z z(08-W{aqw7xDS+zato9B%O%}(bEK4*qAVM!*5!-#q4n)%0KI37tA663@QE;=R83aE zDYpH!xKa|H72})VN;;#3f zDp|wpEPb68Uc)IHB!RH``pl7kK;$}vX_z7^Tw&=e?kTX*x;JZJUyyi_oa$Rw=%^v}ws(16g5mRX%51NHTRhfbi+fCj%~L{tt~b B|8W2S literal 0 HcmV?d00001 diff --git a/doc/src/Eqs/min_spin_damping.tex b/doc/src/Eqs/min_spin_damping.tex new file mode 100644 index 0000000000..88b05447d3 --- /dev/null +++ b/doc/src/Eqs/min_spin_damping.tex @@ -0,0 +1,13 @@ +\documentclass[preview]{standalone} +\usepackage{varwidth} +\usepackage[utf8x]{inputenc} +\usepackage{amsmath, amssymb, graphics, setspace} + +\begin{document} +\begin{varwidth}{50in} + \begin{equation} + \frac{d \vec{s}_{i}}{dt} = \lambda\, \vec{s}_{i} \times\left( \vec{\omega}_{i} \times\vec{s}_{i} \right) + \nonumber + \end{equation} +\end{varwidth} +\end{document} diff --git a/doc/src/Eqs/min_spin_timestep.jpg b/doc/src/Eqs/min_spin_timestep.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0d8f8d07f9ff6ef23a0b8a136b05bf36a1952bb6 GIT binary patch literal 5984 zcmb7I2UJtr(mn}E=#XGSmyS{+AcCMEB}h{Qr1vTvsfvIYia?}y2w3Q#(gh*(Dj-Oc zDk?~CUaBA%Z1p?|*OBtdl9<%sKn)J(Io9@!0Vc09U)JdKCZ>NeCna0LLEy zMSuhhK4Bt3hzuozLLm?+1t}?vjEaJaijsnolA4ANPECWLp`?V z=9QKH^;^@9WSC2}tLDG)Q?jP< z)1UTxeoo1OkX@;1)hS7`XQNUo!1!ou{<;Qzv(oZW2wJy>`TE(}A_oV+8NM1@-*w3{ zEc#vTICaLJ&?tqXd3Id4kW^4m7j_J+W3>%sx{jDfk_QYG@||igtf@kC z4ZJG!BVrt#j9tw8OSid~vO7~>e~9=Z;lIHm>l5{qqgXLcR9#Jcwjv|hGya{2;X8Gy zE;}iq1>TH*YYO+K@fZ5KrI*62pjTz0r291@V3LcCMFU9GT}rMMO!Bc2Dv@V>ajK+= z-b~6}OSl9<%SuosEtz;FvF3Fcyk^thFlm0O!VWiH(Y87c?V@RGQOIJ9>0kN&8;}1c z|8DAqaXw~a z(fjQJ2ac+Fj``1=T#}5-FlEtO{L+Urg68plQbMmL!`rC1jE6b``~pk5OJ=VlAdeCu zRx^u`TXC5bA(D(>iSwVpl85aqbd;j<)Iqy(0$t3);ln|U^dOcPOQyt_Ya6%lg2^pz zAh|%%a*;-v<{!qBBHy|Eg2Vvq8Zf5K@tK`-s`*3|- zino>QC{+NpZ!5X8dGHUroo?m42%B@7alCibHaI<0Cp*pA@Y3Gn9!{Lj19LG&5y|DC z{(3`{A;;SDT*g=3aYj=P*=Z-K=D3IaUHiimQUXHMnoTRV-s(;(a{Lf$q_>zD)?mV~ zhhTjNXma_Mt-jJOf7(o2I;{O;g`M`K#UOrbJwFR4_U8&F_M|Hy=!5@&0RKWNCrQA>b_pP$bf-8)I7wnz!^Uiv7z1F0Inj}=_!focCBn=L$>ZTo7Z(KbMHMtE@&xy#CR z3}AiV?lkTWFqzjzi5X#>I=L2gS1P%=i|V8$Joes5JP<(d_;L76_4K<+TyZ(nViF*G zWUA}SZ!3R6BKAFln4#AFo&3Y(r)VMXT|Snpd=cxzVr$FG`B|i84(>@Cdas_-pw*Wf z>8rVNs6sQ5gk`lfoQ5+#CA{-&;&q{{OHje_%XVXKhWt*PuXTKQ@yEa|a}*2I#k*%( zMQ77ML$XBk+xrZrVVyuJe~OaL``I6#G|4)IHAiBLxYl(>J}(UK!y}U*O6ceHsIyGo zC>qDShYVeo7oXJI9_U<*ApcsxdMSGHv20NTAx2ogH9z>CbdOtLywKC% z;J4?Lmg&E{K4dHW%t~P+-FYkP&Mq1g^u%{g(YHqPQ?ZWZizMph|6Zv+!@FoU>&&Qr zEn|1#bU^ zl_3+Y&*C#Ac??|Mjwxnbz1Wt*U@AK8dur|LMJ+tTXUvp@T@pi8P4wBmMru#i8&3n6 z=Py2$Jro~Tv$5_pJ8yAs;F2Gn{3Rsxb~@*3z2`NTiTTtImA#^`o$%JKqv9POiyfkB zO@>(R)Z|I5{TFVxXRWRRH3dnpK1>=`@Lp3Ed&W^^ov0;Uec}5E=Rwm!(w{$xAz~XK zo{>k-|t1`BM|D{jiw^AX&Sv}=z1Lxa7En`o29MyISrK(YjsJuu`q!SV;$Ze zKK?M$;i2;o@s-mlH?GP^h?TgwQ>nHqr|BcYUt~L9(buaqn`q&}k9EDC)NRO=zcaBL z|G2Hx6tRo9kF0RBGt|;8GQ06KZ+kNQZPFbU!479aO2?N*{;qwm=eYEq#}|$!o;G~` zl&>q2R_)nVAbdGzV*QUo;rn+BHhHe{-L96DptUav5BU5&b-#auOM6;5QL#XGK6Y&- zZzlOPJk`aOT971BzbCOQfhIieeZ>nSPp zXQ*|}-=qX>cT?f=g%vZxnQWz7m#)6%aCn6@>sGe5+^{C3Q|DoHFJHUNB;T6ETj}v7 z1A%GytUVybgVQCIjVkNWTiL$1R5+kHkaEt2%g|f6HnpVNBjB-e>t=d98`v`lkG+{w z>wTA{ZQ-in>D2&AzK@s`eOu+k;q4n$XzKl>b6?o^=4D^WY(@38T2npQ!Gwokp3oL) zF*vTP=jT0cF|)$>t2Xznc(x-yZ+*N#r&%>dX(1h}B!ru654f4Iy#j9=HSF?FM=iTl zYGRHk>MKbpZOhK|2H)Q@%}R%Tti(}fMRS(R1=aHq9?IM)D7$G*O&O5$I{d*5@eS^_ z7IPF9P$X+jyz<}$K?+L}=0lUsO13^2poJEhn;a6HGXU*QJ>jbD_h~WQQP~Sqcu(zM z`{e7U3?udRJ^FJ}S2S`h&jxn2DY2h_v?5tXPVbt#l2;$68eTD??)X0Z+JjNbNiBiP zI5%3#7OUh$BfsbaT)Vk~%S&bqe~iTK9vCX}h^%BJF*V1bTtgildY?OmR7>B8Z&jl^ zB|PUlNqG6E6cP4dr9CML;~_0xL+G0^2I2lk*}h(9t$7UgI0X_JCf$_$)2r}}$(ddE zTBEmGTQ067x$+dg7}n0T>Qifj>88;7O&9mFr&jjYgj?P2jn8fY^9;mf>u=;ANyQY= z2K-!p4;EYe`e;1l6q6^jJypgsxx9Gay72J%IOS}OU#qw{!F|UxqUFP4AtJTq(;sPa zMT@wOL-xn|lG`Ot+sdJRWQD9MJ^CSm&Yf8=UhEASXih6LYfENJB7>FFbKibi8P&>? z0wx))7Wqh`_B_s_c_d9$aOo~p??*-VFm3U=WNVZ`M)3Cq&kE|Cw!ae!3##9-SuHyL z@yfeWK_jyBq2JIk!1`t+tkK;(arVa*#$(`(=uY#;pPN6&My z5_T26^Im3KEWzYgh0V2S(EE%LMls3{H|I&Er&62z{Xww!OVp17wZKua4uCy|M~%l^UM_rMax z>s!<~xwW)0Z_HJHv*Fu5FCxyKB&jnH@pXKo{6UBCbZyv?b&G`!C&Tt>OFiwhGvB^m zTl}#vqFT&6O#vP|Mc6z{r_2wVXWHv?vzuhvh27xuq}dKy_S(A_Ph(eEF)_a8{H@B* zSf=R7NT1WcF_eeqr(L0b7`u`EZGx>~OhgYLVMoz$++!Vg=T~wpnccc%_4m>b z_~eRA%6scb?j;mByyOGzo9nXT?vfl{ZFgE_QG|NG$Na3TtS!>GNz8$znmz6`{F}>5 z#(AZ&Z~}Q_2W)nAP&ka)M-r)|Q?twxbCz`4J0#Ojr0>lh*CQUh)Pk?7x3oV1Wpuvy z;KR}71*sdUQtv!77Np)O0-IS}8s`?KMnzZ#!B3p}1UK4o8J)-&|Lbf)aEwrL3T{UH z%tBd+&~k}TQd=x1gX;|*UfgL%%NDEy%$04-dE%O%RTA`6Hm%u^-cFLe7)9Cm;I`X} zjt3tK2`S>6sy;pE6A^#(8K3fEa>rWyS-xcG1}SxirGEA)FAOCEt%MiH+)v!n1S>@$7(dRAdt^ua~Pe9)O|;W`sLRj- z*UIqWoVwgbxOrc{rJQ%(stWx8sh;HSDJDW1ItswTun1+6Qg#Lza!IN>^u5_+gPU=Z z?-tbguV-ymZ;8S(hu$2@29g=S63DciYnKh5v5LtKqc3Yi=fdm~c;qIq&ufG)FJF>H zQ?{sOK)(ua&*bTO(k=6uNfdY2e}xlkyP515@L=6`x!VV#z5K^5W#g+sZdLn`E_W>e zp?ppwVy=%C)p979RN)$$6(pA>y+3nTR8(y4#!MTVS?@F+{-K@PMN{>5lb5HfC1}@me6@GevO$)?@`A--uA+ehoLQWciz)dTSoL?D z?+U8!$ea-eg+@ZV)M1ch9{f`Bwv7*RpILIBB8o9CCqizq%*4JUhO#D=nbn1g(v0(WOZslqcD9~*AH?ZL~7!;-@` zKOVfl{|wgrQ0ForFy)RiB%r(56IvAy_|~uinV24Rrbr-vZ1IuSkX6fV14acthZz?# zl4KipK7|Yb`Z9481){%stLG#BKy8FT@#1>P5&m4%}j0PMzF(yWObeVvB3(YZaH?+qZ2jGMludfh9cTnG%0U#5q(( z^|;vdgO}o{p)b?mO)OB!FHvjyBk65o17Px&a12NtvDSF#QX3Y4%nFuJl7i`zgIfNA zkKe5PuN)C7iFn|?k62qhXZ*3zUB<`EgAN0n1{Gp^gLQ#g1g3rJ_27ZT$X-@8W34wg zzx=!{mGLw3aU_F6CZWkjHFxg}=%%%)`(R~srY8$&A#{YQ%%JC`Do`F8hmP36WWFs0 zsb$4=D%+Y@lxePUjM&VVdu%l;#ORsTz!>nDfqq_2g;0}>Cl+)gYFI#xd;6B>F+jes z^>dJPs@$JzYdBa_(TJNK)hO*&I_0)2OHZYC`!Ws|-re6?klk}<$$Q%1zwlYs^N-){ z-?yInfA9Op(U!#BdoZ`I$Bc9tFyCEdbaLz=rSPpoWG@Y6o-Mp%PZuIzJw|#zJe+QW z+47pDLgV9*1xFp=Is{mLWiPKO~>i=&|FU1mqj2Nb{~Db#9oS-rO3g>`2;)q zx7q;gRywY8Gj>v4;FJM39o?FMmkkvFCHejsRjIt%-Cf`~tb*=uhq31ByP!0MKb?w0 z#!^ROwJaC_w&d91b&4vTxo*Vg;!Jo0;J@Lm2OFeAGAo&xoGQ3K&5uNmk;14RNVbs# zBIU=w>Bvb(#-1_=E-hcsu`kE_KGrK8hh}q11Dve2$gTam=4=d(QOaZVINWI`lq*;*D$;-JGro*Q4Wbiag+p0|_K@Q>IM-oAMB0Z)1-2 z{9)L=#73c;+1Ad_kSfygmpUIu?XSC;dhpz)(q{@GKLjdHf5urvm14c!9wmqo|xnjcMn6m7NUms&PmUJ5K3e<2C7brPBpe zD>JHJy3zUA!bxKBvtgeM0^xQrPYoE_RTvkKx6yl1>1a93@9dLoc^F1HLWjWRQI@XS z&`}Ix!e^L#GoNdby)JFi1|QXFVabqV%g$lD>UYiA*Nw)Y!3Pd*EWQR8t)9QmNs%s& z7ap_cs4IBb-i<7k5h^vJY)O>fIedg%y30cr(>ZL)D@*`9$?rX|l?RRHV1YRI@P;OU QPIn^d(7|c_7&spP7aqDz-T(jq literal 0 HcmV?d00001 diff --git a/doc/src/Eqs/min_spin_timestep.tex b/doc/src/Eqs/min_spin_timestep.tex new file mode 100644 index 0000000000..b0f6e68e4d --- /dev/null +++ b/doc/src/Eqs/min_spin_timestep.tex @@ -0,0 +1,14 @@ +\documentclass[preview]{standalone} +\usepackage{varwidth} +\usepackage[utf8x]{inputenc} +\usepackage{amsmath, amssymb, graphics, setspace} + +\begin{document} +\begin{varwidth}{50in} + \begin{equation} + {\Delta t}_{\rm max} = \frac{2\pi}{\kappa + \left|\vec{\omega}_{\rm max} \right|} + \nonumber + \end{equation} +\end{varwidth} +\end{document} diff --git a/doc/src/min_spin.txt b/doc/src/min_spin.txt index 468cde0fec..de25100102 100644 --- a/doc/src/min_spin.txt +++ b/doc/src/min_spin.txt @@ -27,7 +27,8 @@ timestep, according to: :c,image(Eqs/min_spin_damping.jpg) -with lambda a damping coefficient (similar to a Gilbert damping) +with lambda a damping coefficient (similar to a Gilbert +damping). Lambda can be defined by setting the {alpha_damp} keyword with the "min_modify"_min_modify.html command. @@ -50,7 +51,10 @@ command. NOTE: The {spin} style replaces the force tolerance by a torque tolerance. See "minimize"_minimize.html for more explanation. -[Restrictions:] none +[Restrictions:] + +This minimization procedure is only applied to spin degrees of +fredom for a frozen lattice configuration. [Related commands:] diff --git a/examples/SPIN/spinmin/in.spinmin.bfo b/examples/SPIN/spinmin/in.spinmin.bfo index 5b678c8a4d..511fa26b20 100644 --- a/examples/SPIN/spinmin/in.spinmin.bfo +++ b/examples/SPIN/spinmin/in.spinmin.bfo @@ -30,8 +30,6 @@ neigh_modify every 10 check yes delay 20 #fix 1 all precession/spin zeeman 0.001 0.0 0.0 1.0 anisotropy 0.01 1.0 0.0 0.0 fix 1 all precession/spin anisotropy 0.0000033 0.0 0.0 1.0 fix_modify 1 energy yes -fix 2 all langevin/spin 0.0 0.1 21 -fix 3 all nve/spin lattice no timestep 0.0001 diff --git a/examples/SPIN/spinmin/in.spinmin.iron b/examples/SPIN/spinmin/in.spinmin.iron index b87a811cc7..1f84d4fc9b 100644 --- a/examples/SPIN/spinmin/in.spinmin.iron +++ b/examples/SPIN/spinmin/in.spinmin.iron @@ -28,8 +28,6 @@ neigh_modify every 10 check yes delay 20 #fix 1 all precession/spin zeeman 0.001 0.0 0.0 1.0 anisotropy 0.01 1.0 0.0 0.0 fix 1 all precession/spin anisotropy 0.0001 0.0 0.0 1.0 fix_modify 1 energy yes -fix 2 all langevin/spin 0.0 0.1 21 -fix 3 all nve/spin lattice no timestep 0.0001 diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index 99aa4ac3b7..61a61cd6bf 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -32,7 +32,6 @@ #include "modify.h" #include "math_special.h" #include "math_const.h" -#include "fix_neb_spin.h" using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/SPIN/pair_spin_dmi.cpp b/src/SPIN/pair_spin_dmi.cpp index 200cafb999..e9e6691a88 100644 --- a/src/SPIN/pair_spin_dmi.cpp +++ b/src/SPIN/pair_spin_dmi.cpp @@ -174,7 +174,7 @@ void PairSpinDmi::init_style() ifix++; } if (ifix == modify->nfix) - error->all(FLERR,"pair/spin style requires nve/spin"); + error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin diff --git a/src/SPIN/pair_spin_exchange.cpp b/src/SPIN/pair_spin_exchange.cpp index 5b8ec60cd6..aecbbeb97d 100644 --- a/src/SPIN/pair_spin_exchange.cpp +++ b/src/SPIN/pair_spin_exchange.cpp @@ -161,7 +161,7 @@ void PairSpinExchange::init_style() ifix++; } if (ifix == modify->nfix) - error->all(FLERR,"pair/spin style requires nve/spin"); + error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin diff --git a/src/SPIN/pair_spin_magelec.cpp b/src/SPIN/pair_spin_magelec.cpp index 95c29b233d..be1cbcd6c4 100644 --- a/src/SPIN/pair_spin_magelec.cpp +++ b/src/SPIN/pair_spin_magelec.cpp @@ -167,7 +167,7 @@ void PairSpinMagelec::init_style() ifix++; } if (ifix == modify->nfix) - error->all(FLERR,"pair/spin style requires nve/spin"); + error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin diff --git a/src/SPIN/pair_spin_neel.cpp b/src/SPIN/pair_spin_neel.cpp index 64fca23b7a..58173892d9 100644 --- a/src/SPIN/pair_spin_neel.cpp +++ b/src/SPIN/pair_spin_neel.cpp @@ -174,7 +174,7 @@ void PairSpinNeel::init_style() ifix++; } if (ifix == modify->nfix) - error->all(FLERR,"pair/spin style requires nve/spin"); + error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin From 30be5e94d9c7990a3e97ba6bda5cbaed953881a3 Mon Sep 17 00:00:00 2001 From: julient31 Date: Mon, 25 Mar 2019 14:22:16 -0600 Subject: [PATCH 43/49] Commit3 JT 032519 - updated the README file - updated examples/SPIN/spinmin/ --- examples/SPIN/spinmin/in.spinmin.bfo | 2 +- src/SPIN/README | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/SPIN/spinmin/in.spinmin.bfo b/examples/SPIN/spinmin/in.spinmin.bfo index 511fa26b20..95a1a0f29f 100644 --- a/examples/SPIN/spinmin/in.spinmin.bfo +++ b/examples/SPIN/spinmin/in.spinmin.bfo @@ -52,4 +52,4 @@ dump 1 all custom 50 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3 min_style spin min_modify alpha_damp 1.0 discret_factor 10.0 -minimize 0.0 0.0 10000 1000 +minimize 1.0e-10 0.0 1000 100 diff --git a/src/SPIN/README b/src/SPIN/README index e371e39767..53e456bacb 100644 --- a/src/SPIN/README +++ b/src/SPIN/README @@ -9,6 +9,7 @@ atom in the system * implementing magnetic pair interactions and magnetic forces * thermostating and applying a transverse damping to the magnetic spins * computing and outputing magnetic quantities +* minimizing the energy or total torque of a magnetic system The different options provided by this package are explained in the LAMMPS documentation. From 81a4d293dbc1703eb6f3f5f0a51c3f7d9ba6670f Mon Sep 17 00:00:00 2001 From: julient31 Date: Mon, 25 Mar 2019 15:43:58 -0600 Subject: [PATCH 44/49] Commit4 JT 032519 - corrected documentation (errors in min_spin.txt and min_modify.txt) - changed the code accordingly --- doc/src/lammps.book | 1 + doc/src/min_modify.txt | 10 +++++----- doc/src/min_spin.txt | 16 +++++++--------- examples/SPIN/spinmin/in.spinmin.bfo | 2 +- examples/SPIN/spinmin/in.spinmin.iron | 2 +- src/SPIN/min_spin.cpp | 10 +++++----- src/SPIN/min_spin.h | 2 +- 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/doc/src/lammps.book b/doc/src/lammps.book index 6b220ed241..eb8aa16968 100644 --- a/doc/src/lammps.book +++ b/doc/src/lammps.book @@ -175,6 +175,7 @@ mass.html message.html min_modify.html min_style.html +min_spin.html minimize.html molecule.html neb.html diff --git a/doc/src/min_modify.txt b/doc/src/min_modify.txt index 525d6716d8..d342e8bf01 100644 --- a/doc/src/min_modify.txt +++ b/doc/src/min_modify.txt @@ -13,14 +13,14 @@ min_modify command :h3 min_modify keyword values ... :pre one or more keyword/value pairs may be listed :ulb,l -keyword = {dmax} or {line} or {alpha_damp} or {discret_factor} +keyword = {dmax} or {line} or {alpha_damp} or {discrete_factor} {dmax} value = max max = maximum distance for line search to move (distance units) {line} value = {backtrack} or {quadratic} or {forcezero} backtrack,quadratic,forcezero = style of linesearch to use {alpha_damp} value = damping damping = fictitious Gilbert damping for spin minimization (adim) - {discret_factor} value = factor + {discrete_factor} value = factor factor = discretization factor for adaptive spin timestep (adim) :pre :ule @@ -69,16 +69,16 @@ difference of two large values (energy before and energy after) and that difference may be smaller than machine epsilon even if atoms could move in the gradient direction to reduce forces further. -Keywords {alpha_damp} and {discret_factor} only make sense when +Keywords {alpha_damp} and {discrete_factor} only make sense when a "min_spin"_min_spin.html command is declared. Keyword {alpha_damp} defines an analog of a magnetic Gilbert damping. It defines a relaxation rate toward an equilibrium for a given magnetic system. -Keyword {discret_factor} defines a discretization factor for the +Keyword {discrete_factor} defines a discretization factor for the adaptive timestep used in the {spin} minimization. See "min_spin"_min_spin.html for more information about those quantities. -Default values are alpha_damp = 1.0 and discret_factor = 10.0. +Default values are {alpha_damp} = 1.0 and {discrete_factor} = 10.0. [Restrictions:] none diff --git a/doc/src/min_spin.txt b/doc/src/min_spin.txt index de25100102..890e324aca 100644 --- a/doc/src/min_spin.txt +++ b/doc/src/min_spin.txt @@ -3,7 +3,6 @@ :link(lws,http://lammps.sandia.gov) :link(ld,Manual.html) :link(lc,Commands_all.html) - :line min_style spin command :h3 @@ -14,8 +13,7 @@ min_style spin :pre [Examples:] -min_style spin -min_modify alpha_damp 1.0 discret_factor 10.0 :pre +min_style spin :pre [Description:] @@ -33,19 +31,19 @@ Lambda can be defined by setting the {alpha_damp} keyword with the "min_modify"_min_modify.html command. The minimization procedure solves this equation using an -adaptive timestep. The value of this timestep is conditionned +adaptive timestep. The value of this timestep is defined by the largest precession frequency that has to be solved in the system: :c,image(Eqs/min_spin_timestep.jpg) -with |omega|_{max} the norm of the largest precession frequency +with {|omega|_{max}} the norm of the largest precession frequency in the system (across all processes, and across all replicas if a spin/neb calculation is performed). -Kappa defines a discretization factor {discret_factor} for the +Kappa defines a discretization factor {discrete_factor} for the definition of this timestep. -{discret_factor} can be defined with the "min_modify"_min_modify.html +{discrete_factor} can be defined with the "min_modify"_min_modify.html command. NOTE: The {spin} style replaces the force tolerance by a torque @@ -54,7 +52,7 @@ tolerance. See "minimize"_minimize.html for more explanation. [Restrictions:] This minimization procedure is only applied to spin degrees of -fredom for a frozen lattice configuration. +freedom for a frozen lattice configuration. [Related commands:] @@ -63,5 +61,5 @@ fredom for a frozen lattice configuration. [Default:] -The option defaults are alpha_damp = 1.0 and discret_factor = +The option defaults are {alpha_damp} = 1.0 and {discrete_factor} = 10.0. diff --git a/examples/SPIN/spinmin/in.spinmin.bfo b/examples/SPIN/spinmin/in.spinmin.bfo index 95a1a0f29f..5ebc9e0afe 100644 --- a/examples/SPIN/spinmin/in.spinmin.bfo +++ b/examples/SPIN/spinmin/in.spinmin.bfo @@ -51,5 +51,5 @@ compute outsp all property/atom spx spy spz sp fmx fmy fmz dump 1 all custom 50 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7] min_style spin -min_modify alpha_damp 1.0 discret_factor 10.0 +min_modify alpha_damp 1.0 discrete_factor 10.0 minimize 1.0e-10 0.0 1000 100 diff --git a/examples/SPIN/spinmin/in.spinmin.iron b/examples/SPIN/spinmin/in.spinmin.iron index 1f84d4fc9b..ebbd229b89 100644 --- a/examples/SPIN/spinmin/in.spinmin.iron +++ b/examples/SPIN/spinmin/in.spinmin.iron @@ -51,5 +51,5 @@ compute outsp all property/atom spx spy spz sp fmx fmy fmz dump 1 all custom 100 dump.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] c_outsp[4] c_outsp[5] c_outsp[6] c_outsp[7] min_style spin -min_modify alpha_damp 1.0 discret_factor 10.0 +min_modify alpha_damp 1.0 discrete_factor 10.0 minimize 1.0e-10 1.0e-10 100000 1000 diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index 61a61cd6bf..97aebdd25c 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -51,7 +51,7 @@ MinSpin::MinSpin(LAMMPS *lmp) : Min(lmp) {} void MinSpin::init() { alpha_damp = 1.0; - discret_factor = 10.0; + discrete_factor = 10.0; Min::init(); @@ -84,9 +84,9 @@ int MinSpin::modify_param(int narg, char **arg) alpha_damp = force->numeric(FLERR,arg[1]); return 2; } - if (strcmp(arg[0],"discret_factor") == 0) { + if (strcmp(arg[0],"discrete_factor") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); - discret_factor = force->numeric(FLERR,arg[1]); + discrete_factor = force->numeric(FLERR,arg[1]); return 2; } return 0; @@ -229,9 +229,9 @@ double MinSpin::evaluate_dt() error->all(FLERR,"Incorrect fmaxsqall calculation"); // define max timestep by dividing by the - // inverse of max frequency by discret_factor + // inverse of max frequency by discrete_factor - dtmax = MY_2PI/(discret_factor*sqrt(fmaxsqall)); + dtmax = MY_2PI/(discrete_factor*sqrt(fmaxsqall)); return dtmax; } diff --git a/src/SPIN/min_spin.h b/src/SPIN/min_spin.h index 569bcbaab2..224d205000 100644 --- a/src/SPIN/min_spin.h +++ b/src/SPIN/min_spin.h @@ -45,7 +45,7 @@ class MinSpin : public Min { double dts; double alpha_damp; // damping for spin minimization - double discret_factor; // factor for spin timestep evaluation + double discrete_factor; // factor for spin timestep evaluation double *spvec; // variables for atomic dof, as 1d vector double *fmvec; // variables for atomic dof, as 1d vector From 36b645d2384da4c4da855c26f3805d033aa04964 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 20:46:42 -0400 Subject: [PATCH 45/49] add min_spin page to toclist --- doc/src/commands_list.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/commands_list.txt b/doc/src/commands_list.txt index 61221b26d8..6f90d9c93a 100644 --- a/doc/src/commands_list.txt +++ b/doc/src/commands_list.txt @@ -62,6 +62,7 @@ Commands :h1 mass message min_modify + min_spin min_style minimize molecule From 7b3f95299002b2e0800a66e92fff8625af6318c5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 20:47:17 -0400 Subject: [PATCH 46/49] whitespace cleanup and dead code removal --- src/SPIN/compute_spin.cpp | 16 +++---- src/SPIN/fix_langevin_spin.cpp | 6 +-- src/SPIN/fix_nve_spin.cpp | 82 ++++++++++++++++---------------- src/SPIN/fix_precession_spin.cpp | 2 +- src/SPIN/min_spin.cpp | 69 +++++++++++++-------------- src/SPIN/pair_spin_dmi.cpp | 48 +++++++++---------- src/SPIN/pair_spin_exchange.cpp | 42 ++++++++-------- src/SPIN/pair_spin_magelec.cpp | 28 +++++------ src/SPIN/pair_spin_neel.cpp | 12 ++--- 9 files changed, 150 insertions(+), 155 deletions(-) diff --git a/src/SPIN/compute_spin.cpp b/src/SPIN/compute_spin.cpp index dc16190c98..0a881e1de6 100644 --- a/src/SPIN/compute_spin.cpp +++ b/src/SPIN/compute_spin.cpp @@ -84,7 +84,7 @@ void ComputeSpin::compute_vector() invoked_vector = update->ntimestep; - countsp = countsptot = 0.0; + countsp = countsptot = 0.0; mag[0] = mag[1] = mag[2] = mag[3] = 0.0; magtot[0] = magtot[1] = magtot[2] = magtot[3] = 0.0; magenergy = magenergytot = 0.0; @@ -96,7 +96,7 @@ void ComputeSpin::compute_vector() double **sp = atom->sp; double **fm = atom->fm; double tx,ty,tz; - + int nlocal = atom->nlocal; // compute total magnetization and magnetic energy @@ -105,16 +105,16 @@ void ComputeSpin::compute_vector() for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (atom->sp_flag) { - mag[0] += sp[i][0]; - mag[1] += sp[i][1]; - mag[2] += sp[i][2]; - magenergy -= (sp[i][0]*fm[i][0] + sp[i][1]*fm[i][1] + sp[i][2]*fm[i][2]); + mag[0] += sp[i][0]; + mag[1] += sp[i][1]; + mag[2] += sp[i][2]; + magenergy -= (sp[i][0]*fm[i][0] + sp[i][1]*fm[i][1] + sp[i][2]*fm[i][2]); tx = sp[i][1]*fm[i][2]-sp[i][2]*fm[i][1]; ty = sp[i][2]*fm[i][0]-sp[i][0]*fm[i][2]; tz = sp[i][0]*fm[i][1]-sp[i][1]*fm[i][0]; tempnum += tx*tx+ty*ty+tz*tz; - tempdenom += sp[i][0]*fm[i][0]+fm[i][1]*sp[i][1]+sp[i][2]*fm[i][2]; - countsp++; + tempdenom += sp[i][0]*fm[i][0]+fm[i][1]*sp[i][1]+sp[i][2]*fm[i][2]; + countsp++; } } else error->all(FLERR,"Compute compute/spin requires atom/spin style"); diff --git a/src/SPIN/fix_langevin_spin.cpp b/src/SPIN/fix_langevin_spin.cpp index 55b4d8dfec..ec6f719a77 100644 --- a/src/SPIN/fix_langevin_spin.cpp +++ b/src/SPIN/fix_langevin_spin.cpp @@ -131,8 +131,8 @@ void FixLangevinSpin::init() gil_factor = 1.0/(1.0+(alpha_t)*(alpha_t)); dts = update->dt; - double hbar = force->hplanck/MY_2PI; // eV/(rad.THz) - double kb = force->boltz; // eV/K + double hbar = force->hplanck/MY_2PI; // eV/(rad.THz) + double kb = force->boltz; // eV/K D = (MY_2PI*alpha_t*gil_factor*kb*temp); D /= (hbar*dts); sigma = sqrt(2.0*D); @@ -158,7 +158,7 @@ void FixLangevinSpin::add_tdamping(double spi[3], double fmi[3]) double cpx = fmi[1]*spi[2] - fmi[2]*spi[1]; double cpy = fmi[2]*spi[0] - fmi[0]*spi[2]; double cpz = fmi[0]*spi[1] - fmi[1]*spi[0]; - + // adding the transverse damping fmi[0] -= alpha_t*cpx; diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 7d96aca6d4..8d549ed64a 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -183,7 +183,7 @@ void FixNVESpin::init() npairs = pair->instance_total; for (int i = 0; ipair_match("spin",0,i)) { - npairspin ++; + npairspin ++; } } } @@ -203,8 +203,8 @@ void FixNVESpin::init() } else if (npairspin > 1) { for (int i = 0; ipair_match("spin",0,i)) { - spin_pairs[count] = (PairSpin *) force->pair_match("spin",0,i); - count++; + spin_pairs[count] = (PairSpin *) force->pair_match("spin",0,i); + count++; } } } @@ -264,8 +264,8 @@ void FixNVESpin::init() void FixNVESpin::initial_integrate(int /*vflag*/) { double dtfm; - - double **x = atom->x; + + double **x = atom->x; double **v = atom->v; double **f = atom->f; double *rmass = atom->rmass; @@ -291,32 +291,32 @@ void FixNVESpin::initial_integrate(int /*vflag*/) // update half s for all atoms - if (sector_flag) { // sectoring seq. update - for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal + if (sector_flag) { // sectoring seq. update + for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal comm->forward_comm(); int i = stack_foot[j]; while (i >= 0) { ComputeInteractionsSpin(i); - AdvanceSingleSpin(i); - i = forward_stacks[i]; + AdvanceSingleSpin(i); + i = forward_stacks[i]; } } - for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal + for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal comm->forward_comm(); int i = stack_head[j]; while (i >= 0) { ComputeInteractionsSpin(i); - AdvanceSingleSpin(i); - i = backward_stacks[i]; + AdvanceSingleSpin(i); + i = backward_stacks[i]; } } - } else if (sector_flag == 0) { // serial seq. update - comm->forward_comm(); // comm. positions of ghost atoms - for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal + } else if (sector_flag == 0) { // serial seq. update + comm->forward_comm(); // comm. positions of ghost atoms + for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } - for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal + for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } @@ -336,32 +336,32 @@ void FixNVESpin::initial_integrate(int /*vflag*/) // update half s for all particles - if (sector_flag) { // sectoring seq. update - for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal + if (sector_flag) { // sectoring seq. update + for (int j = 0; j < nsectors; j++) { // advance quarter s for nlocal comm->forward_comm(); int i = stack_foot[j]; while (i >= 0) { ComputeInteractionsSpin(i); - AdvanceSingleSpin(i); - i = forward_stacks[i]; + AdvanceSingleSpin(i); + i = forward_stacks[i]; } } - for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal + for (int j = nsectors-1; j >= 0; j--) { // advance quarter s for nlocal comm->forward_comm(); int i = stack_head[j]; while (i >= 0) { ComputeInteractionsSpin(i); - AdvanceSingleSpin(i); - i = backward_stacks[i]; + AdvanceSingleSpin(i); + i = backward_stacks[i]; } } - } else if (sector_flag == 0) { // serial seq. update - comm->forward_comm(); // comm. positions of ghost atoms - for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal-1 + } else if (sector_flag == 0) { // serial seq. update + comm->forward_comm(); // comm. positions of ghost atoms + for (int i = 0; i < nlocal; i++){ // advance quarter s for nlocal-1 ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } - for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal-1 + for (int i = nlocal-1; i >= 0; i--){ // advance quarter s for nlocal-1 ComputeInteractionsSpin(i); AdvanceSingleSpin(i); } @@ -384,10 +384,10 @@ void FixNVESpin::setup_pre_neighbor() void FixNVESpin::pre_neighbor() { - double **x = atom->x; + double **x = atom->x; int nlocal = atom->nlocal; - if (nlocal_max < nlocal) { // grow linked lists if necessary + if (nlocal_max < nlocal) { // grow linked lists if necessary nlocal_max = nlocal; backward_stacks = memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); forward_stacks = memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); @@ -399,7 +399,7 @@ void FixNVESpin::pre_neighbor() } int nseci; - for (int j = 0; j < nsectors; j++) { // stacking backward order + for (int j = 0; j < nsectors; j++) { // stacking backward order for (int i = 0; i < nlocal; i++) { nseci = coords2sector(x[i]); if (j != nseci) continue; @@ -407,7 +407,7 @@ void FixNVESpin::pre_neighbor() stack_head[j] = i; } } - for (int j = nsectors-1; j >= 0; j--) { // stacking forward order + for (int j = nsectors-1; j >= 0; j--) { // stacking forward order for (int i = nlocal-1; i >= 0; i--) { nseci = coords2sector(x[i]); if (j != nseci) continue; @@ -453,11 +453,11 @@ void FixNVESpin::ComputeInteractionsSpin(int i) // update langevin damping and random force - if (maglangevin_flag) { // mag. langevin - if (tdamp_flag) { // transverse damping + if (maglangevin_flag) { // mag. langevin + if (tdamp_flag) { // transverse damping locklangevinspin->add_tdamping(spi,fmi); } - if (temp_flag) { // spin temperature + if (temp_flag) { // spin temperature locklangevinspin->add_temperature(fmi); } } @@ -567,7 +567,7 @@ void FixNVESpin::AdvanceSingleSpin(int i) g[0] = g[1] = g[2] = 0.0; fm2 = (fm[i][0]*fm[i][0])+(fm[i][1]*fm[i][1])+(fm[i][2]*fm[i][2]); energy = (sp[i][0]*fm[i][0])+(sp[i][1]*fm[i][1])+(sp[i][2]*fm[i][2]); - dts2 = dts*dts; + dts2 = dts*dts; cp[0] = fm[i][1]*sp[i][2]-fm[i][2]*sp[i][1]; cp[1] = fm[i][2]*sp[i][0]-fm[i][0]*sp[i][2]; @@ -576,18 +576,18 @@ void FixNVESpin::AdvanceSingleSpin(int i) g[0] = sp[i][0]+cp[0]*dts; g[1] = sp[i][1]+cp[1]*dts; g[2] = sp[i][2]+cp[2]*dts; - + g[0] += (fm[i][0]*energy-0.5*sp[i][0]*fm2)*0.5*dts2; g[1] += (fm[i][1]*energy-0.5*sp[i][1]*fm2)*0.5*dts2; g[2] += (fm[i][2]*energy-0.5*sp[i][2]*fm2)*0.5*dts2; - + g[0] /= (1+0.25*fm2*dts2); g[1] /= (1+0.25*fm2*dts2); g[2] /= (1+0.25*fm2*dts2); - + sp[i][0] = g[0]; sp[i][1] = g[1]; - sp[i][2] = g[2]; + sp[i][2] = g[2]; // renormalization (check if necessary) @@ -616,9 +616,9 @@ void FixNVESpin::AdvanceSingleSpin(int i) /* ---------------------------------------------------------------------- */ void FixNVESpin::final_integrate() -{ +{ double dtfm; - + double **v = atom->v; double **f = atom->f; double *rmass = atom->rmass; diff --git a/src/SPIN/fix_precession_spin.cpp b/src/SPIN/fix_precession_spin.cpp index d065f38d16..9ee691c227 100644 --- a/src/SPIN/fix_precession_spin.cpp +++ b/src/SPIN/fix_precession_spin.cpp @@ -177,7 +177,7 @@ void FixPrecessionSpin::min_setup(int vflag) /* ---------------------------------------------------------------------- */ -void FixPrecessionSpin::post_force(int vflag) +void FixPrecessionSpin::post_force(int /* vflag */) { // update mag field with time (potential improvement) diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index 97aebdd25c..2bddc110e7 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -19,6 +19,8 @@ #include #include +#include +#include #include "min_spin.h" #include "universe.h" #include "atom.h" @@ -27,8 +29,6 @@ #include "output.h" #include "timer.h" #include "error.h" -#include -#include #include "modify.h" #include "math_special.h" #include "math_const.h" @@ -104,10 +104,10 @@ void MinSpin::reset_vectors() // size sp is 4N vector nvec = 4 * atom->nlocal; if (nvec) spvec = atom->sp[0]; - + nvec = 3 * atom->nlocal; if (nvec) fmvec = atom->fm[0]; - + if (nvec) xvec = atom->x[0]; if (nvec) fvec = atom->f[0]; } @@ -119,7 +119,7 @@ void MinSpin::reset_vectors() int MinSpin::iterate(int maxiter) { bigint ntimestep; - double fmdotfm,fmdotfmall; + double fmdotfm; int flag,flagall; for (int iter = 0; iter < maxiter; iter++) { @@ -132,12 +132,12 @@ int MinSpin::iterate(int maxiter) // optimize timestep accross processes / replicas // need a force calculation for timestep optimization - + energy_force(0); dts = evaluate_dt(); - + // apply damped precessional dynamics to the spins - + advance_spins(dts); eprevious = ecurrent; @@ -200,11 +200,10 @@ double MinSpin::evaluate_dt() double fmsq; double fmaxsqone,fmaxsqloc,fmaxsqall; int nlocal = atom->nlocal; - int *mask = atom->mask; double **fm = atom->fm; - // finding max fm on this proc. - + // finding max fm on this proc. + fmsq = fmaxsqone = fmaxsqloc = fmaxsqall = 0.0; for (int i = 0; i < nlocal; i++) { fmsq = fm[i][0]*fm[i][0]+fm[i][1]*fm[i][1]+fm[i][2]*fm[i][2]; @@ -212,10 +211,10 @@ double MinSpin::evaluate_dt() } // finding max fm on this replica - - fmaxsqloc = fmaxsqone; - MPI_Allreduce(&fmaxsqone,&fmaxsqloc,1,MPI_DOUBLE,MPI_MAX,world); - + + fmaxsqloc = fmaxsqone; + MPI_Allreduce(&fmaxsqone,&fmaxsqloc,1,MPI_DOUBLE,MPI_MAX,world); + // finding max fm over all replicas, if necessary // this communicator would be invalid for multiprocess replicas @@ -228,7 +227,7 @@ double MinSpin::evaluate_dt() if (fmaxsqall == 0.0) error->all(FLERR,"Incorrect fmaxsqall calculation"); - // define max timestep by dividing by the + // define max timestep by dividing by the // inverse of max frequency by discrete_factor dtmax = MY_2PI/(discrete_factor*sqrt(fmaxsqall)); @@ -243,58 +242,57 @@ double MinSpin::evaluate_dt() void MinSpin::advance_spins(double dts) { int nlocal = atom->nlocal; - int *mask = atom->mask; double **sp = atom->sp; double **fm = atom->fm; double tdampx,tdampy,tdampz; double msq,scale,fm2,energy,dts2; double cp[3],g[3]; - dts2 = dts*dts; + dts2 = dts*dts; // loop on all spins on proc. for (int i = 0; i < nlocal; i++) { - + // calc. damping torque - + tdampx = -alpha_damp*(fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1]); tdampy = -alpha_damp*(fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2]); tdampz = -alpha_damp*(fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0]); - + // apply advance algorithm (geometric, norm preserving) - + fm2 = (tdampx*tdampx+tdampy*tdampy+tdampz*tdampz); energy = (sp[i][0]*tdampx)+(sp[i][1]*tdampy)+(sp[i][2]*tdampz); - + cp[0] = tdampy*sp[i][2]-tdampz*sp[i][1]; cp[1] = tdampz*sp[i][0]-tdampx*sp[i][2]; cp[2] = tdampx*sp[i][1]-tdampy*sp[i][0]; - + g[0] = sp[i][0]+cp[0]*dts; g[1] = sp[i][1]+cp[1]*dts; g[2] = sp[i][2]+cp[2]*dts; - + g[0] += (tdampx*energy-0.5*sp[i][0]*fm2)*0.5*dts2; g[1] += (tdampy*energy-0.5*sp[i][1]*fm2)*0.5*dts2; g[2] += (tdampz*energy-0.5*sp[i][2]*fm2)*0.5*dts2; - + g[0] /= (1+0.25*fm2*dts2); g[1] /= (1+0.25*fm2*dts2); g[2] /= (1+0.25*fm2*dts2); sp[i][0] = g[0]; sp[i][1] = g[1]; - sp[i][2] = g[2]; - + sp[i][2] = g[2]; + // renormalization (check if necessary) - + msq = g[0]*g[0] + g[1]*g[1] + g[2]*g[2]; scale = 1.0/sqrt(msq); sp[i][0] *= scale; sp[i][1] *= scale; sp[i][2] *= scale; - + // no comm. to atoms with same tag // because no need for simplecticity } @@ -306,16 +304,13 @@ void MinSpin::advance_spins(double dts) double MinSpin::fmnorm_sqr() { - int i,n; - double *fmatom; - int nlocal = atom->nlocal; double tx,ty,tz; double **sp = atom->sp; double **fm = atom->fm; // calc. magnetic torques - + double local_norm2_sqr = 0.0; for (int i = 0; i < nlocal; i++) { tx = (fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1]); @@ -324,11 +319,11 @@ double MinSpin::fmnorm_sqr() local_norm2_sqr += tx*tx + ty*ty + tz*tz; } - - // no extra atom calc. for spins + + // no extra atom calc. for spins if (nextra_atom) - error->all(FLERR,"extra atom option not available yet"); + error->all(FLERR,"extra atom option not available yet"); double norm2_sqr = 0.0; MPI_Allreduce(&local_norm2_sqr,&norm2_sqr,1,MPI_DOUBLE,MPI_SUM,world); diff --git a/src/SPIN/pair_spin_dmi.cpp b/src/SPIN/pair_spin_dmi.cpp index e9e6691a88..d26f5e917e 100644 --- a/src/SPIN/pair_spin_dmi.cpp +++ b/src/SPIN/pair_spin_dmi.cpp @@ -238,7 +238,7 @@ void PairSpinDmi::compute(int eflag, int vflag) double **x = atom->x; double **f = atom->f; double **fm = atom->fm; - double **sp = atom->sp; + double **sp = atom->sp; int *type = atom->type; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; @@ -295,32 +295,32 @@ void PairSpinDmi::compute(int eflag, int vflag) // compute dmi interaction if (rsq <= local_cut2) { - compute_dmi(i,j,eij,fmi,spj); - if (lattice_flag) { - compute_dmi_mech(i,j,rsq,eij,fi,spi,spj); - } + compute_dmi(i,j,eij,fmi,spj); + if (lattice_flag) { + compute_dmi_mech(i,j,rsq,eij,fi,spi,spj); + } } - f[i][0] += fi[0]; - f[i][1] += fi[1]; + f[i][0] += fi[0]; + f[i][1] += fi[1]; f[i][2] += fi[2]; - fm[i][0] += fmi[0]; - fm[i][1] += fmi[1]; + fm[i][0] += fmi[0]; + fm[i][1] += fmi[1]; fm[i][2] += fmi[2]; if (newton_pair || j < nlocal) { - f[j][0] -= fi[0]; - f[j][1] -= fi[1]; + f[j][0] -= fi[0]; + f[j][1] -= fi[1]; f[j][2] -= fi[2]; } if (eflag) { - evdwl -= (spi[0]*fmi[0] + spi[1]*fmi[1] + spi[2]*fmi[2]); - evdwl *= hbar; + evdwl -= (spi[0]*fmi[0] + spi[1]*fmi[1] + spi[2]*fmi[2]); + evdwl *= hbar; } else evdwl = 0.0; if (evflag) ev_tally_xyz(i,j,nlocal,newton_pair, - evdwl,ecoul,fi[0],fi[1],fi[2],delx,dely,delz); + evdwl,ecoul,fi[0],fi[1],fi[2],delx,dely,delz); } } @@ -342,7 +342,7 @@ void PairSpinDmi::compute_single_pair(int ii, double fmi[3]) double delx,dely,delz; double spj[3]; - int i,j,jnum,itype,jtype,ntypes; + int j,jnum,itype,jtype,ntypes; int k,locflag; int *jlist,*numneigh,**firstneigh; @@ -350,7 +350,7 @@ void PairSpinDmi::compute_single_pair(int ii, double fmi[3]) numneigh = list->numneigh; firstneigh = list->firstneigh; - + // check if interaction applies to type of ii itype = type[ii]; @@ -360,20 +360,20 @@ void PairSpinDmi::compute_single_pair(int ii, double fmi[3]) while (k <= ntypes) { if (k <= itype) { if (setflag[k][itype] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else if (k > itype) { if (setflag[itype][k] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else error->all(FLERR,"Wrong type number"); } - // if interaction applies to type ii, + // if interaction applies to type ii, // locflag = 1 and compute pair interaction //i = ilist[ii]; @@ -422,7 +422,7 @@ void PairSpinDmi::compute_dmi(int i, int j, double eij[3], double fmi[3], double { int *type = atom->type; int itype, jtype; - double dmix, dmiy, dmiz; + double dmix, dmiy, dmiz; itype = type[i]; jtype = type[j]; @@ -444,7 +444,7 @@ void PairSpinDmi::compute_dmi_mech(int i, int j, double rsq, double /*eij*/[3], { int *type = atom->type; int itype, jtype; - double dmix,dmiy,dmiz; + double dmix,dmiy,dmiz; itype = type[i]; jtype = type[j]; double csx,csy,csz,cdmx,cdmy,cdmz,irij; @@ -509,7 +509,7 @@ void PairSpinDmi::write_restart(FILE *fp) for (j = i; j <= atom->ntypes; j++) { fwrite(&setflag[i][j],sizeof(int),1,fp); if (setflag[i][j]) { - fwrite(&DM[i][j],sizeof(double),1,fp); + fwrite(&DM[i][j],sizeof(double),1,fp); fwrite(&v_dmx[i][j],sizeof(double),1,fp); fwrite(&v_dmy[i][j],sizeof(double),1,fp); fwrite(&v_dmz[i][j],sizeof(double),1,fp); diff --git a/src/SPIN/pair_spin_exchange.cpp b/src/SPIN/pair_spin_exchange.cpp index aecbbeb97d..7edd6cec0c 100644 --- a/src/SPIN/pair_spin_exchange.cpp +++ b/src/SPIN/pair_spin_exchange.cpp @@ -223,7 +223,7 @@ void PairSpinExchange::compute(int eflag, int vflag) double **x = atom->x; double **f = atom->f; double **fm = atom->fm; - double **sp = atom->sp; + double **sp = atom->sp; int *type = atom->type; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; @@ -278,32 +278,32 @@ void PairSpinExchange::compute(int eflag, int vflag) // compute exchange interaction if (rsq <= local_cut2) { - compute_exchange(i,j,rsq,fmi,spj); + compute_exchange(i,j,rsq,fmi,spj); if (lattice_flag) { - compute_exchange_mech(i,j,rsq,eij,fi,spi,spj); - } + compute_exchange_mech(i,j,rsq,eij,fi,spi,spj); + } } - f[i][0] += fi[0]; - f[i][1] += fi[1]; + f[i][0] += fi[0]; + f[i][1] += fi[1]; f[i][2] += fi[2]; - fm[i][0] += fmi[0]; - fm[i][1] += fmi[1]; + fm[i][0] += fmi[0]; + fm[i][1] += fmi[1]; fm[i][2] += fmi[2]; if (newton_pair || j < nlocal) { - f[j][0] -= fi[0]; - f[j][1] -= fi[1]; + f[j][0] -= fi[0]; + f[j][1] -= fi[1]; f[j][2] -= fi[2]; } if (eflag) { - evdwl -= (spi[0]*fmi[0] + spi[1]*fmi[1] + spi[2]*fmi[2]); - evdwl *= hbar; + evdwl -= (spi[0]*fmi[0] + spi[1]*fmi[1] + spi[2]*fmi[2]); + evdwl *= hbar; } else evdwl = 0.0; if (evflag) ev_tally_xyz(i,j,nlocal,newton_pair, - evdwl,ecoul,fi[0],fi[1],fi[2],delx,dely,delz); + evdwl,ecoul,fi[0],fi[1],fi[2],delx,dely,delz); } } @@ -325,7 +325,7 @@ void PairSpinExchange::compute_single_pair(int ii, double fmi[3]) double delx,dely,delz; double spj[3]; - int i,j,jnum,itype,jtype,ntypes; + int j,jnum,itype,jtype,ntypes; int k,locflag; int *jlist,*numneigh,**firstneigh; @@ -343,24 +343,24 @@ void PairSpinExchange::compute_single_pair(int ii, double fmi[3]) while (k <= ntypes) { if (k <= itype) { if (setflag[k][itype] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else if (k > itype) { if (setflag[itype][k] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else error->all(FLERR,"Wrong type number"); } - // if interaction applies to type ii, + // if interaction applies to type ii, // locflag = 1 and compute pair interaction if (locflag == 1) { - + xi[0] = x[ii][0]; xi[1] = x[ii][1]; xi[2] = x[ii][2]; @@ -388,7 +388,7 @@ void PairSpinExchange::compute_single_pair(int ii, double fmi[3]) compute_exchange(ii,j,rsq,fmi,spj); } } - } + } } /* ---------------------------------------------------------------------- diff --git a/src/SPIN/pair_spin_magelec.cpp b/src/SPIN/pair_spin_magelec.cpp index be1cbcd6c4..5c0abe894d 100644 --- a/src/SPIN/pair_spin_magelec.cpp +++ b/src/SPIN/pair_spin_magelec.cpp @@ -332,7 +332,7 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3]) double delx,dely,delz; double spj[3]; - int i,j,jnum,itype,jtype,ntypes; + int j,jnum,itype,jtype,ntypes; int k,locflag; int *jlist,*numneigh,**firstneigh; @@ -340,7 +340,7 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3]) numneigh = list->numneigh; firstneigh = list->firstneigh; - + // check if interaction applies to type of ii itype = type[ii]; @@ -350,42 +350,42 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3]) while (k <= ntypes) { if (k <= itype) { if (setflag[k][itype] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else if (k > itype) { if (setflag[itype][k] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else error->all(FLERR,"Wrong type number"); } - // if interaction applies to type ii, + // if interaction applies to type ii, // locflag = 1 and compute pair interaction if (locflag == 1) { - + xi[0] = x[ii][0]; xi[1] = x[ii][1]; xi[2] = x[ii][2]; - + jlist = firstneigh[ii]; jnum = numneigh[ii]; - + for (int jj = 0; jj < jnum; jj++) { - + j = jlist[jj]; j &= NEIGHMASK; jtype = type[j]; local_cut2 = cut_spin_magelec[itype][jtype]*cut_spin_magelec[itype][jtype]; - + spj[0] = sp[j][0]; spj[1] = sp[j][1]; spj[2] = sp[j][2]; - + delx = xi[0] - x[j][0]; dely = xi[1] - x[j][1]; delz = xi[2] - x[j][2]; @@ -394,7 +394,7 @@ void PairSpinMagelec::compute_single_pair(int ii, double fmi[3]) eij[0] = -inorm*delx; eij[1] = -inorm*dely; eij[2] = -inorm*delz; - + if (rsq <= local_cut2) { compute_magelec(ii,j,eij,fmi,spj); } diff --git a/src/SPIN/pair_spin_neel.cpp b/src/SPIN/pair_spin_neel.cpp index 58173892d9..1eea62d02c 100644 --- a/src/SPIN/pair_spin_neel.cpp +++ b/src/SPIN/pair_spin_neel.cpp @@ -351,7 +351,7 @@ void PairSpinNeel::compute_single_pair(int ii, double fmi[3]) numneigh = list->numneigh; firstneigh = list->firstneigh; - + // check if interaction applies to type of ii itype = type[ii]; @@ -361,20 +361,20 @@ void PairSpinNeel::compute_single_pair(int ii, double fmi[3]) while (k <= ntypes) { if (k <= itype) { if (setflag[k][itype] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else if (k > itype) { if (setflag[itype][k] == 1) { - locflag =1; - break; + locflag =1; + break; } k++; } else error->all(FLERR,"Wrong type number"); } - // if interaction applies to type ii, + // if interaction applies to type ii, // locflag = 1 and compute pair interaction if (locflag == 1) { From 82d646cede4ffa447de256b5ec77754d3e4ff711 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 20:58:13 -0400 Subject: [PATCH 47/49] print warning about missing fix nve/spin only on MPI rank 0 --- src/SPIN/pair_spin_dmi.cpp | 2 +- src/SPIN/pair_spin_exchange.cpp | 2 +- src/SPIN/pair_spin_magelec.cpp | 2 +- src/SPIN/pair_spin_neel.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SPIN/pair_spin_dmi.cpp b/src/SPIN/pair_spin_dmi.cpp index d26f5e917e..d0506e972d 100644 --- a/src/SPIN/pair_spin_dmi.cpp +++ b/src/SPIN/pair_spin_dmi.cpp @@ -173,7 +173,7 @@ void PairSpinDmi::init_style() if (strcmp(modify->fix[ifix]->style,"nve/spin") == 0) break; ifix++; } - if (ifix == modify->nfix) + if ((ifix == modify->nfix) && (comm->me == 0)) error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin diff --git a/src/SPIN/pair_spin_exchange.cpp b/src/SPIN/pair_spin_exchange.cpp index 7edd6cec0c..cb3242c711 100644 --- a/src/SPIN/pair_spin_exchange.cpp +++ b/src/SPIN/pair_spin_exchange.cpp @@ -160,7 +160,7 @@ void PairSpinExchange::init_style() if (strcmp(modify->fix[ifix]->style,"nve/spin") == 0) break; ifix++; } - if (ifix == modify->nfix) + if ((ifix == modify->nfix) && (comm->me == 0)) error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin diff --git a/src/SPIN/pair_spin_magelec.cpp b/src/SPIN/pair_spin_magelec.cpp index 5c0abe894d..6ff003521d 100644 --- a/src/SPIN/pair_spin_magelec.cpp +++ b/src/SPIN/pair_spin_magelec.cpp @@ -166,7 +166,7 @@ void PairSpinMagelec::init_style() if (strcmp(modify->fix[ifix]->style,"nve/spin") == 0) break; ifix++; } - if (ifix == modify->nfix) + if ((ifix == modify->nfix) && (comm->me == 0)) error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin diff --git a/src/SPIN/pair_spin_neel.cpp b/src/SPIN/pair_spin_neel.cpp index 1eea62d02c..a39d6f3461 100644 --- a/src/SPIN/pair_spin_neel.cpp +++ b/src/SPIN/pair_spin_neel.cpp @@ -173,7 +173,7 @@ void PairSpinNeel::init_style() if (strcmp(modify->fix[ifix]->style,"nve/spin") == 0) break; ifix++; } - if (ifix == modify->nfix) + if ((ifix == modify->nfix) && (comm->me == 0)) error->warning(FLERR,"Using pair/spin style without nve/spin"); // get the lattice_flag from nve/spin @@ -343,7 +343,7 @@ void PairSpinNeel::compute_single_pair(int ii, double fmi[3]) double xi[3], rij[3], eij[3]; double spi[3], spj[3]; - int i,j,jnum,itype,jtype,ntypes; + int j,jnum,itype,jtype,ntypes; int k,locflag; int *jlist,*numneigh,**firstneigh; From 19d25203ade0e71f690db427f9ed720f3582c6de Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 21:05:13 -0400 Subject: [PATCH 48/49] add min_style spin to commands overview --- doc/src/Commands_all.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/Commands_all.txt b/doc/src/Commands_all.txt index ddb8e121cb..66c348ee30 100644 --- a/doc/src/Commands_all.txt +++ b/doc/src/Commands_all.txt @@ -79,6 +79,7 @@ An alphabetic list of all general LAMMPS commands. "minimize"_minimize.html, "min_modify"_min_modify.html, "min_style"_min_style.html, +"min_style spin"_min_spin.html, "molecule"_molecule.html, "ndx2group"_group2ndx.html, "neb"_neb.html, From d7a2949d1ab0237c20b1e0cf21d9dea2f0bf8b65 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Mar 2019 21:30:48 -0400 Subject: [PATCH 49/49] Revert "Rendezvous" --- src/RIGID/fix_rigid_small.cpp | 512 ++++++------ src/RIGID/fix_rigid_small.h | 26 +- src/RIGID/fix_shake.cpp | 804 ++++++------------- src/RIGID/fix_shake.h | 43 +- src/comm.cpp | 428 ---------- src/comm.h | 13 - src/create_atoms.cpp | 37 +- src/hashlittle.cpp | 349 -------- src/hashlittle.h | 5 - src/irregular.cpp | 203 +---- src/irregular.h | 2 - src/read_data.cpp | 15 - src/read_restart.cpp | 15 - src/replicate.cpp | 8 +- src/special.cpp | 1416 ++++++++++++++------------------- src/special.h | 38 +- 16 files changed, 1207 insertions(+), 2707 deletions(-) delete mode 100644 src/hashlittle.cpp delete mode 100644 src/hashlittle.h diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index d74dd0fc3b..fb185d7702 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -28,14 +28,12 @@ #include "modify.h" #include "group.h" #include "comm.h" -#include "neighbor.h" #include "force.h" #include "input.h" #include "output.h" #include "variable.h" #include "random_mars.h" #include "math_const.h" -#include "hashlittle.h" #include "memory.h" #include "error.h" @@ -45,8 +43,6 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all - #define MAXLINE 1024 #define CHUNK 1024 #define ATTRIBUTE_PERBODY 20 @@ -74,7 +70,8 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : xcmimage(NULL), displace(NULL), eflags(NULL), orient(NULL), dorient(NULL), avec_ellipsoid(NULL), avec_line(NULL), avec_tri(NULL), counts(NULL), itensor(NULL), mass_body(NULL), langextra(NULL), random(NULL), - id_dilate(NULL), onemols(NULL) + id_dilate(NULL), onemols(NULL), hash(NULL), bbox(NULL), ctr(NULL), + idclose(NULL), rsqclose(NULL) { int i; @@ -110,18 +107,18 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // parse args for rigid body specification int *mask = atom->mask; - tagint *bodyID = NULL; + tagint *bodyid = NULL; int nlocal = atom->nlocal; if (narg < 4) error->all(FLERR,"Illegal fix rigid/small command"); if (strcmp(arg[3],"molecule") == 0) { if (atom->molecule_flag == 0) error->all(FLERR,"Fix rigid/small requires atom attribute molecule"); - bodyID = atom->molecule; + bodyid = atom->molecule; } else if (strcmp(arg[3],"custom") == 0) { if (narg < 5) error->all(FLERR,"Illegal fix rigid/small command"); - bodyID = new tagint[nlocal]; + bodyid = new tagint[nlocal]; customflag = 1; // determine whether atom-style variable or atom property is used. @@ -129,11 +126,9 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : int is_double=0; int custom_index = atom->find_custom(arg[4]+2,is_double); if (custom_index == -1) - error->all(FLERR,"Fix rigid/small custom requires " - "previously defined property/atom"); + error->all(FLERR,"Fix rigid/small custom requires previously defined property/atom"); else if (is_double) - error->all(FLERR,"Fix rigid/small custom requires " - "integer-valued property/atom"); + error->all(FLERR,"Fix rigid/small custom requires integer-valued property/atom"); int minval = INT_MAX; int *value = atom->ivector[custom_index]; @@ -144,17 +139,15 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) - bodyID[i] = (tagint)(value[i] - minval + 1); - else bodyID[i] = 0; + bodyid[i] = (tagint)(value[i] - minval + 1); + else bodyid[i] = 0; } else if (strstr(arg[4],"v_") == arg[4]) { int ivariable = input->variable->find(arg[4]+2); if (ivariable < 0) - error->all(FLERR,"Variable name for fix rigid/small custom " - "does not exist"); + error->all(FLERR,"Variable name for fix rigid/small custom does not exist"); if (input->variable->atomstyle(ivariable) == 0) - error->all(FLERR,"Fix rigid/small custom variable is not " - "atom-style variable"); + error->all(FLERR,"Fix rigid/small custom variable is no atom-style variable"); double *value = new double[nlocal]; input->variable->compute_atom(ivariable,0,value,1,0); int minval = INT_MAX; @@ -165,8 +158,8 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) - bodyID[i] = (tagint)((tagint)value[i] - minval + 1); - else bodyID[0] = 0; + bodyid[i] = (tagint)((tagint)value[i] - minval + 1); + else bodyid[0] = 0; delete[] value; } else error->all(FLERR,"Unsupported fix rigid custom property"); } else error->all(FLERR,"Illegal fix rigid/small command"); @@ -174,11 +167,10 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : if (atom->map_style == 0) error->all(FLERR,"Fix rigid/small requires an atom map, see atom_modify"); - // maxmol = largest bodyID # - + // maxmol = largest bodyid # maxmol = -1; for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) maxmol = MAX(maxmol,bodyID[i]); + if (mask[i] & groupbit) maxmol = MAX(maxmol,bodyid[i]); tagint itmp; MPI_Allreduce(&maxmol,&itmp,1,MPI_LMP_TAGINT,MPI_MAX,world); @@ -408,19 +400,8 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : // sets bodytag for owned atoms // body attributes are computed later by setup_bodies() - double time1 = MPI_Wtime(); - - create_bodies(bodyID); - if (customflag) delete [] bodyID; - - double time2 = MPI_Wtime(); - - if (comm->me == 0) { - if (screen) - fprintf(screen," create bodies CPU = %g secs\n",time2-time1); - if (logfile) - fprintf(logfile," create bodies CPU = %g secs\n",time2-time1); - } + create_bodies(bodyid); + if (customflag) delete [] bodyid; // set nlocal_body and allocate bodies I own @@ -588,22 +569,12 @@ void FixRigidSmall::init() if (rflag && (modify->fmask[i] & POST_FORCE) && !modify->fix[i]->rigid_flag) { char str[128]; - snprintf(str,128,"Fix %s alters forces after fix rigid", - modify->fix[i]->id); + snprintf(str,128,"Fix %s alters forces after fix rigid",modify->fix[i]->id); error->warning(FLERR,str); } } } - // error if maxextent > comm->cutghost - // NOTE: could just warn if an override flag set - // NOTE: this could fail for comm multi mode if user sets a wrong cutoff - // for atom types in rigid bodies - need a more careful test - - double cutghost = MAX(neighbor->cutneighmax,comm->cutghostuser); - if (maxextent > cutghost) - error->all(FLERR,"Rigid body extent > ghost cutoff - use comm_modify cutoff"); - // error if npt,nph fix comes before rigid fix for (i = 0; i < modify->nfix; i++) { @@ -1543,72 +1514,175 @@ void FixRigidSmall::set_v() set bodytag for all owned atoms ------------------------------------------------------------------------- */ -void FixRigidSmall::create_bodies(tagint *bodyID) +void FixRigidSmall::create_bodies(tagint *bodyid) { - int i,m; + int i,m,n; + double unwrap[3]; - // allocate buffer for input to rendezvous comm - // ncount = # of my atoms in bodies - + // error check on image flags of atoms in rigid bodies + + imageint *image = atom->image; int *mask = atom->mask; int nlocal = atom->nlocal; + int *periodicity = domain->periodicity; + int xbox,ybox,zbox; + + int flag = 0; + for (i = 0; i < nlocal; i++) { + if (!(mask[i] & groupbit)) continue; + xbox = (image[i] & IMGMASK) - IMGMAX; + ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; + zbox = (image[i] >> IMG2BITS) - IMGMAX; + if ((xbox && !periodicity[0]) || (ybox && !periodicity[1]) || + (zbox && !periodicity[2])) flag = 1; + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall) error->all(FLERR,"Fix rigid/small atom has non-zero image flag " + "in a non-periodic dimension"); + + // allocate buffer for passing messages around ring of procs + // percount = max number of values to put in buffer for each of ncount + int ncount = 0; for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) ncount++; - int *proclist; - memory->create(proclist,ncount,"rigid/small:proclist"); - InRvous *inbuf = (InRvous *) - memory->smalloc(ncount*sizeof(InRvous),"rigid/small:inbuf"); + int percount = 5; + double *buf; + memory->create(buf,ncount*percount,"rigid/small:buf"); - // setup buf to pass to rendezvous comm - // one BodyMsg datum for each constituent atom - // datum = me, local index of atom, atomID, bodyID, unwrapped coords - // owning proc for each datum = random hash of bodyID + // create map hash for storing unique body IDs of my atoms + // key = body ID + // value = index into per-body data structure + // n = # of entries in hash + + hash = new std::map(); + hash->clear(); + + // setup hash + // key = body ID + // value = index into N-length data structure + // n = count of unique bodies my atoms are part of + + n = 0; + for (i = 0; i < nlocal; i++) { + if (!(mask[i] & groupbit)) continue; + if (hash->find(bodyid[i]) == hash->end()) (*hash)[bodyid[i]] = n++; + } + + // bbox = bounding box of each rigid body my atoms are part of + + memory->create(bbox,n,6,"rigid/small:bbox"); + + for (i = 0; i < n; i++) { + bbox[i][0] = bbox[i][2] = bbox[i][4] = BIG; + bbox[i][1] = bbox[i][3] = bbox[i][5] = -BIG; + } + + // pack my atoms into buffer as body ID, unwrapped coords double **x = atom->x; - tagint *tag = atom->tag; - imageint *image = atom->image; m = 0; for (i = 0; i < nlocal; i++) { if (!(mask[i] & groupbit)) continue; - proclist[m] = hashlittle(&bodyID[i],sizeof(tagint),0) % nprocs; - inbuf[m].me = me; - inbuf[m].ilocal = i; - inbuf[m].atomID = tag[i]; - inbuf[m].bodyID = bodyID[i]; - domain->unmap(x[i],image[i],inbuf[m].x); - m++; + domain->unmap(x[i],image[i],unwrap); + buf[m++] = bodyid[i]; + buf[m++] = unwrap[0]; + buf[m++] = unwrap[1]; + buf[m++] = unwrap[2]; } - // perform rendezvous operation - // each proc owns random subset of bodies - // receives all atoms in those bodies - // func = compute bbox of each body, find atom closest to geometric center + // pass buffer around ring of procs + // func = update bbox with atom coords from every proc + // when done, have full bbox for every rigid body my atoms are part of - char *buf; - int nreturn = comm->rendezvous(RVOUS,ncount,(char *) inbuf,sizeof(InRvous), - 0,proclist, - rendezvous_body,0,buf,sizeof(OutRvous), - (void *) this); - OutRvous *outbuf = (OutRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); + comm->ring(m,sizeof(double),buf,1,ring_bbox,NULL,(void *)this); - // set bodytag of all owned atoms based on outbuf info for constituent atoms + // check if any bbox is size 0.0, meaning rigid body is a single particle - for (i = 0; i < nlocal; i++) - if (!(mask[i] & groupbit)) bodytag[i] = 0; + flag = 0; + for (i = 0; i < n; i++) + if (bbox[i][0] == bbox[i][1] && bbox[i][2] == bbox[i][3] && + bbox[i][4] == bbox[i][5]) flag = 1; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall) + error->all(FLERR,"One or more rigid bodies are a single particle"); - for (m = 0; m < nreturn; m++) - bodytag[outbuf[m].ilocal] = outbuf[m].atomID; + // ctr = center pt of each rigid body my atoms are part of - memory->sfree(outbuf); + memory->create(ctr,n,6,"rigid/small:bbox"); - // maxextent = max of rsqfar across all procs + for (i = 0; i < n; i++) { + ctr[i][0] = 0.5 * (bbox[i][0] + bbox[i][1]); + ctr[i][1] = 0.5 * (bbox[i][2] + bbox[i][3]); + ctr[i][2] = 0.5 * (bbox[i][4] + bbox[i][5]); + } + + // idclose = ID of atom in body closest to center pt (smaller ID if tied) + // rsqclose = distance squared from idclose to center pt + + memory->create(idclose,n,"rigid/small:idclose"); + memory->create(rsqclose,n,"rigid/small:rsqclose"); + + for (i = 0; i < n; i++) rsqclose[i] = BIG; + + // pack my atoms into buffer as body ID, atom ID, unwrapped coords + + tagint *tag = atom->tag; + + m = 0; + for (i = 0; i < nlocal; i++) { + if (!(mask[i] & groupbit)) continue; + domain->unmap(x[i],image[i],unwrap); + buf[m++] = bodyid[i]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = unwrap[0]; + buf[m++] = unwrap[1]; + buf[m++] = unwrap[2]; + } + + // pass buffer around ring of procs + // func = update idclose,rsqclose with atom IDs from every proc + // when done, have idclose for every rigid body my atoms are part of + + comm->ring(m,sizeof(double),buf,2,ring_nearest,NULL,(void *)this); + + // set bodytag of all owned atoms, based on idclose + // find max value of rsqclose across all procs + + double rsqmax = 0.0; + for (i = 0; i < nlocal; i++) { + bodytag[i] = 0; + if (!(mask[i] & groupbit)) continue; + m = hash->find(bodyid[i])->second; + bodytag[i] = idclose[m]; + rsqmax = MAX(rsqmax,rsqclose[m]); + } + + // pack my atoms into buffer as bodytag of owning atom, unwrapped coords + + m = 0; + for (i = 0; i < nlocal; i++) { + if (!(mask[i] & groupbit)) continue; + domain->unmap(x[i],image[i],unwrap); + buf[m++] = ubuf(bodytag[i]).d; + buf[m++] = unwrap[0]; + buf[m++] = unwrap[1]; + buf[m++] = unwrap[2]; + } + + // pass buffer around ring of procs + // func = update rsqfar for atoms belonging to bodies I own + // when done, have rsqfar for all atoms in bodies I own + + rsqfar = 0.0; + comm->ring(m,sizeof(double),buf,3,ring_farthest,NULL,(void *)this); + + // find maxextent of rsqfar across all procs // if defined, include molecule->maxextent MPI_Allreduce(&rsqfar,&maxextent,1,MPI_DOUBLE,MPI_MAX,world); @@ -1617,156 +1691,125 @@ void FixRigidSmall::create_bodies(tagint *bodyID) for (int i = 0; i < nmol; i++) maxextent = MAX(maxextent,onemols[i]->maxextent); } -} - -/* ---------------------------------------------------------------------- - process rigid bodies assigned to me - buf = list of N BodyMsg datums -------------------------------------------------------------------------- */ - -int FixRigidSmall::rendezvous_body(int n, char *inbuf, - int &rflag, int *&proclist, char *&outbuf, - void *ptr) -{ - int i,j,m; - double delx,dely,delz,rsq; - int *iclose; - tagint *idclose; - double *x,*xown,*rsqclose; - double **bbox,**ctr; - - FixRigidSmall *frsptr = (FixRigidSmall *) ptr; - Memory *memory = frsptr->memory; - Error *error = frsptr->error; - MPI_Comm world = frsptr->world; - - // setup hash - // use STL map instead of atom->map - // b/c know nothing about body ID values specified by user - // ncount = number of bodies assigned to me - // key = body ID - // value = index into Ncount-length data structure - - InRvous *in = (InRvous *) inbuf; - std::map hash; - tagint id; - - int ncount = 0; - for (i = 0; i < n; i++) { - id = in[i].bodyID; - if (hash.find(id) == hash.end()) hash[id] = ncount++; - } - - // bbox = bounding box of each rigid body - - memory->create(bbox,ncount,6,"rigid/small:bbox"); - - for (m = 0; m < ncount; m++) { - bbox[m][0] = bbox[m][2] = bbox[m][4] = BIG; - bbox[m][1] = bbox[m][3] = bbox[m][5] = -BIG; - } - - for (i = 0; i < n; i++) { - m = hash.find(in[i].bodyID)->second; - x = in[i].x; - bbox[m][0] = MIN(bbox[m][0],x[0]); - bbox[m][1] = MAX(bbox[m][1],x[0]); - bbox[m][2] = MIN(bbox[m][2],x[1]); - bbox[m][3] = MAX(bbox[m][3],x[1]); - bbox[m][4] = MIN(bbox[m][4],x[2]); - bbox[m][5] = MAX(bbox[m][5],x[2]); - } - - // check if any bbox is size 0.0, meaning rigid body is a single particle - - int flag = 0; - for (m = 0; m < ncount; m++) - if (bbox[m][0] == bbox[m][1] && bbox[m][2] == bbox[m][3] && - bbox[m][4] == bbox[m][5]) flag = 1; - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); // sync here? - if (flagall) - error->all(FLERR,"One or more rigid bodies are a single particle"); - - // ctr = geometric center pt of each rigid body - - memory->create(ctr,ncount,3,"rigid/small:bbox"); - - for (m = 0; m < ncount; m++) { - ctr[m][0] = 0.5 * (bbox[m][0] + bbox[m][1]); - ctr[m][1] = 0.5 * (bbox[m][2] + bbox[m][3]); - ctr[m][2] = 0.5 * (bbox[m][4] + bbox[m][5]); - } - - // idclose = atomID closest to center point of each body - - memory->create(idclose,ncount,"rigid/small:idclose"); - memory->create(iclose,ncount,"rigid/small:iclose"); - memory->create(rsqclose,ncount,"rigid/small:rsqclose"); - for (m = 0; m < ncount; m++) rsqclose[m] = BIG; - - for (i = 0; i < n; i++) { - m = hash.find(in[i].bodyID)->second; - x = in[i].x; - delx = x[0] - ctr[m][0]; - dely = x[1] - ctr[m][1]; - delz = x[2] - ctr[m][2]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= rsqclose[m]) { - if (rsq == rsqclose[m] && in[i].atomID > idclose[m]) continue; - iclose[m] = i; - idclose[m] = in[i].atomID; - rsqclose[m] = rsq; - } - } - - // compute rsqfar for all bodies I own - // set rsqfar back in caller - - double rsqfar = 0.0; - - for (int i = 0; i < n; i++) { - m = hash.find(in[i].bodyID)->second; - xown = in[iclose[m]].x; - x = in[i].x; - delx = x[0] - xown[0]; - dely = x[1] - xown[1]; - delz = x[2] - xown[2]; - rsq = delx*delx + dely*dely + delz*delz; - rsqfar = MAX(rsqfar,rsq); - } - - frsptr->rsqfar = rsqfar; - - // pass list of OutRvous datums back to comm->rendezvous - - int nout = n; - memory->create(proclist,nout,"rigid/small:proclist"); - OutRvous *out = (OutRvous *) - memory->smalloc(nout*sizeof(OutRvous),"rigid/small:out"); - - for (int i = 0; i < nout; i++) { - proclist[i] = in[i].me; - out[i].ilocal = in[i].ilocal; - m = hash.find(in[i].bodyID)->second; - out[i].atomID = idclose[m]; - } - - outbuf = (char *) out; // clean up - // Comm::rendezvous will delete proclist and out (outbuf) + delete hash; + memory->destroy(buf); memory->destroy(bbox); memory->destroy(ctr); memory->destroy(idclose); - memory->destroy(iclose); memory->destroy(rsqclose); +} - // flag = 2: new outbuf +/* ---------------------------------------------------------------------- + process rigid body atoms from another proc + update bounding box for rigid bodies my atoms are part of +------------------------------------------------------------------------- */ - rflag = 2; - return nout; +void FixRigidSmall::ring_bbox(int n, char *cbuf, void *ptr) +{ + FixRigidSmall *frsptr = (FixRigidSmall *) ptr; + std::map *hash = frsptr->hash; + double **bbox = frsptr->bbox; + + double *buf = (double *) cbuf; + int ndatums = n/4; + + int j,imol; + double *x; + + int m = 0; + for (int i = 0; i < ndatums; i++, m += 4) { + imol = static_cast (buf[m]); + if (hash->find(imol) != hash->end()) { + j = hash->find(imol)->second; + x = &buf[m+1]; + bbox[j][0] = MIN(bbox[j][0],x[0]); + bbox[j][1] = MAX(bbox[j][1],x[0]); + bbox[j][2] = MIN(bbox[j][2],x[1]); + bbox[j][3] = MAX(bbox[j][3],x[1]); + bbox[j][4] = MIN(bbox[j][4],x[2]); + bbox[j][5] = MAX(bbox[j][5],x[2]); + } + } +} + +/* ---------------------------------------------------------------------- + process rigid body atoms from another proc + update nearest atom to body center for rigid bodies my atoms are part of +------------------------------------------------------------------------- */ + +void FixRigidSmall::ring_nearest(int n, char *cbuf, void *ptr) +{ + FixRigidSmall *frsptr = (FixRigidSmall *) ptr; + std::map *hash = frsptr->hash; + double **ctr = frsptr->ctr; + tagint *idclose = frsptr->idclose; + double *rsqclose = frsptr->rsqclose; + + double *buf = (double *) cbuf; + int ndatums = n/5; + + int j,imol; + tagint tag; + double delx,dely,delz,rsq; + double *x; + + int m = 0; + for (int i = 0; i < ndatums; i++, m += 5) { + imol = static_cast (buf[m]); + if (hash->find(imol) != hash->end()) { + j = hash->find(imol)->second; + tag = (tagint) ubuf(buf[m+1]).i; + x = &buf[m+2]; + delx = x[0] - ctr[j][0]; + dely = x[1] - ctr[j][1]; + delz = x[2] - ctr[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq <= rsqclose[j]) { + if (rsq == rsqclose[j] && tag > idclose[j]) continue; + idclose[j] = tag; + rsqclose[j] = rsq; + } + } + } +} + +/* ---------------------------------------------------------------------- + process rigid body atoms from another proc + update rsqfar = distance from owning atom to other atom +------------------------------------------------------------------------- */ + +void FixRigidSmall::ring_farthest(int n, char *cbuf, void *ptr) +{ + FixRigidSmall *frsptr = (FixRigidSmall *) ptr; + double **x = frsptr->atom->x; + imageint *image = frsptr->atom->image; + int nlocal = frsptr->atom->nlocal; + + double *buf = (double *) cbuf; + int ndatums = n/4; + + int iowner; + tagint tag; + double delx,dely,delz,rsq; + double *xx; + double unwrap[3]; + + int m = 0; + for (int i = 0; i < ndatums; i++, m += 4) { + tag = (tagint) ubuf(buf[m]).i; + iowner = frsptr->atom->map(tag); + if (iowner < 0 || iowner >= nlocal) continue; + frsptr->domain->unmap(x[iowner],image[iowner],unwrap); + xx = &buf[m+1]; + delx = xx[0] - unwrap[0]; + dely = xx[1] - unwrap[1]; + delz = xx[2] - unwrap[2]; + rsq = delx*delx + dely*dely + delz*delz; + frsptr->rsqfar = MAX(frsptr->rsqfar,rsq); + } } /* ---------------------------------------------------------------------- @@ -2429,9 +2472,9 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) int nlocal = atom->nlocal; - std::map hash; + hash = new std::map(); for (i = 0; i < nlocal; i++) - if (bodyown[i] >= 0) hash[atom->molecule[i]] = bodyown[i]; + if (bodyown[i] >= 0) (*hash)[atom->molecule[i]] = bodyown[i]; // open file and read header @@ -2490,11 +2533,11 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) id = ATOTAGINT(values[0]); if (id <= 0 || id > maxmol) error->all(FLERR,"Invalid rigid body ID in fix rigid/small file"); - if (hash.find(id) == hash.end()) { + if (hash->find(id) == hash->end()) { buf = next + 1; continue; } - m = hash[id]; + m = (*hash)[id]; inbody[m] = 1; if (which == 0) { @@ -2533,6 +2576,7 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) delete [] buffer; delete [] values; + delete hash; } /* ---------------------------------------------------------------------- diff --git a/src/RIGID/fix_rigid_small.h b/src/RIGID/fix_rigid_small.h index f6ad1b7206..3f6826f9bb 100644 --- a/src/RIGID/fix_rigid_small.h +++ b/src/RIGID/fix_rigid_small.h @@ -23,7 +23,7 @@ FixStyle(rigid/small,FixRigidSmall) #include "fix.h" // replace this later -//#include +#include namespace LAMMPS_NS { @@ -180,21 +180,13 @@ class FixRigidSmall : public Fix { // class data used by ring communication callbacks + std::map *hash; + double **bbox; + double **ctr; + tagint *idclose; + double *rsqclose; double rsqfar; - struct InRvous { - int me,ilocal; - tagint atomID,bodyID; - double x[3]; - }; - - struct OutRvous { - int ilocal; - tagint atomID; - }; - - // local methods - void image_shift(); void set_xv(); void set_v(); @@ -207,9 +199,11 @@ class FixRigidSmall : public Fix { void grow_body(); void reset_atom2body(); - // callback function for rendezvous communication + // callback functions for ring communication - static int rendezvous_body(int, char *, int &, int *&, char *&, void *); + static void ring_bbox(int, char *, void *); + static void ring_nearest(int, char *, void *); + static void ring_farthest(int, char *, void *); // debug diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index dcdb190d45..e0d1bf132b 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -39,8 +39,6 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all - #define BIG 1.0e20 #define MASSDELTA 0.1 @@ -221,19 +219,8 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : // identify all SHAKE clusters - double time1 = MPI_Wtime(); - find_clusters(); - double time2 = MPI_Wtime(); - - if (comm->me == 0) { - if (screen) - fprintf(screen," find clusters CPU = %g secs\n",time2-time1); - if (logfile) - fprintf(logfile," find clusters CPU = %g secs\n",time2-time1); - } - // initialize list of SHAKE clusters to constrain maxlist = 0; @@ -720,6 +707,13 @@ void FixShake::find_clusters() int nlocal = atom->nlocal; int angles_allow = atom->avec->angles_allow; + // setup ring of procs + + int next = me + 1; + int prev = me -1; + if (next == nprocs) next = 0; + if (prev < 0) prev = nprocs - 1; + // ----------------------------------------------------- // allocate arrays for self (1d) and bond partners (2d) // max = max # of bond partners for owned atoms = 2nd dim of partner arrays @@ -761,10 +755,6 @@ void FixShake::find_clusters() memory->create(partner_shake,nlocal,max,"shake:partner_shake"); memory->create(partner_nshake,nlocal,max,"shake:partner_nshake"); - // setup atomIDs and procowner vectors in rendezvous decomposition - - atom_owners(); - // ----------------------------------------------------- // set npartner and partner_tag from special arrays // ----------------------------------------------------- @@ -788,13 +778,86 @@ void FixShake::find_clusters() } // ----------------------------------------------------- - // set partner_mask, partner_type, partner_massflag, - // partner_bondtype for all my bonded partners - // requires rendezvous communication for off-proc partners + // set partner_mask, partner_type, partner_massflag, partner_bondtype + // for bonded partners + // requires communication for off-proc partners // ----------------------------------------------------- - partner_info(npartner,partner_tag,partner_mask,partner_type, - partner_massflag,partner_bondtype); + // fill in mask, type, massflag, bondtype if own bond partner + // info to store in buf for each off-proc bond = nper = 6 + // 2 atoms IDs in bond, space for mask, type, massflag, bondtype + // nbufmax = largest buffer needed to hold info from any proc + + int nper = 6; + + nbuf = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + partner_mask[i][j] = 0; + partner_type[i][j] = 0; + partner_massflag[i][j] = 0; + partner_bondtype[i][j] = 0; + + m = atom->map(partner_tag[i][j]); + if (m >= 0 && m < nlocal) { + partner_mask[i][j] = mask[m]; + partner_type[i][j] = type[m]; + if (nmass) { + if (rmass) massone = rmass[m]; + else massone = mass[type[m]]; + partner_massflag[i][j] = masscheck(massone); + } + n = bondtype_findset(i,tag[i],partner_tag[i][j],0); + if (n) partner_bondtype[i][j] = n; + else { + n = bondtype_findset(m,tag[i],partner_tag[i][j],0); + if (n) partner_bondtype[i][j] = n; + } + } else nbuf += nper; + } + } + + memory->create(buf,nbuf,"shake:buf"); + + // fill buffer with info + + size = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + m = atom->map(partner_tag[i][j]); + if (m < 0 || m >= nlocal) { + buf[size] = tag[i]; + buf[size+1] = partner_tag[i][j]; + buf[size+2] = 0; + buf[size+3] = 0; + buf[size+4] = 0; + n = bondtype_findset(i,tag[i],partner_tag[i][j],0); + if (n) buf[size+5] = n; + else buf[size+5] = 0; + size += nper; + } + } + } + + // cycle buffer around ring of procs back to self + + comm->ring(size,sizeof(tagint),buf,1,ring_bonds,buf,(void *)this); + + // store partner info returned to me + + m = 0; + while (m < size) { + i = atom->map(buf[m]); + for (j = 0; j < npartner[i]; j++) + if (buf[m+1] == partner_tag[i][j]) break; + partner_mask[i][j] = buf[m+2]; + partner_type[i][j] = buf[m+3]; + partner_massflag[i][j] = buf[m+4]; + partner_bondtype[i][j] = buf[m+5]; + m += nper; + } + + memory->destroy(buf); // error check for unfilled partner info // if partner_type not set, is an error @@ -805,18 +868,17 @@ void FixShake::find_clusters() // else it's an error flag = 0; - int flag2 = 0; for (i = 0; i < nlocal; i++) for (j = 0; j < npartner[i]; j++) { - if (partner_type[i][j] == 0) flag++; + if (partner_type[i][j] == 0) flag = 1; if (!(mask[i] & groupbit)) continue; if (!(partner_mask[i][j] & groupbit)) continue; - if (partner_bondtype[i][j] == 0) flag2++; + if (partner_bondtype[i][j] == 0) flag = 1; } MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); if (flag_all) error->all(FLERR,"Did not find fix shake partner info"); - + // ----------------------------------------------------- // identify SHAKEable bonds // set nshake[i] = # of SHAKE bonds attached to atom i @@ -869,11 +931,56 @@ void FixShake::find_clusters() // ----------------------------------------------------- // set partner_nshake for bonded partners - // requires rendezvous communication for off-proc partners + // requires communication for off-proc partners // ----------------------------------------------------- - nshake_info(npartner,partner_tag,partner_nshake); - + // fill in partner_nshake if own bond partner + // info to store in buf for each off-proc bond = + // 2 atoms IDs in bond, space for nshake value + // nbufmax = largest buffer needed to hold info from any proc + + nbuf = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + m = atom->map(partner_tag[i][j]); + if (m >= 0 && m < nlocal) partner_nshake[i][j] = nshake[m]; + else nbuf += 3; + } + } + + memory->create(buf,nbuf,"shake:buf"); + + // fill buffer with info + + size = 0; + for (i = 0; i < nlocal; i++) { + for (j = 0; j < npartner[i]; j++) { + m = atom->map(partner_tag[i][j]); + if (m < 0 || m >= nlocal) { + buf[size] = tag[i]; + buf[size+1] = partner_tag[i][j]; + size += 3; + } + } + } + + // cycle buffer around ring of procs back to self + + comm->ring(size,sizeof(tagint),buf,2,ring_nshake,buf,(void *)this); + + // store partner info returned to me + + m = 0; + while (m < size) { + i = atom->map(buf[m]); + for (j = 0; j < npartner[i]; j++) + if (buf[m+1] == partner_tag[i][j]) break; + partner_nshake[i][j] = buf[m+2]; + m += 3; + } + + memory->destroy(buf); + // ----------------------------------------------------- // error checks // no atom with nshake > 3 @@ -881,7 +988,7 @@ void FixShake::find_clusters() // ----------------------------------------------------- flag = 0; - for (i = 0; i < nlocal; i++) if (nshake[i] > 3) flag++; + for (i = 0; i < nlocal; i++) if (nshake[i] > 3) flag = 1; MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); if (flag_all) error->all(FLERR,"Shake cluster of more than 4 atoms"); @@ -889,7 +996,7 @@ void FixShake::find_clusters() for (i = 0; i < nlocal; i++) { if (nshake[i] <= 1) continue; for (j = 0; j < npartner[i]; j++) - if (partner_shake[i][j] && partner_nshake[i][j] > 1) flag++; + if (partner_shake[i][j] && partner_nshake[i][j] > 1) flag = 1; } MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); if (flag_all) error->all(FLERR,"Shake clusters are connected"); @@ -957,18 +1064,68 @@ void FixShake::find_clusters() // ----------------------------------------------------- // set shake_flag,shake_atom,shake_type for non-central atoms - // requires rendezvous communication for off-proc atoms + // requires communication for off-proc atoms // ----------------------------------------------------- - shake_info(npartner,partner_tag,partner_shake); + // fill in shake arrays for each bond partner I own + // info to store in buf for each off-proc bond = + // all values from shake_flag, shake_atom, shake_type + // nbufmax = largest buffer needed to hold info from any proc + + nbuf = 0; + for (i = 0; i < nlocal; i++) { + if (shake_flag[i] == 0) continue; + for (j = 0; j < npartner[i]; j++) { + if (partner_shake[i][j] == 0) continue; + m = atom->map(partner_tag[i][j]); + if (m >= 0 && m < nlocal) { + shake_flag[m] = shake_flag[i]; + shake_atom[m][0] = shake_atom[i][0]; + shake_atom[m][1] = shake_atom[i][1]; + shake_atom[m][2] = shake_atom[i][2]; + shake_atom[m][3] = shake_atom[i][3]; + shake_type[m][0] = shake_type[i][0]; + shake_type[m][1] = shake_type[i][1]; + shake_type[m][2] = shake_type[i][2]; + } else nbuf += 9; + } + } + + memory->create(buf,nbuf,"shake:buf"); + + // fill buffer with info + + size = 0; + for (i = 0; i < nlocal; i++) { + if (shake_flag[i] == 0) continue; + for (j = 0; j < npartner[i]; j++) { + if (partner_shake[i][j] == 0) continue; + m = atom->map(partner_tag[i][j]); + if (m < 0 || m >= nlocal) { + buf[size] = partner_tag[i][j]; + buf[size+1] = shake_flag[i]; + buf[size+2] = shake_atom[i][0]; + buf[size+3] = shake_atom[i][1]; + buf[size+4] = shake_atom[i][2]; + buf[size+5] = shake_atom[i][3]; + buf[size+6] = shake_type[i][0]; + buf[size+7] = shake_type[i][1]; + buf[size+8] = shake_type[i][2]; + size += 9; + } + } + } + + // cycle buffer around ring of procs back to self + + comm->ring(size,sizeof(tagint),buf,3,ring_shake,NULL,(void *)this); + + memory->destroy(buf); // ----------------------------------------------------- // free local memory // ----------------------------------------------------- - memory->destroy(atomIDs); - memory->destroy(procowner); - memory->destroy(npartner); memory->destroy(nshake); memory->destroy(partner_tag); @@ -1042,551 +1199,98 @@ void FixShake::find_clusters() } /* ---------------------------------------------------------------------- - setup atomIDs and procowner + when receive buffer, scan bond partner IDs for atoms I own + if I own partner: + fill in mask and type and massflag + search for bond with 1st atom and fill in bondtype ------------------------------------------------------------------------- */ -void FixShake::atom_owners() +void FixShake::ring_bonds(int ndatum, char *cbuf, void *ptr) { - tagint *tag = atom->tag; - int nlocal = atom->nlocal; - - int *proclist; - memory->create(proclist,nlocal,"shake:proclist"); - IDRvous *idbuf = (IDRvous *) - memory->smalloc((bigint) nlocal*sizeof(IDRvous),"shake:idbuf"); - - // setup input buf to rendezvous comm - // input datums = pairs of bonded atoms - // owning proc for each datum = random hash of atomID - // one datum for each owned atom: datum = owning proc, atomID - - for (int i = 0; i < nlocal; i++) { - proclist[i] = tag[i] % nprocs; - idbuf[i].me = me; - idbuf[i].atomID = tag[i]; - } - - // perform rendezvous operation - // each proc assigned every 1/Pth atom - - char *buf; - comm->rendezvous(RVOUS,nlocal,(char *) idbuf,sizeof(IDRvous), - 0,proclist, - rendezvous_ids,0,buf,0,(void *) this); - - memory->destroy(proclist); - memory->sfree(idbuf); -} - -/* ---------------------------------------------------------------------- - setup partner_mask, partner_type, partner_massflag, partner_bondtype -------------------------------------------------------------------------- */ - -void FixShake::partner_info(int *npartner, tagint **partner_tag, - int **partner_mask, int **partner_type, - int **partner_massflag, int **partner_bondtype) -{ - int i,j,m,n; - int nlocal = atom->nlocal; - - // nsend = # of my datums to send - // one datum for every off-processor partner - - int nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - m = atom->map(partner_tag[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } - } - - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - PartnerInfo *inbuf = (PartnerInfo *) - memory->smalloc((bigint) nsend*sizeof(PartnerInfo),"special:inbuf"); - - // set values in 4 partner arrays for all partner atoms I own - // also setup input buf to rendezvous comm - // input datums = pair of bonded atoms where I do not own partner - // owning proc for each datum = partner_tag % nprocs - // datum: atomID = partner_tag (off-proc), partnerID = tag (on-proc) - // 4 values for my owned atom - + FixShake *fsptr = (FixShake *)ptr; + Atom *atom = fsptr->atom; double *rmass = atom->rmass; double *mass = atom->mass; - int *type = atom->type; int *mask = atom->mask; - tagint *tag = atom->tag; - - double massone; - - nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - partner_mask[i][j] = 0; - partner_type[i][j] = 0; - partner_massflag[i][j] = 0; - partner_bondtype[i][j] = 0; - - m = atom->map(partner_tag[i][j]); - - if (m >= 0 && m < nlocal) { - partner_mask[i][j] = mask[m]; - partner_type[i][j] = type[m]; - if (nmass) { - if (rmass) massone = rmass[m]; - else massone = mass[type[m]]; - partner_massflag[i][j] = masscheck(massone); - } - n = bondtype_findset(i,tag[i],partner_tag[i][j],0); - if (n) partner_bondtype[i][j] = n; - else { - n = bondtype_findset(m,tag[i],partner_tag[i][j],0); - if (n) partner_bondtype[i][j] = n; - } - - } else { - proclist[nsend] = partner_tag[i][j] % nprocs; - inbuf[nsend].atomID = partner_tag[i][j]; - inbuf[nsend].partnerID = tag[i]; - inbuf[nsend].mask = mask[i]; - inbuf[nsend].type = type[i]; - if (nmass) { - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - inbuf[nsend].massflag = masscheck(massone); - } else inbuf[nsend].massflag = 0; - - // my atom may own bond, in which case set partner_bondtype - // else receiver of this datum will own the bond and return the value - - n = bondtype_findset(i,tag[i],partner_tag[i][j],0); - if (n) { - partner_bondtype[i][j] = n; - inbuf[nsend].bondtype = n; - } else inbuf[nsend].bondtype = 0; - - nsend++; - } - } - } - - // perform rendezvous operation - // each proc owns random subset of atoms - // receives all data needed to populate un-owned partner 4 values - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PartnerInfo), - 0,proclist, - rendezvous_partners_info, - 0,buf,sizeof(PartnerInfo), - (void *) this); - PartnerInfo *outbuf = (PartnerInfo *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set partner 4 values for un-onwed partners based on output info - // outbuf.atomID = my owned atom, outbuf.partnerID = partner the info is for - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - for (j = 0; j < npartner[i]; j++) - if (partner_tag[i][j] == outbuf[m].partnerID) break; - partner_mask[i][j] = outbuf[m].mask; - partner_type[i][j] = outbuf[m].type; - partner_massflag[i][j] = outbuf[m].massflag; - - // only set partner_bondtype if my atom did not set it - // when setting up rendezvous - // if this proc set it, then sender of this datum set outbuf.bondtype = 0 - - if (partner_bondtype[i][j] == 0) - partner_bondtype[i][j] = outbuf[m].bondtype; - } - - memory->sfree(outbuf); -} - -/* ---------------------------------------------------------------------- - setup partner_nshake -------------------------------------------------------------------------- */ - -void FixShake::nshake_info(int *npartner, tagint **partner_tag, - int **partner_nshake) -{ - int i,j,m,n; + int *type = atom->type; int nlocal = atom->nlocal; - - // nsend = # of my datums to send - // one datum for every off-processor partner - - int nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - m = atom->map(partner_tag[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } - } - - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - NShakeInfo *inbuf = (NShakeInfo *) - memory->smalloc((bigint) nsend*sizeof(NShakeInfo),"special:inbuf"); - - // set partner_nshake for all partner atoms I own - // also setup input buf to rendezvous comm - // input datums = pair of bonded atoms where I do not own partner - // owning proc for each datum = partner_tag % nprocs - // datum: atomID = partner_tag (off-proc), partnerID = tag (on-proc) - // nshake value for my owned atom - - tagint *tag = atom->tag; - - nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - partner_nshake[i][j] = 0; - m = atom->map(partner_tag[i][j]); - if (m >= 0 && m < nlocal) { - partner_nshake[i][j] = nshake[m]; - } else { - proclist[nsend] = partner_tag[i][j] % nprocs; - inbuf[nsend].atomID = partner_tag[i][j]; - inbuf[nsend].partnerID = tag[i]; - inbuf[nsend].nshake = nshake[i]; - nsend++; - } - } - } - - // perform rendezvous operation - // each proc owns random subset of atoms - // receives all data needed to populate un-owned partner nshake - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(NShakeInfo), - 0,proclist, - rendezvous_nshake,0,buf,sizeof(NShakeInfo), - (void *) this); - NShakeInfo *outbuf = (NShakeInfo *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set partner nshake for un-onwed partners based on output info - // outbuf.atomID = my owned atom, outbuf.partnerID = partner the info is for - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - for (j = 0; j < npartner[i]; j++) - if (partner_tag[i][j] == outbuf[m].partnerID) break; - partner_nshake[i][j] = outbuf[m].nshake; - } - - memory->sfree(outbuf); -} - -/* ---------------------------------------------------------------------- - setup shake_flag, shake_atom, shake_type -------------------------------------------------------------------------- */ - -void FixShake::shake_info(int *npartner, tagint **partner_tag, - int **partner_shake) -{ - int i,j,m,n; - int nlocal = atom->nlocal; - - // nsend = # of my datums to send - // one datum for every off-processor partner - - int nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < npartner[i]; j++) { - m = atom->map(partner_tag[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } - } - - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - ShakeInfo *inbuf = (ShakeInfo *) - memory->smalloc((bigint) nsend*sizeof(ShakeInfo),"special:inbuf"); - - // set 3 shake arrays for all partner atoms I own - // also setup input buf to rendezvous comm - // input datums = partner atom where I do not own partner - // owning proc for each datum = partner_tag % nprocs - // datum: atomID = partner_tag (off-proc) - // values in 3 shake arrays - - nsend = 0; - for (i = 0; i < nlocal; i++) { - if (shake_flag[i] == 0) continue; - for (j = 0; j < npartner[i]; j++) { - if (partner_shake[i][j] == 0) continue; - m = atom->map(partner_tag[i][j]); - - if (m >= 0 && m < nlocal) { - shake_flag[m] = shake_flag[i]; - shake_atom[m][0] = shake_atom[i][0]; - shake_atom[m][1] = shake_atom[i][1]; - shake_atom[m][2] = shake_atom[i][2]; - shake_atom[m][3] = shake_atom[i][3]; - shake_type[m][0] = shake_type[i][0]; - shake_type[m][1] = shake_type[i][1]; - shake_type[m][2] = shake_type[i][2]; - - } else { - proclist[nsend] = partner_tag[i][j] % nprocs; - inbuf[nsend].atomID = partner_tag[i][j]; - inbuf[nsend].shake_flag = shake_flag[i]; - inbuf[nsend].shake_atom[0] = shake_atom[i][0]; - inbuf[nsend].shake_atom[1] = shake_atom[i][1]; - inbuf[nsend].shake_atom[2] = shake_atom[i][2]; - inbuf[nsend].shake_atom[3] = shake_atom[i][3]; - inbuf[nsend].shake_type[0] = shake_type[i][0]; - inbuf[nsend].shake_type[1] = shake_type[i][1]; - inbuf[nsend].shake_type[2] = shake_type[i][2]; - nsend++; - } - } - } - - // perform rendezvous operation - // each proc owns random subset of atoms - // receives all data needed to populate un-owned shake info - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(ShakeInfo), - 0,proclist, - rendezvous_shake,0,buf,sizeof(ShakeInfo), - (void *) this); - ShakeInfo *outbuf = (ShakeInfo *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set shake info for un-onwed partners based on output info - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - shake_flag[i] = outbuf[m].shake_flag; - shake_atom[i][0] = outbuf[m].shake_atom[0]; - shake_atom[i][1] = outbuf[m].shake_atom[1]; - shake_atom[i][2] = outbuf[m].shake_atom[2]; - shake_atom[i][3] = outbuf[m].shake_atom[3]; - shake_type[i][0] = outbuf[m].shake_type[0]; - shake_type[i][1] = outbuf[m].shake_type[1]; - shake_type[i][2] = outbuf[m].shake_type[2]; - } - - memory->sfree(outbuf); -} - -/* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N IDRvous datums - no outbuf -------------------------------------------------------------------------- */ - -int FixShake::rendezvous_ids(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) -{ - FixShake *fsptr = (FixShake *) ptr; - Memory *memory = fsptr->memory; - - tagint *atomIDs; - int *procowner; - - memory->create(atomIDs,n,"special:atomIDs"); - memory->create(procowner,n,"special:procowner"); - - IDRvous *in = (IDRvous *) inbuf; - - for (int i = 0; i < n; i++) { - atomIDs[i] = in[i].atomID; - procowner[i] = in[i].me; - } - - // store rendezvous data in FixShake class - - fsptr->nrvous = n; - fsptr->atomIDs = atomIDs; - fsptr->procowner = procowner; - - // flag = 0: no second comm needed in rendezvous - - flag = 0; - return 0; -} - -/* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N PairRvous datums - outbuf = same list of N PairRvous datums, routed to different procs -------------------------------------------------------------------------- */ - -int FixShake::rendezvous_partners_info(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) -{ - int i,m; - - FixShake *fsptr = (FixShake *) ptr; - Atom *atom = fsptr->atom; - Memory *memory = fsptr->memory; - - // clear atom map so it can be here as a hash table - // faster than an STL map for large atom counts - - atom->map_clear(); - - // hash atom IDs stored in rendezvous decomposition - - int nrvous = fsptr->nrvous; - tagint *atomIDs = fsptr->atomIDs; - - for (i = 0; i < nrvous; i++) - atom->map_one(atomIDs[i],i); - - // proclist = owner of atomID in caller decomposition - // outbuf = info about owned atomID = 4 values - - PartnerInfo *in = (PartnerInfo *) inbuf; - int *procowner = fsptr->procowner; - memory->create(proclist,n,"shake:proclist"); - - double massone; int nmass = fsptr->nmass; - for (i = 0; i < n; i++) { - m = atom->map(in[i].atomID); - proclist[i] = procowner[m]; + tagint *buf = (tagint *) cbuf; + int m,n; + double massone; + + for (int i = 0; i < ndatum; i += 6) { + m = atom->map(buf[i+1]); + if (m >= 0 && m < nlocal) { + buf[i+2] = mask[m]; + buf[i+3] = type[m]; + if (nmass) { + if (rmass) massone = rmass[m]; + else massone = mass[type[m]]; + buf[i+4] = fsptr->masscheck(massone); + } + if (buf[i+5] == 0) { + n = fsptr->bondtype_findset(m,buf[i],buf[i+1],0); + if (n) buf[i+5] = n; + } + } } - - outbuf = inbuf; - - // re-create atom map - - atom->map_init(0); - atom->nghost = 0; - atom->map_set(); - - // flag = 1: outbuf = inbuf - - flag = 1; - return n; } /* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N NShakeInfo datums - outbuf = same list of N NShakeInfo datums, routed to different procs + when receive buffer, scan bond partner IDs for atoms I own + if I own partner, fill in nshake value ------------------------------------------------------------------------- */ -int FixShake::rendezvous_nshake(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) +void FixShake::ring_nshake(int ndatum, char *cbuf, void *ptr) { - int i,j,m; - - FixShake *fsptr = (FixShake *) ptr; + FixShake *fsptr = (FixShake *)ptr; Atom *atom = fsptr->atom; - Memory *memory = fsptr->memory; + int nlocal = atom->nlocal; - // clear atom map so it can be here as a hash table - // faster than an STL map for large atom counts + int *nshake = fsptr->nshake; - atom->map_clear(); + tagint *buf = (tagint *) cbuf; + int m; - // hash atom IDs stored in rendezvous decomposition - - int nrvous = fsptr->nrvous; - tagint *atomIDs = fsptr->atomIDs; - - for (i = 0; i < nrvous; i++) - atom->map_one(atomIDs[i],i); - - // proclist = owner of atomID in caller decomposition - // outbuf = info about owned atomID - - NShakeInfo *in = (NShakeInfo *) inbuf; - int *procowner = fsptr->procowner; - memory->create(proclist,n,"shake:proclist"); - - for (i = 0; i < n; i++) { - m = atom->map(in[i].atomID); - proclist[i] = procowner[m]; + for (int i = 0; i < ndatum; i += 3) { + m = atom->map(buf[i+1]); + if (m >= 0 && m < nlocal) buf[i+2] = nshake[m]; } - - outbuf = inbuf; - - // re-create atom map - - atom->map_init(0); - atom->nghost = 0; - atom->map_set(); - - // flag = 1: outbuf = inbuf - - flag = 1; - return n; } + /* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N PairRvous datums - outbuf = same list of N PairRvous datums, routed to different procs + when receive buffer, scan bond partner IDs for atoms I own + if I own partner, fill in nshake value ------------------------------------------------------------------------- */ -int FixShake::rendezvous_shake(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) +void FixShake::ring_shake(int ndatum, char *cbuf, void *ptr) { - int i,j,m; - - FixShake *fsptr = (FixShake *) ptr; + FixShake *fsptr = (FixShake *)ptr; Atom *atom = fsptr->atom; - Memory *memory = fsptr->memory; + int nlocal = atom->nlocal; - // clear atom map so it can be here as a hash table - // faster than an STL map for large atom counts + int *shake_flag = fsptr->shake_flag; + tagint **shake_atom = fsptr->shake_atom; + int **shake_type = fsptr->shake_type; - atom->map_clear(); + tagint *buf = (tagint *) cbuf; + int m; - // hash atom IDs stored in rendezvous decomposition - - int nrvous = fsptr->nrvous; - tagint *atomIDs = fsptr->atomIDs; - - for (i = 0; i < nrvous; i++) - atom->map_one(atomIDs[i],i); - - // proclist = owner of atomID in caller decomposition - // outbuf = info about owned atomID - - ShakeInfo *in = (ShakeInfo *) inbuf; - int *procowner = fsptr->procowner; - memory->create(proclist,n,"shake:proclist"); - - for (i = 0; i < n; i++) { - m = atom->map(in[i].atomID); - proclist[i] = procowner[m]; + for (int i = 0; i < ndatum; i += 9) { + m = atom->map(buf[i]); + if (m >= 0 && m < nlocal) { + shake_flag[m] = buf[i+1]; + shake_atom[m][0] = buf[i+2]; + shake_atom[m][1] = buf[i+3]; + shake_atom[m][2] = buf[i+4]; + shake_atom[m][3] = buf[i+5]; + shake_type[m][0] = buf[i+6]; + shake_type[m][1] = buf[i+7]; + shake_type[m][2] = buf[i+8]; + } } - - outbuf = inbuf; - - // re-create atom map - - atom->map_init(0); - atom->nghost = 0; - atom->map_set(); - - // flag = 1: outbuf = inbuf; - - flag = 1; - return n; } /* ---------------------------------------------------------------------- diff --git a/src/RIGID/fix_shake.h b/src/RIGID/fix_shake.h index b99a35f958..d4e7b85ec4 100644 --- a/src/RIGID/fix_shake.h +++ b/src/RIGID/fix_shake.h @@ -120,11 +120,6 @@ class FixShake : public Fix { int nmol; void find_clusters(); - void atom_owners(); - void partner_info(int *, tagint **, int **, int **, int **, int **); - void nshake_info(int *, tagint **, int **); - void shake_info(int *, tagint **, int **); - int masscheck(double); void unconstrained_update(); void unconstrained_update_respa(int); @@ -136,40 +131,12 @@ class FixShake : public Fix { int bondtype_findset(int, tagint, tagint, int); int angletype_findset(int, tagint, tagint, int); - // data used by rendezvous callback methods + // static variable for ring communication callback to access class data + // callback functions for ring communication - int nrvous; - tagint *atomIDs; - int *procowner; - - struct IDRvous { - int me; - tagint atomID; - }; - - struct PartnerInfo { - tagint atomID,partnerID; - int mask,type,massflag,bondtype; - }; - - struct NShakeInfo { - tagint atomID,partnerID; - int nshake; - }; - - struct ShakeInfo { - tagint atomID; - tagint shake_atom[4]; - int shake_flag; - int shake_type[3]; - }; - - // callback functions for rendezvous communication - - static int rendezvous_ids(int, char *, int &, int *&, char *&, void *); - static int rendezvous_partners_info(int, char *, int &, int *&, char *&, void *); - static int rendezvous_nshake(int, char *, int &, int *&, char *&, void *); - static int rendezvous_shake(int, char *, int &, int *&, char *&, void *); + static void ring_bonds(int, char *, void *); + static void ring_nshake(int, char *, void *); + static void ring_shake(int, char *, void *); }; } diff --git a/src/comm.cpp b/src/comm.cpp index 729f96581a..f355a562fc 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -28,7 +28,6 @@ #include "dump.h" #include "group.h" #include "procmap.h" -#include "irregular.h" #include "accelerator_kokkos.h" #include "memory.h" #include "error.h" @@ -726,433 +725,6 @@ void Comm::ring(int n, int nper, void *inbuf, int messtag, memory->destroy(bufcopy); } -/* ---------------------------------------------------------------------- - rendezvous communication operation - three stages: - first comm sends inbuf from caller decomp to rvous decomp - callback operates on data in rendevous decomp - second comm sends outbuf from rvous decomp back to caller decomp - inputs: - which = perform (0) irregular or (1) MPI_All2allv communication - n = # of datums in inbuf - inbuf = vector of input datums - insize = byte size of each input datum - inorder = 0 for inbuf in random proc order, 1 for datums ordered by proc - procs: inorder 0 = proc to send each datum to, 1 = # of datums/proc, - callback = caller function to invoke in rendezvous decomposition - takes input datums, returns output datums - outorder = same as inorder, but for datums returned by callback() - ptr = pointer to caller class, passed to callback() - outputs: - nout = # of output datums (function return) - outbuf = vector of output datums - outsize = byte size of each output datum - callback inputs: - nrvous = # of rvous decomp datums in inbuf_rvous - inbuf_rvous = vector of rvous decomp input datums - ptr = pointer to caller class - callback outputs: - nrvous_out = # of rvous decomp output datums (function return) - flag = 0 for no second comm, 1 for outbuf_rvous = inbuf_rvous, - 2 for second comm with new outbuf_rvous - procs_rvous = outorder 0 = proc to send each datum to, 1 = # of datums/proc - allocated - outbuf_rvous = vector of rvous decomp output datums - NOTE: could use MPI_INT or MPI_DOUBLE insead of MPI_CHAR - to avoid checked-for overflow in MPI_Alltoallv? -------------------------------------------------------------------------- */ - -int Comm:: -rendezvous(int which, int n, char *inbuf, int insize, - int inorder, int *procs, - int (*callback)(int, char *, int &, int *&, char *&, void *), - int outorder, char *&outbuf, int outsize, void *ptr, int statflag) -{ - if (which == 0) - return rendezvous_irregular(n,inbuf,insize,inorder,procs,callback, - outorder,outbuf,outsize,ptr,statflag); - else - return rendezvous_all2all(n,inbuf,insize,inorder,procs,callback, - outorder,outbuf,outsize,ptr,statflag); -} - -/* ---------------------------------------------------------------------- */ - -int Comm:: -rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, - int (*callback)(int, char *, int &, int *&, char *&, void *), - int outorder, char *&outbuf, - int outsize, void *ptr, int statflag) -{ - // irregular comm of inbuf from caller decomp to rendezvous decomp - - Irregular *irregular = new Irregular(lmp); - - int nrvous; - if (inorder) nrvous = irregular->create_data_grouped(n,procs); - else nrvous = irregular->create_data(n,procs); - - char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, - "rendezvous:inbuf"); - irregular->exchange_data(inbuf,insize,inbuf_rvous); - - bigint irregular1_bytes = irregular->memory_usage(); - irregular->destroy_data(); - delete irregular; - - // peform rendezvous computation via callback() - // callback() allocates/populates proclist_rvous and outbuf_rvous - - int flag; - int *procs_rvous; - char *outbuf_rvous; - int nrvous_out = callback(nrvous,inbuf_rvous,flag, - procs_rvous,outbuf_rvous,ptr); - - if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous - if (flag == 0) { - if (statflag) rendezvous_stats(n,0,nrvous,nrvous_out,insize,outsize, - (bigint) nrvous_out*sizeof(int) + - irregular1_bytes); - return 0; // all nout_rvous are 0, no 2nd comm stage - } - - // irregular comm of outbuf from rendezvous decomp back to caller decomp - // caller will free outbuf - - irregular = new Irregular(lmp); - - int nout; - if (outorder) - nout = irregular->create_data_grouped(nrvous_out,procs_rvous); - else nout = irregular->create_data(nrvous_out,procs_rvous); - - outbuf = (char *) memory->smalloc((bigint) nout*outsize, - "rendezvous:outbuf"); - irregular->exchange_data(outbuf_rvous,outsize,outbuf); - - bigint irregular2_bytes = irregular->memory_usage(); - irregular->destroy_data(); - delete irregular; - - memory->destroy(procs_rvous); - memory->sfree(outbuf_rvous); - - // return number of output datums - // last arg to stats() = memory for procs_rvous + irregular comm - - if (statflag) rendezvous_stats(n,nout,nrvous,nrvous_out,insize,outsize, - (bigint) nrvous_out*sizeof(int) + - MAX(irregular1_bytes,irregular2_bytes)); - return nout; -} - -/* ---------------------------------------------------------------------- */ - -int Comm:: -rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, - int (*callback)(int, char *, int &, int *&, char *&, void *), - int outorder, char *&outbuf, int outsize, void *ptr, - int statflag) -{ - int iproc; - bigint all2all1_bytes,all2all2_bytes; - int *sendcount,*sdispls,*recvcount,*rdispls; - int *procs_a2a; - bigint *offsets; - char *inbuf_a2a,*outbuf_a2a; - - // create procs and inbuf for All2all if necesary - - if (!inorder) { - memory->create(procs_a2a,nprocs,"rendezvous:procs"); - inbuf_a2a = (char *) memory->smalloc((bigint) n*insize, - "rendezvous:inbuf"); - memory->create(offsets,nprocs,"rendezvous:offsets"); - - for (int i = 0; i < nprocs; i++) procs_a2a[i] = 0; - for (int i = 0; i < n; i++) procs_a2a[procs[i]]++; - - offsets[0] = 0; - for (int i = 1; i < nprocs; i++) - offsets[i] = offsets[i-1] + insize*procs_a2a[i-1]; - - bigint offset = 0; - for (int i = 0; i < n; i++) { - iproc = procs[i]; - memcpy(&inbuf_a2a[offsets[iproc]],&inbuf[offset],insize); - offsets[iproc] += insize; - offset += insize; - } - - all2all1_bytes = nprocs*sizeof(int) + nprocs*sizeof(bigint) + n*insize; - - } else { - procs_a2a = procs; - inbuf_a2a = inbuf; - all2all1_bytes = 0; - } - - // create args for MPI_Alltoallv() on input data - - memory->create(sendcount,nprocs,"rendezvous:sendcount"); - memcpy(sendcount,procs_a2a,nprocs*sizeof(int)); - - memory->create(recvcount,nprocs,"rendezvous:recvcount"); - MPI_Alltoall(sendcount,1,MPI_INT,recvcount,1,MPI_INT,world); - - memory->create(sdispls,nprocs,"rendezvous:sdispls"); - memory->create(rdispls,nprocs,"rendezvous:rdispls"); - sdispls[0] = rdispls[0] = 0; - for (int i = 1; i < nprocs; i++) { - sdispls[i] = sdispls[i-1] + sendcount[i-1]; - rdispls[i] = rdispls[i-1] + recvcount[i-1]; - } - int nrvous = rdispls[nprocs-1] + recvcount[nprocs-1]; - - // test for overflow of input data due to imbalance or insize - // means that individual sdispls or rdispls values overflow - - int overflow = 0; - if ((bigint) n*insize > MAXSMALLINT) overflow = 1; - if ((bigint) nrvous*insize > MAXSMALLINT) overflow = 1; - int overflowall; - MPI_Allreduce(&overflow,&overflowall,1,MPI_INT,MPI_MAX,world); - if (overflowall) error->all(FLERR,"Overflow input size in rendezvous_a2a"); - - for (int i = 0; i < nprocs; i++) { - sendcount[i] *= insize; - sdispls[i] *= insize; - recvcount[i] *= insize; - rdispls[i] *= insize; - } - - // all2all comm of inbuf from caller decomp to rendezvous decomp - - char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, - "rendezvous:inbuf"); - - MPI_Alltoallv(inbuf_a2a,sendcount,sdispls,MPI_CHAR, - inbuf_rvous,recvcount,rdispls,MPI_CHAR,world); - - if (!inorder) { - memory->destroy(procs_a2a); - memory->sfree(inbuf_a2a); - memory->destroy(offsets); - } - - // peform rendezvous computation via callback() - // callback() allocates/populates proclist_rvous and outbuf_rvous - - int flag; - int *procs_rvous; - char *outbuf_rvous; - - int nrvous_out = callback(nrvous,inbuf_rvous,flag, - procs_rvous,outbuf_rvous,ptr); - - if (flag != 1) memory->sfree(inbuf_rvous); // outbuf_rvous = inbuf_vous - if (flag == 0) { - memory->destroy(sendcount); - memory->destroy(recvcount); - memory->destroy(sdispls); - memory->destroy(rdispls); - if (statflag) rendezvous_stats(n,0,nrvous,nrvous_out,insize,outsize, - (bigint) nrvous_out*sizeof(int) + - 4*nprocs*sizeof(int) + all2all1_bytes); - return 0; // all nout_rvous are 0, no 2nd irregular - } - - - - - - - // create procs and outbuf for All2all if necesary - - if (!outorder) { - memory->create(procs_a2a,nprocs,"rendezvous_a2a:procs"); - - outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize, - "rendezvous:outbuf"); - memory->create(offsets,nprocs,"rendezvous:offsets"); - - for (int i = 0; i < nprocs; i++) procs_a2a[i] = 0; - for (int i = 0; i < nrvous_out; i++) procs_a2a[procs_rvous[i]]++; - - offsets[0] = 0; - for (int i = 1; i < nprocs; i++) - offsets[i] = offsets[i-1] + outsize*procs_a2a[i-1]; - - bigint offset = 0; - for (int i = 0; i < nrvous_out; i++) { - iproc = procs_rvous[i]; - memcpy(&outbuf_a2a[offsets[iproc]],&outbuf_rvous[offset],outsize); - offsets[iproc] += outsize; - offset += outsize; - } - - all2all2_bytes = nprocs*sizeof(int) + nprocs*sizeof(bigint) + - nrvous_out*outsize; - - } else { - procs_a2a = procs_rvous; - outbuf_a2a = outbuf_rvous; - all2all2_bytes = 0; - } - - // comm outbuf from rendezvous decomposition back to caller - - memcpy(sendcount,procs_a2a,nprocs*sizeof(int)); - - MPI_Alltoall(sendcount,1,MPI_INT,recvcount,1,MPI_INT,world); - - sdispls[0] = rdispls[0] = 0; - for (int i = 1; i < nprocs; i++) { - sdispls[i] = sdispls[i-1] + sendcount[i-1]; - rdispls[i] = rdispls[i-1] + recvcount[i-1]; - } - int nout = rdispls[nprocs-1] + recvcount[nprocs-1]; - - // test for overflow of outbuf due to imbalance or outsize - // means that individual sdispls or rdispls values overflow - - overflow = 0; - if ((bigint) nrvous*outsize > MAXSMALLINT) overflow = 1; - if ((bigint) nout*outsize > MAXSMALLINT) overflow = 1; - MPI_Allreduce(&overflow,&overflowall,1,MPI_INT,MPI_MAX,world); - if (overflowall) error->all(FLERR,"Overflow output in rendezvous_a2a"); - - for (int i = 0; i < nprocs; i++) { - sendcount[i] *= outsize; - sdispls[i] *= outsize; - recvcount[i] *= outsize; - rdispls[i] *= outsize; - } - - // all2all comm of outbuf from rendezvous decomp back to caller decomp - // caller will free outbuf - - outbuf = (char *) memory->smalloc((bigint) nout*outsize,"rendezvous:outbuf"); - - MPI_Alltoallv(outbuf_a2a,sendcount,sdispls,MPI_CHAR, - outbuf,recvcount,rdispls,MPI_CHAR,world); - - memory->destroy(procs_rvous); - memory->sfree(outbuf_rvous); - - if (!outorder) { - memory->destroy(procs_a2a); - memory->sfree(outbuf_a2a); - memory->destroy(offsets); - } - - // clean up - - memory->destroy(sendcount); - memory->destroy(recvcount); - memory->destroy(sdispls); - memory->destroy(rdispls); - - // return number of output datums - // last arg to stats() = mem for procs_rvous + per-proc vecs + reordering ops - - if (statflag) rendezvous_stats(n,nout,nrvous,nrvous_out,insize,outsize, - (bigint) nrvous_out*sizeof(int) + - 4*nprocs*sizeof(int) + - MAX(all2all1_bytes,all2all2_bytes)); - return nout; -} - -/* ---------------------------------------------------------------------- - print balance and memory info for rendezvous operation - useful for debugging -------------------------------------------------------------------------- */ - -void Comm::rendezvous_stats(int n, int nout, int nrvous, int nrvous_out, - int insize, int outsize, bigint commsize) -{ - bigint size_in_all,size_in_max,size_in_min; - bigint size_out_all,size_out_max,size_out_min; - bigint size_inrvous_all,size_inrvous_max,size_inrvous_min; - bigint size_outrvous_all,size_outrvous_max,size_outrvous_min; - bigint size_comm_all,size_comm_max,size_comm_min; - - bigint size = (bigint) n*insize; - MPI_Allreduce(&size,&size_in_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_in_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_in_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = (bigint) nout*outsize; - MPI_Allreduce(&size,&size_out_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_out_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_out_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = (bigint) nrvous*insize; - MPI_Allreduce(&size,&size_inrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_inrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_inrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = (bigint) nrvous_out*insize; - MPI_Allreduce(&size,&size_outrvous_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_outrvous_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_outrvous_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - size = commsize; - MPI_Allreduce(&size,&size_comm_all,1,MPI_LMP_BIGINT,MPI_SUM,world); - MPI_Allreduce(&size,&size_comm_max,1,MPI_LMP_BIGINT,MPI_MAX,world); - MPI_Allreduce(&size,&size_comm_min,1,MPI_LMP_BIGINT,MPI_MIN,world); - - int mbytes = 1024*1024; - - if (me == 0) { - if (screen) { - fprintf(screen,"Rendezvous balance and memory info: (tot,ave,max,min) \n"); - fprintf(screen," input datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_in_all/insize,1.0*size_in_all/nprocs/insize, - size_in_max/insize,size_in_min/insize); - fprintf(screen," input data (MB): %g %g %g %g\n", - 1.0*size_in_all/mbytes,1.0*size_in_all/nprocs/mbytes, - 1.0*size_in_max/mbytes,1.0*size_in_min/mbytes); - if (outsize) - fprintf(screen," output datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_out_all/outsize,1.0*size_out_all/nprocs/outsize, - size_out_max/outsize,size_out_min/outsize); - else - fprintf(screen," output datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - 0,0.0,0,0); - fprintf(screen," output data (MB): %g %g %g %g\n", - 1.0*size_out_all/mbytes,1.0*size_out_all/nprocs/mbytes, - 1.0*size_out_max/mbytes,1.0*size_out_min/mbytes); - fprintf(screen," input rvous datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_inrvous_all/insize,1.0*size_inrvous_all/nprocs/insize, - size_inrvous_max/insize,size_inrvous_min/insize); - fprintf(screen," input rvous data (MB): %g %g %g %g\n", - 1.0*size_inrvous_all/mbytes,1.0*size_inrvous_all/nprocs/mbytes, - 1.0*size_inrvous_max/mbytes,1.0*size_inrvous_min/mbytes); - if (outsize) - fprintf(screen," output rvous datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - size_outrvous_all/outsize,1.0*size_outrvous_all/nprocs/outsize, - size_outrvous_max/outsize,size_outrvous_min/outsize); - else - fprintf(screen," output rvous datum count: " - BIGINT_FORMAT " %g " BIGINT_FORMAT " " BIGINT_FORMAT "\n", - 0,0.0,0,0); - fprintf(screen," output rvous data (MB): %g %g %g %g\n", - 1.0*size_outrvous_all/mbytes,1.0*size_outrvous_all/nprocs/mbytes, - 1.0*size_outrvous_max/mbytes,1.0*size_outrvous_min/mbytes); - fprintf(screen," rvous comm (MB): %g %g %g %g\n", - 1.0*size_comm_all/mbytes,1.0*size_comm_all/nprocs/mbytes, - 1.0*size_comm_max/mbytes,1.0*size_comm_min/mbytes); - } - } -} - /* ---------------------------------------------------------------------- proc 0 reads Nlines from file into buf and bcasts buf to all procs caller allocates buf to max size needed diff --git a/src/comm.h b/src/comm.h index 9c0112b4c4..2579f9b283 100644 --- a/src/comm.h +++ b/src/comm.h @@ -109,10 +109,6 @@ class Comm : protected Pointers { void ring(int, int, void *, int, void (*)(int, char *, void *), void *, void *, int self = 1); - int rendezvous(int, int, char *, int, int, int *, - int (*)(int, char *, int &, int *&, char *&, void *), - int, char *&, int, void *, int statflag=0); - int read_lines_from_file(FILE *, int, int, char *); int read_lines_from_file_universe(FILE *, int, int, char *); @@ -146,15 +142,6 @@ class Comm : protected Pointers { int ncores; // # of cores per node int coregrid[3]; // 3d grid of cores within a node int user_coregrid[3]; // user request for cores in each dim - - int rendezvous_irregular(int, char *, int, int, int *, - int (*)(int, char *, int &, int *&, char *&, void *), - int, char *&, int, void *, int); - int rendezvous_all2all(int, char *, int, int, int *, - int (*)(int, char *, int &, int *&, char *&, void *), - int, char *&, int, void *, int); - void rendezvous_stats(int, int, int, int, int, int, bigint); - public: enum{MULTIPLE}; }; diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 52e4256fca..cb0da42970 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -514,6 +514,9 @@ void CreateAtoms::command(int narg, char **arg) if (domain->triclinic) domain->lamda2x(atom->nlocal); } + MPI_Barrier(world); + double time2 = MPI_Wtime(); + // clean up delete ranmol; @@ -523,6 +526,21 @@ void CreateAtoms::command(int narg, char **arg) delete [] ystr; delete [] zstr; + // print status + + if (comm->me == 0) { + if (screen) { + fprintf(screen,"Created " BIGINT_FORMAT " atoms\n", + atom->natoms-natoms_previous); + fprintf(screen," Time spent = %g secs\n",time2-time1); + } + if (logfile) { + fprintf(logfile,"Created " BIGINT_FORMAT " atoms\n", + atom->natoms-natoms_previous); + fprintf(logfile," Time spent = %g secs\n",time2-time1); + } + } + // for MOLECULE mode: // create special bond lists for molecular systems, // but not for atom style template @@ -532,25 +550,6 @@ void CreateAtoms::command(int narg, char **arg) if (atom->molecular == 1 && onemol->bondflag && !onemol->specialflag) { Special special(lmp); special.build(); - - } - } - - // print status - - MPI_Barrier(world); - double time2 = MPI_Wtime(); - - if (comm->me == 0) { - if (screen) { - fprintf(screen,"Created " BIGINT_FORMAT " atoms\n", - atom->natoms-natoms_previous); - fprintf(screen," create_atoms CPU = %g secs\n",time2-time1); - } - if (logfile) { - fprintf(logfile,"Created " BIGINT_FORMAT " atoms\n", - atom->natoms-natoms_previous); - fprintf(logfile," create_atoms CPU = %g secs\n",time2-time1); } } } diff --git a/src/hashlittle.cpp b/src/hashlittle.cpp deleted file mode 100644 index f1d4e61142..0000000000 --- a/src/hashlittle.cpp +++ /dev/null @@ -1,349 +0,0 @@ -// Hash function hashlittle() -// from lookup3.c, by Bob Jenkins, May 2006, Public Domain -// bob_jenkins@burtleburtle.net - -#include -#include -#include - -// if the system defines the __BYTE_ORDER__ define, -// we use it instead of guessing the platform - -#if defined(__BYTE_ORDER__) -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define HASH_LITTLE_ENDIAN 1 -# else -# define HASH_LITTLE_ENDIAN 0 -# endif -#else // heuristic platform guess -# if defined(__bg__) -# define HASH_LITTLE_ENDIAN 0 // IBM BlueGene is big endian -# else -# define HASH_LITTLE_ENDIAN 1 // Intel and AMD x86 are little endian -# endif -#endif - -#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) - -/* -------------------------------------------------------------------------------- -mix -- mix 3 32-bit values reversibly. - -This is reversible, so any information in (a,b,c) before mix() is -still in (a,b,c) after mix(). - -If four pairs of (a,b,c) inputs are run through mix(), or through -mix() in reverse, there are at least 32 bits of the output that -are sometimes the same for one pair and different for another pair. -This was tested for: -* pairs that differed by one bit, by two bits, in any combination - of top bits of (a,b,c), or in any combination of bottom bits of - (a,b,c). -* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed - the output delta to a Gray code (a^(a>>1)) so a string of 1's (as - is commonly produced by subtraction) look like a single 1-bit - difference. -* the base values were pseudorandom, all zero but one bit set, or - all zero plus a counter that starts at zero. - -Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that -satisfy this are - 4 6 8 16 19 4 - 9 15 3 18 27 15 - 14 9 3 7 17 3 -Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing -for "differ" defined as + with a one-bit base and a two-bit delta. I -used http://burtleburtle.net/bob/hash/avalanche.html to choose -the operations, constants, and arrangements of the variables. - -This does not achieve avalanche. There are input bits of (a,b,c) -that fail to affect some output bits of (a,b,c), especially of a. The -most thoroughly mixed value is c, but it doesn't really even achieve -avalanche in c. - -This allows some parallelism. Read-after-writes are good at doubling -the number of bits affected, so the goal of mixing pulls in the opposite -direction as the goal of parallelism. I did what I could. Rotates -seem to cost as much as shifts on every machine I could lay my hands -on, and rotates are much kinder to the top and bottom bits, so I used -rotates. -------------------------------------------------------------------------------- -*/ -#define mix(a,b,c) \ -{ \ - a -= c; a ^= rot(c, 4); c += b; \ - b -= a; b ^= rot(a, 6); a += c; \ - c -= b; c ^= rot(b, 8); b += a; \ - a -= c; a ^= rot(c,16); c += b; \ - b -= a; b ^= rot(a,19); a += c; \ - c -= b; c ^= rot(b, 4); b += a; \ -} - -/* -------------------------------------------------------------------------------- -final -- final mixing of 3 32-bit values (a,b,c) into c - -Pairs of (a,b,c) values differing in only a few bits will usually -produce values of c that look totally different. This was tested for -* pairs that differed by one bit, by two bits, in any combination - of top bits of (a,b,c), or in any combination of bottom bits of - (a,b,c). -* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed - the output delta to a Gray code (a^(a>>1)) so a string of 1's (as - is commonly produced by subtraction) look like a single 1-bit - difference. -* the base values were pseudorandom, all zero but one bit set, or - all zero plus a counter that starts at zero. - -These constants passed: - 14 11 25 16 4 14 24 - 12 14 25 16 4 14 24 -and these came close: - 4 8 15 26 3 22 24 - 10 8 15 26 3 22 24 - 11 8 15 26 3 22 24 -------------------------------------------------------------------------------- -*/ -#define final(a,b,c) \ -{ \ - c ^= b; c -= rot(b,14); \ - a ^= c; a -= rot(c,11); \ - b ^= a; b -= rot(a,25); \ - c ^= b; c -= rot(b,16); \ - a ^= c; a -= rot(c,4); \ - b ^= a; b -= rot(a,14); \ - c ^= b; c -= rot(b,24); \ -} - -/* -------------------------------------------------------------------------------- -hashlittle() -- hash a variable-length key into a 32-bit value - k : the key (the unaligned variable-length array of bytes) - length : the length of the key, counting by bytes - initval : can be any 4-byte value -Returns a 32-bit value. Every bit of the key affects every bit of -the return value. Two keys differing by one or two bits will have -totally different hash values. - -The best hash table sizes are powers of 2. There is no need to do -mod a prime (mod is sooo slow!). If you need less than 32 bits, -use a bitmask. For example, if you need only 10 bits, do - h = (h & hashmask(10)); -In which case, the hash table should have hashsize(10) elements. - -If you are hashing n strings (uint8_t **)k, do it like this: - for (i=0, h=0; i 12) - { - a += k[0]; - b += k[1]; - c += k[2]; - mix(a,b,c); - length -= 12; - k += 3; - } - - /*----------------------------- handle the last (probably partial) block */ - /* - * "k[2]&0xffffff" actually reads beyond the end of the string, but - * then masks off the part it's not allowed to read. Because the - * string is aligned, the masked-off tail is in the same word as the - * rest of the string. Every machine with memory protection I've seen - * does it on word boundaries, so is OK with this. But VALGRIND will - * still catch it and complain. The masking trick does make the hash - * noticably faster for short strings (like English words). - */ -#ifndef VALGRIND - - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; - case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; - case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=k[1]&0xffffff; a+=k[0]; break; - case 6 : b+=k[1]&0xffff; a+=k[0]; break; - case 5 : b+=k[1]&0xff; a+=k[0]; break; - case 4 : a+=k[0]; break; - case 3 : a+=k[0]&0xffffff; break; - case 2 : a+=k[0]&0xffff; break; - case 1 : a+=k[0]&0xff; break; - case 0 : return c; /* zero length strings require no mixing */ - } - -#else /* make valgrind happy */ - - k8 = (const uint8_t *)k; - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ - case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ - case 9 : c+=k8[8]; /* fall through */ - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ - case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ - case 5 : b+=k8[4]; /* fall through */ - case 4 : a+=k[0]; break; - case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ - case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ - case 1 : a+=k8[0]; break; - case 0 : return c; - } - -#endif /* !valgrind */ - - } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { - const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ - const uint8_t *k8; - - /*--------------- all but last block: aligned reads and different mixing */ - while (length > 12) - { - a += k[0] + (((uint32_t)k[1])<<16); - b += k[2] + (((uint32_t)k[3])<<16); - c += k[4] + (((uint32_t)k[5])<<16); - mix(a,b,c); - length -= 12; - k += 6; - } - - /*----------------------------- handle the last (probably partial) block */ - k8 = (const uint8_t *)k; - switch(length) - { - case 12: c+=k[4]+(((uint32_t)k[5])<<16); - b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ - case 10: c+=k[4]; - b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 9 : c+=k8[8]; /* fall through */ - case 8 : b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ - case 6 : b+=k[2]; - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 5 : b+=k8[4]; /* fall through */ - case 4 : a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ - case 2 : a+=k[0]; - break; - case 1 : a+=k8[0]; - break; - case 0 : return c; /* zero length requires no mixing */ - } - - } else { /* need to read the key one byte at a time */ - const uint8_t *k = (const uint8_t *)key; - - /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - a += ((uint32_t)k[1])<<8; - a += ((uint32_t)k[2])<<16; - a += ((uint32_t)k[3])<<24; - b += k[4]; - b += ((uint32_t)k[5])<<8; - b += ((uint32_t)k[6])<<16; - b += ((uint32_t)k[7])<<24; - c += k[8]; - c += ((uint32_t)k[9])<<8; - c += ((uint32_t)k[10])<<16; - c += ((uint32_t)k[11])<<24; - mix(a,b,c); - length -= 12; - k += 12; - } - - /*-------------------------------- last block: affect all 32 bits of (c) */ - switch(length) /* all the case statements fall through */ - { - case 12: c+=((uint32_t)k[11])<<24; - case 11: c+=((uint32_t)k[10])<<16; - case 10: c+=((uint32_t)k[9])<<8; - case 9 : c+=k[8]; - case 8 : b+=((uint32_t)k[7])<<24; - case 7 : b+=((uint32_t)k[6])<<16; - case 6 : b+=((uint32_t)k[5])<<8; - case 5 : b+=k[4]; - case 4 : a+=((uint32_t)k[3])<<24; - case 3 : a+=((uint32_t)k[2])<<16; - case 2 : a+=((uint32_t)k[1])<<8; - case 1 : a+=k[0]; - break; - case 0 : return c; - } - } - - final(a,b,c); - return c; - -#else /* PURIFY_HATES_HASHLITTLE */ -/* I don't know what it is about Jenkins' hashlittle function, but - * it drives purify insane, even with VALGRIND defined. It makes - * purify unusable!! The code execution doesn't even make sense. - * Below is a (probably) weaker hash function that at least allows - * testing with purify. - */ -#define MAXINT_DIV_PHI 11400714819323198485U - - uint32_t h, rest, *p, bytes, num_bytes; - char *byteptr; - - num_bytes = length; - - /* First hash the uint32_t-sized portions of the key */ - h = 0; - for (p = (uint32_t *)key, bytes=num_bytes; - bytes >= (uint32_t) sizeof(uint32_t); - bytes-=sizeof(uint32_t), p++){ - h = (h^(*p))*MAXINT_DIV_PHI; - } - - /* Then take care of the remaining bytes, if any */ - rest = 0; - for (byteptr = (char *)p; bytes > 0; bytes--, byteptr++){ - rest = (rest<<8) | (*byteptr); - } - - /* If extra bytes, merge the two parts */ - if (rest) - h = (h^rest)*MAXINT_DIV_PHI; - - return h; -#endif /* PURIFY_HATES_HASHLITTLE */ -} diff --git a/src/hashlittle.h b/src/hashlittle.h deleted file mode 100644 index 7b57a35c80..0000000000 --- a/src/hashlittle.h +++ /dev/null @@ -1,5 +0,0 @@ -// Hash function hashlittle() -// from lookup3.c, by Bob Jenkins, May 2006, Public Domain -// bob_jenkins@burtleburtle.net - -uint32_t hashlittle(const void *key, size_t length, uint32_t); diff --git a/src/irregular.cpp b/src/irregular.cpp index c27a8c8e18..9c15f135d0 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -501,8 +501,7 @@ int compare_standalone(const int i, const int j, void *ptr) void Irregular::exchange_atom(double *sendbuf, int *sizes, double *recvbuf) { - int i,m,n,count; - bigint offset; + int i,m,n,offset,count; // post all receives @@ -622,7 +621,6 @@ int Irregular::create_data(int n, int *proclist, int sortflag) num_send = new int[nsend_proc]; index_send = new int[n-work1[me]]; index_self = new int[work1[me]]; - maxindex = n; // proc_send = procs I send to // num_send = # of datums I send to each proc @@ -680,182 +678,8 @@ int Irregular::create_data(int n, int *proclist, int sortflag) // receive incoming messages // proc_recv = procs I recv from - // num_recv = # of datums each proc sends me - // nrecvdatum = total # of datums I recv - - int nrecvdatum = 0; - for (i = 0; i < nrecv_proc; i++) { - MPI_Recv(&num_recv[i],1,MPI_INT,MPI_ANY_SOURCE,0,world,status); - proc_recv[i] = status->MPI_SOURCE; - nrecvdatum += num_recv[i]; - } - nrecvdatum += num_self; - - // sort proc_recv and num_recv by proc ID if requested - // useful for debugging to insure reproducible ordering of received datums - - if (sortflag) { - int *order = new int[nrecv_proc]; - int *proc_recv_ordered = new int[nrecv_proc]; - int *num_recv_ordered = new int[nrecv_proc]; - - for (i = 0; i < nrecv_proc; i++) order[i] = i; - -#if defined(LMP_QSORT) - proc_recv_copy = proc_recv; - qsort(order,nrecv_proc,sizeof(int),compare_standalone); -#else - merge_sort(order,nrecv_proc,(void *)proc_recv,compare_standalone); -#endif - - int j; - for (i = 0; i < nrecv_proc; i++) { - j = order[i]; - proc_recv_ordered[i] = proc_recv[j]; - num_recv_ordered[i] = num_recv[j]; - } - - memcpy(proc_recv,proc_recv_ordered,nrecv_proc*sizeof(int)); - memcpy(num_recv,num_recv_ordered,nrecv_proc*sizeof(int)); - delete [] order; - delete [] proc_recv_ordered; - delete [] num_recv_ordered; - } - - // barrier to insure all MPI_ANY_SOURCE messages are received - // else another proc could proceed to exchange_data() and send to me - - MPI_Barrier(world); - - // return # of datums I will receive - - return nrecvdatum; -} - -/* ---------------------------------------------------------------------- - create communication plan based on list of datums of uniform size - n = # of datums to send - procs = how many datums to send to each proc, must include self - sort = flag for sorting order of received messages by proc ID - return total # of datums I will recv, including any to self -------------------------------------------------------------------------- */ - -int Irregular::create_data_grouped(int n, int *procs, int sortflag) -{ - int i,j,k,m; - - // setup for collective comm - // work1 = # of datums I send to each proc, set self to 0 - // work2 = 1 for all procs, used for ReduceScatter - - for (i = 0; i < nprocs; i++) { - work1[i] = procs[i]; - work2[i] = 1; - } - work1[me] = 0; - - // nrecv_proc = # of procs I receive messages from, not including self - // options for performing ReduceScatter operation - // some are more efficient on some machines at big sizes - -#ifdef LAMMPS_RS_ALLREDUCE_INPLACE - MPI_Allreduce(MPI_IN_PLACE,work1,nprocs,MPI_INT,MPI_SUM,world); - nrecv_proc = work1[me]; -#else -#ifdef LAMMPS_RS_ALLREDUCE - MPI_Allreduce(work1,work2,nprocs,MPI_INT,MPI_SUM,world); - nrecv_proc = work2[me]; -#else - MPI_Reduce_scatter(work1,&nrecv_proc,work2,MPI_INT,MPI_SUM,world); -#endif -#endif - - // allocate receive arrays - - proc_recv = new int[nrecv_proc]; - num_recv = new int[nrecv_proc]; - request = new MPI_Request[nrecv_proc]; - status = new MPI_Status[nrecv_proc]; - - // work1 = # of datums I send to each proc, including self - // nsend_proc = # of procs I send messages to, not including self - - for (i = 0; i < nprocs; i++) work1[i] = procs[i]; - - nsend_proc = 0; - for (i = 0; i < nprocs; i++) - if (work1[i]) nsend_proc++; - if (work1[me]) nsend_proc--; - - // allocate send and self arrays - - proc_send = new int[nsend_proc]; - num_send = new int[nsend_proc]; - index_send = new int[n-work1[me]]; - index_self = new int[work1[me]]; - maxindex = n; - - // proc_send = procs I send to - // num_send = # of datums I send to each proc - // num_self = # of datums I copy to self - // to balance pattern of send messages: - // each proc begins with iproc > me, continues until iproc = me - // reset work1 to store which send message each proc corresponds to - - int iproc = me; - int isend = 0; - for (i = 0; i < nprocs; i++) { - iproc++; - if (iproc == nprocs) iproc = 0; - if (iproc == me) { - num_self = work1[iproc]; - work1[iproc] = 0; - } else if (work1[iproc] > 0) { - proc_send[isend] = iproc; - num_send[isend] = work1[iproc]; - work1[iproc] = isend; - isend++; - } - } - - // work2 = offsets into index_send for each proc I send to - // m = ptr into index_self - // index_send = list of which datums to send to each proc - // 1st N1 values are datum indices for 1st proc, - // next N2 values are datum indices for 2nd proc, etc - // index_self = list of which datums to copy to self - - work2[0] = 0; - for (i = 1; i < nsend_proc; i++) work2[i] = work2[i-1] + num_send[i-1]; - - m = 0; - i = 0; - for (iproc = 0; iproc < nprocs; iproc++) { - k = procs[iproc]; - for (j = 0; j < k; j++) { - if (iproc == me) index_self[m++] = i++; - else { - isend = work1[iproc]; - index_send[work2[isend]++] = i++; - } - } - } - - // tell receivers how much data I send - // sendmax_proc = largest # of datums I send in a single message - - sendmax_proc = 0; - for (i = 0; i < nsend_proc; i++) { - MPI_Request tmpReq; // Use non-blocking send to avoid possible deadlock - MPI_Isend(&num_send[i],1,MPI_INT,proc_send[i],0,world,&tmpReq); - MPI_Request_free(&tmpReq); // the MPI_Barrier below marks completion - sendmax_proc = MAX(sendmax_proc,num_send[i]); - } - - // receive incoming messages - // proc_recv = procs I recv from - // num_recv = # of datums each proc sends me - // nrecvdatum = total # of datums I recv + // num_recv = total size of message each proc sends me + // nrecvdatum = total size of data I recv int nrecvdatum = 0; for (i = 0; i < nrecv_proc; i++) { @@ -915,13 +739,11 @@ int Irregular::create_data_grouped(int n, int *procs, int sortflag) void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf) { - int i,n,count; - bigint m; // these 2 lines enable send/recv buf to be larger than 2 GB - char *dest; + int i,m,n,offset,count; // post all receives, starting after self copies - bigint offset = num_self*nbytes; + offset = num_self*nbytes; for (int irecv = 0; irecv < nrecv_proc; irecv++) { MPI_Irecv(&recvbuf[offset],num_recv[irecv]*nbytes,MPI_CHAR, proc_recv[irecv],0,world,&request[irecv]); @@ -943,34 +765,23 @@ void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf) n = 0; for (int isend = 0; isend < nsend_proc; isend++) { count = num_send[isend]; - dest = buf; for (i = 0; i < count; i++) { m = index_send[n++]; - memcpy(dest,&sendbuf[m*nbytes],nbytes); - dest += nbytes; + memcpy(&buf[i*nbytes],&sendbuf[m*nbytes],nbytes); } MPI_Send(buf,count*nbytes,MPI_CHAR,proc_send[isend],0,world); } // copy datums to self, put at beginning of recvbuf - dest = recvbuf; for (i = 0; i < num_self; i++) { m = index_self[i]; - memcpy(dest,&sendbuf[m*nbytes],nbytes); - dest += nbytes; + memcpy(&recvbuf[i*nbytes],&sendbuf[m*nbytes],nbytes); } // wait on all incoming messages if (nrecv_proc) MPI_Waitall(nrecv_proc,request,status); - - // approximate memory tally - // DEBUG lines - - //bigint irregular_bytes = 2*nprocs*sizeof(int); - //irregular_bytes += maxindex*sizeof(int); - //irregular_bytes += maxbuf; } /* ---------------------------------------------------------------------- diff --git a/src/irregular.h b/src/irregular.h index d56bcb253d..1f74fe801b 100644 --- a/src/irregular.h +++ b/src/irregular.h @@ -33,7 +33,6 @@ class Irregular : protected Pointers { int *procassign = NULL); int migrate_check(); int create_data(int, int *, int sortflag = 0); - int create_data_grouped(int, int *, int sortflag = 0); void exchange_data(char *, int, char *); void destroy_data(); bigint memory_usage(); @@ -49,7 +48,6 @@ class Irregular : protected Pointers { double *dbuf; // double buf for largest single atom send int maxbuf; // size of char buf in bytes char *buf; // char buf for largest single data send - int maxindex; // combined size of index_send + index_self int *mproclist,*msizes; // persistent vectors in migrate_atoms int maxlocal; // allocated size of mproclist and msizes diff --git a/src/read_data.cpp b/src/read_data.cpp index e2efbaaefa..2f4484010b 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -120,9 +120,6 @@ void ReadData::command(int narg, char **arg) { if (narg < 1) error->all(FLERR,"Illegal read_data command"); - MPI_Barrier(world); - double time1 = MPI_Wtime(); - // optional args addflag = NONE; @@ -909,18 +906,6 @@ void ReadData::command(int narg, char **arg) force->kspace = saved_kspace; } - - // total time - - MPI_Barrier(world); - double time2 = MPI_Wtime(); - - if (comm->me == 0) { - if (screen) - fprintf(screen," read_data CPU = %g secs\n",time2-time1); - if (logfile) - fprintf(logfile," read_data CPU = %g secs\n",time2-time1); - } } /* ---------------------------------------------------------------------- diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 5aa4622a67..73dc37f4cb 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -81,9 +81,6 @@ void ReadRestart::command(int narg, char **arg) if (domain->box_exist) error->all(FLERR,"Cannot read_restart after simulation box is defined"); - MPI_Barrier(world); - double time1 = MPI_Wtime(); - MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); @@ -565,18 +562,6 @@ void ReadRestart::command(int narg, char **arg) Special special(lmp); special.build(); } - - // total time - - MPI_Barrier(world); - double time2 = MPI_Wtime(); - - if (comm->me == 0) { - if (screen) - fprintf(screen," read_restart CPU = %g secs\n",time2-time1); - if (logfile) - fprintf(logfile," read_restart CPU = %g secs\n",time2-time1); - } } /* ---------------------------------------------------------------------- diff --git a/src/replicate.cpp b/src/replicate.cpp index 3c8f4a8aee..cdadf1fd1f 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -76,7 +76,7 @@ void Replicate::command(int narg, char **arg) if (atom->nextra_grow || atom->nextra_restart || atom->nextra_store) error->all(FLERR,"Cannot replicate with fixes that store atom quantities"); - // record wall time for atom replication + // Record wall time for atom replication MPI_Barrier(world); double time1 = MPI_Wtime(); @@ -762,15 +762,15 @@ void Replicate::command(int narg, char **arg) special.build(); } - // total time + // Wall time MPI_Barrier(world); double time2 = MPI_Wtime(); if (me == 0) { if (screen) - fprintf(screen," replicate CPU = %g secs\n",time2-time1); + fprintf(screen," Time spent = %g secs\n",time2-time1); if (logfile) - fprintf(logfile," replicate CPU = %g secs\n",time2-time1); + fprintf(logfile," Time spent = %g secs\n",time2-time1); } } diff --git a/src/special.cpp b/src/special.cpp index b9287df472..fccc930353 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -21,14 +21,12 @@ #include "modify.h" #include "fix.h" #include "accelerator_kokkos.h" -#include "atom_masks.h" #include "memory.h" #include "error.h" +#include "atom_masks.h" using namespace LAMMPS_NS; -#define RVOUS 1 // 0 for irregular, 1 for all2all - /* ---------------------------------------------------------------------- */ Special::Special(LAMMPS *lmp) : Pointers(lmp) @@ -56,8 +54,18 @@ Special::~Special() void Special::build() { + int i,j,k,size; + int max,maxall,nbuf; + tagint *buf; + MPI_Barrier(world); - double time1 = MPI_Wtime(); + + int nlocal = atom->nlocal; + + tagint *tag = atom->tag; + int *num_bond = atom->num_bond; + tagint **bond_atom = atom->bond_atom; + int **nspecial = atom->nspecial; if (me == 0 && screen) { const double * const special_lj = force->special_lj; @@ -71,57 +79,224 @@ void Special::build() // initialize nspecial counters to 0 - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { + for (i = 0; i < nlocal; i++) { nspecial[i][0] = 0; nspecial[i][1] = 0; nspecial[i][2] = 0; } - // setup atomIDs and procowner vectors in rendezvous decomposition + // ----------------------------------------------------- + // compute nspecial[i][0] = # of 1-2 neighbors of atom i + // ----------------------------------------------------- - atom_owners(); + // bond partners stored by atom itself - // tally nspecial[i][0] = # of 1-2 neighbors of atom i + for (i = 0; i < nlocal; i++) nspecial[i][0] = num_bond[i]; + + // if newton_bond off, then done + // else only counted 1/2 of all bonds, so count other half + + if (force->newton_bond) { + + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = global tag of 2nd atom in each bond + + nbuf = 0; + for (i = 0; i < nlocal; i++) nbuf += num_bond[i]; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with global tags of bond partners of my atoms + + size = 0; + for (i = 0; i < nlocal; i++) + for (j = 0; j < num_bond[i]; j++) + buf[size++] = bond_atom[i][j]; + + // cycle buffer around ring of procs back to self + // when receive buffer, scan tags for atoms I own + // when find one, increment nspecial count for that atom + + comm->ring(size,sizeof(tagint),buf,1,ring_one,NULL,(void *)this); + + memory->destroy(buf); + } + + // ---------------------------------------------------- // create onetwo[i] = list of 1-2 neighbors for atom i + // ---------------------------------------------------- - if (force->newton_bond) onetwo_build_newton(); - else onetwo_build_newton_off(); + max = 0; + for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][0]); - // print max # of 1-2 neighbors + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-2 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-2 neighbors\n",maxall); } + memory->create(onetwo,nlocal,maxall,"special:onetwo"); + + // count = accumulating counter + + memory->create(count,nlocal,"special:count"); + for (i = 0; i < nlocal; i++) count[i] = 0; + + // add bond partners stored by atom to onetwo list + + for (i = 0; i < nlocal; i++) + for (j = 0; j < num_bond[i]; j++) + onetwo[i][count[i]++] = bond_atom[i][j]; + + // if newton_bond off, then done + // else only stored 1/2 of all bonds, so store other half + + if (force->newton_bond) { + + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = 2 global tags in each bond + + nbuf = 0; + for (i = 0; i < nlocal; i++) nbuf += 2*num_bond[i]; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with global tags of both atoms in bond + + size = 0; + for (i = 0; i < nlocal; i++) + for (j = 0; j < num_bond[i]; j++) { + buf[size++] = tag[i]; + buf[size++] = bond_atom[i][j]; + } + + // cycle buffer around ring of procs back to self + // when receive buffer, scan 2nd-atom tags for atoms I own + // when find one, add 1st-atom tag to onetwo list for 2nd atom + + comm->ring(size,sizeof(tagint),buf,2,ring_two,NULL,(void *)this); + + memory->destroy(buf); + } + + memory->destroy(count); + + // ----------------------------------------------------- // done if special_bond weights for 1-3, 1-4 are set to 1.0 + // ----------------------------------------------------- if (force->special_lj[2] == 1.0 && force->special_coul[2] == 1.0 && force->special_lj[3] == 1.0 && force->special_coul[3] == 1.0) { dedup(); combine(); fix_alteration(); - memory->destroy(procowner); - memory->destroy(atomIDs); - timer_output(time1); return; } - // tally nspecial[i][1] = # of 1-3 neighbors of atom i + // ----------------------------------------------------- + // compute nspecial[i][1] = # of 1-3 neighbors of atom i + // ----------------------------------------------------- + + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = 2 scalars + list of 1-2 neighbors + + nbuf = 0; + for (i = 0; i < nlocal; i++) nbuf += 2 + nspecial[i][0]; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with: + // (1) = counter for 1-3 neighbors, initialized to 0 + // (2) = # of 1-2 neighbors + // (3:N) = list of 1-2 neighbors + + size = 0; + for (i = 0; i < nlocal; i++) { + buf[size++] = 0; + buf[size++] = nspecial[i][0]; + for (j = 0; j < nspecial[i][0]; j++) buf[size++] = onetwo[i][j]; + } + + // cycle buffer around ring of procs back to self + // when receive buffer, scan list of 1-2 neighbors for atoms I own + // when find one, increment 1-3 count by # of 1-2 neighbors of my atom, + // subtracting one since my list will contain original atom + + comm->ring(size,sizeof(tagint),buf,3,ring_three,buf,(void *)this); + + // extract count from buffer that has cycled back to me + // nspecial[i][1] = # of 1-3 neighbors of atom i + + j = 0; + for (i = 0; i < nlocal; i++) { + nspecial[i][1] = buf[j]; + j += 2 + nspecial[i][0]; + } + + memory->destroy(buf); + + // ---------------------------------------------------- // create onethree[i] = list of 1-3 neighbors for atom i + // ---------------------------------------------------- - onethree_build(); - - // print max # of 1-3 neighbors + max = 0; + for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][1]); + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-3 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-3 neighbors\n",maxall); } + memory->create(onethree,nlocal,maxall,"special:onethree"); + + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = 4 scalars + list of 1-2 neighs + list of 1-3 neighs + + nbuf = 0; + for (i = 0; i < nlocal; i++) nbuf += 4 + nspecial[i][0] + nspecial[i][1]; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with: + // (1) = global tag of original atom + // (2) = # of 1-2 neighbors + // (3) = # of 1-3 neighbors + // (4) = counter for 1-3 neighbors, initialized to 0 + // (5:N) = list of 1-2 neighbors + // (N+1:2N) space for list of 1-3 neighbors + + size = 0; + for (i = 0; i < nlocal; i++) { + buf[size++] = tag[i]; + buf[size++] = nspecial[i][0]; + buf[size++] = nspecial[i][1]; + buf[size++] = 0; + for (j = 0; j < nspecial[i][0]; j++) buf[size++] = onetwo[i][j]; + size += nspecial[i][1]; + } + + // cycle buffer around ring of procs back to self + // when receive buffer, scan list of 1-2 neighbors for atoms I own + // when find one, add its neighbors to 1-3 list + // increment the count in buf(i+4) + // exclude the atom whose tag = original + // this process may include duplicates but they will be culled later + + comm->ring(size,sizeof(tagint),buf,4,ring_four,buf,(void *)this); + + // fill onethree with buffer values that have been returned to me + // sanity check: accumulated buf[i+3] count should equal + // nspecial[i][1] for each atom + + j = 0; + for (i = 0; i < nlocal; i++) { + if (buf[j+3] != nspecial[i][1]) + error->one(FLERR,"1-3 bond count is inconsistent"); + j += 4 + nspecial[i][0]; + for (k = 0; k < nspecial[i][1]; k++) + onethree[i][k] = buf[j++]; + } + + memory->destroy(buf); + // done if special_bond weights for 1-4 are set to 1.0 if (force->special_lj[3] == 1.0 && force->special_coul[3] == 1.0) { @@ -129,410 +304,117 @@ void Special::build() if (force->special_angle) angle_trim(); combine(); fix_alteration(); - memory->destroy(procowner); - memory->destroy(atomIDs); - timer_output(time1); return; } - // tally nspecial[i][2] = # of 1-4 neighbors of atom i + // ----------------------------------------------------- + // compute nspecial[i][2] = # of 1-4 neighbors of atom i + // ----------------------------------------------------- + + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = 2 scalars + list of 1-3 neighbors + + nbuf = 0; + for (i = 0; i < nlocal; i++) nbuf += 2 + nspecial[i][1]; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with: + // (1) = counter for 1-4 neighbors, initialized to 0 + // (2) = # of 1-3 neighbors + // (3:N) = list of 1-3 neighbors + + size = 0; + for (i = 0; i < nlocal; i++) { + buf[size++] = 0; + buf[size++] = nspecial[i][1]; + for (j = 0; j < nspecial[i][1]; j++) buf[size++] = onethree[i][j]; + } + + // cycle buffer around ring of procs back to self + // when receive buffer, scan list of 1-3 neighbors for atoms I own + // when find one, increment 1-4 count by # of 1-2 neighbors of my atom + // may include duplicates and original atom but they will be culled later + + comm->ring(size,sizeof(tagint),buf,5,ring_five,buf,(void *)this); + + // extract count from buffer that has cycled back to me + // nspecial[i][2] = # of 1-4 neighbors of atom i + + j = 0; + for (i = 0; i < nlocal; i++) { + nspecial[i][2] = buf[j]; + j += 2 + nspecial[i][1]; + } + + memory->destroy(buf); + + // ---------------------------------------------------- // create onefour[i] = list of 1-4 neighbors for atom i + // ---------------------------------------------------- - onefour_build(); - - // print max # of 1-4 neighbors + max = 0; + for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][2]); + MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); if (me == 0) { if (screen) fprintf(screen," %d = max # of 1-4 neighbors\n",maxall); if (logfile) fprintf(logfile," %d = max # of 1-4 neighbors\n",maxall); } - // finish processing the onetwo, onethree, onefour lists + memory->create(onefour,nlocal,maxall,"special:onefour"); + + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = 3 scalars + list of 1-3 neighs + list of 1-4 neighs + + nbuf = 0; + for (i = 0; i < nlocal; i++) + nbuf += 3 + nspecial[i][1] + nspecial[i][2]; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with: + // (1) = # of 1-3 neighbors + // (2) = # of 1-4 neighbors + // (3) = counter for 1-4 neighbors, initialized to 0 + // (4:N) = list of 1-3 neighbors + // (N+1:2N) space for list of 1-4 neighbors + + size = 0; + for (i = 0; i < nlocal; i++) { + buf[size++] = nspecial[i][1]; + buf[size++] = nspecial[i][2]; + buf[size++] = 0; + for (j = 0; j < nspecial[i][1]; j++) buf[size++] = onethree[i][j]; + size += nspecial[i][2]; + } + + // cycle buffer around ring of procs back to self + // when receive buffer, scan list of 1-3 neighbors for atoms I own + // when find one, add its neighbors to 1-4 list + // incrementing the count in buf(i+4) + // this process may include duplicates but they will be culled later + + comm->ring(size,sizeof(tagint),buf,6,ring_six,buf,(void *)this); + + // fill onefour with buffer values that have been returned to me + // sanity check: accumulated buf[i+2] count should equal + // nspecial[i][2] for each atom + + j = 0; + for (i = 0; i < nlocal; i++) { + if (buf[j+2] != nspecial[i][2]) + error->one(FLERR,"1-4 bond count is inconsistent"); + j += 3 + nspecial[i][1]; + for (k = 0; k < nspecial[i][2]; k++) + onefour[i][k] = buf[j++]; + } + + memory->destroy(buf); dedup(); if (force->special_angle) angle_trim(); if (force->special_dihedral) dihedral_trim(); combine(); fix_alteration(); - memory->destroy(procowner); - memory->destroy(atomIDs); - - timer_output(time1); -} - -/* ---------------------------------------------------------------------- - setup atomIDs and procowner -------------------------------------------------------------------------- */ - -void Special::atom_owners() -{ - tagint *tag = atom->tag; - int nlocal = atom->nlocal; - - int *proclist; - memory->create(proclist,nlocal,"special:proclist"); - IDRvous *idbuf = (IDRvous *) - memory->smalloc((bigint) nlocal*sizeof(IDRvous),"special:idbuf"); - - // setup input buf for rendezvous comm - // one datum for each owned atom: datum = owning proc, atomID - // each proc assigned every 1/Pth atom - - for (int i = 0; i < nlocal; i++) { - proclist[i] = tag[i] % nprocs; - idbuf[i].me = me; - idbuf[i].atomID = tag[i]; - } - - // perform rendezvous operation - - char *buf; - comm->rendezvous(RVOUS,nlocal,(char *) idbuf,sizeof(IDRvous),0,proclist, - rendezvous_ids,0,buf,0,(void *) this); - - memory->destroy(proclist); - memory->sfree(idbuf); -} - -/* ---------------------------------------------------------------------- - onetwo build when newton_bond flag on - uses rendezvous comm -------------------------------------------------------------------------- */ - -void Special::onetwo_build_newton() -{ - int i,j,m; - - tagint *tag = atom->tag; - int *num_bond = atom->num_bond; - tagint **bond_atom = atom->bond_atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - // nsend = # of my datums to send - - int nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_bond[i]; j++) { - m = atom->map(bond_atom[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } - } - - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // one datum for each unowned bond partner: bond partner ID, atomID - // owning proc for each datum = bond partner ID % nprocs - - nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_bond[i]; j++) { - m = atom->map(bond_atom[i][j]); - if (m >= 0 && m < nlocal) continue; - proclist[nsend] = bond_atom[i][j] % nprocs; - inbuf[nsend].atomID = bond_atom[i][j]; - inbuf[nsend].partnerID = tag[i]; - nsend++; - } - } - - // perform rendezvous operation - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), - 0,proclist, - rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); - PairRvous *outbuf = (PairRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set nspecial[0] and onetwo for all owned atoms - // based on owned info plus rendezvous output info - // output datums = pairs of atoms that are 1-2 neighbors - - for (i = 0; i < nlocal; i++) { - nspecial[i][0] = num_bond[i]; - for (j = 0; j < num_bond[i]; j++) { - m = atom->map(bond_atom[i][j]); - if (m >= 0 && m < nlocal) nspecial[m][0]++; - } - } - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - nspecial[i][0]++; - } - - int max = 0; - for (i = 0; i < nlocal; i++) - max = MAX(max,nspecial[i][0]); - - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onetwo,nlocal,maxall,"special:onetwo"); - - for (i = 0; i < nlocal; i++) nspecial[i][0] = 0; - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_bond[i]; j++) { - onetwo[i][nspecial[i][0]++] = bond_atom[i][j]; - m = atom->map(bond_atom[i][j]); - if (m >= 0 && m < nlocal) onetwo[m][nspecial[m][0]++] = tag[i]; - } - } - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - onetwo[i][nspecial[i][0]++] = outbuf[m].partnerID; - } - - memory->sfree(outbuf); -} - -/* ---------------------------------------------------------------------- - onetwo build with newton_bond flag off - no need for rendezvous comm -------------------------------------------------------------------------- */ - -void Special::onetwo_build_newton_off() -{ - int i,j; - - int *num_bond = atom->num_bond; - tagint **bond_atom = atom->bond_atom; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - int max = 0; - for (i = 0; i < nlocal; i++) - max = MAX(max,num_bond[i]); - - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onetwo,nlocal,maxall,"special:onetwo"); - - // nsend = # of my datums to send - // include nlocal datums with owner of each atom - - for (i = 0; i < nlocal; i++) { - nspecial[i][0] = num_bond[i]; - for (j = 0; j < num_bond[i]; j++) - onetwo[i][j] = bond_atom[i][j]; - } -} - -/* ---------------------------------------------------------------------- - onethree build - uses rendezvous comm -------------------------------------------------------------------------- */ - -void Special::onethree_build() -{ - int i,j,k,m,proc; - - tagint *tag = atom->tag; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - // nsend = # of my datums to send - - int nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][0]; j++) { - m = atom->map(onetwo[i][j]); - if (m < 0 || m >= nlocal) nsend += nspecial[i][0]-1; - } - } - - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // datums = pairs of onetwo partners where either is unknown - // these pairs are onethree neighbors - // datum = onetwo ID, onetwo ID - // owning proc for each datum = onetwo ID % nprocs - - nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][0]; j++) { - m = atom->map(onetwo[i][j]); - if (m >= 0 && m < nlocal) continue; - proc = onetwo[i][j] % nprocs; - for (k = 0; k < nspecial[i][0]; k++) { - if (j == k) continue; - proclist[nsend] = proc; - inbuf[nsend].atomID = onetwo[i][j]; - inbuf[nsend].partnerID = onetwo[i][k]; - nsend++; - } - } - } - - // perform rendezvous operation - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), - 0,proclist, - rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); - PairRvous *outbuf = (PairRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set nspecial[1] and onethree for all owned atoms - // based on owned info plus rendezvous output info - // output datums = pairs of atoms that are 1-3 neighbors - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][0]; j++) { - m = atom->map(onetwo[i][j]); - if (m >= 0 && m < nlocal) nspecial[m][1] += nspecial[i][0]-1; - } - } - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - nspecial[i][1]++; - } - - int max = 0; - for (i = 0; i < nlocal; i++) - max = MAX(max,nspecial[i][1]); - - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onethree,nlocal,maxall,"special:onethree"); - - for (i = 0; i < nlocal; i++) nspecial[i][1] = 0; - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][0]; j++) { - m = atom->map(onetwo[i][j]); - if (m < 0 || m >= nlocal) continue; - for (k = 0; k < nspecial[i][0]; k++) { - if (j == k) continue; - onethree[m][nspecial[m][1]++] = onetwo[i][k]; - } - } - } - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - onethree[i][nspecial[i][1]++] = outbuf[m].partnerID; - } - - memory->sfree(outbuf); -} - -/* ---------------------------------------------------------------------- - onefour build - uses rendezvous comm -------------------------------------------------------------------------- */ - -void Special::onefour_build() -{ - int i,j,k,m,proc; - - tagint *tag = atom->tag; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - - // nsend = # of my datums to send - - int nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][1]; j++) { - m = atom->map(onethree[i][j]); - if (m < 0 || m >= nlocal) nsend += nspecial[i][0]; - } - } - - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // datums = pairs of onethree and onetwo partners where onethree is unknown - // these pairs are onefour neighbors - // datum = onetwo ID, onetwo ID - // owning proc for each datum = onethree ID % nprocs - - nsend = 0; - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][1]; j++) { - m = atom->map(onethree[i][j]); - if (m >= 0 && m < nlocal) continue; - proc = onethree[i][j] % nprocs; - for (k = 0; k < nspecial[i][0]; k++) { - proclist[nsend] = proc; - inbuf[nsend].atomID = onethree[i][j]; - inbuf[nsend].partnerID = onetwo[i][k]; - nsend++; - } - } - } - - // perform rendezvous operation - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), - 0,proclist, - rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); - PairRvous *outbuf = (PairRvous *) buf; - - memory->destroy(proclist); - memory->sfree(inbuf); - - // set nspecial[2] and onefour for all owned atoms - // based on owned info plus rendezvous output info - // output datums = pairs of atoms that are 1-4 neighbors - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][1]; j++) { - m = atom->map(onethree[i][j]); - if (m >= 0 && m < nlocal) nspecial[m][2] += nspecial[i][0]; - } - } - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - nspecial[i][2]++; - } - - int max = 0; - for (i = 0; i < nlocal; i++) - max = MAX(max,nspecial[i][2]); - - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - memory->create(onefour,nlocal,maxall,"special:onefour"); - - for (i = 0; i < nlocal; i++) nspecial[i][2] = 0; - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < nspecial[i][1]; j++) { - m = atom->map(onethree[i][j]); - if (m < 0 || m >= nlocal) continue; - for (k = 0; k < nspecial[i][0]; k++) { - onefour[m][nspecial[m][2]++] = onetwo[i][k]; - } - } - } - - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - onefour[i][nspecial[i][2]++] = outbuf[m].partnerID; - } - - memory->sfree(outbuf); } /* ---------------------------------------------------------------------- @@ -777,24 +659,21 @@ void Special::combine() trim list of 1-3 neighbors by checking defined angles delete a 1-3 neigh if they are not end atoms of a defined angle and if they are not 1,3 or 2,4 atoms of a defined dihedral - uses rendezvous comm ------------------------------------------------------------------------- */ void Special::angle_trim() { - int i,j,k,m;; + int i,j,m,n; int *num_angle = atom->num_angle; int *num_dihedral = atom->num_dihedral; tagint **angle_atom1 = atom->angle_atom1; - tagint **angle_atom2 = atom->angle_atom2; tagint **angle_atom3 = atom->angle_atom3; tagint **dihedral_atom1 = atom->dihedral_atom1; tagint **dihedral_atom2 = atom->dihedral_atom2; tagint **dihedral_atom3 = atom->dihedral_atom3; tagint **dihedral_atom4 = atom->dihedral_atom4; int **nspecial = atom->nspecial; - tagint *tag = atom->tag; int nlocal = atom->nlocal; // stats on old 1-3 neighbor counts @@ -813,206 +692,73 @@ void Special::angle_trim() " %g = # of 1-3 neighbors before angle trim\n",allcount); } - // if angles or dihedrals are defined - // rendezvous angle 1-3 and dihedral 1-3,2-4 pairs + // if angles or dihedrals are defined, + // flag each 1-3 neigh if it appears in an angle or dihedral if ((num_angle && atom->nangles) || (num_dihedral && atom->ndihedrals)) { - // nsend = # of my datums to send - // latter is only for angles or dihedrlas where I own atom2 (newton bond off) + // dflag = flag for 1-3 neighs of all owned atoms + + int maxcount = 0; + for (i = 0; i < nlocal; i++) maxcount = MAX(maxcount,nspecial[i][1]); + memory->create(dflag,nlocal,maxcount,"special::dflag"); - int nsend = 0; for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_angle[i]; j++) { - if (tag[i] != angle_atom2[i][j]) continue; - m = atom->map(angle_atom1[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(angle_atom3[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - m = atom->map(dihedral_atom1[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(dihedral_atom3[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(dihedral_atom4[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } + n = nspecial[i][1]; + for (j = 0; j < n; j++) dflag[i][j] = 0; } - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = list of 1,3 atoms in each angle stored by atom + // and list of 1,3 and 2,4 atoms in each dihedral stored by atom - // setup input buf to rendezvous comm - // datums = pairs of onetwo partners where either is unknown - // these pairs are onethree neighbors - // datum = onetwo ID, onetwo ID - // owning proc for each datum = onetwo ID % nprocs - - nsend = 0; + int nbuf = 0; for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_angle[i]; j++) { - if (tag[i] != angle_atom2[i][j]) continue; - - m = atom->map(angle_atom1[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = angle_atom1[i][j] % nprocs; - inbuf[nsend].atomID = angle_atom1[i][j]; - inbuf[nsend].partnerID = angle_atom3[i][j]; - nsend++; - } - - m = atom->map(angle_atom3[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = angle_atom3[i][j] % nprocs; - inbuf[nsend].atomID = angle_atom3[i][j]; - inbuf[nsend].partnerID = angle_atom1[i][j]; - nsend++; - } - } - - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - - m = atom->map(dihedral_atom1[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom1[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom1[i][j]; - inbuf[nsend].partnerID = dihedral_atom3[i][j]; - nsend++; - } - - m = atom->map(dihedral_atom3[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom3[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom3[i][j]; - inbuf[nsend].partnerID = dihedral_atom1[i][j]; - nsend++; - } - - m = atom->map(dihedral_atom4[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom4[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom4[i][j]; - inbuf[nsend].partnerID = dihedral_atom2[i][j]; - nsend++; - } - } + if (num_angle && atom->nangles) nbuf += 2*num_angle[i]; + if (num_dihedral && atom->ndihedrals) nbuf += 2*2*num_dihedral[i]; } + int *buf; + memory->create(buf,nbuf,"special:buf"); - // perform rendezvous operation - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), - 0,proclist, - rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); - PairRvous *outbuf = (PairRvous *) buf; + // fill buffer with list of 1,3 atoms in each angle + // and with list of 1,3 and 2,4 atoms in each dihedral - memory->destroy(proclist); - memory->sfree(inbuf); + int size = 0; + if (num_angle && atom->nangles) + for (i = 0; i < nlocal; i++) + for (j = 0; j < num_angle[i]; j++) { + buf[size++] = angle_atom1[i][j]; + buf[size++] = angle_atom3[i][j]; + } - // flag all onethree atoms to keep + if (num_dihedral && atom->ndihedrals) + for (i = 0; i < nlocal; i++) + for (j = 0; j < num_dihedral[i]; j++) { + buf[size++] = dihedral_atom1[i][j]; + buf[size++] = dihedral_atom3[i][j]; + buf[size++] = dihedral_atom2[i][j]; + buf[size++] = dihedral_atom4[i][j]; + } - int max = 0; - for (i = 0; i < nlocal; i++) - max = MAX(max,nspecial[i][1]); - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - - int **flag; - memory->create(flag,nlocal,maxall,"special:flag"); + // cycle buffer around ring of procs back to self + // when receive buffer, scan list of 1,3 atoms looking for atoms I own + // when find one, scan its 1-3 neigh list and mark I,J as in an angle - for (i = 0; i < nlocal; i++) + comm->ring(size,sizeof(tagint),buf,7,ring_seven,NULL,(void *)this); + + // delete 1-3 neighbors if they are not flagged in dflag + + for (i = 0; i < nlocal; i++) { + m = 0; for (j = 0; j < nspecial[i][1]; j++) - flag[i][j] = 0; - - // reset nspecial[1] and onethree for all owned atoms based on output info - // based on owned info plus rendezvous output info - // output datums = pairs of atoms that are 1-3 neighbors - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_angle[i]; j++) { - if (tag[i] != angle_atom2[i][j]) continue; - - m = atom->map(angle_atom1[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == angle_atom3[i][j]) { - flag[m][k] = 1; - break; - } - } - - m = atom->map(angle_atom3[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == angle_atom1[i][j]) { - flag[m][k] = 1; - break; - } - } - } - - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - - m = atom->map(dihedral_atom1[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == dihedral_atom3[i][j]) { - flag[m][k] = 1; - break; - } - } - - m = atom->map(dihedral_atom3[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == dihedral_atom1[i][j]) { - flag[m][k] = 1; - break; - } - } - - m = atom->map(dihedral_atom4[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == dihedral_atom2[i][j]) { - flag[m][k] = 1; - break; - } - } - } + if (dflag[i][j]) onethree[i][m++] = onethree[i][j]; + nspecial[i][1] = m; } - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - for (k = 0; k < nspecial[i][1]; k++) - if (onethree[i][k] == outbuf[m].partnerID) { - flag[i][k] = 1; - break; - } - } - - memory->destroy(outbuf); + // clean up - // use flag values to compress onefour list for each atom - - for (i = 0; i < nlocal; i++) { - j = 0; - while (j < nspecial[i][1]) { - if (flag[i][j] == 0) { - onethree[i][j] = onethree[i][nspecial[i][1]-1]; - flag[i][j] = flag[i][nspecial[i][1]-1]; - nspecial[i][1]--; - } else j++; - } - } - - memory->destroy(flag); + memory->destroy(dflag); + memory->destroy(buf); // if no angles or dihedrals are defined, delete all 1-3 neighs @@ -1037,21 +783,18 @@ void Special::angle_trim() } /* ---------------------------------------------------------------------- - trim list of 1-4 neighbors by checking all defined dihedrals + trim list of 1-4 neighbors by checking defined dihedrals delete a 1-4 neigh if they are not end atoms of a defined dihedral - uses rendezvous comm ------------------------------------------------------------------------- */ void Special::dihedral_trim() { - int i,j,k,m; + int i,j,m,n; int *num_dihedral = atom->num_dihedral; tagint **dihedral_atom1 = atom->dihedral_atom1; - tagint **dihedral_atom2 = atom->dihedral_atom2; tagint **dihedral_atom4 = atom->dihedral_atom4; int **nspecial = atom->nspecial; - tagint *tag = atom->tag; int nlocal = atom->nlocal; // stats on old 1-4 neighbor counts @@ -1070,134 +813,58 @@ void Special::dihedral_trim() " %g = # of 1-4 neighbors before dihedral trim\n",allcount); } - // if dihedrals are defined, rendezvous the dihedral 1-4 pairs + // if dihedrals are defined, flag each 1-4 neigh if it appears in a dihedral if (num_dihedral && atom->ndihedrals) { - // nsend = # of my datums to send + // dflag = flag for 1-4 neighs of all owned atoms + + int maxcount = 0; + for (i = 0; i < nlocal; i++) maxcount = MAX(maxcount,nspecial[i][2]); + memory->create(dflag,nlocal,maxcount,"special::dflag"); - int nsend = 0; for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - m = atom->map(dihedral_atom1[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(dihedral_atom4[i][j]); - if (m < 0 || m >= nlocal) nsend++; - } + n = nspecial[i][2]; + for (j = 0; j < n; j++) dflag[i][j] = 0; } - int *proclist; - memory->create(proclist,nsend,"special:proclist"); - PairRvous *inbuf = (PairRvous *) - memory->smalloc((bigint) nsend*sizeof(PairRvous),"special:inbuf"); - - // setup input buf to rendezvous comm - // datums = pairs of onefour atom IDs in a dihedral defined for my atoms - // only dihedrals where I own atom2 (in case newton_bond off) - // datum = atom1 ID and atom4 ID - // send the datum twice, to owner of atom1 ID and atom4 ID - // owning procs for each datum = atom1 or atom4 ID % nprocs + // nbufmax = largest buffer needed to hold info from any proc + // info for each atom = list of 1,4 atoms in each dihedral stored by atom - nsend = 0; - for (i = 0; i < nlocal; i++) { + int nbuf = 0; + for (i = 0; i < nlocal; i++) nbuf += 2*num_dihedral[i]; + int *buf; + memory->create(buf,nbuf,"special:buf"); + + // fill buffer with list of 1,4 atoms in each dihedral + + int size = 0; + for (i = 0; i < nlocal; i++) for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - - m = atom->map(dihedral_atom1[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom1[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom1[i][j]; - inbuf[nsend].partnerID = dihedral_atom4[i][j]; - nsend++; - } - - m = atom->map(dihedral_atom4[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom4[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom4[i][j]; - inbuf[nsend].partnerID = dihedral_atom1[i][j]; - nsend++; - } + buf[size++] = dihedral_atom1[i][j]; + buf[size++] = dihedral_atom4[i][j]; } - } - // perform rendezvous operation - - char *buf; - int nreturn = comm->rendezvous(RVOUS,nsend,(char *) inbuf,sizeof(PairRvous), - 0,proclist, - rendezvous_pairs,0,buf,sizeof(PairRvous), - (void *) this); - PairRvous *outbuf = (PairRvous *) buf; + // cycle buffer around ring of procs back to self + // when receive buffer, scan list of 1,4 atoms looking for atoms I own + // when find one, scan its 1-4 neigh list and mark I,J as in a dihedral - memory->destroy(proclist); - memory->sfree(inbuf); + comm->ring(size,sizeof(tagint),buf,8,ring_eight,NULL,(void *)this); - // flag all of my onefour IDs to keep + // delete 1-4 neighbors if they are not flagged in dflag - int max = 0; - for (i = 0; i < nlocal; i++) - max = MAX(max,nspecial[i][2]); - MPI_Allreduce(&max,&maxall,1,MPI_INT,MPI_MAX,world); - - int **flag; - memory->create(flag,nlocal,maxall,"special:flag"); - - for (i = 0; i < nlocal; i++) + for (i = 0; i < nlocal; i++) { + m = 0; for (j = 0; j < nspecial[i][2]; j++) - flag[i][j] = 0; - - for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - - m = atom->map(dihedral_atom1[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][2]; k++) - if (onefour[m][k] == dihedral_atom4[i][j]) { - flag[m][k] = 1; - break; - } - } - - m = atom->map(dihedral_atom4[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][2]; k++) - if (onefour[m][k] == dihedral_atom1[i][j]) { - flag[m][k] = 1; - break; - } - } - } + if (dflag[i][j]) onefour[i][m++] = onefour[i][j]; + nspecial[i][2] = m; } - for (m = 0; m < nreturn; m++) { - i = atom->map(outbuf[m].atomID); - for (k = 0; k < nspecial[i][2]; k++) - if (onefour[i][k] == outbuf[m].partnerID) { - flag[i][k] = 1; - break; - } - } + // clean up - memory->destroy(outbuf); + memory->destroy(dflag); + memory->destroy(buf); - // use flag values to compress onefour list for each atom - - for (i = 0; i < nlocal; i++) { - j = 0; - while (j < nspecial[i][2]) { - if (flag[i][j] == 0) { - onefour[i][j] = onefour[i][nspecial[i][2]-1]; - flag[i][j] = flag[i][nspecial[i][2]-1]; - nspecial[i][2]--; - } else j++; - } - } - - memory->destroy(flag); - // if no dihedrals are defined, delete all 1-4 neighs } else { @@ -1221,95 +888,262 @@ void Special::dihedral_trim() } /* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N IDRvous datums - no outbuf + when receive buffer, scan tags for atoms I own + when find one, increment nspecial count for that atom ------------------------------------------------------------------------- */ -int Special::rendezvous_ids(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) -{ - Special *sptr = (Special *) ptr; - Memory *memory = sptr->memory; - - int *procowner; - tagint *atomIDs; - - memory->create(procowner,n,"special:procowner"); - memory->create(atomIDs,n,"special:atomIDs"); - - IDRvous *in = (IDRvous *) inbuf; - - for (int i = 0; i < n; i++) { - procowner[i] = in[i].me; - atomIDs[i] = in[i].atomID; - } - - // store rendezvous data in Special class - - sptr->nrvous = n; - sptr->procowner = procowner; - sptr->atomIDs = atomIDs; - - // flag = 0: no second comm needed in rendezvous - - flag = 0; - return 0; -} - - -/* ---------------------------------------------------------------------- - process data for atoms assigned to me in rendezvous decomposition - inbuf = list of N PairRvous datums - outbuf = same list of N PairRvous datums, routed to different procs -------------------------------------------------------------------------- */ - -int Special::rendezvous_pairs(int n, char *inbuf, - int &flag, int *&proclist, char *&outbuf, - void *ptr) +void Special::ring_one(int ndatum, char *cbuf, void *ptr) { Special *sptr = (Special *) ptr; Atom *atom = sptr->atom; - Memory *memory = sptr->memory; - - // clear atom map so it can be used here as a hash table - // faster than an STL map for large atom counts - - atom->map_clear(); - - // hash atom IDs stored in rendezvous decomposition - - int nrvous = sptr->nrvous; - tagint *atomIDs = sptr->atomIDs; - - for (int i = 0; i < nrvous; i++) - atom->map_one(atomIDs[i],i); - - // proclist = owner of atomID in caller decomposition - - PairRvous *in = (PairRvous *) inbuf; - int *procowner = sptr->procowner; - memory->create(proclist,n,"special:proclist"); + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + tagint *buf = (tagint *) cbuf; int m; - for (int i = 0; i < n; i++) { - m = atom->map(in[i].atomID); - proclist[i] = procowner[m]; + + for (int i = 0; i < ndatum; i++) { + m = atom->map(buf[i]); + if (m >= 0 && m < nlocal) nspecial[m][0]++; } +} - outbuf = inbuf; - - // re-create atom map +/* ---------------------------------------------------------------------- + when receive buffer, scan 2nd-atom tags for atoms I own + when find one, add 1st-atom tag to onetwo list for 2nd atom +------------------------------------------------------------------------- */ - atom->map_init(0); - atom->nghost = 0; - atom->map_set(); +void Special::ring_two(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int nlocal = atom->nlocal; - // flag = 1: outbuf = inbuf - - flag = 1; - return n; + tagint **onetwo = sptr->onetwo; + int *count = sptr->count; + + tagint *buf = (tagint *) cbuf; + int m; + + for (int i = 1; i < ndatum; i += 2) { + m = atom->map(buf[i]); + if (m >= 0 && m < nlocal) onetwo[m][count[m]++] = buf[i-1]; + } +} + +/* ---------------------------------------------------------------------- + when receive buffer, scan list of 1-2 neighbors for atoms I own + when find one, increment 1-3 count by # of 1-2 neighbors of my atom, + subtracting one since my list will contain original atom +------------------------------------------------------------------------- */ + +void Special::ring_three(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + tagint *buf = (tagint *) cbuf; + int i,j,m,n,num12; + + i = 0; + while (i < ndatum) { + n = buf[i]; + num12 = buf[i+1]; + for (j = 0; j < num12; j++) { + m = atom->map(buf[i+2+j]); + if (m >= 0 && m < nlocal) + n += nspecial[m][0] - 1; + } + buf[i] = n; + i += 2 + num12; + } +} + +/* ---------------------------------------------------------------------- + when receive buffer, scan list of 1-2 neighbors for atoms I own + when find one, add its neighbors to 1-3 list + increment the count in buf(i+4) + exclude the atom whose tag = original + this process may include duplicates but they will be culled later +------------------------------------------------------------------------- */ + +void Special::ring_four(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + tagint **onetwo = sptr->onetwo; + + tagint *buf = (tagint *) cbuf; + tagint original; + int i,j,k,m,n,num12,num13; + + i = 0; + while (i < ndatum) { + original = buf[i]; + num12 = buf[i+1]; + num13 = buf[i+2]; + n = buf[i+3]; + for (j = 0; j < num12; j++) { + m = atom->map(buf[i+4+j]); + if (m >= 0 && m < nlocal) + for (k = 0; k < nspecial[m][0]; k++) + if (onetwo[m][k] != original) + buf[i+4+num12+(n++)] = onetwo[m][k]; + } + buf[i+3] = n; + i += 4 + num12 + num13; + } +} + +/* ---------------------------------------------------------------------- + when receive buffer, scan list of 1-3 neighbors for atoms I own + when find one, increment 1-4 count by # of 1-2 neighbors of my atom + may include duplicates and original atom but they will be culled later +------------------------------------------------------------------------- */ + +void Special::ring_five(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + tagint *buf = (tagint *) cbuf; + int i,j,m,n,num13; + + i = 0; + while (i < ndatum) { + n = buf[i]; + num13 = buf[i+1]; + for (j = 0; j < num13; j++) { + m = atom->map(buf[i+2+j]); + if (m >= 0 && m < nlocal) n += nspecial[m][0]; + } + buf[i] = n; + i += 2 + num13; + } +} + +/* ---------------------------------------------------------------------- + when receive buffer, scan list of 1-3 neighbors for atoms I own + when find one, add its neighbors to 1-4 list + incrementing the count in buf(i+4) + this process may include duplicates but they will be culled later +------------------------------------------------------------------------- */ + +void Special::ring_six(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + tagint **onetwo = sptr->onetwo; + + tagint *buf = (tagint *) cbuf; + int i,j,k,m,n,num13,num14; + + i = 0; + while (i < ndatum) { + num13 = buf[i]; + num14 = buf[i+1]; + n = buf[i+2]; + for (j = 0; j < num13; j++) { + m = atom->map(buf[i+3+j]); + if (m >= 0 && m < nlocal) + for (k = 0; k < nspecial[m][0]; k++) + buf[i+3+num13+(n++)] = onetwo[m][k]; + } + buf[i+2] = n; + i += 3 + num13 + num14; + } +} + +/* ---------------------------------------------------------------------- + when receive buffer, scan list of 1,3 atoms looking for atoms I own + when find one, scan its 1-3 neigh list and mark I,J as in an angle +------------------------------------------------------------------------- */ + +void Special::ring_seven(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + tagint **onethree = sptr->onethree; + int **dflag = sptr->dflag; + + tagint *buf = (tagint *) cbuf; + tagint iglobal,jglobal; + int i,m,ilocal,jlocal; + + i = 0; + while (i < ndatum) { + iglobal = buf[i]; + jglobal = buf[i+1]; + ilocal = atom->map(iglobal); + jlocal = atom->map(jglobal); + if (ilocal >= 0 && ilocal < nlocal) + for (m = 0; m < nspecial[ilocal][1]; m++) + if (jglobal == onethree[ilocal][m]) { + dflag[ilocal][m] = 1; + break; + } + if (jlocal >= 0 && jlocal < nlocal) + for (m = 0; m < nspecial[jlocal][1]; m++) + if (iglobal == onethree[jlocal][m]) { + dflag[jlocal][m] = 1; + break; + } + i += 2; + } +} + +/* ---------------------------------------------------------------------- + when receive buffer, scan list of 1,4 atoms looking for atoms I own + when find one, scan its 1-4 neigh list and mark I,J as in a dihedral +------------------------------------------------------------------------- */ + +void Special::ring_eight(int ndatum, char *cbuf, void *ptr) +{ + Special *sptr = (Special *) ptr; + Atom *atom = sptr->atom; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + + tagint **onefour = sptr->onefour; + int **dflag = sptr->dflag; + + tagint *buf = (tagint *) cbuf; + tagint iglobal,jglobal; + int i,m,ilocal,jlocal; + + i = 0; + while (i < ndatum) { + iglobal = buf[i]; + jglobal = buf[i+1]; + ilocal = atom->map(iglobal); + jlocal = atom->map(jglobal); + if (ilocal >= 0 && ilocal < nlocal) + for (m = 0; m < nspecial[ilocal][2]; m++) + if (jglobal == onefour[ilocal][m]) { + dflag[ilocal][m] = 1; + break; + } + if (jlocal >= 0 && jlocal < nlocal) + for (m = 0; m < nspecial[jlocal][2]; m++) + if (iglobal == onefour[jlocal][m]) { + dflag[jlocal][m] = 1; + break; + } + i += 2; + } } /* ---------------------------------------------------------------------- @@ -1325,15 +1159,3 @@ void Special::fix_alteration() modify->fix[ifix]->rebuild_special(); } -/* ---------------------------------------------------------------------- - print timing output -------------------------------------------------------------------------- */ - -void Special::timer_output(double time1) -{ - double time2 = MPI_Wtime(); - if (comm->me == 0) { - if (screen) fprintf(screen," special bonds CPU = %g secs\n",time2-time1); - if (logfile) fprintf(logfile," special bonds CPU = %g secs\n",time2-time1); - } -} diff --git a/src/special.h b/src/special.h index d02a8522f6..9f25200336 100644 --- a/src/special.h +++ b/src/special.h @@ -26,43 +26,29 @@ class Special : protected Pointers { private: int me,nprocs; - int maxall; tagint **onetwo,**onethree,**onefour; - // data used by rendezvous callback methods + // data used by ring callback methods - int nrvous; - tagint *atomIDs; - int *procowner; - - struct IDRvous { - int me; - tagint atomID; - }; - - struct PairRvous { - tagint atomID,partnerID; - }; - - // private methods - - void atom_owners(); - void onetwo_build_newton(); - void onetwo_build_newton_off(); - void onethree_build(); - void onefour_build(); + int *count; + int **dflag; void dedup(); void angle_trim(); void dihedral_trim(); void combine(); void fix_alteration(); - void timer_output(double); - // callback functions for rendezvous communication + // callback functions for ring communication - static int rendezvous_ids(int, char *, int &, int *&, char *&, void *); - static int rendezvous_pairs(int, char *, int &, int *&, char *&, void *); + static void ring_one(int, char *, void *); + static void ring_two(int, char *, void *); + static void ring_three(int, char *, void *); + static void ring_four(int, char *, void *); + static void ring_five(int, char *, void *); + static void ring_six(int, char *, void *); + static void ring_seven(int, char *, void *); + static void ring_eight(int, char *, void *); }; }