forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10328 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
6755d5b44f
commit
cccc6475d9
|
@ -655,22 +655,22 @@ void Force::set_special(int narg, char **arg)
|
|||
compute bounds implied by numeric str with a possible wildcard asterik
|
||||
1 = lower bound, nmax = upper bound
|
||||
5 possibilities:
|
||||
(1) i = i to i, (2) * = 1 to nmax,
|
||||
(3) i* = i to nmax, (4) *j = 1 to j, (5) i*j = i to j
|
||||
(1) i = i to i, (2) * = nmin to nmax,
|
||||
(3) i* = i to nmax, (4) *j = nmin to j, (5) i*j = i to j
|
||||
return nlo,nhi
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Force::bounds(char *str, int nmax, int &nlo, int &nhi)
|
||||
void Force::bounds(char *str, int nmax, int &nlo, int &nhi, int nmin)
|
||||
{
|
||||
char *ptr = strchr(str,'*');
|
||||
|
||||
if (ptr == NULL) {
|
||||
nlo = nhi = atoi(str);
|
||||
} else if (strlen(str) == 1) {
|
||||
nlo = 1;
|
||||
nlo = nmin;
|
||||
nhi = nmax;
|
||||
} else if (ptr == str) {
|
||||
nlo = 1;
|
||||
nlo = nmin;
|
||||
nhi = atoi(ptr+1);
|
||||
} else if (strlen(ptr+1) == 0) {
|
||||
nlo = atoi(str);
|
||||
|
@ -680,7 +680,8 @@ void Force::bounds(char *str, int nmax, int &nlo, int &nhi)
|
|||
nhi = atoi(ptr+1);
|
||||
}
|
||||
|
||||
if (nlo < 1 || nhi > nmax) error->all(FLERR,"Numeric index is out of bounds");
|
||||
if (nlo < nmin || nhi > nmax)
|
||||
error->all(FLERR,"Numeric index is out of bounds");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
|
@ -99,7 +99,7 @@ class Force : protected Pointers {
|
|||
class KSpace *kspace_match(const char *, int);
|
||||
|
||||
void set_special(int, char **);
|
||||
void bounds(char *, int, int &, int &);
|
||||
void bounds(char *, int, int &, int &, int nmin=1);
|
||||
double numeric(const char *, int, char *);
|
||||
int inumeric(const char *, int, char *);
|
||||
bigint memory_usage();
|
||||
|
|
|
@ -67,6 +67,7 @@ void Set::command(int narg, char **arg)
|
|||
id = new char[n];
|
||||
strcpy(id,arg[1]);
|
||||
select = NULL;
|
||||
selection(atom->nlocal);
|
||||
|
||||
// loop over keyword/value pairs
|
||||
// call appropriate routine to reset attributes
|
||||
|
@ -374,8 +375,7 @@ void Set::selection(int n)
|
|||
} else if (style == MOL_SELECT) {
|
||||
if (atom->molecule_flag == 0)
|
||||
error->all(FLERR,"Cannot use set mol with no molecule IDs defined");
|
||||
if (strcmp(id,"0") == 0) nlo = nhi = 0;
|
||||
else force->bounds(id,BIG,nlo,nhi);
|
||||
else force->bounds(id,BIG,nlo,nhi,0);
|
||||
|
||||
int *molecule = atom->molecule;
|
||||
for (int i = 0; i < n; i++)
|
||||
|
@ -423,8 +423,6 @@ void Set::set(int keyword)
|
|||
AtomVecLine *avec_line = (AtomVecLine *) atom->style_match("line");
|
||||
AtomVecTri *avec_tri = (AtomVecTri *) atom->style_match("tri");
|
||||
|
||||
selection(atom->nlocal);
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (!select[i]) continue;
|
||||
|
@ -563,7 +561,6 @@ void Set::setrandom(int keyword)
|
|||
AtomVecLine *avec_line = (AtomVecLine *) atom->style_match("line");
|
||||
AtomVecTri *avec_tri = (AtomVecTri *) atom->style_match("tri");
|
||||
|
||||
selection(atom->nlocal);
|
||||
RanPark *random = new RanPark(lmp,1);
|
||||
double **x = atom->x;
|
||||
int seed = ivalue;
|
||||
|
|
|
@ -3234,7 +3234,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
|||
newtree->left = newtree->middle = newtree->right = NULL;
|
||||
treestack[ntreestack++] = newtree;
|
||||
|
||||
// special function for file-style or atomfile-stlye variables
|
||||
// special function for file-style or atomfile-style variables
|
||||
|
||||
} else if (strcmp(word,"next") == 0) {
|
||||
if (narg != 1)
|
||||
|
@ -3260,16 +3260,14 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
|||
treestack[ntreestack++] = newtree;
|
||||
} else argstack[nargstack++] = value;
|
||||
|
||||
// ATOMFILE has one value per atom, only valid for
|
||||
// save values in tree
|
||||
// ATOMFILE has per-atom values, save values in tree
|
||||
// copy current per-atom values into result so can read next ones
|
||||
// set selfalloc = 1 so result will be deleted by free_tree() after eval
|
||||
|
||||
} else if (style[ivar] == ATOMFILE) {
|
||||
if (tree == NULL)
|
||||
error->all(FLERR,"Atomfile variable in equal-style variable formula");
|
||||
|
||||
// copy current per-atom values into result so can read next ones
|
||||
// set selfalloc = 1 so will be deleted by free_tree() after eval
|
||||
|
||||
double *result;
|
||||
memory->create(result,atom->nlocal,"variable:result");
|
||||
memcpy(result,reader[ivar]->fix->vstore,atom->nlocal*sizeof(double));
|
||||
|
|
Loading…
Reference in New Issue