add error location propagation to atom->set_mass() and atom->check_mass()
This commit is contained in:
@ -336,7 +336,7 @@ void PairEAMAlloyGPU::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,setfl->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ void PairEAMFSGPU::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,fs->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -936,7 +936,7 @@ void PairEAMAlloyKokkos<DeviceType>::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,setfl->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -941,7 +941,7 @@ void PairEAMFSKokkos<DeviceType>::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,fs->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ void PairADP::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,setfl->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ void PairEAM::coeff(int narg, char **arg)
|
||||
if (i == j) {
|
||||
setflag[i][i] = 1;
|
||||
map[i] = ifuncfl;
|
||||
atom->set_mass(i,funcfl[ifuncfl].mass);
|
||||
atom->set_mass(FLERR,i,funcfl[ifuncfl].mass);
|
||||
count++;
|
||||
}
|
||||
scale[i][j] = 1.0;
|
||||
|
||||
@ -99,7 +99,7 @@ void PairEAMAlloy::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,setfl->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
scale[i][j] = 1.0;
|
||||
|
||||
@ -99,7 +99,7 @@ void PairEAMFS::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,fs->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
scale[i][j] = 1.0;
|
||||
|
||||
@ -415,7 +415,7 @@ void PairEIM::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++)
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,setfl->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
@ -397,7 +397,7 @@ void PairMEAM::coeff(int narg, char **arg)
|
||||
for (int j = i; j <= n; j++)
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
@ -165,7 +165,7 @@ void PRD::command(int narg, char **arg)
|
||||
// create Velocity class for velocity creation in dephasing
|
||||
// pass it temperature compute, loop_setting, dist_setting settings
|
||||
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
velocity = new Velocity(lmp);
|
||||
velocity->init_external("all");
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
|
||||
else if (strcmp(arg[next],"t") == 0) mode = 't';
|
||||
else if (strcmp(arg[next],"m") == 0) {
|
||||
mode = 'm';
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
|
||||
// break if keyword that is not b,a,t,m
|
||||
|
||||
|
||||
@ -1983,7 +1983,7 @@ void PairMGPT::coeff(int narg, char **arg)
|
||||
|
||||
// Set atomic mass.
|
||||
for(int i = 1; i <= atom->ntypes; i++)
|
||||
atom->set_mass(i, splinepot.mass);
|
||||
atom->set_mass(FLERR,i, splinepot.mass);
|
||||
|
||||
// Initialize linear algebra routines.
|
||||
linalg = mgpt_linalg(lmax,single_precision);
|
||||
|
||||
@ -195,7 +195,7 @@ void FixAddTorque::post_force(int vflag)
|
||||
modify->addstep_compute(update->ntimestep + 1);
|
||||
}
|
||||
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double masstotal = group->mass(igroup);
|
||||
group->xcm(igroup,masstotal,xcm);
|
||||
group->inertia(igroup,xcm,inertia);
|
||||
|
||||
@ -98,7 +98,7 @@ void PairEAMAlloyOMP::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,setfl->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
scale[i][j] = 1.0;
|
||||
|
||||
@ -98,7 +98,7 @@ void PairEAMFSOMP::coeff(int narg, char **arg)
|
||||
for (j = i; j <= n; j++) {
|
||||
if (map[i] >= 0 && map[j] >= 0) {
|
||||
setflag[i][j] = 1;
|
||||
if (i == j) atom->set_mass(i,fs->mass[map[i]]);
|
||||
if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]);
|
||||
count++;
|
||||
}
|
||||
scale[i][j] = 1.0;
|
||||
|
||||
34
src/atom.cpp
34
src/atom.cpp
@ -503,7 +503,7 @@ void Atom::init()
|
||||
|
||||
// check arrays that are atom type in length
|
||||
|
||||
check_mass();
|
||||
check_mass(FLERR);
|
||||
|
||||
// setup of firstgroup
|
||||
|
||||
@ -1408,23 +1408,23 @@ void Atom::allocate_type_arrays()
|
||||
type_offset may be used when reading multiple data files
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::set_mass(const char *str, int type_offset)
|
||||
void Atom::set_mass(const char *file, int line, const char *str, int type_offset)
|
||||
{
|
||||
if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style");
|
||||
if (mass == NULL) error->all(file,line,"Cannot set mass for this atom style");
|
||||
|
||||
int itype;
|
||||
double mass_one;
|
||||
int n = sscanf(str,"%d %lg",&itype,&mass_one);
|
||||
if (n != 2) error->all(FLERR,"Invalid mass line in data file");
|
||||
if (n != 2) error->all(file,line,"Invalid mass line in data file");
|
||||
itype += type_offset;
|
||||
|
||||
if (itype < 1 || itype > ntypes)
|
||||
error->all(FLERR,"Invalid type for mass set");
|
||||
error->all(file,line,"Invalid type for mass set");
|
||||
|
||||
mass[itype] = mass_one;
|
||||
mass_setflag[itype] = 1;
|
||||
|
||||
if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value");
|
||||
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1432,16 +1432,16 @@ void Atom::set_mass(const char *str, int type_offset)
|
||||
called from EAM pair routine
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::set_mass(int itype, double value)
|
||||
void Atom::set_mass(const char *file, int line, int itype, double value)
|
||||
{
|
||||
if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style");
|
||||
if (mass == NULL) error->all(file,line,"Cannot set mass for this atom style");
|
||||
if (itype < 1 || itype > ntypes)
|
||||
error->all(FLERR,"Invalid type for mass set");
|
||||
error->all(file,line,"Invalid type for mass set");
|
||||
|
||||
mass[itype] = value;
|
||||
mass_setflag[itype] = 1;
|
||||
|
||||
if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value");
|
||||
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1449,19 +1449,19 @@ void Atom::set_mass(int itype, double value)
|
||||
called from reading of input script
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::set_mass(int narg, char **arg)
|
||||
void Atom::set_mass(const char *file, int line, int narg, char **arg)
|
||||
{
|
||||
if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style");
|
||||
if (mass == NULL) error->all(file,line,"Cannot set mass for this atom style");
|
||||
|
||||
int lo,hi;
|
||||
force->bounds(arg[0],ntypes,lo,hi);
|
||||
if (lo < 1 || hi > ntypes) error->all(FLERR,"Invalid type for mass set");
|
||||
force->bounds(file,line,arg[0],ntypes,lo,hi);
|
||||
if (lo < 1 || hi > ntypes) error->all(file,line,"Invalid type for mass set");
|
||||
|
||||
for (int itype = lo; itype <= hi; itype++) {
|
||||
mass[itype] = atof(arg[1]);
|
||||
mass_setflag[itype] = 1;
|
||||
|
||||
if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value");
|
||||
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1481,12 +1481,12 @@ void Atom::set_mass(double *values)
|
||||
check that all masses have been set
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::check_mass()
|
||||
void Atom::check_mass(const char *file, int line)
|
||||
{
|
||||
if (mass == NULL) return;
|
||||
for (int itype = 1; itype <= ntypes; itype++)
|
||||
if (mass_setflag[itype] == 0)
|
||||
error->all(FLERR,"Not all per-type masses are set");
|
||||
error->all(file,line,"Not all per-type masses are set");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -235,11 +235,11 @@ class Atom : protected Pointers {
|
||||
void data_bodies(int, char *, class AtomVecBody *, tagint);
|
||||
|
||||
virtual void allocate_type_arrays();
|
||||
void set_mass(const char *, int);
|
||||
void set_mass(int, double);
|
||||
void set_mass(int, char **);
|
||||
void set_mass(const char *, int, const char *, int);
|
||||
void set_mass(const char *, int, int, double);
|
||||
void set_mass(const char *, int, int, char **);
|
||||
void set_mass(double *);
|
||||
void check_mass();
|
||||
void check_mass(const char *, int);
|
||||
|
||||
int radius_consistency(int, double &);
|
||||
int shape_consistency(int, double &, double &, double &);
|
||||
|
||||
@ -1622,7 +1622,7 @@ void Input::mass()
|
||||
if (narg != 2) error->all(FLERR,"Illegal mass command");
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Mass command before simulation box is defined");
|
||||
atom->set_mass(narg,arg);
|
||||
atom->set_mass(FLERR,narg,arg);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -210,7 +210,7 @@ void Molecule::compute_mass()
|
||||
if (massflag) return;
|
||||
massflag = 1;
|
||||
|
||||
if (!rmassflag) atom->check_mass();
|
||||
if (!rmassflag) atom->check_mass(FLERR);
|
||||
|
||||
masstotal = 0.0;
|
||||
for (int i = 0; i < natoms; i++) {
|
||||
@ -234,7 +234,7 @@ void Molecule::compute_com()
|
||||
if (!comflag) {
|
||||
comflag = 1;
|
||||
|
||||
if (!rmassflag) atom->check_mass();
|
||||
if (!rmassflag) atom->check_mass(FLERR);
|
||||
|
||||
double onemass;
|
||||
com[0] = com[1] = com[2] = 0.0;
|
||||
@ -299,7 +299,7 @@ void Molecule::compute_inertia()
|
||||
if (!inertiaflag) {
|
||||
inertiaflag = 1;
|
||||
|
||||
if (!rmassflag) atom->check_mass();
|
||||
if (!rmassflag) atom->check_mass(FLERR);
|
||||
|
||||
double onemass,dx,dy,dz;
|
||||
for (int i = 0; i < 6; i++) itensor[i] = 0.0;
|
||||
|
||||
@ -1645,7 +1645,7 @@ void ReadData::mass()
|
||||
for (int i = 0; i < ntypes; i++) {
|
||||
next = strchr(buf,'\n');
|
||||
*next = '\0';
|
||||
atom->set_mass(buf,toffset);
|
||||
atom->set_mass(FLERR,buf,toffset);
|
||||
buf = next + 1;
|
||||
}
|
||||
delete [] original;
|
||||
|
||||
@ -3675,7 +3675,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"xcm") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double xcm[3];
|
||||
if (narg == 2) {
|
||||
double masstotal = group->mass(igroup);
|
||||
@ -3691,7 +3691,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"vcm") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double vcm[3];
|
||||
if (narg == 2) {
|
||||
double masstotal = group->mass(igroup);
|
||||
@ -3730,7 +3730,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"gyration") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double xcm[3];
|
||||
if (narg == 1) {
|
||||
double masstotal = group->mass(igroup);
|
||||
@ -3749,7 +3749,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"angmom") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double xcm[3],lmom[3];
|
||||
if (narg == 2) {
|
||||
double masstotal = group->mass(igroup);
|
||||
@ -3767,7 +3767,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"torque") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double xcm[3],tq[3];
|
||||
if (narg == 2) {
|
||||
double masstotal = group->mass(igroup);
|
||||
@ -3785,7 +3785,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"inertia") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double xcm[3],inertia[3][3];
|
||||
if (narg == 2) {
|
||||
double masstotal = group->mass(igroup);
|
||||
@ -3806,7 +3806,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||
else error->all(FLERR,"Invalid group function in variable formula");
|
||||
|
||||
} else if (strcmp(word,"omega") == 0) {
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
double xcm[3],angmom[3],inertia[3][3],omega[3];
|
||||
if (narg == 2) {
|
||||
double masstotal = group->mass(igroup);
|
||||
|
||||
@ -60,7 +60,7 @@ void Velocity::command(int narg, char **arg)
|
||||
|
||||
// atom masses must all be set
|
||||
|
||||
atom->check_mass();
|
||||
atom->check_mass(FLERR);
|
||||
|
||||
// identify group
|
||||
|
||||
|
||||
Reference in New Issue
Block a user