change check for reset image flags to print messages only once per data file

This commit is contained in:
Axel Kohlmeyer
2021-10-13 21:54:18 -04:00
parent afad3f42d5
commit f4851e9103
3 changed files with 28 additions and 21 deletions

View File

@ -260,6 +260,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
map_hash = nullptr;
unique_tags = nullptr;
reset_image_flag[0] = reset_image_flag[1] = reset_image_flag[2] = false;
atom_style = nullptr;
avec = nullptr;
@ -1134,7 +1135,6 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
// remap atom into simulation box
// if atom is in my sub-domain, unpack its values
int flagx = 0, flagy = 0, flagz = 0;
for (int i = 0; i < n; i++) {
next = strchr(buf,'\n');
@ -1154,9 +1154,9 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
imz = utils::inumeric(FLERR,values[iptr+2],false,lmp);
if ((domain->dimension == 2) && (imz != 0))
error->all(FLERR,"Z-direction image flag must be 0 for 2d-systems");
if ((!domain->xperiodic) && (imx != 0)) { flagx = 1; imx = 0; }
if ((!domain->yperiodic) && (imy != 0)) { flagy = 1; imy = 0; }
if ((!domain->zperiodic) && (imz != 0)) { flagz = 1; imz = 0; }
if ((!domain->xperiodic) && (imx != 0)) { reset_image_flag[0] = true; imx = 0; }
if ((!domain->yperiodic) && (imy != 0)) { reset_image_flag[1] = true; imy = 0; }
if ((!domain->zperiodic) && (imz != 0)) { reset_image_flag[2] = true; imz = 0; }
}
imagedata = ((imageint) (imx + IMGMAX) & IMGMASK) |
(((imageint) (imy + IMGMAX) & IMGMASK) << IMGBITS) |
@ -1192,23 +1192,6 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
buf = next + 1;
}
// warn if reading data with non-zero image flags for non-periodic boundaries.
// we may want to turn this into an error at some point, since this essentially
// creates invalid position information that works by accident most of the time.
if (comm->me == 0) {
if (flagx)
error->warning(FLERR,"Non-zero imageflag(s) in x direction for "
"non-periodic boundary reset to zero");
if (flagy)
error->warning(FLERR,"Non-zero imageflag(s) in y direction for "
"non-periodic boundary reset to zero");
if (flagz)
error->warning(FLERR,"Non-zero imageflag(s) in z direction for "
"non-periodic boundary reset to zero");
}
delete [] values;
}