Unverified Commit eb39866e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1340 from akohlmey/bonus-data-checks

Bonus data checks and updates. Part 1
parents 05774ed8 0efc3765
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 *);
+1 −1
Original line number Diff line number Diff line
@@ -1286,7 +1286,7 @@ void AtomVecBody::data_atom(double *coord, imageint imagetmp, char **values)
  body[nlocal] = atoi(values[2]);
  if (body[nlocal] == 0) body[nlocal] = -1;
  else if (body[nlocal] == 1) body[nlocal] = 0;
  else error->one(FLERR,"Invalid atom type in Atoms section of data file");
  else error->one(FLERR,"Invalid bodyflag in Atoms section of data file");

  rmass[nlocal] = atof(values[3]);
  if (rmass[nlocal] <= 0.0)
+3 −1
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ class AtomVecBody : public AtomVec {
  double radius_body(int, int, int *, double *);
  void set_quat(int, double *);

  int nlocal_bonus;

 private:
  tagint *tag;
  int *type,*mask;
@@ -102,7 +104,7 @@ class AtomVecBody : public AtomVec {
  double **angmom,**torque;
  int *body;

  int nlocal_bonus,nghost_bonus,nmax_bonus;
  int nghost_bonus,nmax_bonus;
  int intdoubleratio;       // sizeof(double) / sizeof(int)

  MyPoolChunk<int> *icp;
+1 −1
Original line number Diff line number Diff line
@@ -1148,7 +1148,7 @@ void AtomVecEllipsoid::data_atom(double *coord, imageint imagetmp,
  ellipsoid[nlocal] = atoi(values[2]);
  if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1;
  else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0;
  else error->one(FLERR,"Invalid atom type in Atoms section of data file");
  else error->one(FLERR,"Invalid ellipsoidflag in Atoms section of data file");

  rmass[nlocal] = atof(values[3]);
  if (rmass[nlocal] <= 0.0)
Loading