forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15418 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
e6c5898e53
commit
98aee05152
|
@ -82,7 +82,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
|||
arghold = arg;
|
||||
arg = earg;
|
||||
|
||||
// parse remaining values until one isn't recognized
|
||||
// parse values until one isn't recognized
|
||||
|
||||
which = new int[nargnew];
|
||||
argindex = new int[nargnew];
|
||||
|
|
|
@ -57,15 +57,25 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
|||
global_freq = nfreq;
|
||||
no_change_box = 1;
|
||||
|
||||
// expand args if any have wildcard character "*"
|
||||
|
||||
int expand = 0;
|
||||
char **earg,**arghold;
|
||||
int nargnew = input->expand_args(narg-7,&arg[7],1,earg);
|
||||
|
||||
if (earg != &arg[7]) expand = 1;
|
||||
arghold = arg;
|
||||
arg = earg;
|
||||
|
||||
// parse values until one isn't recognized
|
||||
|
||||
int iarg = 7;
|
||||
which = new int[narg-iarg];
|
||||
argindex = new int[narg-iarg];
|
||||
ids = new char*[narg-iarg];
|
||||
value2index = new int[narg-iarg];
|
||||
which = new int[nargnew];
|
||||
argindex = new int[nargnew];
|
||||
ids = new char*[nargnew];
|
||||
value2index = new int[nargnew];
|
||||
nvalues = 0;
|
||||
|
||||
int iarg = 7;
|
||||
while (iarg < narg) {
|
||||
ids[nvalues] = NULL;
|
||||
|
||||
|
@ -152,7 +162,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
|||
char *title2 = NULL;
|
||||
char *title3 = NULL;
|
||||
|
||||
while (iarg < narg) {
|
||||
while (iarg < nargnew) {
|
||||
if (strcmp(arg[iarg],"norm") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
if (strcmp(arg[iarg+1],"all") == 0) {
|
||||
|
@ -349,7 +359,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
|||
else if (ncoord == 3)
|
||||
fprintf(fp,"# Chunk OrigID Coord1 Coord2 Coord3 Ncount");
|
||||
}
|
||||
for (int i = 0; i < nvalues; i++) fprintf(fp," %s",arg[7+i]);
|
||||
for (int i = 0; i < nvalues; i++) fprintf(fp," %s",earg[i]);
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
if (ferror(fp))
|
||||
|
@ -362,6 +372,15 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
|||
delete [] title2;
|
||||
delete [] title3;
|
||||
|
||||
// if wildcard expansion occurred, free earg memory from expand_args()
|
||||
// wait to do this until after file comment lines are printed
|
||||
|
||||
if (expand) {
|
||||
for (int i = 0; i < nvalues; i++) delete [] earg[i];
|
||||
memory->sfree(earg);
|
||||
arg = arghold;
|
||||
}
|
||||
|
||||
// this fix produces a global array
|
||||
// size_array_rows is variable and set by allocate()
|
||||
|
||||
|
|
|
@ -56,16 +56,26 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
|||
|
||||
global_freq = nfreq;
|
||||
|
||||
// expand args if any have wildcard character "*"
|
||||
|
||||
int expand = 0;
|
||||
char **earg,**arghold;
|
||||
int nargnew = input->expand_args(narg-6,&arg[6],0,earg);
|
||||
|
||||
if (earg != &arg[6]) expand = 1;
|
||||
arghold = arg;
|
||||
arg = earg;
|
||||
|
||||
// parse values until one isn't recognized
|
||||
|
||||
which = new int[narg-6];
|
||||
argindex = new int[narg-6];
|
||||
ids = new char*[narg-6];
|
||||
value2index = new int[narg-6];
|
||||
which = new int[nargnew];
|
||||
argindex = new int[nargnew];
|
||||
ids = new char*[nargnew];
|
||||
value2index = new int[nargnew];
|
||||
nvalues = 0;
|
||||
|
||||
int iarg = 6;
|
||||
while (iarg < narg) {
|
||||
int iarg = 0;
|
||||
while (iarg < nargnew) {
|
||||
if (strncmp(arg[iarg],"c_",2) == 0 ||
|
||||
strncmp(arg[iarg],"f_",2) == 0 ||
|
||||
strncmp(arg[iarg],"v_",2) == 0) {
|
||||
|
@ -107,7 +117,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
|||
char *title2 = NULL;
|
||||
char *title3 = NULL;
|
||||
|
||||
while (iarg < narg) {
|
||||
while (iarg < nargnew) {
|
||||
if (strcmp(arg[iarg],"type") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
|
||||
if (strcmp(arg[iarg+1],"auto") == 0) type = AUTO;
|
||||
|
@ -245,27 +255,27 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
|||
fprintf(fp,"# Index TimeDelta Ncount");
|
||||
if (type == AUTO)
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
fprintf(fp," %s*%s",arg[6+i],arg[6+i]);
|
||||
fprintf(fp," %s*%s",earg[i],earg[i]);
|
||||
else if (type == UPPER)
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
for (int j = i+1; j < nvalues; j++)
|
||||
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
||||
fprintf(fp," %s*%s",earg[i],earg[j]);
|
||||
else if (type == LOWER)
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
for (int j = 0; j < i-1; j++)
|
||||
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
||||
fprintf(fp," %s*%s",earg[i],earg[j]);
|
||||
else if (type == AUTOUPPER)
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
for (int j = i; j < nvalues; j++)
|
||||
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
||||
fprintf(fp," %s*%s",earg[i],earg[j]);
|
||||
else if (type == AUTOLOWER)
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
for (int j = 0; j < i; j++)
|
||||
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
||||
fprintf(fp," %s*%s",earg[i],earg[j]);
|
||||
else if (type == FULL)
|
||||
for (int i = 0; i < nvalues; i++)
|
||||
for (int j = 0; j < nvalues; j++)
|
||||
fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
|
||||
fprintf(fp," %s*%s",earg[i],earg[j]);
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
if (ferror(fp))
|
||||
|
@ -278,6 +288,15 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
|||
delete [] title2;
|
||||
delete [] title3;
|
||||
|
||||
// if wildcard expansion occurred, free earg memory from expand_args()
|
||||
// wait to do this until after file comment lines are printed
|
||||
|
||||
if (expand) {
|
||||
for (int i = 0; i < nvalues; i++) delete [] earg[i];
|
||||
memory->sfree(earg);
|
||||
arg = arghold;
|
||||
}
|
||||
|
||||
// allocate and initialize memory for averaging
|
||||
// set count and corr to zero since they accumulate
|
||||
// also set save versions to zero in case accessed via compute_array()
|
||||
|
|
|
@ -92,146 +92,108 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
|||
} else break;
|
||||
}
|
||||
|
||||
options(narg,arg);
|
||||
if (nvalues == 0) error->all(FLERR,"No values in fix ave/histo command");
|
||||
|
||||
// parse values until one isn't recognized
|
||||
// if mode = VECTOR and value is a global array:
|
||||
// expand it as if columns listed one by one
|
||||
// adjust nvalues accordingly via maxvalues
|
||||
options(iarg,narg,arg);
|
||||
|
||||
// expand args if any have wildcard character "*"
|
||||
// this can reset nvalues
|
||||
|
||||
int expand = 0;
|
||||
char **earg,**arghold;
|
||||
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;
|
||||
int maxvalues = nvalues;
|
||||
allocate_values(maxvalues);
|
||||
nvalues = 0;
|
||||
allocate_values(nvalues);
|
||||
|
||||
iarg = 9;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"x") == 0) {
|
||||
which[nvalues] = X;
|
||||
argindex[nvalues] = 0;
|
||||
ids[nvalues] = NULL;
|
||||
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[iarg],"y") == 0) {
|
||||
which[nvalues] = X;
|
||||
argindex[nvalues] = 1;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"y") == 0) {
|
||||
which[i] = X;
|
||||
argindex[i] = 1;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"z") == 0) {
|
||||
which[nvalues] = X;
|
||||
argindex[nvalues] = 2;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"z") == 0) {
|
||||
which[i] = X;
|
||||
argindex[i] = 2;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
|
||||
} else if (strcmp(arg[iarg],"vx") == 0) {
|
||||
which[nvalues] = V;
|
||||
argindex[nvalues] = 0;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"vx") == 0) {
|
||||
which[i] = V;
|
||||
argindex[i] = 0;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"vy") == 0) {
|
||||
which[nvalues] = V;
|
||||
argindex[nvalues] = 1;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"vy") == 0) {
|
||||
which[i] = V;
|
||||
argindex[i] = 1;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"vz") == 0) {
|
||||
which[nvalues] = V;
|
||||
argindex[nvalues] = 2;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"vz") == 0) {
|
||||
which[i] = V;
|
||||
argindex[i] = 2;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
|
||||
} else if (strcmp(arg[iarg],"fx") == 0) {
|
||||
which[nvalues] = F;
|
||||
argindex[nvalues] = 0;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"fx") == 0) {
|
||||
which[i] = F;
|
||||
argindex[i] = 0;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"fy") == 0) {
|
||||
which[nvalues] = F;
|
||||
argindex[nvalues] = 1;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"fy") == 0) {
|
||||
which[i] = F;
|
||||
argindex[i] = 1;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"fz") == 0) {
|
||||
which[nvalues] = F;
|
||||
argindex[nvalues] = 2;
|
||||
ids[nvalues] = NULL;
|
||||
nvalues++;
|
||||
} else if (strcmp(arg[i],"fz") == 0) {
|
||||
which[i] = F;
|
||||
argindex[i] = 2;
|
||||
ids[i] = NULL;
|
||||
iarg++;
|
||||
|
||||
} else if ((strncmp(arg[iarg],"c_",2) == 0) ||
|
||||
(strncmp(arg[iarg],"f_",2) == 0) ||
|
||||
(strncmp(arg[iarg],"v_",2) == 0)) {
|
||||
if (arg[iarg][0] == 'c') which[nvalues] = COMPUTE;
|
||||
else if (arg[iarg][0] == 'f') which[nvalues] = FIX;
|
||||
else if (arg[iarg][0] == 'v') which[nvalues] = VARIABLE;
|
||||
} else if ((strncmp(arg[i],"c_",2) == 0) ||
|
||||
(strncmp(arg[i],"f_",2) == 0) ||
|
||||
(strncmp(arg[i],"v_",2) == 0)) {
|
||||
if (arg[i][0] == 'c') which[i] = COMPUTE;
|
||||
else if (arg[i][0] == 'f') which[i] = FIX;
|
||||
else if (arg[i][0] == 'v') which[i] = VARIABLE;
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
int n = strlen(arg[i]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
strcpy(suffix,&arg[i][2]);
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
error->all(FLERR,"Illegal fix ave/histo command");
|
||||
argindex[nvalues] = atoi(ptr+1);
|
||||
argindex[i] = atoi(ptr+1);
|
||||
*ptr = '\0';
|
||||
} else argindex[nvalues] = 0;
|
||||
} else argindex[i] = 0;
|
||||
|
||||
n = strlen(suffix) + 1;
|
||||
ids[nvalues] = new char[n];
|
||||
strcpy(ids[nvalues],suffix);
|
||||
ids[i] = new char[n];
|
||||
strcpy(ids[i],suffix);
|
||||
delete [] suffix;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == VECTOR && which[nvalues] == COMPUTE &&
|
||||
argindex[nvalues] == 0) {
|
||||
int icompute = modify->find_compute(ids[nvalues]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix ave/histo does not exist");
|
||||
if (modify->compute[icompute]->array_flag) {
|
||||
int ncols = modify->compute[icompute]->size_array_cols;
|
||||
maxvalues += ncols-1;
|
||||
allocate_values(maxvalues);
|
||||
argindex[nvalues] = 1;
|
||||
for (int icol = 1; icol < ncols; icol++) {
|
||||
which[nvalues+icol] = which[nvalues];
|
||||
argindex[nvalues+icol] = icol+1;
|
||||
n = strlen(ids[nvalues]) + 1;
|
||||
ids[nvalues+icol] = new char[n];
|
||||
strcpy(ids[nvalues+icol],ids[nvalues]);
|
||||
}
|
||||
nvalues += ncols-1;
|
||||
}
|
||||
// if wildcard expansion occurred, free earg memory from expand_args()
|
||||
|
||||
} else if (mode == VECTOR && which[nvalues] == FIX &&
|
||||
argindex[nvalues] == 0) {
|
||||
int ifix = modify->find_fix(ids[nvalues]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix ave/histo does not exist");
|
||||
if (modify->fix[ifix]->array_flag) {
|
||||
int ncols = modify->fix[ifix]->size_array_cols;
|
||||
maxvalues += ncols-1;
|
||||
allocate_values(maxvalues);
|
||||
argindex[nvalues] = 1;
|
||||
for (int icol = 1; icol < ncols; icol++) {
|
||||
which[nvalues+icol] = which[nvalues];
|
||||
argindex[nvalues+icol] = icol+1;
|
||||
n = strlen(ids[nvalues]) + 1;
|
||||
ids[nvalues+icol] = new char[n];
|
||||
strcpy(ids[nvalues+icol],ids[nvalues]);
|
||||
}
|
||||
nvalues += ncols-1;
|
||||
}
|
||||
}
|
||||
|
||||
nvalues++;
|
||||
iarg++;
|
||||
} else break;
|
||||
if (expand) {
|
||||
for (int i = 0; i < nvalues; i++) delete [] earg[i];
|
||||
memory->sfree(earg);
|
||||
arg = arghold;
|
||||
}
|
||||
|
||||
// setup and error check
|
||||
|
@ -955,7 +917,7 @@ void FixAveHisto::bin_atoms(double *values, int stride)
|
|||
parse optional args
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixAveHisto::options(int narg, char **arg)
|
||||
void FixAveHisto::options(int iarg, int narg, char **arg)
|
||||
{
|
||||
// option defaults
|
||||
|
||||
|
@ -971,7 +933,6 @@ void FixAveHisto::options(int narg, char **arg)
|
|||
|
||||
// optional args
|
||||
|
||||
int iarg = 9 + nvalues;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"file") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
|
||||
|
|
|
@ -65,7 +65,7 @@ class FixAveHisto : public Fix {
|
|||
void bin_one(double);
|
||||
void bin_vector(int, double *, int);
|
||||
void bin_atoms(double *, int);
|
||||
void options(int, char **);
|
||||
void options(int, int, char **);
|
||||
void allocate_values(int);
|
||||
bigint nextvalid();
|
||||
};
|
||||
|
|
|
@ -288,7 +288,7 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
|
|||
delete [] title3;
|
||||
|
||||
// if wildcard expansion occurred, free earg memory from expand_args()
|
||||
// wait to do this after file comment lines are printed
|
||||
// wait to do this until after file comment lines are printed
|
||||
|
||||
if (expand) {
|
||||
for (int i = 0; i < nvalues; i++) delete [] earg[i];
|
||||
|
|
Loading…
Reference in New Issue