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

This commit is contained in:
sjplimp
2015-07-17 23:20:48 +00:00
parent 6d665f1860
commit 1ebb654b4d
6 changed files with 475 additions and 180 deletions

View File

@ -587,6 +587,26 @@ int Group::find(const char *name)
return -1;
}
/* ----------------------------------------------------------------------
find group with name or create group if it doesn't exist
return group index
------------------------------------------------------------------------- */
int Group::find_or_create(const char *name)
{
int igroup = find(name);
if (igroup >= 0) return igroup;
if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups");
igroup = find_unused();
int n = strlen(name) + 1;
names[igroup] = new char[n];
strcpy(names[igroup],name);
ngroup++;
return igroup;
}
/* ----------------------------------------------------------------------
return index of first available group
should never be called when group limit has been reached