145
if (strcmp(arg[1],"clear") == 0) {
146
int igroup = find(arg[0]);
147
if (igroup == -1) error->all (FLERR,"Could not find group clear group ID");
148
if (igroup == 0) error->all (FLERR,"Cannot clear group all");
150
int *mask = atom->mask;
151
int nlocal = atom->nlocal;
152
int bits = inversemask[igroup];
153
for (i = 0; i < nlocal; i++) mask[i] &= bits;
136
158
// find group in existing list
137
159
// add a new group if igroup = -1
187
209
(strcmp(arg[2],"<") == 0 || strcmp(arg[2],">") == 0 ||
188
210
strcmp(arg[2],"<=") == 0 || strcmp(arg[2],">=") == 0 ||
211
strcmp(arg[2],"==") == 0 || strcmp(arg[2],"!=") == 0 ||
189
212
strcmp(arg[2],"<>") == 0)) {
191
214
int condition = -1;
330
353
memory->destroy(aflag);
357
} else if (strcmp(arg[1],"include") == 0) {
359
if (narg != 3) error->all(FLERR,"Illegal group command");
360
if (strcmp(arg[2],"molecule") != 0)
361
error->all(FLERR,"Illegal group command");
363
add_molecules(igroup,bit);
332
365
// style = subtract
334
367
} else if (strcmp(arg[1],"subtract") == 0) {
569
602
/* ----------------------------------------------------------------------
603
add atoms to group that are in same molecules as atoms already in group
604
do not include molID = 0
605
------------------------------------------------------------------------- */
607
void Group::add_molecules(int igroup, int bit)
609
// hash = unique molecule IDs of atoms already in group
611
hash = new std::map<tagint,int>();
613
tagint *molecule = atom->molecule;
614
int *mask = atom->mask;
615
int nlocal = atom->nlocal;
617
for (int i = 0; i < nlocal; i++)
619
if (molecule[i] == 0) continue;
620
if (hash->find(molecule[i]) == hash->end()) (*hash)[molecule[i]] = 1;
623
// list = set of unique molecule IDs for atoms to add
624
// pass list to all other procs via comm->ring()
626
int n = hash->size();
628
memory->create(list,n,"group:list");
631
std::map<tagint,int>::iterator pos;
632
for (pos = hash->begin(); pos != hash->end(); ++pos) list[n++] = pos->first;
636
comm->ring(n,sizeof(tagint),list,1,molring,NULL);
639
memory->destroy(list);
642
/* ----------------------------------------------------------------------
643
callback from comm->ring()
644
cbuf = list of N molecule IDs, put them in hash
645
loop over my atoms, if matches molecule ID in hash,
646
add atom to group flagged by molbit
647
------------------------------------------------------------------------- */
649
void Group::molring(int n, char *cbuf)
651
tagint *list = (tagint *) cbuf;
652
std::map<tagint,int> *hash = cptr->hash;
653
int nlocal = cptr->atom->nlocal;
654
tagint *molecule = cptr->atom->molecule;
655
int *mask = cptr->atom->mask;
656
int molbit = cptr->molbit;
659
for (int i = 0; i < n; i++) (*hash)[list[i]] = 1;
661
for (int i = 0; i < nlocal; i++)
662
if (hash->find(molecule[i]) != hash->end()) mask[i] |= molbit;
665
/* ----------------------------------------------------------------------
570
666
write group info to a restart file
571
667
only called by proc 0
572
668
------------------------------------------------------------------------- */