git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@7003 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
85
src/atom.cpp
85
src/atom.cpp
@ -42,9 +42,6 @@ using namespace LAMMPS_NS;
|
||||
#define EPSILON 1.0e-6
|
||||
#define CUDA_CHUNK 3000
|
||||
|
||||
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
||||
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
@ -322,7 +319,7 @@ AtomVec *Atom::new_avec(const char *style, int narg, char **arg,
|
||||
#include "style_atom.h"
|
||||
#undef ATOM_CLASS
|
||||
|
||||
else error->all("Invalid atom style");
|
||||
else error->all(FLERR,"Invalid atom style");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -348,7 +345,7 @@ void Atom::init()
|
||||
if (firstgroupname) {
|
||||
firstgroup = group->find(firstgroupname);
|
||||
if (firstgroup < 0)
|
||||
error->all("Could not find atom_modify first group ID");
|
||||
error->all(FLERR,"Could not find atom_modify first group ID");
|
||||
} else firstgroup = -1;
|
||||
|
||||
// init AtomVec
|
||||
@ -391,20 +388,20 @@ AtomVec *Atom::style_match(const char *style)
|
||||
|
||||
void Atom::modify_params(int narg, char **arg)
|
||||
{
|
||||
if (narg == 0) error->all("Illegal atom_modify command");
|
||||
if (narg == 0) error->all(FLERR,"Illegal atom_modify command");
|
||||
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"map") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal atom_modify command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command");
|
||||
if (strcmp(arg[iarg+1],"array") == 0) map_style = 1;
|
||||
else if (strcmp(arg[iarg+1],"hash") == 0) map_style = 2;
|
||||
else error->all("Illegal atom_modify command");
|
||||
else error->all(FLERR,"Illegal atom_modify command");
|
||||
if (domain->box_exist)
|
||||
error->all("Atom_modify map command after simulation box is defined");
|
||||
error->all(FLERR,"Atom_modify map command after simulation box is defined");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"first") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal atom_modify command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command");
|
||||
if (strcmp(arg[iarg+1],"all") == 0) {
|
||||
delete [] firstgroupname;
|
||||
firstgroupname = NULL;
|
||||
@ -416,16 +413,16 @@ void Atom::modify_params(int narg, char **arg)
|
||||
}
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"sort") == 0) {
|
||||
if (iarg+3 > narg) error->all("Illegal atom_modify command");
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal atom_modify command");
|
||||
sortfreq = atoi(arg[iarg+1]);
|
||||
userbinsize = atof(arg[iarg+2]);
|
||||
if (sortfreq < 0 || userbinsize < 0.0)
|
||||
error->all("Illegal atom_modify command");
|
||||
error->all(FLERR,"Illegal atom_modify command");
|
||||
if (sortfreq >= 0 && firstgroupname)
|
||||
error->all("Atom_modify sort and first options "
|
||||
error->all(FLERR,"Atom_modify sort and first options "
|
||||
"cannot be used together");
|
||||
iarg += 3;
|
||||
} else error->all("Illegal atom_modify command");
|
||||
} else error->all(FLERR,"Illegal atom_modify command");
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,7 +443,7 @@ void Atom::map_init()
|
||||
map_delete();
|
||||
|
||||
if (tag_enable == 0)
|
||||
error->all("Cannot create an atom map unless atoms have IDs");
|
||||
error->all(FLERR,"Cannot create an atom map unless atoms have IDs");
|
||||
|
||||
int max = 0;
|
||||
for (int i = 0; i < nlocal; i++) max = MAX(max,tag[i]);
|
||||
@ -764,7 +761,7 @@ void Atom::data_atoms(int n, char *buf)
|
||||
*next = '\n';
|
||||
|
||||
if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3)
|
||||
error->all("Incorrect atom format in data file");
|
||||
error->all(FLERR,"Incorrect atom format in data file");
|
||||
|
||||
char **values = new char*[nwords];
|
||||
|
||||
@ -814,10 +811,10 @@ void Atom::data_atoms(int n, char *buf)
|
||||
next = strchr(buf,'\n');
|
||||
|
||||
values[0] = strtok(buf," \t\n\r\f");
|
||||
if (values[0] == NULL) error->all("Incorrect atom format in data file");
|
||||
if (values[0] == NULL) error->all(FLERR,"Incorrect atom format in data file");
|
||||
for (m = 1; m < nwords; m++) {
|
||||
values[m] = strtok(NULL," \t\n\r\f");
|
||||
if (values[m] == NULL) error->all("Incorrect atom format in data file");
|
||||
if (values[m] == NULL) error->all(FLERR,"Incorrect atom format in data file");
|
||||
}
|
||||
|
||||
if (imageflag)
|
||||
@ -863,7 +860,7 @@ void Atom::data_vels(int n, char *buf)
|
||||
*next = '\n';
|
||||
|
||||
if (nwords != avec->size_data_vel)
|
||||
error->all("Incorrect velocity format in data file");
|
||||
error->all(FLERR,"Incorrect velocity format in data file");
|
||||
|
||||
char **values = new char*[nwords];
|
||||
|
||||
@ -880,7 +877,7 @@ void Atom::data_vels(int n, char *buf)
|
||||
|
||||
tagdata = atoi(values[0]);
|
||||
if (tagdata <= 0 || tagdata > map_tag_max)
|
||||
error->one("Invalid atom ID in Velocities section of data file");
|
||||
error->one(FLERR,"Invalid atom ID in Velocities section of data file");
|
||||
if ((m = map(tagdata)) >= 0) avec->data_vel(m,&values[1]);
|
||||
|
||||
buf = next + 1;
|
||||
@ -906,7 +903,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus)
|
||||
*next = '\n';
|
||||
|
||||
if (nwords != avec_bonus->size_data_bonus)
|
||||
error->all("Incorrect bonus data format in data file");
|
||||
error->all(FLERR,"Incorrect bonus data format in data file");
|
||||
|
||||
char **values = new char*[nwords];
|
||||
|
||||
@ -923,7 +920,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus)
|
||||
|
||||
tagdata = atoi(values[0]);
|
||||
if (tagdata <= 0 || tagdata > map_tag_max)
|
||||
error->one("Invalid atom ID in Bonus section of data file");
|
||||
error->one(FLERR,"Invalid atom ID in Bonus section of data file");
|
||||
|
||||
// ok to call child's data_atom_bonus() method thru parent avec_bonus,
|
||||
// since data_bonus() was called with child ptr, and method is virtual
|
||||
@ -952,9 +949,9 @@ void Atom::data_bonds(int n, char *buf)
|
||||
sscanf(buf,"%d %d %d %d",&tmp,&itype,&atom1,&atom2);
|
||||
if (atom1 <= 0 || atom1 > map_tag_max ||
|
||||
atom2 <= 0 || atom2 > map_tag_max)
|
||||
error->one("Invalid atom ID in Bonds section of data file");
|
||||
error->one(FLERR,"Invalid atom ID in Bonds section of data file");
|
||||
if (itype <= 0 || itype > nbondtypes)
|
||||
error->one("Invalid bond type in Bonds section of data file");
|
||||
error->one(FLERR,"Invalid bond type in Bonds section of data file");
|
||||
if ((m = map(atom1)) >= 0) {
|
||||
bond_type[m][num_bond[m]] = itype;
|
||||
bond_atom[m][num_bond[m]] = atom2;
|
||||
@ -988,9 +985,9 @@ void Atom::data_angles(int n, char *buf)
|
||||
if (atom1 <= 0 || atom1 > map_tag_max ||
|
||||
atom2 <= 0 || atom2 > map_tag_max ||
|
||||
atom3 <= 0 || atom3 > map_tag_max)
|
||||
error->one("Invalid atom ID in Angles section of data file");
|
||||
error->one(FLERR,"Invalid atom ID in Angles section of data file");
|
||||
if (itype <= 0 || itype > nangletypes)
|
||||
error->one("Invalid angle type in Angles section of data file");
|
||||
error->one(FLERR,"Invalid angle type in Angles section of data file");
|
||||
if ((m = map(atom2)) >= 0) {
|
||||
angle_type[m][num_angle[m]] = itype;
|
||||
angle_atom1[m][num_angle[m]] = atom1;
|
||||
@ -1036,9 +1033,9 @@ void Atom::data_dihedrals(int n, char *buf)
|
||||
atom2 <= 0 || atom2 > map_tag_max ||
|
||||
atom3 <= 0 || atom3 > map_tag_max ||
|
||||
atom4 <= 0 || atom4 > map_tag_max)
|
||||
error->one("Invalid atom ID in Dihedrals section of data file");
|
||||
error->one(FLERR,"Invalid atom ID in Dihedrals section of data file");
|
||||
if (itype <= 0 || itype > ndihedraltypes)
|
||||
error->one("Invalid dihedral type in Dihedrals section of data file");
|
||||
error->one(FLERR,"Invalid dihedral type in Dihedrals section of data file");
|
||||
if ((m = map(atom2)) >= 0) {
|
||||
dihedral_type[m][num_dihedral[m]] = itype;
|
||||
dihedral_atom1[m][num_dihedral[m]] = atom1;
|
||||
@ -1095,9 +1092,9 @@ void Atom::data_impropers(int n, char *buf)
|
||||
atom2 <= 0 || atom2 > map_tag_max ||
|
||||
atom3 <= 0 || atom3 > map_tag_max ||
|
||||
atom4 <= 0 || atom4 > map_tag_max)
|
||||
error->one("Invalid atom ID in Impropers section of data file");
|
||||
error->one(FLERR,"Invalid atom ID in Impropers section of data file");
|
||||
if (itype <= 0 || itype > nimpropertypes)
|
||||
error->one("Invalid improper type in Impropers section of data file");
|
||||
error->one(FLERR,"Invalid improper type in Impropers section of data file");
|
||||
if ((m = map(atom2)) >= 0) {
|
||||
improper_type[m][num_improper[m]] = itype;
|
||||
improper_atom1[m][num_improper[m]] = atom1;
|
||||
@ -1157,19 +1154,19 @@ void Atom::allocate_type_arrays()
|
||||
|
||||
void Atom::set_mass(const char *str)
|
||||
{
|
||||
if (mass == NULL) error->all("Cannot set mass for this atom style");
|
||||
if (mass == NULL) error->all(FLERR,"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("Invalid mass line in data file");
|
||||
if (n != 2) error->all(FLERR,"Invalid mass line in data file");
|
||||
|
||||
if (itype < 1 || itype > ntypes) error->all("Invalid type for mass set");
|
||||
if (itype < 1 || itype > ntypes) error->all(FLERR,"Invalid type for mass set");
|
||||
|
||||
mass[itype] = mass_one;
|
||||
mass_setflag[itype] = 1;
|
||||
|
||||
if (mass[itype] <= 0.0) error->all("Invalid mass value");
|
||||
if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1179,13 +1176,13 @@ void Atom::set_mass(const char *str)
|
||||
|
||||
void Atom::set_mass(int itype, double value)
|
||||
{
|
||||
if (mass == NULL) error->all("Cannot set mass for this atom style");
|
||||
if (itype < 1 || itype > ntypes) error->all("Invalid type for mass set");
|
||||
if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style");
|
||||
if (itype < 1 || itype > ntypes) error->all(FLERR,"Invalid type for mass set");
|
||||
|
||||
mass[itype] = value;
|
||||
mass_setflag[itype] = 1;
|
||||
|
||||
if (mass[itype] <= 0.0) error->all("Invalid mass value");
|
||||
if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1195,17 +1192,17 @@ void Atom::set_mass(int itype, double value)
|
||||
|
||||
void Atom::set_mass(int narg, char **arg)
|
||||
{
|
||||
if (mass == NULL) error->all("Cannot set mass for this atom style");
|
||||
if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style");
|
||||
|
||||
int lo,hi;
|
||||
force->bounds(arg[0],ntypes,lo,hi);
|
||||
if (lo < 1 || hi > ntypes) error->all("Invalid type for mass set");
|
||||
if (lo < 1 || hi > ntypes) error->all(FLERR,"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("Invalid mass value");
|
||||
if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1229,7 +1226,7 @@ void Atom::check_mass()
|
||||
{
|
||||
if (mass == NULL) return;
|
||||
for (int itype = 1; itype <= ntypes; itype++)
|
||||
if (mass_setflag[itype] == 0) error->all("All masses are not set");
|
||||
if (mass_setflag[itype] == 0) error->all(FLERR,"All masses are not set");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1433,7 +1430,7 @@ void Atom::sort()
|
||||
// if (current[i] != permute[i]) flag = 1;
|
||||
//int flagall;
|
||||
//MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world);
|
||||
//if (flagall) error->all("Atom sort did not operate correctly");
|
||||
//if (flagall) error->all(FLERR,"Atom sort did not operate correctly");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1463,7 +1460,7 @@ void Atom::setup_sort_bins()
|
||||
binsize = pow(1.0*CUDA_CHUNK/natoms*area,1.0/2.0);
|
||||
}
|
||||
}
|
||||
if (binsize == 0.0) error->all("Atom sorting has bin size = 0.0");
|
||||
if (binsize == 0.0) error->all(FLERR,"Atom sorting has bin size = 0.0");
|
||||
|
||||
double bininv = 1.0/binsize;
|
||||
|
||||
@ -1495,7 +1492,7 @@ void Atom::setup_sort_bins()
|
||||
bininvz = nbinz / (bboxhi[2]-bboxlo[2]);
|
||||
|
||||
if (1.0*nbinx*nbiny*nbinz > INT_MAX)
|
||||
error->one("Too many atom sorting bins");
|
||||
error->one(FLERR,"Too many atom sorting bins");
|
||||
|
||||
nbins = nbinx*nbiny*nbinz;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user