git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10351 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -233,14 +233,19 @@ Atom::~Atom()
|
||||
// delete custom atom arrays
|
||||
|
||||
for (int i = 0; i < nivector; i++) {
|
||||
memory->destroy(ivector[i]);
|
||||
delete [] iname[i];
|
||||
memory->destroy(ivector[i]);
|
||||
}
|
||||
for (int i = 0; i < ndvector; i++) {
|
||||
memory->destroy(dvector[i]);
|
||||
delete [] dname[i];
|
||||
memory->destroy(dvector[i]);
|
||||
}
|
||||
|
||||
memory->sfree(iname);
|
||||
memory->sfree(dname);
|
||||
memory->sfree(ivector);
|
||||
memory->sfree(dvector);
|
||||
|
||||
// delete per-type arrays
|
||||
|
||||
delete [] mass;
|
||||
|
||||
@ -43,6 +43,7 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
// customize a new keyword by adding to if statement
|
||||
|
||||
pack_choice = new FnPtrPack[nvalues];
|
||||
index = new int[nvalues];
|
||||
|
||||
int i;
|
||||
for (int iarg = 3; iarg < narg; iarg++) {
|
||||
@ -336,6 +337,21 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
"atom property that isn't allocated");
|
||||
pack_choice[i] = &ComputePropertyAtom::pack_corner3z;
|
||||
|
||||
} else if (strstr(arg[iarg],"i_") == arg[iarg]) {
|
||||
int flag;
|
||||
index[i] = atom->find_custom(&arg[iarg][2],flag);
|
||||
if (index[i] < 0 || flag != 0)
|
||||
error->all(FLERR,"Compute property/atom floating point "
|
||||
"vector does not exist");
|
||||
pack_choice[i] = &ComputePropertyAtom::pack_iname;
|
||||
} else if (strstr(arg[iarg],"d_") == arg[iarg]) {
|
||||
int flag;
|
||||
index[i] = atom->find_custom(&arg[iarg][2],flag);
|
||||
if (index[i] < 0 || flag != 1)
|
||||
error->all(FLERR,"Compute property/atom integer "
|
||||
"vector does not exist");
|
||||
pack_choice[i] = &ComputePropertyAtom::pack_dname;
|
||||
|
||||
} else error->all(FLERR,"Invalid keyword in compute property/atom command");
|
||||
}
|
||||
|
||||
@ -349,6 +365,7 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
ComputePropertyAtom::~ComputePropertyAtom()
|
||||
{
|
||||
delete [] pack_choice;
|
||||
delete [] index;
|
||||
memory->destroy(vector);
|
||||
memory->destroy(array);
|
||||
}
|
||||
@ -1667,3 +1684,33 @@ void ComputePropertyAtom::pack_corner3z(int n)
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputePropertyAtom::pack_iname(int n)
|
||||
{
|
||||
int *ivector = atom->ivector[index[n]];
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = ivector[i];
|
||||
else buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputePropertyAtom::pack_dname(int n)
|
||||
{
|
||||
double *dvector = atom->dvector[index[n]];
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = dvector[i];
|
||||
else buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ class ComputePropertyAtom : public Compute {
|
||||
private:
|
||||
int nvalues;
|
||||
int nmax;
|
||||
int *index;
|
||||
double *vector;
|
||||
double **array;
|
||||
double *buf;
|
||||
@ -119,6 +120,9 @@ class ComputePropertyAtom : public Compute {
|
||||
void pack_corner3x(int);
|
||||
void pack_corner3y(int);
|
||||
void pack_corner3z(int);
|
||||
|
||||
void pack_iname(int);
|
||||
void pack_dname(int);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
34
src/set.cpp
34
src/set.cpp
@ -43,7 +43,7 @@ enum{ATOM_SELECT,MOL_SELECT,TYPE_SELECT,GROUP_SELECT,REGION_SELECT};
|
||||
enum{TYPE,TYPE_FRACTION,MOLECULE,X,Y,Z,CHARGE,MASS,SHAPE,LENGTH,TRI,
|
||||
DIPOLE,DIPOLE_RANDOM,QUAT,QUAT_RANDOM,THETA,ANGMOM,
|
||||
DIAMETER,DENSITY,VOLUME,IMAGE,BOND,ANGLE,DIHEDRAL,IMPROPER,
|
||||
MESO_E,MESO_CV,MESO_RHO};
|
||||
MESO_E,MESO_CV,MESO_RHO,INAME,DNAME};
|
||||
|
||||
#define BIG INT_MAX
|
||||
|
||||
@ -384,6 +384,28 @@ void Set::command(int narg, char **arg)
|
||||
set(MESO_RHO);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strstr(arg[iarg],"i_") == arg[iarg]) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1);
|
||||
else ivalue = force->numeric(FLERR,arg[iarg+1]);
|
||||
int flag;
|
||||
index_custom = atom->find_custom(&arg[iarg][2],flag);
|
||||
if (index_custom < 0 || flag != 0)
|
||||
error->all(FLERR,"Set command integer vector does not exist");
|
||||
set(INAME);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strstr(arg[iarg],"i_") == arg[iarg]) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1);
|
||||
else dvalue = force->numeric(FLERR,arg[iarg+1]);
|
||||
int flag;
|
||||
index_custom = atom->find_custom(&arg[iarg][2],flag);
|
||||
if (index_custom < 0 || flag != 1)
|
||||
error->all(FLERR,"Set command floating point vector does not exist");
|
||||
set(DNAME);
|
||||
iarg += 2;
|
||||
|
||||
} else error->all(FLERR,"Illegal set command");
|
||||
|
||||
// statistics
|
||||
@ -652,6 +674,16 @@ void Set::set(int keyword)
|
||||
atom->angmom[i][2] = zvalue;
|
||||
}
|
||||
|
||||
// set value for custom integer or double vector
|
||||
|
||||
else if (keyword == INAME) {
|
||||
atom->ivector[index_custom][i] = ivalue;
|
||||
}
|
||||
|
||||
else if (keyword == DNAME) {
|
||||
atom->dvector[index_custom][i] = dvalue;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user