Unverified Commit d3853af4 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add singlezero keyword to compute fragment/atom to give all single non-bonded atoms an ID of 0

parent 12f62583
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -15,12 +15,13 @@ Syntax
.. parsed-literal::

   compute ID group-ID cluster/atom cutoff
   compute ID group-ID fragment/atom
   compute ID group-ID fragment/atom [singlezero]
   compute ID group-ID aggregate/atom cutoff

* ID, group-ID are documented in :doc:`compute <compute>` command
* *cluster/atom* or *fragment/atom* or *aggregate/atom* = style name of this compute command
* cutoff = distance within which to label atoms as part of same cluster (distance units)
* *singlezero* = keyword to trigger assigning an ID of 0 to fragments with a single atom (optional)

Examples
""""""""
@@ -52,6 +53,12 @@ bond/break <fix_bond_break>`. The cluster ID or fragment ID of every
atom in the cluster will be set to the smallest atom ID of any atom in
the cluster or fragment, respectively.

The *singlezero* keyword turns on a special treatment for fragments,
where all fragments within the compute group that contain only a single
atom will have a fragment ID of 0.  This can be useful in cases where
the fragment IDs are used as input for other commands in LAMMPS that
treat such single atoms different.

An aggregate is defined by combining the rules for clusters and
fragments, i.e. a set of atoms, where each of it is within the cutoff
distance from one or more atoms within a fragment that is part of
+38 −24
Original line number Diff line number Diff line
@@ -38,7 +38,12 @@ ComputeFragmentAtom::ComputeFragmentAtom(LAMMPS *lmp, int narg, char **arg) :
  Compute(lmp, narg, arg),
  fragmentID(NULL)
{
  if (narg != 3) error->all(FLERR,"Illegal compute fragment/atom command");
  singleflag = 0;

  if ((narg < 3) || (narg > 4))
    error->all(FLERR,"Illegal compute fragment/atom command");
  if ((narg == 4) && (strcmp(arg[3],"singlezero") == 0))
    singleflag = 1;

  if (atom->avec->bonds_allow == 0)
    error->all(FLERR,"Compute fragment/atom used when bonds are not allowed");
@@ -114,6 +119,7 @@ void ComputeFragmentAtom::compute_peratom()

  // owned + ghost atoms start with fragmentID = atomID
  // atoms not in group have fragmentID = 0
  // if singleflag is set atoms without bonds have fragmentID 0 as well.

  tagint *tag = atom->tag;
  int *mask = atom->mask;
@@ -122,9 +128,10 @@ void ComputeFragmentAtom::compute_peratom()
  int nlocal = atom->nlocal;
  int nall = nlocal + atom->nghost;
  
  for (i = 0; i < nall; i++)
  for (i = 0; i < nall; i++) {
    if (mask[i] & groupbit) fragmentID[i] = tag[i];
    else fragmentID[i] = 0;
  }

  // loop until no ghost atom fragment ID is changed
  // acquire fragmentIDs of ghost atoms
@@ -152,9 +159,16 @@ void ComputeFragmentAtom::compute_peratom()
    for (i = 0; i < nlocal; i++) {

      // skip atom I if not in group or already marked
      // also skip and set fragment ID to zero if singleflag is set
      // and the atom is an isolated atom without bonds
      
      if (!(mask[i] & groupbit)) continue;
      if (markflag[i]) continue;
      if (singleflag && (nspecial[i][0] == 0)) {
        fragmentID[i] = 0;
        markflag[i] = 1;
        continue;
      }

      // find one cluster of bond-connected atoms
      // ncluster = # of owned and ghost atoms in cluster
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class ComputeFragmentAtom : public Compute {
  double memory_usage();

 private:
  int nmax,commflag;
  int nmax,commflag,singleflag;
  int *stack,*clist,*markflag;
  double *fragmentID;
};