Commit 0944eda3 authored by Steve Plimpton's avatar Steve Plimpton
Browse files

final details for offset keyword added to reset_mol_ids

parent 7870a891
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -53,6 +53,19 @@ also be useful after molecules have been deleted with the
has lost molecules, e.g. via the :doc:`fix evaporate <fix_evaporate>`
command.

The *offset* keyword can be used to change the range of new molecule
IDs assigned.  If *Noffset* = 0 (the default) and the specified group
is *all*, then new molecule IDs will be from 1 to N.  If *Noffset* = 0
and the group is not all, then new molecule IDs will be from M+1 to
M+N, where M is the largest molecule ID for any atom not in the group.
This insures new molecule IDs do not collide with existing molecule
IDs that are not changed by this command.

If *Noffset* is set to a value greater than 0, then new molecule IDs
will be from Noffset+1 to Noffset+N.  If the group is not all, it is
up to you to insure the choice of *Noffset* does not produce
collisions between existing and new molecule IDs.

.. note::

   The same as explained for the :doc:`compute fragment/atom
@@ -75,4 +88,7 @@ Related commands
:doc:`fix evaporate <fix_evaporate>`,
:doc:`delete_atoms <delete_atoms>`

**Default:** none
**Default:**

The default keyword setting is offset = 0.
+13 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ void ResetMolIDs::command(int narg, char **arg)
  if (igroup == -1) error->all(FLERR,"Could not find reset_mol_ids group ID");
  int groupbit = group->bitmask[igroup];

  bigint offset = 0;
  tagint offset = 0;
  
  int iarg = 1;
  while (iarg < narg) {
@@ -119,7 +119,7 @@ void ResetMolIDs::command(int narg, char **arg)

  // invoke peratom method of compute chunk/atom
  // compress new molecule IDs to be contiguous 1 to Nmol
  // NOTE: use of compute chunk/atom limits # of molecules to 32-bit int
  // NOTE: use of compute chunk/atom limits # of molecules to a 32-bit int
  
  icompute = modify->find_compute(idchunk);
  ComputeChunkAtom *cca = (ComputeChunkAtom *) modify->compute[icompute];
@@ -127,6 +127,17 @@ void ResetMolIDs::command(int narg, char **arg)
  ids = cca->vector_atom;
  int nchunk = cca->nchunk;

  // if offset = 0 and group != all,
  // reset offset to largest molID of non-group atoms

  if (offset == 0 && groupbit != 1) {
    tagint mymol = 0;
    for (int i = 0; i < nlocal; i++)
      if (!(mask[i] & groupbit))
	mymol = MAX(mymol,molecule[i]);
    MPI_Allreduce(&mymol,&offset,1,MPI_LMP_TAGINT,MPI_MAX,world);
  }
  
  // copy chunkID to molecule ID + offset
  // only for atoms in the group