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

This commit is contained in:
sjplimp
2016-08-08 13:47:55 +00:00
parent 0029040f11
commit 056ff192c6
11 changed files with 38 additions and 83 deletions

View File

@ -100,67 +100,58 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
// this can reset nvalues
int expand = 0;
char **earg,**arghold;
char **earg;
nvalues = input->expand_args(nvalues,&arg[9],mode,earg);
if (earg != &arg[9]) expand = 1;
arghold = arg;
arg = earg;
// parse values
which = argindex = value2index = NULL;
ids = NULL;
allocate_values(nvalues);
which = new int[nvalues];
argindex = new int[nvalues];
value2index = new int[nvalues];
ids = new char*[nvalues];
for (int i = 0; i < nvalues; i++) {
if (strcmp(arg[i],"x") == 0) {
which[i] = X;
argindex[i] = 0;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"y") == 0) {
which[i] = X;
argindex[i] = 1;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"z") == 0) {
which[i] = X;
argindex[i] = 2;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"vx") == 0) {
which[i] = V;
argindex[i] = 0;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"vy") == 0) {
which[i] = V;
argindex[i] = 1;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"vz") == 0) {
which[i] = V;
argindex[i] = 2;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"fx") == 0) {
which[i] = F;
argindex[i] = 0;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"fy") == 0) {
which[i] = F;
argindex[i] = 1;
ids[i] = NULL;
iarg++;
} else if (strcmp(arg[i],"fz") == 0) {
which[i] = F;
argindex[i] = 2;
ids[i] = NULL;
iarg++;
} else if ((strncmp(arg[i],"c_",2) == 0) ||
(strncmp(arg[i],"f_",2) == 0) ||
@ -193,7 +184,6 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
if (expand) {
for (int i = 0; i < nvalues; i++) delete [] earg[i];
memory->sfree(earg);
arg = arghold;
}
// setup and error check
@ -496,11 +486,11 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
FixAveHisto::~FixAveHisto()
{
memory->destroy(which);
memory->destroy(argindex);
memory->destroy(value2index);
delete [] which;
delete [] argindex;
delete [] value2index;
for (int i = 0; i < nvalues; i++) delete [] ids[i];
memory->sfree(ids);
delete [] ids;
if (fp && me == 0) fclose(fp);
@ -1003,18 +993,6 @@ void FixAveHisto::options(int iarg, int narg, char **arg)
}
}
/* ----------------------------------------------------------------------
reallocate vectors for each input value, of length N
------------------------------------------------------------------------- */
void FixAveHisto::allocate_values(int n)
{
memory->grow(which,n,"ave/hsito:which");
memory->grow(argindex,n,"ave/histo:argindex");
memory->grow(value2index,n,"ave/histo:value2index");
ids = (char **) memory->srealloc(ids,n*sizeof(char *),"ave/histo:ids");
}
/* ----------------------------------------------------------------------
calculate nvalid = next step on which end_of_step does something
can be this timestep if multiple of nfreq and nrepeat = 1