git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15414 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -102,7 +102,7 @@ Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
flushflag = 0;
|
||||
|
||||
// set style and corresponding lineflag
|
||||
// custom style builds its own line of keywords
|
||||
// custom style builds its own line of keywords, including wildcard expansion
|
||||
// customize a new thermo style by adding to if statement
|
||||
// allocate line string used for 3 tasks
|
||||
// concat of custom style args
|
||||
@ -121,14 +121,29 @@ Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
|
||||
} else if (strcmp(style,"custom") == 0) {
|
||||
if (narg == 1) error->all(FLERR,"Illegal thermo style custom command");
|
||||
|
||||
// expand args if any have wildcard character "*"
|
||||
|
||||
int expand = 0;
|
||||
char **earg;
|
||||
int nvalues = input->expand_args(narg-1,&arg[1],0,earg);
|
||||
if (earg != &arg[1]) expand = 1;
|
||||
|
||||
line = new char[256+narg*64];
|
||||
line[0] = '\0';
|
||||
for (int iarg = 1; iarg < narg; iarg++) {
|
||||
strcat(line,arg[iarg]);
|
||||
for (int iarg = 0; iarg < nvalues; iarg++) {
|
||||
strcat(line,earg[iarg]);
|
||||
strcat(line," ");
|
||||
}
|
||||
line[strlen(line)-1] = '\0';
|
||||
|
||||
// if wildcard expansion occurred, free earg memory from exapnd_args()
|
||||
|
||||
if (expand) {
|
||||
for (int i = 0; i < nvalues; i++) delete [] earg[i];
|
||||
memory->sfree(earg);
|
||||
}
|
||||
|
||||
} else error->all(FLERR,"Illegal thermo style command");
|
||||
|
||||
// ptrs, flags, IDs for compute objects thermo may use or create
|
||||
@ -573,7 +588,7 @@ void Thermo::allocate()
|
||||
int n = nfield_initial + 1;
|
||||
|
||||
keyword = new char*[n];
|
||||
for (int i = 0; i < n; i++) keyword[i] = new char[32];
|
||||
for (int i = 0; i < n; i++) keyword[i] = NULL;
|
||||
vfunc = new FnPtr[n];
|
||||
vtype = new int[n];
|
||||
|
||||
@ -821,7 +836,6 @@ void Thermo::parse_fields(char *str)
|
||||
|
||||
// compute value = c_ID, fix value = f_ID, variable value = v_ID
|
||||
// count trailing [] and store int arguments
|
||||
// copy = at most 8 chars of ID to pass to addfield
|
||||
|
||||
} else if ((strncmp(word,"c_",2) == 0) || (strncmp(word,"f_",2) == 0) ||
|
||||
(strncmp(word,"v_",2) == 0)) {
|
||||
@ -829,9 +843,6 @@ void Thermo::parse_fields(char *str)
|
||||
int n = strlen(word);
|
||||
char *id = new char[n];
|
||||
strcpy(id,&word[2]);
|
||||
char copy[9];
|
||||
strncpy(copy,id,8);
|
||||
copy[8] = '\0';
|
||||
|
||||
// parse zero or one or two trailing brackets from ID
|
||||
// argindex1,argindex2 = int inside each bracket pair, 0 if no bracket
|
||||
@ -878,7 +889,7 @@ void Thermo::parse_fields(char *str)
|
||||
field2index[nfield] = add_compute(id,VECTOR);
|
||||
else
|
||||
field2index[nfield] = add_compute(id,ARRAY);
|
||||
addfield(copy,&Thermo::compute_compute,FLOAT);
|
||||
addfield(word,&Thermo::compute_compute,FLOAT);
|
||||
|
||||
} else if (word[0] == 'f') {
|
||||
n = modify->find_fix(id);
|
||||
@ -903,7 +914,7 @@ void Thermo::parse_fields(char *str)
|
||||
}
|
||||
|
||||
field2index[nfield] = add_fix(id);
|
||||
addfield(copy,&Thermo::compute_fix,FLOAT);
|
||||
addfield(word,&Thermo::compute_fix,FLOAT);
|
||||
|
||||
} else if (word[0] == 'v') {
|
||||
n = input->variable->find(id);
|
||||
@ -919,7 +930,7 @@ void Thermo::parse_fields(char *str)
|
||||
error->all(FLERR,"Thermo custom variable cannot have two indices");
|
||||
|
||||
field2index[nfield] = add_variable(id);
|
||||
addfield(copy,&Thermo::compute_variable,FLOAT);
|
||||
addfield(word,&Thermo::compute_variable,FLOAT);
|
||||
}
|
||||
|
||||
delete [] id;
|
||||
@ -936,6 +947,8 @@ void Thermo::parse_fields(char *str)
|
||||
|
||||
void Thermo::addfield(const char *key, FnPtr func, int typeflag)
|
||||
{
|
||||
int n = strlen(key) + 1;
|
||||
keyword[nfield] = new char[n];
|
||||
strcpy(keyword[nfield],key);
|
||||
vfunc[nfield] = func;
|
||||
vtype[nfield] = typeflag;
|
||||
|
||||
Reference in New Issue
Block a user