From d0470799ac8b491b6e88179cd03554f875698b76 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Wed, 28 Jun 2017 06:26:21 -0400 Subject: [PATCH] consistently check for all per-atom-type masses being set only when per-atom masses are not set rather than placing an if statement around every incidence of calling atom->check_mass() to ensure it is only called when per atom masses are not set, we place that check _inside_ Atom::check_mass(). This avoids unexpected error messages. --- src/atom.cpp | 3 ++- src/molecule.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index df4db0a842..e46b1a7242 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1514,12 +1514,13 @@ void Atom::set_mass(double *values) } /* ---------------------------------------------------------------------- - check that all masses have been set + check that all per-atom-type masses have been set ------------------------------------------------------------------------- */ void Atom::check_mass(const char *file, int line) { if (mass == NULL) return; + if (rmass_flag) return; for (int itype = 1; itype <= ntypes; itype++) if (mass_setflag[itype] == 0) error->all(file,line,"Not all per-type masses are set"); diff --git a/src/molecule.cpp b/src/molecule.cpp index 76b28e3d47..e0e9ec8aaf 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -219,7 +219,7 @@ void Molecule::compute_mass() if (massflag) return; massflag = 1; - if (!rmassflag) atom->check_mass(FLERR); + atom->check_mass(FLERR); masstotal = 0.0; for (int i = 0; i < natoms; i++) { @@ -243,7 +243,7 @@ void Molecule::compute_com() if (!comflag) { comflag = 1; - if (!rmassflag) atom->check_mass(FLERR); + atom->check_mass(FLERR); double onemass; com[0] = com[1] = com[2] = 0.0; @@ -308,7 +308,7 @@ void Molecule::compute_inertia() if (!inertiaflag) { inertiaflag = 1; - if (!rmassflag) atom->check_mass(FLERR); + atom->check_mass(FLERR); double onemass,dx,dy,dz; for (int i = 0; i < 6; i++) itensor[i] = 0.0; -- GitLab