improved error messages in a bunch of region commands

This commit is contained in:
vpalkar
2022-08-15 15:04:18 -04:00
parent d9320c61bb
commit c1f81eb640
7 changed files with 21 additions and 17 deletions

View File

@ -80,8 +80,9 @@ RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
// error check // error check
if (xlo > xhi || ylo > yhi || zlo > zhi) if (xlo > xhi) error->all(FLERR,"Illegal region block xlo: {} >= xhi: {}", xlo, xhi);
error->all(FLERR,"Illegal region block command"); if (ylo > yhi) error->all(FLERR,"Illegal region block ylo: {} >= yhi: {}", ylo, yhi);
if (zlo > zhi) error->all(FLERR,"Illegal region block zlo: {} >= zhi: {}", zlo, zhi);
// extent of block // extent of block

View File

@ -40,10 +40,10 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
if (openflag) if (openflag)
for (int i=3; i<6; i++) for (int i=3; i<6; i++)
if (open_faces[i]) if (open_faces[i])
error->all(FLERR,"Illegal open face {} in region cylinder command", i); error->all(FLERR,"Illegal region cylinder open face: {}", i);
if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") != 0 && strcmp(arg[2],"z") != 0) if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") != 0 && strcmp(arg[2],"z") != 0)
error->all(FLERR,"Illegal axis {} in region cylinder command", arg[2]); error->all(FLERR,"Illegal region cylinder axis: {}", arg[2]);
axis = arg[2][0]; axis = arg[2][0];
if (axis == 'x') { if (axis == 'x') {

View File

@ -101,7 +101,9 @@ RegEllipsoid::RegEllipsoid(LAMMPS *lmp, int narg, char **arg) :
// error check // error check
if (a < 0.0 || b < 0.0 || c < 0.0) error->all(FLERR, "Illegal region ellipsoid command"); if (a < 0.0) error->all(FLERR, "Illegal region ellipsoid a: {}", a);
if (b < 0.0) error->all(FLERR, "Illegal region ellipsoid b: {}", b);
if (c < 0.0) error->all(FLERR, "Illegal region ellipsoid c: {}", c);
// extent of ellipsoid // extent of ellipsoid
// for variable axes, uses initial axes and origin for variable center // for variable axes, uses initial axes and origin for variable center

View File

@ -37,7 +37,7 @@ RegPlane::RegPlane(LAMMPS *lmp, int narg, char **arg) :
// enforce unit normal // enforce unit normal
double rsq = normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]; double rsq = normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2];
if (rsq == 0.0) error->all(FLERR,"Illegal region plane command"); if (rsq == 0.0) error->all(FLERR,"Illegal region plane normal vector: {} {} {}", normal[0], normal[1], normal[2]);
normal[0] /= sqrt(rsq); normal[0] /= sqrt(rsq);
normal[1] /= sqrt(rsq); normal[1] /= sqrt(rsq);
normal[2] /= sqrt(rsq); normal[2] /= sqrt(rsq);

View File

@ -84,23 +84,24 @@ RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
// prism cannot be 0 thickness in any dim, else inverse blows up // prism cannot be 0 thickness in any dim, else inverse blows up
// non-zero tilt values cannot be used if either dim is INF on both ends // non-zero tilt values cannot be used if either dim is INF on both ends
if (xlo >= xhi || ylo >= yhi || zlo >= zhi) if (xlo >= xhi) error->all(FLERR,"Illegal region prism xlo: {} >= xhi: {}", xlo, xhi);
error->all(FLERR,"Illegal region prism command"); if (ylo >= yhi) error->all(FLERR,"Illegal region prism ylo: {} >= yhi: {}", ylo, yhi);
if (zlo >= zhi) error->all(FLERR,"Illegal region prism zlo: {} >= zhi: {}", zlo ,zhi);
if (xy != 0.0 && xlo == -BIG && xhi == BIG) if (xy != 0.0 && xlo == -BIG && xhi == BIG)
error->all(FLERR,"Illegal region prism command"); error->all(FLERR,"Illegal region prism non-zero xy tilt with infinite x size");
if (xy != 0.0 && ylo == -BIG && yhi == BIG) if (xy != 0.0 && ylo == -BIG && yhi == BIG)
error->all(FLERR,"Illegal region prism command"); error->all(FLERR,"Illegal region prism non-zero xy tilt with infinite y size");
if (xz != 0.0 && xlo == -BIG && xhi == BIG) if (xz != 0.0 && xlo == -BIG && xhi == BIG)
error->all(FLERR,"Illegal region prism command"); error->all(FLERR,"Illegal region prism non-zero xz tilt with infinite x size");
if (xz != 0.0 && zlo == -BIG && zhi == BIG) if (xz != 0.0 && zlo == -BIG && zhi == BIG)
error->all(FLERR,"Illegal region prism command"); error->all(FLERR,"Illegal region prism non-zero xz tilt with infinite z size");
if (yz != 0.0 && ylo == -BIG && yhi == BIG) if (yz != 0.0 && ylo == -BIG && yhi == BIG)
error->all(FLERR,"Illegal region prism command"); error->all(FLERR,"Illegal region prism non-zero yz tilt with infinite y size");
if (yz != 0.0 && zlo == -BIG && zhi == BIG) if (yz != 0.0 && zlo == -BIG && zhi == BIG)
error->all(FLERR,"Illegal region prism command"); error->all(FLERR,"Illegal region prism non-zero yz tilt with infinite z size");
// extent of prism // extent of prism

View File

@ -79,7 +79,7 @@ RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) :
// error check // error check
if (radius < 0.0) error->all(FLERR,"Illegal region sphere command"); if (radius < 0.0) error->all(FLERR,"Illegal region sphere radius: {}", radius);
// extent of sphere // extent of sphere
// for variable radius, uses initial radius and origin for variable center // for variable radius, uses initial radius and origin for variable center

View File

@ -28,9 +28,9 @@ RegUnion::RegUnion(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg),
{ {
nregion = 0; nregion = 0;
if (narg < 5) error->all(FLERR, "Illegal region command"); if (narg < 5) error->all(FLERR, "Illegal region union {} arguments 5 expected");
int n = utils::inumeric(FLERR, arg[2], false, lmp); int n = utils::inumeric(FLERR, arg[2], false, lmp);
if (n < 2) error->all(FLERR, "Illegal region command"); if (n < 2) error->all(FLERR, "Illegal region union n: {}", n);
options(narg - (n + 3), &arg[n + 3]); options(narg - (n + 3), &arg[n + 3]);
// build list of region indices to union // build list of region indices to union