git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14912 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{MOLECULE,CHARGE,INTEGER,DOUBLE};
|
||||
enum{MOLECULE,CHARGE,RMASS,INTEGER,DOUBLE};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -43,6 +43,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
molecule_flag = 0;
|
||||
q_flag = 0;
|
||||
rmass_flag = 0;
|
||||
|
||||
nvalue = 0;
|
||||
while (iarg < narg) {
|
||||
@ -64,6 +65,15 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
style[nvalue] = CHARGE;
|
||||
atom->q_flag = q_flag = 1;
|
||||
nvalue++;
|
||||
} else if (strcmp(arg[iarg],"rmass") == 0) {
|
||||
if (atom->rmass_flag)
|
||||
error->all(FLERR,"Fix property/atom rmass when atom_style "
|
||||
"already has rmass attribute");
|
||||
if (rmass_flag)
|
||||
error->all(FLERR,"Fix property/atom cannot specify rmass twice");
|
||||
style[nvalue] = RMASS;
|
||||
atom->rmass_flag = rmass_flag = 1;
|
||||
nvalue++;
|
||||
} else if (strstr(arg[iarg],"i_") == arg[iarg]) {
|
||||
style[nvalue] = INTEGER;
|
||||
int tmp;
|
||||
@ -105,10 +115,12 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (border == 0) {
|
||||
int flag = 0;
|
||||
for (int i = 0; i < nvalue; i++)
|
||||
if (style[i] == MOLECULE || style[i] == CHARGE) flag = 1;
|
||||
if (style[i] == MOLECULE
|
||||
|| style[i] == CHARGE
|
||||
|| style[i] == RMASS) flag = 1;
|
||||
if (flag && comm->me == 0)
|
||||
error->warning(FLERR,"Fix property/atom mol or charge w/out "
|
||||
"ghost communication");
|
||||
error->warning(FLERR,"Fix property/atom mol or charge or rmass"
|
||||
"w/out ghost communication");
|
||||
}
|
||||
|
||||
// store current atom style
|
||||
@ -149,6 +161,10 @@ FixPropertyAtom::~FixPropertyAtom()
|
||||
atom->q_flag = 0;
|
||||
memory->destroy(atom->q);
|
||||
atom->q = NULL;
|
||||
} else if (style[m] == RMASS) {
|
||||
atom->rmass_flag = 0;
|
||||
memory->destroy(atom->rmass);
|
||||
atom->rmass = NULL;
|
||||
} else if (style[m] == INTEGER) {
|
||||
atom->remove_custom(0,index[m]);
|
||||
} else if (style[m] == DOUBLE) {
|
||||
@ -251,6 +267,7 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||
for (j = 0; j < nvalue; j++) {
|
||||
if (style[j] == MOLECULE) atom->molecule[m] = ATOTAGINT(values[j+1]);
|
||||
else if (style[j] == CHARGE) atom->q[m] = atof(values[j+1]);
|
||||
else if (style[j] == RMASS) atom->rmass[m] = atof(values[j+1]);
|
||||
else if (style[j] == INTEGER)
|
||||
atom->ivector[index[j]][m] = atoi(values[j+1]);
|
||||
else if (style[j] == DOUBLE)
|
||||
@ -316,6 +333,9 @@ void FixPropertyAtom::write_data_section_pack(int mth, double **buf)
|
||||
} else if (style[m] == CHARGE) {
|
||||
double *q = atom->q;
|
||||
for (i = 0; i < nlocal; i++) buf[i][mp1] = q[i];
|
||||
} else if (style[m] == RMASS) {
|
||||
double *rmass = atom->rmass;
|
||||
for (i = 0; i < nlocal; i++) buf[i][mp1] = rmass[i];
|
||||
} else if (style[m] == INTEGER) {
|
||||
int *ivec = atom->ivector[index[m]];
|
||||
for (i = 0; i < nlocal; i++) buf[i][mp1] = ubuf(ivec[i]).d;
|
||||
@ -374,6 +394,7 @@ double FixPropertyAtom::memory_usage()
|
||||
for (int m = 0; m < nvalue; m++) {
|
||||
if (style[m] == MOLECULE) bytes = atom->nmax * sizeof(tagint);
|
||||
else if (style[m] == CHARGE) bytes = atom->nmax * sizeof(double);
|
||||
else if (style[m] == RMASS) bytes = atom->nmax * sizeof(double);
|
||||
else if (style[m] == INTEGER) bytes = atom->nmax * sizeof(int);
|
||||
else if (style[m] == DOUBLE) bytes = atom->nmax * sizeof(double);
|
||||
}
|
||||
@ -397,7 +418,10 @@ void FixPropertyAtom::grow_arrays(int nmax)
|
||||
} else if (style[m] == CHARGE) {
|
||||
memory->grow(atom->q,nmax,"atom:q");
|
||||
size_t nbytes = (nmax-nmax_old) * sizeof(double);
|
||||
memset(&atom->q[nmax_old],0,nbytes);
|
||||
} else if (style[m] == RMASS) {
|
||||
memory->grow(atom->rmass,nmax,"atom:rmass");
|
||||
size_t nbytes = (nmax-nmax_old) * sizeof(double);
|
||||
memset(&atom->rmass[nmax_old],0,nbytes);
|
||||
} else if (style[m] == INTEGER) {
|
||||
memory->grow(atom->ivector[index[m]],nmax,"atom:ivector");
|
||||
size_t nbytes = (nmax-nmax_old) * sizeof(int);
|
||||
@ -423,6 +447,8 @@ void FixPropertyAtom::copy_arrays(int i, int j, int delflag)
|
||||
atom->molecule[j] = atom->molecule[i];
|
||||
else if (style[m] == CHARGE)
|
||||
atom->q[j] = atom->q[i];
|
||||
else if (style[m] == RMASS)
|
||||
atom->rmass[j] = atom->rmass[i];
|
||||
else if (style[m] == INTEGER)
|
||||
atom->ivector[index[m]][j] = atom->ivector[index[m]][i];
|
||||
else if (style[m] == DOUBLE)
|
||||
@ -452,6 +478,12 @@ int FixPropertyAtom::pack_border(int n, int *list, double *buf)
|
||||
j = list[i];
|
||||
buf[m++] = q[j];
|
||||
}
|
||||
} else if (style[k] == RMASS) {
|
||||
double *rmass = atom->rmass;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = rmass[j];
|
||||
}
|
||||
} else if (style[k] == INTEGER) {
|
||||
int *ivector = atom->ivector[index[k]];
|
||||
for (i = 0; i < n; i++) {
|
||||
@ -490,6 +522,11 @@ int FixPropertyAtom::unpack_border(int n, int first, double *buf)
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++)
|
||||
q[i] = buf[m++];
|
||||
} else if (style[k] == RMASS) {
|
||||
double *rmass = atom->rmass;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++)
|
||||
rmass[i] = buf[m++];
|
||||
} else if (style[k] == INTEGER) {
|
||||
int *ivector = atom->ivector[index[k]];
|
||||
last = first + n;
|
||||
@ -515,6 +552,7 @@ int FixPropertyAtom::pack_exchange(int i, double *buf)
|
||||
for (int m = 0; m < nvalue; m++) {
|
||||
if (style[m] == MOLECULE) buf[m] = ubuf(atom->molecule[i]).d;
|
||||
else if (style[m] == CHARGE) buf[m] = atom->q[i];
|
||||
else if (style[m] == RMASS) buf[m] = atom->rmass[i];
|
||||
else if (style[m] == INTEGER) buf[m] = ubuf(atom->ivector[index[m]][i]).d;
|
||||
else if (style[m] == DOUBLE) buf[m] = atom->dvector[index[m]][i];
|
||||
}
|
||||
@ -532,6 +570,8 @@ int FixPropertyAtom::unpack_exchange(int nlocal, double *buf)
|
||||
atom->molecule[nlocal] = (tagint) ubuf(buf[m]).i;
|
||||
else if (style[m] == CHARGE)
|
||||
atom->q[nlocal] = buf[m];
|
||||
else if (style[m] == RMASS)
|
||||
atom->rmass[nlocal] = buf[m];
|
||||
else if (style[m] == INTEGER)
|
||||
atom->ivector[index[m]][nlocal] = (int) ubuf(buf[m]).i;
|
||||
else if (style[m] == DOUBLE)
|
||||
@ -552,6 +592,7 @@ int FixPropertyAtom::pack_restart(int i, double *buf)
|
||||
for (int j = 0; j < nvalue; j++) {
|
||||
if (style[j] == MOLECULE) buf[m++] = ubuf(atom->molecule[i]).d;
|
||||
else if (style[j] == CHARGE) buf[m++] = atom->q[i];
|
||||
else if (style[j] == RMASS) buf[m++] = atom->rmass[i];
|
||||
else if (style[j] == INTEGER) buf[m++] = ubuf(atom->ivector[index[j]][i]).d;
|
||||
else if (style[j] == DOUBLE) buf[m++] = atom->dvector[index[j]][i];
|
||||
}
|
||||
@ -578,6 +619,8 @@ void FixPropertyAtom::unpack_restart(int nlocal, int nth)
|
||||
atom->molecule[nlocal] = (tagint) ubuf(extra[nlocal][m++]).i;
|
||||
else if (style[i] == CHARGE)
|
||||
atom->q[nlocal] = extra[nlocal][m++];
|
||||
else if (style[i] == RMASS)
|
||||
atom->rmass[nlocal] = extra[nlocal][m++];
|
||||
else if (style[i] == INTEGER)
|
||||
atom->ivector[index[i]][nlocal] = (int) ubuf(extra[nlocal][m++]).i;
|
||||
else if (style[i] == DOUBLE)
|
||||
|
||||
Reference in New Issue
Block a user