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

This commit is contained in:
sjplimp
2013-02-18 17:00:25 +00:00
parent be4a5a8e54
commit f24bd36fe5
5 changed files with 52 additions and 8 deletions

View File

@ -84,8 +84,7 @@ void PairBrownianPoly::compute(int eflag, int vflag)
double xl[3],a_sq,a_sh,a_pu,Fbmag; double xl[3],a_sq,a_sh,a_pu,Fbmag;
double p1[3],p2[3],p3[3]; double p1[3],p2[3],p3[3];
// this section of code adjusts R0/RT0/RS0 if necessary due to changes
// This section of code adjusts R0/RT0/RS0 if necessary due to changes
// in the volume fraction as a result of fix deform or moving walls // in the volume fraction as a result of fix deform or moving walls
double dims[3], wallcoord; double dims[3], wallcoord;

View File

@ -65,8 +65,6 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
{ {
int i,ibody; int i,ibody;
scalar_flag = 1;
extscalar = 0;
time_integrate = 1; time_integrate = 1;
rigid_flag = 1; rigid_flag = 1;
virial_flag = 1; virial_flag = 1;

View File

@ -383,7 +383,8 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
// else $x becomes x followed by NULL // else $x becomes x followed by NULL
// beyond = points to text following variable // beyond = points to text following variable
int n; int i,n,paren_count;
char immediate[256];
char *var,*value,*beyond; char *var,*value,*beyond;
char quote = '\0'; char quote = '\0';
char *ptr = str; char *ptr = str;
@ -394,23 +395,56 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
char *ptr2 = str2; char *ptr2 = str2;
while (*ptr) { while (*ptr) {
// expand variable and append to str2 // variable substitution
if (*ptr == '$' && !quote) { if (*ptr == '$' && !quote) {
// value = ptr to expanded variable
// variable name between curly braces, e.g. ${a}
if (*(ptr+1) == '{') { if (*(ptr+1) == '{') {
var = ptr+2; var = ptr+2;
int i = 0; i = 0;
while (var[i] != '\0' && var[i] != '}') i++; while (var[i] != '\0' && var[i] != '}') i++;
if (var[i] == '\0') error->one(FLERR,"Invalid variable name"); if (var[i] == '\0') error->one(FLERR,"Invalid variable name");
var[i] = '\0'; var[i] = '\0';
beyond = ptr + strlen(var) + 3; beyond = ptr + strlen(var) + 3;
value = variable->retrieve(var);
// immediate variable between parenthesis, e.g. $(1/2)
} else if (*(ptr+1) == '(') {
var = ptr+2;
paren_count = 0;
i = 0;
while (var[i] != '\0' && !(var[i] == ')' && paren_count == 0)) {
switch (var[i]) {
case '(': paren_count++; break;
case ')': paren_count--; break;
default: ;
}
i++;
}
if (var[i] == '\0') error->one(FLERR,"Invalid immediate variable");
var[i] = '\0';
beyond = ptr + strlen(var) + 3;
sprintf(immediate,"%.20g",variable->compute_equal(var));
value = immediate;
// single character variable name, e.g. $a
} else { } else {
var = ptr; var = ptr;
var[0] = var[1]; var[0] = var[1];
var[1] = '\0'; var[1] = '\0';
beyond = ptr + 2; beyond = ptr + 2;
}
value = variable->retrieve(var); value = variable->retrieve(var);
}
if (value == NULL) error->one(FLERR,"Substitution for illegal variable"); if (value == NULL) error->one(FLERR,"Substitution for illegal variable");
// check if storage in str2 needs to be expanded // check if storage in str2 needs to be expanded
@ -428,8 +462,10 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
if (echo_screen && screen) fprintf(screen,"%s%s\n",str2,beyond); if (echo_screen && screen) fprintf(screen,"%s%s\n",str2,beyond);
if (echo_log && logfile) fprintf(logfile,"%s%s\n",str2,beyond); if (echo_log && logfile) fprintf(logfile,"%s%s\n",str2,beyond);
} }
continue; continue;
} }
if (*ptr == quote) quote = '\0'; if (*ptr == quote) quote = '\0';
else if (*ptr == '"' || *ptr == '\'') quote = *ptr; else if (*ptr == '"' || *ptr == '\'') quote = *ptr;

View File

@ -526,6 +526,16 @@ double Variable::compute_equal(int ivar)
return value; return value;
} }
/* ----------------------------------------------------------------------
return result of immediate equal-style variable evaluation
called from Input::substitute()
------------------------------------------------------------------------- */
double Variable::compute_equal(char *str)
{
return evaluate(str,NULL);
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
compute result of atom-style variable evaluation compute result of atom-style variable evaluation
only computed for atoms in igroup, else result is 0.0 only computed for atoms in igroup, else result is 0.0

View File

@ -31,6 +31,7 @@ class Variable : protected Pointers {
int atomstyle(int); int atomstyle(int);
char *retrieve(char *); char *retrieve(char *);
double compute_equal(int); double compute_equal(int);
double compute_equal(char *);
void compute_atom(int, int, double *, int, int); void compute_atom(int, int, double *, int, int);
int int_between_brackets(char *&); int int_between_brackets(char *&);
double evaluate_boolean(char *); double evaluate_boolean(char *);