add support for checking consistency of atom bonus data

This commit is contained in:
Axel Kohlmeyer
2019-02-17 15:01:13 -05:00
parent 318dd34737
commit 09de4fb953
2 changed files with 46 additions and 0 deletions

View File

@ -58,6 +58,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
natoms = 0; natoms = 0;
nlocal = nghost = nmax = 0; nlocal = nghost = nmax = 0;
ntypes = 0; ntypes = 0;
nellipsoids = nlines = ntris = nbodies = 0;
nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0;
nbonds = nangles = ndihedrals = nimpropers = 0; nbonds = nangles = ndihedrals = nimpropers = 0;
@ -738,6 +739,45 @@ int Atom::tag_consecutive()
return 1; 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 count and return words in a single line
make copy of line before using strtok so as not to change line make copy of line before using strtok so as not to change line

View File

@ -34,6 +34,10 @@ class Atom : protected Pointers {
int tag_enable; // 0/1 if atom ID tags are defined int tag_enable; // 0/1 if atom ID tags are defined
int molecular; // 0 = atomic, 1 = standard molecular system, int molecular; // 0 = atomic, 1 = standard molecular system,
// 2 = molecule template 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; bigint nbonds,nangles,ndihedrals,nimpropers;
int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes;
@ -233,6 +237,8 @@ class Atom : protected Pointers {
void tag_extend(); void tag_extend();
int tag_consecutive(); int tag_consecutive();
void bonus_check();
int parse_data(const char *); int parse_data(const char *);
int count_words(const char *); int count_words(const char *);
int count_words(const char *, char *); int count_words(const char *, char *);