reset_mol_ids: unique created computes

This commit is contained in:
Jacob Gissinger 2020-08-21 14:52:39 -04:00
parent c9773fc288
commit 6fc2ab07ef
3 changed files with 8 additions and 7 deletions

View File

@ -171,7 +171,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
if (strcmp(arg[iarg+1],"yes") == 0) { // default if (strcmp(arg[iarg+1],"yes") == 0) { // default
delete reset_mol_ids; delete reset_mol_ids;
reset_mol_ids = new ResetMolIDs(lmp); reset_mol_ids = new ResetMolIDs(lmp);
reset_mol_ids->create_computes(group->names[igroup]); reset_mol_ids->create_computes(id,group->names[igroup]);
iarg += 2; iarg += 2;
} }
if (strcmp(arg[iarg+1],"no") == 0) { if (strcmp(arg[iarg+1],"no") == 0) {

View File

@ -116,7 +116,7 @@ void ResetMolIDs::command(int narg, char **arg)
// create computes // create computes
create_computes(groupid); create_computes(NULL,groupid);
// reset molecule IDs // reset molecule IDs
@ -140,22 +140,23 @@ void ResetMolIDs::command(int narg, char **arg)
create computes used by reset_mol_ids create computes used by reset_mol_ids
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void ResetMolIDs::create_computes(char *groupid) void ResetMolIDs::create_computes(char *fixid, char *groupid)
{ {
int igroup = group->find(groupid); int igroup = group->find(groupid);
if (igroup == -1) error->all(FLERR,"Could not find reset_mol_ids group ID"); if (igroup == -1) error->all(FLERR,"Could not find reset_mol_ids group ID");
groupbit = group->bitmask[igroup]; groupbit = group->bitmask[igroup];
// create instances of compute fragment/atom, compute reduce (if needed), // create instances of compute fragment/atom, compute reduce (if needed),
// and compute chunk/atom. all use the group-ID for this command // and compute chunk/atom. all use the group-ID for this command.
// 'fixid' allows for creating independent instances of the computes
idfrag = "reset_mol_ids_FRAGMENT_ATOM"; idfrag = fmt::format("{}_reset_mol_ids_FRAGMENT_ATOM",fixid);
if (singleflag) if (singleflag)
modify->add_compute(fmt::format("{} {} fragment/atom single yes",idfrag,groupid)); modify->add_compute(fmt::format("{} {} fragment/atom single yes",idfrag,groupid));
else else
modify->add_compute(fmt::format("{} {} fragment/atom single no",idfrag,groupid)); modify->add_compute(fmt::format("{} {} fragment/atom single no",idfrag,groupid));
idchunk = "reset_mol_ids_CHUNK_ATOM"; idchunk = fmt::format("{}_reset_mol_ids_CHUNK_ATOM",fixid);
if (compressflag) if (compressflag)
modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes", modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes",
idchunk,groupid)); idchunk,groupid));

View File

@ -30,7 +30,7 @@ class ResetMolIDs : protected Pointers {
ResetMolIDs(class LAMMPS *); ResetMolIDs(class LAMMPS *);
~ResetMolIDs(); ~ResetMolIDs();
void command(int, char **); void command(int, char **);
void create_computes(char *); void create_computes(char *, char *);
void reset(); void reset();
private: private: