change check for reset image flags to print messages only once per data file
This commit is contained in:
25
src/atom.cpp
25
src/atom.cpp
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -270,6 +270,10 @@ class Atom : protected Pointers {
|
||||
|
||||
int *sametag; // sametag[I] = next atom with same ID, -1 if no more
|
||||
|
||||
// true if image flags were reset to 0 during data_atoms()
|
||||
|
||||
bool reset_image_flag[3];
|
||||
|
||||
// AtomVec factory types and map
|
||||
|
||||
typedef AtomVec *(*AtomVecCreator)(LAMMPS *);
|
||||
|
||||
@ -312,6 +312,10 @@ void ReadData::command(int narg, char **arg)
|
||||
error->all(FLERR,fmt::format("Cannot open file {}: {}",
|
||||
arg[0], utils::getsyserror()));
|
||||
|
||||
// reset so we can warn about reset image flags exactly once per data file
|
||||
|
||||
atom->reset_image_flag[0] = atom->reset_image_flag[1] = atom->reset_image_flag[2] = false;
|
||||
|
||||
// first time system initialization
|
||||
|
||||
if (addflag == NONE) {
|
||||
@ -1238,6 +1242,22 @@ void ReadData::atoms()
|
||||
nread += nchunk;
|
||||
}
|
||||
|
||||
// warn if we have read 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 (atom->reset_image_flag[0])
|
||||
error->warning(FLERR,"Non-zero imageflag(s) in x direction for "
|
||||
"non-periodic boundary reset to zero");
|
||||
if (atom->reset_image_flag[1])
|
||||
error->warning(FLERR,"Non-zero imageflag(s) in y direction for "
|
||||
"non-periodic boundary reset to zero");
|
||||
if (atom->reset_image_flag[2])
|
||||
error->warning(FLERR,"Non-zero imageflag(s) in z direction for "
|
||||
"non-periodic boundary reset to zero");
|
||||
}
|
||||
|
||||
// check that all atoms were assigned correctly
|
||||
|
||||
bigint n = atom->nlocal;
|
||||
|
||||
Reference in New Issue
Block a user