git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2908 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2009-06-29 15:29:26 +00:00
parent f2c53b8a14
commit da957fdb6d
2 changed files with 16 additions and 9 deletions

View File

@ -42,7 +42,7 @@ enum{INDEX,LOOP,EQUAL,WORLD,UNIVERSE,ULOOP,ATOM};
enum{ARG,OP}; enum{ARG,OP};
enum{DONE,ADD,SUBTRACT,MULTIPLY,DIVIDE,CARAT,UNARY, enum{DONE,ADD,SUBTRACT,MULTIPLY,DIVIDE,CARAT,UNARY,
SQRT,EXP,LN,LOG,SIN,COS,TAN,ASIN,ACOS,ATAN, SQRT,EXP,LN,LOG,SIN,COS,TAN,ASIN,ACOS,ATAN,
CEIL,FLOOR,ROUND,VALUE,ATOMARRAY,TYPEARRAY}; CEIL,FLOOR,ROUND,VALUE,ATOMARRAY,TYPEARRAY,INTARRAY};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -1160,6 +1160,7 @@ double Variable::eval_tree(Tree *tree, int i)
if (tree->type == VALUE) return tree->value; if (tree->type == VALUE) return tree->value;
if (tree->type == ATOMARRAY) return tree->array[i*tree->nstride]; if (tree->type == ATOMARRAY) return tree->array[i*tree->nstride];
if (tree->type == TYPEARRAY) return tree->array[atom->type[i]]; if (tree->type == TYPEARRAY) return tree->array[atom->type[i]];
if (tree->type == INTARRAY) return tree->iarray[i*tree->nstride];
if (tree->type == ADD) if (tree->type == ADD)
return eval_tree(tree->left,i) + eval_tree(tree->right,i); return eval_tree(tree->left,i) + eval_tree(tree->right,i);
@ -1595,7 +1596,7 @@ int Variable::region_function(char *id)
flag = 1 -> vector is a per-atom compute or fix quantity with nstride flag = 1 -> vector is a per-atom compute or fix quantity with nstride
id = positive global ID of atom, converted to local index id = positive global ID of atom, converted to local index
push result onto tree or arg stack push result onto tree or arg stack
customize by adding an atom vector: mass,x,y,z,vx,vy,vz,fx,fy,fz customize by adding an atom vector: mass,type,x,y,z,vx,vy,vz,fx,fy,fz
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Variable::peratom2global(int flag, char *word, void Variable::peratom2global(int flag, char *word,
@ -1613,9 +1614,10 @@ void Variable::peratom2global(int flag, char *word,
if (flag == 0) { if (flag == 0) {
if (strcmp(word,"mass") == 0) { if (strcmp(word,"mass") == 0) {
if (atom->mass) mine = atom->mass[atom->type[index]]; if (atom->rmass) mine = atom->rmass[index];
else mine = atom->rmass[index]; else mine = atom->mass[atom->type[index]];
} }
else if (strcmp(word,"type") == 0) mine = atom->type[index];
else if (strcmp(word,"x") == 0) mine = atom->x[index][0]; else if (strcmp(word,"x") == 0) mine = atom->x[index][0];
else if (strcmp(word,"y") == 0) mine = atom->x[index][1]; else if (strcmp(word,"y") == 0) mine = atom->x[index][1];
else if (strcmp(word,"z") == 0) mine = atom->x[index][2]; else if (strcmp(word,"z") == 0) mine = atom->x[index][2];
@ -1648,7 +1650,7 @@ void Variable::peratom2global(int flag, char *word,
process an atom vector in formula process an atom vector in formula
push result onto tree push result onto tree
word = atom vector word = atom vector
customize by adding an atom vector: mass,x,y,z,vx,vy,vz,fx,fy,fz customize by adding an atom vector: mass,type,x,y,z,vx,vy,vz,fx,fy,fz
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Variable::atom_vector(char *word, Tree **tree, void Variable::atom_vector(char *word, Tree **tree,
@ -1664,13 +1666,17 @@ void Variable::atom_vector(char *word, Tree **tree,
treestack[ntreestack++] = newtree; treestack[ntreestack++] = newtree;
if (strcmp(word,"mass") == 0) { if (strcmp(word,"mass") == 0) {
if (atom->mass) { if (atom->rmass) {
newtree->type = TYPEARRAY;
newtree->array = atom->mass;
} else {
newtree->nstride = 1; newtree->nstride = 1;
newtree->array = atom->rmass; newtree->array = atom->rmass;
} else {
newtree->type = TYPEARRAY;
newtree->array = atom->mass;
} }
} else if (strcmp(word,"type") == 0) {
newtree->type = INTARRAY;
newtree->nstride = 1;
newtree->iarray = atom->type;
} }
else if (strcmp(word,"x") == 0) newtree->array = &atom->x[0][0]; else if (strcmp(word,"x") == 0) newtree->array = &atom->x[0][0];
else if (strcmp(word,"y") == 0) newtree->array = &atom->x[0][1]; else if (strcmp(word,"y") == 0) newtree->array = &atom->x[0][1];

View File

@ -46,6 +46,7 @@ class Variable : protected Pointers {
struct Tree { // parse tree for atom-style variables struct Tree { // parse tree for atom-style variables
double value; double value;
double *array; double *array;
int *iarray;
int nstride; int nstride;
int type; int type;
Tree *left,*right; Tree *left,*right;