log labelmap reading from data file and improve error messages

This commit is contained in:
Axel Kohlmeyer
2022-09-09 06:11:22 -04:00
parent 97717d7cba
commit 2e6526b8f7
3 changed files with 33 additions and 17 deletions

View File

@ -1066,11 +1066,11 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
break; break;
} }
} }
*next = '\n';
if ((nwords != avec->size_data_atom) && (nwords != avec->size_data_atom + 3)) if ((nwords != avec->size_data_atom) && (nwords != avec->size_data_atom + 3))
error->all(FLERR,"Incorrect atom format in {}: {}", location, utils::trim(buf)); error->all(FLERR,"Incorrect format in {}: {}", location, utils::trim(buf));
*next = '\n';
// set bounds for my proc // set bounds for my proc
// if periodic and I am lo/hi proc, adjust bounds by EPSILON // if periodic and I am lo/hi proc, adjust bounds by EPSILON
// insures all data atoms will be owned even with round-off // insures all data atoms will be owned even with round-off
@ -1149,7 +1149,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
// skip over empty or comment lines // skip over empty or comment lines
} else if ((nvalues < nwords) || } else if ((nvalues < nwords) ||
((nvalues > nwords) && (!utils::strmatch(values[nwords],"^#")))) { ((nvalues > nwords) && (!utils::strmatch(values[nwords],"^#")))) {
error->all(FLERR, "Incorrect atom format in {}: {}", location, utils::trim(buf)); error->all(FLERR, "Incorrect format in {}: {}", location, utils::trim(buf));
} else { } else {
int imx = 0, imy = 0, imz = 0; int imx = 0, imy = 0, imz = 0;
if (imageflag) { if (imageflag) {

View File

@ -108,46 +108,50 @@ void CreateBox::command(int narg, char **arg)
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg], "bond/types") == 0) { if (strcmp(arg[iarg], "bond/types") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box bond/type", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box bond/type", error);
if (!atom->avec->bonds_allow) error->all(FLERR, "No bonds allowed with this atom style"); if (!atom->avec->bonds_allow)
error->all(FLERR, "No bonds allowed with atom style {}", atom->get_style());
atom->nbondtypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->nbondtypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "angle/types") == 0) { } else if (strcmp(arg[iarg], "angle/types") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box angle/types", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box angle/types", error);
if (!atom->avec->angles_allow) error->all(FLERR, "No angles allowed with this atom style"); if (!atom->avec->angles_allow)
error->all(FLERR, "No angles allowed with atom style {}", atom->get_style());
atom->nangletypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->nangletypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "dihedral/types") == 0) { } else if (strcmp(arg[iarg], "dihedral/types") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box dihedral/types", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box dihedral/types", error);
if (!atom->avec->dihedrals_allow) if (!atom->avec->dihedrals_allow)
error->all(FLERR, "No dihedrals allowed with this atom style"); error->all(FLERR, "No dihedrals allowed with atom style {}", atom->get_style());
atom->ndihedraltypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->ndihedraltypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "improper/types") == 0) { } else if (strcmp(arg[iarg], "improper/types") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box improper/types", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box improper/types", error);
if (!atom->avec->impropers_allow) if (!atom->avec->impropers_allow)
error->all(FLERR, "No impropers allowed with this atom style"); error->all(FLERR, "No impropers allowed with atom style {}", atom->get_style());
atom->nimpropertypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->nimpropertypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "extra/bond/per/atom") == 0) { } else if (strcmp(arg[iarg], "extra/bond/per/atom") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/bond/per/atom", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/bond/per/atom", error);
if (!atom->avec->bonds_allow) error->all(FLERR, "No bonds allowed with this atom style"); if (!atom->avec->bonds_allow)
error->all(FLERR, "No bonds allowed with atom style {}", atom->get_style());
atom->bond_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->bond_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "extra/angle/per/atom") == 0) { } else if (strcmp(arg[iarg], "extra/angle/per/atom") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/angle/per/atom", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/angle/per/atom", error);
if (!atom->avec->angles_allow) error->all(FLERR, "No angles allowed with this atom style"); if (!atom->avec->angles_allow)
error->all(FLERR, "No angles allowed with atom style {}", atom->get_style());
atom->angle_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->angle_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "extra/dihedral/per/atom") == 0) { } else if (strcmp(arg[iarg], "extra/dihedral/per/atom") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/dihedral/per/atom", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/dihedral/per/atom", error);
if (!atom->avec->dihedrals_allow) if (!atom->avec->dihedrals_allow)
error->all(FLERR, "No dihedrals allowed with this atom style"); error->all(FLERR, "No dihedrals allowed with atom style {}", atom->get_style());
atom->dihedral_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->dihedral_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "extra/improper/per/atom") == 0) { } else if (strcmp(arg[iarg], "extra/improper/per/atom") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/improper/per/atom", error); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "create_box extra/improper/per/atom", error);
if (!atom->avec->impropers_allow) if (!atom->avec->impropers_allow)
error->all(FLERR, "No impropers allowed with this atom style"); error->all(FLERR, "No impropers allowed with atom style {}", atom->get_style());
atom->improper_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); atom->improper_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "extra/special/per/atom") == 0) { } else if (strcmp(arg[iarg], "extra/special/per/atom") == 0) {

View File

@ -906,13 +906,23 @@ void ReadData::command(int narg, char **arg)
// at end of 1st pass, error check for required sections // at end of 1st pass, error check for required sections
// customize for new sections // customize for new sections
if ((nbonds && !bondflag) || (nangles && !angleflag) || (ndihedrals && !dihedralflag) || if (nbonds && !bondflag)
(nimpropers && !improperflag)) error->one(FLERR, "Bonds section for {} bonds not found", nbonds);
error->one(FLERR, "A required molecular topology section not found in data file"); if (nangles && !angleflag)
error->one(FLERR, "Angles section for {} angles not found", nangles);
if (ndihedrals && !dihedralflag)
error->one(FLERR, "Dihedrals section for {} dihedrals not found", ndihedrals);
if (nimpropers && !improperflag)
error->one(FLERR, "Impropers section for {} impropers not found", nimpropers);
if ((nellipsoids && !ellipsoidflag) || (nlines && !lineflag) || (ntris && !triflag) || if (nellipsoids && !ellipsoidflag)
(nbodies && !bodyflag)) error->one(FLERR, "Ellipsoids section for {} ellipsoids not found", nellipsoids);
error->one(FLERR, "Required bonus data not found in data file"); if (nlines && !lineflag)
error->one(FLERR, "Lines section for {} lines not found", nlines);
if (ntris && !triflag)
error->one(FLERR, "Triangles section for {} triangles not found", ntris);
if (nbodies && !bodyflag)
error->one(FLERR, "Bodies section for {} bodies not found", nbodies);
// break out of loop if no molecular topology in file // break out of loop if no molecular topology in file
// else make 2nd pass // else make 2nd pass
@ -2124,6 +2134,8 @@ void ReadData::typelabels(int mode)
int lntypes = 0; int lntypes = 0;
std::vector<std::string> *labels; std::vector<std::string> *labels;
std::unordered_map<std::string, int> *labels_map; std::unordered_map<std::string, int> *labels_map;
if (me == 0)
utils::logmesg(lmp, " reading {} labelmap ...\n", utils::lowercase(labeltypes[mode]));
switch (mode) { switch (mode) {
case Atom::ATOM: case Atom::ATOM: