diff --git a/src/atom.cpp b/src/atom.cpp index be4d12d52e..a149268767 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -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 diff --git a/src/atom.h b/src/atom.h index 324ad0f2d2..b2a657cf1a 100644 --- a/src/atom.h +++ b/src/atom.h @@ -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 *);