diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 7ce242e15a066b039304c1dbe65c613da1e2161d..29cfaa55285720a470aea0b3b5d963562356500a 100755 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -88,6 +88,7 @@ void ComputeTempAsphere::recount() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; int itype; int rot_dof = 0; diff --git a/src/ASPHERE/fix_npt_asphere.cpp b/src/ASPHERE/fix_npt_asphere.cpp index 16cc8b7071634ff809c66a3fad36c1376d6607c9..f8d66e21ffb228826d9ef012ffcc9dceb65bacb3 100755 --- a/src/ASPHERE/fix_npt_asphere.cpp +++ b/src/ASPHERE/fix_npt_asphere.cpp @@ -91,6 +91,7 @@ void FixNPTASphere::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double dtfm; for (i = 0; i < nlocal; i++) { @@ -156,6 +157,7 @@ void FixNPTASphere::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double dtfm; for (i = 0; i < nlocal; i++) { diff --git a/src/ASPHERE/fix_nve_asphere.cpp b/src/ASPHERE/fix_nve_asphere.cpp index 19c1b6f681e452dbbb13c3292505e5165b5f8012..5286913229fec36b1b7193398aef6d9e52083717 100755 --- a/src/ASPHERE/fix_nve_asphere.cpp +++ b/src/ASPHERE/fix_nve_asphere.cpp @@ -76,6 +76,7 @@ void FixNVEASphere::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -113,7 +114,8 @@ void FixNVEASphere::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; - + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { dtfm = dtf / mass[type[i]]; diff --git a/src/ASPHERE/fix_nvt_asphere.cpp b/src/ASPHERE/fix_nvt_asphere.cpp index f4a9bb2b8f0501385ba537eb0b398600184b5dc2..440dcadf28e7f85ea898337634a48f28e0ceedec 100755 --- a/src/ASPHERE/fix_nvt_asphere.cpp +++ b/src/ASPHERE/fix_nvt_asphere.cpp @@ -73,6 +73,7 @@ void FixNVTASphere::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { @@ -115,6 +116,7 @@ void FixNVTASphere::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/DIPOLE/fix_nve_dipole.cpp b/src/DIPOLE/fix_nve_dipole.cpp index f9b847aaed3ee29fc07f15805e9f867fe8886a4d..7015dce4c9f8a4ad814ae41b9748ffcef4ef5186 100644 --- a/src/DIPOLE/fix_nve_dipole.cpp +++ b/src/DIPOLE/fix_nve_dipole.cpp @@ -95,6 +95,7 @@ void FixNVEDipole::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double g[3]; @@ -148,6 +149,7 @@ void FixNVEDipole::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; // update v for all particles // update omega for all dipoles diff --git a/src/GRANULAR/fix_freeze.cpp b/src/GRANULAR/fix_freeze.cpp index 67e3d1dbd89e1df56ecb246426a8d5681de3a736..d839d975b2182d6bb48404047ab2e5f4b28c668d 100644 --- a/src/GRANULAR/fix_freeze.cpp +++ b/src/GRANULAR/fix_freeze.cpp @@ -68,6 +68,7 @@ void FixFreeze::post_force(int vflag) double **torque = atom->torque; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { diff --git a/src/GRANULAR/fix_nve_gran.cpp b/src/GRANULAR/fix_nve_gran.cpp index 7b52b633e6c68fd016a134fc085dffefb897f3d1..c196c0befbd51ccfcfaeab41b8feaa48c67d48af 100644 --- a/src/GRANULAR/fix_nve_gran.cpp +++ b/src/GRANULAR/fix_nve_gran.cpp @@ -75,6 +75,7 @@ void FixNVEGran::initial_integrate(int vflag) double *radius = atom->radius; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { @@ -111,6 +112,7 @@ void FixNVEGran::final_integrate() double *radius = atom->radius; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/atom.cpp b/src/atom.cpp index 14d1d1e740e30b84b91af2347b41d4908f484fd4..d706e958a8413c05883aae91e94ceb6cb113d582 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -52,6 +52,8 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) nbonds = nangles = ndihedrals = nimpropers = 0; bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; + firstgroupname = NULL; + // initialize atom arrays // customize by adding new array @@ -136,6 +138,7 @@ Atom::~Atom() { delete [] atom_style; delete avec; + delete [] firstgroupname; // delete atom arrays // customize by adding new array @@ -273,6 +276,14 @@ void Atom::init() check_shape(); check_dipole(); + // setup of firstgroup + + if (firstgroupname) { + firstgroup = group->find(firstgroupname); + if (firstgroup < 0) + error->all("Could not find atom_modify first group ID"); + } else firstgroup = -1; + // init sub-style avec->init(); @@ -310,6 +321,15 @@ void Atom::modify_params(int narg, char **arg) else if (strcmp(arg[iarg+1],"hash") == 0) map_style = 2; else error->all("Illegal atom_modify command"); iarg += 2; + } else if (strcmp(arg[iarg],"first") == 0) { + if (iarg+2 > narg) error->all("Illegal atom_modify command"); + if (strcmp(arg[iarg+1],"all") == 0) delete [] firstgroupname; + else { + int n = strlen(arg[iarg+1]) + 1; + firstgroupname = new char[n]; + strcpy(firstgroupname,arg[iarg+1]); + } + iarg += 2; } else error->all("Illegal atom_modify command"); } } @@ -1205,6 +1225,36 @@ void Atom::check_dipole() error->all("All dipole moments are not set"); } +/* ---------------------------------------------------------------------- + reorder owned atoms so those in firstgroup appear first + called by comm->exchange() if atom_modify first group is set + only owned atoms exist at this point, no ghost atoms +------------------------------------------------------------------------- */ + +void Atom::first_reorder() +{ + // insure there is one extra atom location at end of arrays for swaps + + if (nlocal == nmax) avec->grow(0); + + // loop over owned atoms + // nfirst = index of first atom not in firstgroup + // when find firstgroup atom out of place, swap it with atom nfirst + + int bitmask = group->bitmask[firstgroup]; + nfirst = 0; + while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & bitmask && i > nfirst) { + avec->copy(i,nlocal); + avec->copy(nfirst,i); + avec->copy(nlocal,nfirst); + while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; + } + } +} + /* ---------------------------------------------------------------------- register a callback to a fix so it can manage atom-based arrays happens when fix is created diff --git a/src/atom.h b/src/atom.h index fd9bd0f84fa346f944d84cd6e14b93dd639950c0..b9404bae7fe095f68683e449e542500f46b0a3bb 100644 --- a/src/atom.h +++ b/src/atom.h @@ -35,6 +35,10 @@ class Atom : protected Pointers { int nbonds,nangles,ndihedrals,nimpropers; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; + int firstgroup; // store atoms in this group first, -1 if unset + int nfirst; // # of atoms in first group on this proc + char *firstgroupname; // group-ID to store first, NULL if unset + // per-atom arrays // customize by adding new array @@ -132,6 +136,8 @@ class Atom : protected Pointers { void set_dipole(double *); void check_dipole(); + void first_reorder(); + void add_callback(int); void delete_callback(const char *, int); void update_callback(int); diff --git a/src/comm.cpp b/src/comm.cpp index 51f74e9b0fd4a154f24da3d8cb9f1a50deb271e7..7698e9c8c37c92f41e63083a37e417747d4fbec3 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -58,7 +58,7 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp) user_procgrid[0] = user_procgrid[1] = user_procgrid[2] = 0; grid2proc = NULL; - igroup = 0; + bordergroup = 0; style = SINGLE; multilo = multihi = NULL; cutghostmulti = NULL; @@ -172,7 +172,6 @@ void Comm::init() { triclinic = domain->triclinic; map_style = atom->map_style; - groupbit = group->bitmask[igroup]; // comm_only = 1 if only x,f are exchanged in forward/reverse comm @@ -488,8 +487,7 @@ void Comm::reverse_communicate() } /* ---------------------------------------------------------------------- - exchange: - move atoms to correct processors + exchange: move atoms to correct processors atoms exchanged with all 6 stencil neighbors send out atoms that have left my box, receive ones entering my box atoms will be lost if not inside some proc's box @@ -591,11 +589,12 @@ void Comm::exchange() else m += static_cast<int> (buf[m]); } } + + if (atom->firstgroupname) atom->first_reorder(); } /* ---------------------------------------------------------------------- - borders: - make lists of nearby atoms to send to neighboring procs at every timestep + borders: list nearby atoms to send to neighboring procs at every timestep one list is created for every swap that will be made as list is made, actually do swaps this does equivalent of a communicate (so don't need to explicitly @@ -606,9 +605,10 @@ void Comm::exchange() void Comm::borders() { - int i,n,itype,iswap,dim,ineed,maxneed,nsend,nrecv,nfirst,nlast,smax,rmax; + int i,n,itype,iswap,dim,ineed,maxneed,smax,rmax; + int nsend,nrecv,nfirst,nlast,ngroup; double lo,hi; - int *type,*mask; + int *type; double **x; double *buf,*mlo,*mhi; MPI_Request request; @@ -652,37 +652,51 @@ void Comm::borders() nsend = 0; - // SINGLE vs MULTI, all atoms versus only atoms in group + // find send atoms according to SINGLE vs MULTI + // all atoms eligible versus atoms in bordergroup + // only need to limit loop to bordergroup for first sends (ineed < 2) + // on these sends, break loop in two: owned (in group) and ghost - if (igroup) { - mask = atom->mask; + if (!bordergroup || ineed >= 2) { if (style == SINGLE) { for (i = nfirst; i < nlast; i++) - if (mask[i] & groupbit) { - if (x[i][dim] >= lo && x[i][dim] <= hi) { - if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); - sendlist[iswap][nsend++] = i; - } + if (x[i][dim] >= lo && x[i][dim] <= hi) { + if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); + sendlist[iswap][nsend++] = i; } } else { - for (i = nfirst; i < nlast; i++) - if (mask[i] & groupbit) { - itype = type[i]; - if (x[i][dim] >= mlo[itype] && x[i][dim] <= mhi[itype]) { - if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); - sendlist[iswap][nsend++] = i; - } + for (i = nfirst; i < nlast; i++) { + itype = type[i]; + if (x[i][dim] >= mlo[itype] && x[i][dim] <= mhi[itype]) { + if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); + sendlist[iswap][nsend++] = i; } + } } + } else { if (style == SINGLE) { - for (i = nfirst; i < nlast; i++) + ngroup = atom->nfirst; + for (i = 0; i < ngroup; i++) + if (x[i][dim] >= lo && x[i][dim] <= hi) { + if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); + sendlist[iswap][nsend++] = i; + } + for (i = atom->nlocal; i < nlast; i++) if (x[i][dim] >= lo && x[i][dim] <= hi) { if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); sendlist[iswap][nsend++] = i; } } else { - for (i = nfirst; i < nlast; i++) { + ngroup = atom->nfirst; + for (i = 0; i < ngroup; i++) { + itype = type[i]; + if (x[i][dim] >= mlo[itype] && x[i][dim] <= mhi[itype]) { + if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); + sendlist[iswap][nsend++] = i; + } + } + for (i = atom->nlocal; i < nlast; i++) { itype = type[i]; if (x[i][dim] >= mlo[itype] && x[i][dim] <= mhi[itype]) { if (nsend == maxsendlist[iswap]) grow_list(iswap,nsend); @@ -1504,9 +1518,12 @@ void Comm::set(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"group") == 0) { if (iarg+2 > narg) error->all("Illegal communicate command"); - igroup = group->find(arg[iarg+1]); - if (igroup < 0) + bordergroup = group->find(arg[iarg+1]); + if (bordergroup < 0) error->all("Invalid group ID in communicate command"); + if (bordergroup && (atom->firstgroupname == NULL || + strcmp(arg[iarg+1],atom->firstgroupname) != 0)) + error->all("Communicate group != atom_modify first group"); iarg += 2; } else error->all("Illegal communicate command"); } diff --git a/src/comm.h b/src/comm.h index b6b8ef0576bf1cb8885095779565606f1b44865e..54078ad9504549a4d8e28b212ff6503af988314a 100644 --- a/src/comm.h +++ b/src/comm.h @@ -71,7 +71,7 @@ class Comm : protected Pointers { int comm_x_only,comm_f_only; // 1 if only exchange x,f in for/rev comm int map_style; // non-0 if global->local mapping is done int ***grid2proc; // which proc owns i,j,k loc in 3d grid - int igroup,groupbit; // only communicate this group + int bordergroup; // only communicate this group in borders int *firstrecv; // where to put 1st recv atom in each swap int **sendlist; // list of atoms to send in each swap diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp index 31a3e0d31a396c7df96f11805bbf6f3053773d2d..8d0f1a123d7bb947ca1a4991bf976a6e93e150d6 100644 --- a/src/fix_enforce2d.cpp +++ b/src/fix_enforce2d.cpp @@ -79,6 +79,7 @@ void FixEnforce2D::post_force(int vflag) double **f = atom->f; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { diff --git a/src/fix_npt.cpp b/src/fix_npt.cpp index 7b518971398868ca609d0a6683ee7e46c89ab5a9..7636739f6ccdd93498b71e6409cf46a9122f6a9b 100644 --- a/src/fix_npt.cpp +++ b/src/fix_npt.cpp @@ -374,6 +374,7 @@ void FixNPT::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double dtfm; for (i = 0; i < nlocal; i++) { @@ -422,6 +423,7 @@ void FixNPT::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double dtfm; for (i = 0; i < nlocal; i++) { @@ -499,6 +501,7 @@ void FixNPT::initial_integrate_respa(int vflag, int ilevel, int flag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; // outermost level - update eta_dot and omega_dot, apply to v, remap box // all other levels - NVE update of v @@ -604,6 +607,7 @@ void FixNPT::final_integrate_respa(int ilevel) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/fix_nve.cpp b/src/fix_nve.cpp index a471c7217e64091c8e06869fa2c92c469d565286..8035cf25f58e8c5a390b5e137d94fd1e61d5ad28 100644 --- a/src/fix_nve.cpp +++ b/src/fix_nve.cpp @@ -70,6 +70,7 @@ void FixNVE::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; if (mass) { for (int i = 0; i < nlocal; i++) { @@ -112,6 +113,7 @@ void FixNVE::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; if (mass) { for (int i = 0; i < nlocal; i++) { diff --git a/src/fix_nve_limit.cpp b/src/fix_nve_limit.cpp index d43684c7087a29a72b0dccbf8e89c60388ad6789..f246ed6f5bc32d03de923825fbbe79ee96022762 100644 --- a/src/fix_nve_limit.cpp +++ b/src/fix_nve_limit.cpp @@ -79,6 +79,7 @@ void FixNVELimit::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; if (mass) { for (int i = 0; i < nlocal; i++) { @@ -141,6 +142,7 @@ void FixNVELimit::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; if (mass) { for (int i = 0; i < nlocal; i++) { diff --git a/src/fix_nve_noforce.cpp b/src/fix_nve_noforce.cpp index 2d8d91ec770894e8721d73045bff4edfc247fe9e..618daadb8a54660a160a1b93be307143f65c01e1 100644 --- a/src/fix_nve_noforce.cpp +++ b/src/fix_nve_noforce.cpp @@ -57,6 +57,7 @@ void FixNVENoforce::initial_integrate(int vflag) double **v = atom->v; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/fix_nvt.cpp b/src/fix_nvt.cpp index f6807c127c0a16342ed533762466d2e70ab03156..76b4bc1caa5ba49a7081055ae31f253ffe4cf29d 100644 --- a/src/fix_nvt.cpp +++ b/src/fix_nvt.cpp @@ -167,6 +167,7 @@ void FixNVT::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { @@ -195,6 +196,7 @@ void FixNVT::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { @@ -238,6 +240,7 @@ void FixNVT::initial_integrate_respa(int vflag, int ilevel, int flag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; // outermost level - update eta_dot and apply to v // all other levels - NVE update of v @@ -305,6 +308,7 @@ void FixNVT::final_integrate_respa(int ilevel) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/fix_nvt_sllod.cpp b/src/fix_nvt_sllod.cpp index 57db99d8126bf17aedc996bc4c0760826be8a82f..d0fcbdbb3705fa36b658107859561f665407a8ad 100644 --- a/src/fix_nvt_sllod.cpp +++ b/src/fix_nvt_sllod.cpp @@ -91,6 +91,7 @@ void FixNVTSlodd::initial_integrate(int vflag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double *h_rate = domain->h_rate; double *h_ratelo = domain->h_ratelo; @@ -146,6 +147,7 @@ void FixNVTSlodd::final_integrate() int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; double *h_rate = domain->h_rate; double *h_ratelo = domain->h_ratelo; @@ -211,6 +213,7 @@ void FixNVTSlodd::initial_integrate_respa(int vflag, int ilevel, int flag) int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; // outermost level - update eta_dot and apply to v // all other levels - NVE update of v diff --git a/src/neigh_derive.cpp b/src/neigh_derive.cpp index cb1a2a6709b8ade4276d9a8c204b7f1843ca3682..3e7428f6097979f14d365e34ea964583692b9762 100644 --- a/src/neigh_derive.cpp +++ b/src/neigh_derive.cpp @@ -93,7 +93,7 @@ void Neighbor::half_from_full_newton(NeighList *list) double **x = atom->x; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int *ilist = list->ilist; int *numneigh = list->numneigh; diff --git a/src/neigh_full.cpp b/src/neigh_full.cpp index 81c6c9586a7a31694bd42646b02ee637dd496000..913760ee014a8940ea2d942b3a929baae7501b4e 100644 --- a/src/neigh_full.cpp +++ b/src/neigh_full.cpp @@ -14,6 +14,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "group.h" #include "error.h" using namespace LAMMPS_NS; @@ -25,7 +26,7 @@ using namespace LAMMPS_NS; void Neighbor::full_nsq(NeighList *list) { - int i,j,n,itype,jtype,which; + int i,j,n,itype,jtype,which,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -34,8 +35,12 @@ void Neighbor::full_nsq(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -47,7 +52,6 @@ void Neighbor::full_nsq(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -67,8 +71,8 @@ void Neighbor::full_nsq(NeighList *list) // skip i = j for (j = 0; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; if (i == j) continue; - jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -117,8 +121,9 @@ void Neighbor::full_bin(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -132,7 +137,6 @@ void Neighbor::full_bin(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -209,8 +213,9 @@ void Neighbor::full_multi(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -225,7 +230,6 @@ void Neighbor::full_multi(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; diff --git a/src/neigh_gran.cpp b/src/neigh_gran.cpp index 8adbc4501cc1e630301b7ec713007add82b3ee0e..2fe5fd5f70cd3dd749bcfa99396e5e88849c7adf 100644 --- a/src/neigh_gran.cpp +++ b/src/neigh_gran.cpp @@ -14,6 +14,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "group.h" #include "fix_shear_history.h" #include "error.h" @@ -29,7 +30,7 @@ using namespace LAMMPS_NS; void Neighbor::granular_nsq_no_newton(NeighList *list) { - int i,j,m,n,nn; + int i,j,m,n,nn,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutsq; int *neighptr,*touchptr; @@ -50,7 +51,11 @@ void Neighbor::granular_nsq_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -74,7 +79,6 @@ void Neighbor::granular_nsq_no_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -104,6 +108,7 @@ void Neighbor::granular_nsq_no_newton(NeighList *list) // loop over remaining atoms, owned and ghost for (j = i+1; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; if (exclude && exclusion(i,j,type[i],type[j],mask,molecule)) continue; delx = xtmp - x[j][0]; @@ -169,7 +174,7 @@ void Neighbor::granular_nsq_no_newton(NeighList *list) void Neighbor::granular_nsq_newton(NeighList *list) { - int i,j,n,itag,jtag; + int i,j,n,itag,jtag,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutsq; int *neighptr; @@ -181,7 +186,11 @@ void Neighbor::granular_nsq_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -193,7 +202,6 @@ void Neighbor::granular_nsq_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -213,6 +221,8 @@ void Neighbor::granular_nsq_newton(NeighList *list) // loop over remaining atoms, owned and ghost for (j = i+1; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; + if (j >= nlocal) { jtag = tag[j]; if (itag > jtag) { @@ -288,6 +298,7 @@ void Neighbor::granular_bin_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -313,7 +324,6 @@ void Neighbor::granular_bin_no_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -431,6 +441,7 @@ void Neighbor::granular_bin_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -444,7 +455,6 @@ void Neighbor::granular_bin_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -538,6 +548,7 @@ void Neighbor::granular_bin_newton_tri(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -551,7 +562,6 @@ void Neighbor::granular_bin_newton_tri(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; diff --git a/src/neigh_half_bin.cpp b/src/neigh_half_bin.cpp index 3f19e4cd6e655c1a6d68dfafd24d248cf695dae6..628b37c369e14392c86f64ca7e0ebf1d72498e21 100644 --- a/src/neigh_half_bin.cpp +++ b/src/neigh_half_bin.cpp @@ -42,7 +42,8 @@ void Neighbor::half_bin_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; + if (include_group) nlocal = atom->nfirst; int molecular = atom->molecular; int *ilist = list->ilist; @@ -57,7 +58,6 @@ void Neighbor::half_bin_no_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -135,8 +135,9 @@ void Neighbor::half_bin_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -150,7 +151,6 @@ void Neighbor::half_bin_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -249,8 +249,9 @@ void Neighbor::half_bin_newton_tri(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -264,7 +265,6 @@ void Neighbor::half_bin_newton_tri(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; diff --git a/src/neigh_half_multi.cpp b/src/neigh_half_multi.cpp index cda4965ebc7686e65de09c285c7b9e008bad519e..d955b2e1fd758307a558567bb5e9259be43543b5 100644 --- a/src/neigh_half_multi.cpp +++ b/src/neigh_half_multi.cpp @@ -44,8 +44,9 @@ void Neighbor::half_multi_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -60,7 +61,6 @@ void Neighbor::half_multi_no_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -145,8 +145,9 @@ void Neighbor::half_multi_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -161,7 +162,6 @@ void Neighbor::half_multi_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -269,8 +269,9 @@ void Neighbor::half_multi_newton_tri(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -285,7 +286,6 @@ void Neighbor::half_multi_newton_tri(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; diff --git a/src/neigh_half_nsq.cpp b/src/neigh_half_nsq.cpp index aaee116dcfd198e02ed047121dae22d028a21d0e..bffc77dfcff809059492ade9ad35eac99bc396e5 100644 --- a/src/neigh_half_nsq.cpp +++ b/src/neigh_half_nsq.cpp @@ -14,6 +14,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "group.h" #include "error.h" using namespace LAMMPS_NS; @@ -26,7 +27,7 @@ using namespace LAMMPS_NS; void Neighbor::half_nsq_no_newton(NeighList *list) { - int i,j,n,itype,jtype,which; + int i,j,n,itype,jtype,which,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -35,8 +36,12 @@ void Neighbor::half_nsq_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -48,7 +53,6 @@ void Neighbor::half_nsq_no_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -67,6 +71,7 @@ void Neighbor::half_nsq_no_newton(NeighList *list) // loop over remaining atoms, owned and ghost for (j = i+1; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -102,7 +107,7 @@ void Neighbor::half_nsq_no_newton(NeighList *list) void Neighbor::half_nsq_newton(NeighList *list) { - int i,j,n,itype,jtype,itag,jtag,which; + int i,j,n,itype,jtype,itag,jtag,which,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -112,8 +117,12 @@ void Neighbor::half_nsq_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -125,7 +134,6 @@ void Neighbor::half_nsq_newton(NeighList *list) int npnt = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -146,6 +154,8 @@ void Neighbor::half_nsq_newton(NeighList *list) // itag = jtag is possible for long cutoffs that include images of self for (j = i+1; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; + if (j >= nlocal) { jtag = tag[j]; if (itag > jtag) { diff --git a/src/neigh_respa.cpp b/src/neigh_respa.cpp index 125bfecc997145cb1fa9c4e42b0e7076845b9526..50221dcf47750c4d1b4a649d9890fc36ab6963d9 100644 --- a/src/neigh_respa.cpp +++ b/src/neigh_respa.cpp @@ -14,6 +14,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "group.h" #include "error.h" using namespace LAMMPS_NS; @@ -27,7 +28,7 @@ using namespace LAMMPS_NS; void Neighbor::respa_nsq_no_newton(NeighList *list) { - int i,j,n,itype,jtype,which,n_inner,n_middle; + int i,j,n,itype,jtype,which,n_inner,n_middle,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -36,8 +37,12 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -68,7 +73,6 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) int npnt_middle = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -106,6 +110,7 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) // loop over remaining atoms, owned and ghost for (j = i+1; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -167,7 +172,7 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) void Neighbor::respa_nsq_newton(NeighList *list) { - int i,j,n,itype,jtype,itag,jtag,which,n_inner,n_middle; + int i,j,n,itype,jtype,itag,jtag,which,n_inner,n_middle,bitmask; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -177,8 +182,12 @@ void Neighbor::respa_nsq_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) { + nlocal = atom->nfirst; + bitmask = group->bitmask[include_group]; + } int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -209,7 +218,6 @@ void Neighbor::respa_nsq_newton(NeighList *list) int npnt_middle = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -248,6 +256,8 @@ void Neighbor::respa_nsq_newton(NeighList *list) // loop over remaining atoms, owned and ghost for (j = i+1; j < nall; j++) { + if (include_group && !(mask[j] & bitmask)) continue; + if (j >= nlocal) { jtag = tag[j]; if (itag > jtag) { @@ -339,8 +349,9 @@ void Neighbor::respa_bin_no_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -373,7 +384,6 @@ void Neighbor::respa_bin_no_newton(NeighList *list) int npnt_middle = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -495,8 +505,9 @@ void Neighbor::respa_bin_newton(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -529,7 +540,6 @@ void Neighbor::respa_bin_newton(NeighList *list) int npnt_middle = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; @@ -684,8 +694,9 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) int *mask = atom->mask; int *molecule = atom->molecule; int nlocal = atom->nlocal; - int nall = atom->nlocal + atom->nghost; + int nall = nlocal + atom->nghost; int molecular = atom->molecular; + if (include_group) nlocal = atom->nfirst; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -718,7 +729,6 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) int npnt_middle = 0; for (i = 0; i < nlocal; i++) { - if (include_group && !(mask[i] & include_groupbit)) continue; if (pgsize - npnt < oneatom) { npnt = 0; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 0c0b6b2b8468d25eed38630cc9185cdfdd5c5ddc..06859a4fa581011f29cbd0dc7046d7c50edba0bd 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -340,8 +340,6 @@ void Neighbor::init() n = atom->ntypes; - include_groupbit = group->bitmask[include_group]; - if (nex_type == 0 && nex_group == 0 && nex_mol == 0) exclude = 0; else exclude = 1; @@ -925,27 +923,16 @@ int Neighbor::check_distance() double delx,dely,delz,rsq; double **x = atom->x; - int *mask = atom->mask; int nlocal = atom->nlocal; - int flag = 0; + if (include_group) nlocal = atom->nfirst; - if (include_group) { - for (int i = 0; i < nlocal; i++) - if (mask[i] & include_groupbit) { - delx = x[i][0] - xhold[i][0]; - dely = x[i][1] - xhold[i][1]; - delz = x[i][2] - xhold[i][2]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq > triggersq) flag = 1; - } - } else { - for (int i = 0; i < nlocal; i++) { - delx = x[i][0] - xhold[i][0]; - dely = x[i][1] - xhold[i][1]; - delz = x[i][2] - xhold[i][2]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq > triggersq) flag = 1; - } + int flag = 0; + for (int i = 0; i < nlocal; i++) { + delx = x[i][0] - xhold[i][0]; + dely = x[i][1] - xhold[i][1]; + delz = x[i][2] - xhold[i][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > triggersq) flag = 1; } int flagall; @@ -1308,8 +1295,11 @@ void Neighbor::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"include") == 0) { if (iarg+2 > narg) error->all("Illegal neigh_modify command"); include_group = group->find(arg[iarg+1]); - if (include_group == -1) + if (include_group < 0) error->all("Invalid group ID in neigh_modify command"); + if (include_group && (atom->firstgroupname == NULL || + strcmp(arg[iarg+1],atom->firstgroupname) != 0)) + error->all("Neigh_modify include group != atom_modify first group"); iarg += 2; } else if (strcmp(arg[iarg],"exclude") == 0) { if (iarg+2 > narg) error->all("Illegal neigh_modify command"); @@ -1417,7 +1407,7 @@ int Neighbor::find_special(int i, int j) void Neighbor::bin_atoms() { - int i,ibin,nall; + int i,ibin; for (i = 0; i < mbins; i++) binhead[i] = -1; @@ -1426,15 +1416,23 @@ void Neighbor::bin_atoms() double **x = atom->x; int *mask = atom->mask; - nall = atom->nlocal + atom->nghost; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; if (include_group) { - for (i = nall-1; i >= 0; i--) - if (mask[i] & include_groupbit) { + int bitmask = group->bitmask[include_group]; + for (i = nall-1; i >= nlocal; i--) { + if (mask[i] & bitmask) { ibin = coord2bin(x[i]); bins[i] = binhead[ibin]; binhead[ibin] = i; } + } + for (i = atom->nfirst; i >= 0; i--) { + ibin = coord2bin(x[i]); + bins[i] = binhead[ibin]; + binhead[ibin] = i; + } } else { for (i = nall-1; i >= 0; i--) { ibin = coord2bin(x[i]); diff --git a/src/neighbor.h b/src/neighbor.h index 3fc62c44210b69b8818ca1e10d5d62b51d0577ad..233eb3c8bbaa7a526ce946d22a90de2e34cdaf78 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -123,8 +123,7 @@ class Neighbor : protected Pointers { int special_flag[4]; // flags for 1-2, 1-3, 1-4 neighbors - int include_group; // only form neighbor lists on this group - int include_groupbit; + int include_group; // only build pairwise lists for this group int exclude; // 0 if no type/group exclusions, 1 if yes