Fix the typestr replacement with arg issue
This commit is contained in:
11
src/atom.cpp
11
src/atom.cpp
@ -1944,23 +1944,22 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg)
|
||||
error->all(file,line, "Cannot set per-type atom mass for atom style {}", atom_style);
|
||||
|
||||
char *typestr = utils::expand_type(file, line, arg[0], Atom::ATOM, lmp);
|
||||
if (typestr) arg[0] = typestr;
|
||||
const std::string str = typestr ? typestr : arg[0];
|
||||
delete[] typestr;
|
||||
|
||||
int lo, hi;
|
||||
utils::bounds(file, line, arg[0], 1, ntypes, lo, hi, error);
|
||||
utils::bounds(file, line, str, 1, ntypes, lo, hi, error);
|
||||
if ((lo < 1) || (hi > ntypes))
|
||||
error->all(file, line, "Invalid atom type {} for atom mass", arg[0]);
|
||||
error->all(file, line, "Invalid atom type {} for atom mass", str);
|
||||
|
||||
const double value = utils::numeric(FLERR, arg[1], false, lmp);
|
||||
if (value <= 0.0)
|
||||
error->all(file, line, "Invalid atom mass value {} for type {}", value, arg[0]);
|
||||
error->all(file, line, "Invalid atom mass value {} for type {}", value, str);
|
||||
|
||||
for (int itype = lo; itype <= hi; itype++) {
|
||||
mass[itype] = value;
|
||||
mass_setflag[itype] = 1;
|
||||
}
|
||||
|
||||
delete[] typestr;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user