Unverified Commit 09de4fb9 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add support for checking consistency of atom bonus data

parent 318dd347
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
  natoms = 0;
  nlocal = nghost = nmax = 0;
  ntypes = 0;
  nellipsoids = nlines = ntris = nbodies = 0;
  nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0;
  nbonds = nangles = ndihedrals = nimpropers = 0;

@@ -738,6 +739,45 @@ int Atom::tag_consecutive()
  return 1;
}

/* ----------------------------------------------------------------------
   check that bonus data settings are valid
   error if number of atoms with ellipsoid/line/tri/body flags
   are consistent with global setting.
------------------------------------------------------------------------- */

void Atom::bonus_check()
{
  bigint local_ellipsoids = 0, local_lines = 0, local_tris = 0;
  bigint local_bodies = 0, num_global;

  for (int i = 0; i < nlocal; ++i) {
    if (ellipsoid && (ellipsoid[i] >=0)) ++local_ellipsoids;
    if (line && (line[i] >=0)) ++local_lines;
    if (tri && (tri[i] >=0)) ++local_tris;
    if (body && (body[i] >=0)) ++local_bodies;
  }

  MPI_Allreduce(&local_ellipsoids,&num_global,1,MPI_LMP_BIGINT,MPI_MIN,world);
  if (nellipsoids != num_global)
    error->all(FLERR,"Inconsistent 'ellipsoids' header value and number of "
               "atoms with enabled ellipsoid flags");

  MPI_Allreduce(&local_lines,&num_global,1,MPI_LMP_BIGINT,MPI_MIN,world);
  if (nlines != num_global)
    error->all(FLERR,"Inconsistent 'lines' header value and number of "
               "atoms with enabled line flags");

  MPI_Allreduce(&local_tris,&num_global,1,MPI_LMP_BIGINT,MPI_MIN,world);
  if (ntris != num_global)
    error->all(FLERR,"Inconsistent 'tris' header value and number of "
               "atoms with enabled tri flags");

  MPI_Allreduce(&local_bodies,&num_global,1,MPI_LMP_BIGINT,MPI_MIN,world);
  if (nbodies != num_global)
    error->all(FLERR,"Inconsistent 'bodies' header value and number of "
               "atoms with enabled body flags");
}

/* ----------------------------------------------------------------------
   count and return words in a single line
   make copy of line before using strtok so as not to change line
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@ class Atom : protected Pointers {
  int tag_enable;               // 0/1 if atom ID tags are defined
  int molecular;                // 0 = atomic, 1 = standard molecular system,
                                // 2 = molecule template system
  bigint nellipsoids;           // number of ellipsoids
  bigint nlines;                // number of lines
  bigint ntris;                 // number of triangles
  bigint nbodies;               // number of bodies

  bigint nbonds,nangles,ndihedrals,nimpropers;
  int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes;
@@ -233,6 +237,8 @@ class Atom : protected Pointers {
  void tag_extend();
  int tag_consecutive();

  void bonus_check();

  int parse_data(const char *);
  int count_words(const char *);
  int count_words(const char *, char *);