git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1515 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2008-02-15 19:06:53 +00:00
parent 9fa38a6e94
commit 9864ead231
27 changed files with 243 additions and 110 deletions

View File

@ -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;

View File

@ -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++) {

View File

@ -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,6 +114,7 @@ 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) {

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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

View File

@ -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);

View File

@ -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,29 +652,12 @@ 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 (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;
}
}
} 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;
}
}
}
} else {
if (!bordergroup || ineed >= 2) {
if (style == SINGLE) {
for (i = nfirst; i < nlast; i++)
if (x[i][dim] >= lo && x[i][dim] <= hi) {
@ -690,6 +673,37 @@ void Comm::borders()
}
}
}
} else {
if (style == SINGLE) {
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 {
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);
sendlist[iswap][nsend++] = i;
}
}
}
}
// pack up list of border atoms
@ -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");
}

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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++) {

View File

@ -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++) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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,20 +923,10 @@ 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 {
int flag = 0;
for (int i = 0; i < nlocal; i++) {
delx = x[i][0] - xhold[i][0];
dely = x[i][1] - xhold[i][1];
@ -946,7 +934,6 @@ int Neighbor::check_distance()
rsq = delx*delx + dely*dely + delz*delz;
if (rsq > triggersq) flag = 1;
}
}
int flagall;
MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_MAX,world);
@ -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,11 +1416,19 @@ 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;

View File

@ -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