more files with ArgInfo support added
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
#include "fix_ave_histo.h"
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "error.h"
|
||||
@ -28,7 +29,6 @@
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{X,V,F,COMPUTE,FIX,VARIABLE};
|
||||
enum{ONE,RUNNING};
|
||||
enum{SCALAR,VECTOR,WINDOW};
|
||||
enum{DEFAULT,GLOBAL,PERATOM,LOCAL};
|
||||
@ -113,67 +113,56 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (strcmp(arg[i],"x") == 0) {
|
||||
which[i] = X;
|
||||
which[i] = ArgInfo::X;
|
||||
argindex[i] = 0;
|
||||
ids[i] = nullptr;
|
||||
} else if (strcmp(arg[i],"y") == 0) {
|
||||
which[i] = X;
|
||||
which[i] = ArgInfo::X;
|
||||
argindex[i] = 1;
|
||||
ids[i] = nullptr;
|
||||
} else if (strcmp(arg[i],"z") == 0) {
|
||||
which[i] = X;
|
||||
which[i] = ArgInfo::X;
|
||||
argindex[i] = 2;
|
||||
ids[i] = nullptr;
|
||||
|
||||
} else if (strcmp(arg[i],"vx") == 0) {
|
||||
which[i] = V;
|
||||
which[i] = ArgInfo::V;
|
||||
argindex[i] = 0;
|
||||
ids[i] = nullptr;
|
||||
} else if (strcmp(arg[i],"vy") == 0) {
|
||||
which[i] = V;
|
||||
which[i] = ArgInfo::V;
|
||||
argindex[i] = 1;
|
||||
ids[i] = nullptr;
|
||||
} else if (strcmp(arg[i],"vz") == 0) {
|
||||
which[i] = V;
|
||||
which[i] = ArgInfo::V;
|
||||
argindex[i] = 2;
|
||||
ids[i] = nullptr;
|
||||
|
||||
} else if (strcmp(arg[i],"fx") == 0) {
|
||||
which[i] = F;
|
||||
which[i] = ArgInfo::F;
|
||||
argindex[i] = 0;
|
||||
ids[i] = nullptr;
|
||||
} else if (strcmp(arg[i],"fy") == 0) {
|
||||
which[i] = F;
|
||||
which[i] = ArgInfo::F;
|
||||
argindex[i] = 1;
|
||||
ids[i] = nullptr;
|
||||
} else if (strcmp(arg[i],"fz") == 0) {
|
||||
which[i] = F;
|
||||
which[i] = ArgInfo::F;
|
||||
argindex[i] = 2;
|
||||
ids[i] = nullptr;
|
||||
|
||||
} 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;
|
||||
} else {
|
||||
ArgInfo argi(arg[iarg]);
|
||||
|
||||
int n = strlen(arg[i]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[i][2]);
|
||||
if (argi.get_type() == ArgInfo::NONE) break;
|
||||
if ((argi.get_type() == ArgInfo::UNKNOWN) || (argi.get_dim() > 1))
|
||||
error->all(FLERR,"Invalid fix ave/histo command");
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
error->all(FLERR,"Illegal fix ave/histo command");
|
||||
argindex[i] = atoi(ptr+1);
|
||||
*ptr = '\0';
|
||||
} else argindex[i] = 0;
|
||||
which[nvalues] = argi.get_type();
|
||||
argindex[nvalues] = argi.get_index1();
|
||||
ids[nvalues] = argi.copy_name();
|
||||
|
||||
n = strlen(suffix) + 1;
|
||||
ids[i] = new char[n];
|
||||
strcpy(ids[i],suffix);
|
||||
delete [] suffix;
|
||||
nvalues++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,10 +190,11 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
kindglobal = kindperatom = kindlocal = 0;
|
||||
|
||||
if (which[i] == X || which[i] == V || which[i] == F) {
|
||||
if ((which[i] == ArgInfo::X) || (which[i] == ArgInfo::V)
|
||||
|| (which[i] == ArgInfo::F)) {
|
||||
kindperatom = 1;
|
||||
|
||||
} else if (which[i] == COMPUTE) {
|
||||
} else if (which[i] == ArgInfo::COMPUTE) {
|
||||
int c_id = modify->find_compute(ids[i]);
|
||||
if (c_id < 0) error->all(FLERR,"Fix ave/histo input is invalid compute");
|
||||
Compute *compute = modify->compute[c_id];
|
||||
@ -214,7 +204,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (compute->peratom_flag) kindperatom = 1;
|
||||
if (compute->local_flag) kindlocal = 1;
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
int f_id = modify->find_fix(ids[i]);
|
||||
if (f_id < 0) error->all(FLERR,"Fix ave/histo input is invalid fix");
|
||||
Fix *fix = modify->fix[f_id];
|
||||
@ -224,7 +214,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (fix->peratom_flag) kindperatom = 1;
|
||||
if (fix->local_flag) kindlocal = 1;
|
||||
|
||||
} else if (which[i] == VARIABLE) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||
int ivariable = input->variable->find(ids[i]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Fix ave/histo input is invalid variable");
|
||||
@ -262,7 +252,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,"Fix ave/histo cannot input local values in scalar mode");
|
||||
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (which[i] == COMPUTE && kind == GLOBAL && mode == SCALAR) {
|
||||
if (which[i] == ArgInfo::COMPUTE && kind == GLOBAL && mode == SCALAR) {
|
||||
int icompute = modify->find_compute(ids[i]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix ave/histo does not exist");
|
||||
@ -276,7 +266,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix ave/histo compute vector is accessed out-of-range");
|
||||
|
||||
} else if (which[i] == COMPUTE && kind == GLOBAL && mode == VECTOR) {
|
||||
} else if (which[i] == ArgInfo::COMPUTE && kind == GLOBAL && mode == VECTOR) {
|
||||
int icompute = modify->find_compute(ids[i]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix ave/histo does not exist");
|
||||
@ -291,7 +281,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix ave/histo compute array is accessed out-of-range");
|
||||
|
||||
} else if (which[i] == COMPUTE && kind == PERATOM) {
|
||||
} else if (which[i] == ArgInfo::COMPUTE && kind == PERATOM) {
|
||||
int icompute = modify->find_compute(ids[i]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix ave/histo does not exist");
|
||||
@ -310,7 +300,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix ave/histo compute array is accessed out-of-range");
|
||||
|
||||
} else if (which[i] == COMPUTE && kind == LOCAL) {
|
||||
} else if (which[i] == ArgInfo::COMPUTE && kind == LOCAL) {
|
||||
int icompute = modify->find_compute(ids[i]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix ave/histo does not exist");
|
||||
@ -329,7 +319,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix ave/histo compute array is accessed out-of-range");
|
||||
|
||||
} else if (which[i] == FIX && kind == GLOBAL && mode == SCALAR) {
|
||||
} else if (which[i] == ArgInfo::FIX && kind == GLOBAL && mode == SCALAR) {
|
||||
int ifix = modify->find_fix(ids[i]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix ave/histo does not exist");
|
||||
@ -345,7 +335,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix for fix ave/histo not computed at compatible time");
|
||||
|
||||
} else if (which[i] == FIX && kind == GLOBAL && mode == VECTOR) {
|
||||
} else if (which[i] == ArgInfo::FIX && kind == GLOBAL && mode == VECTOR) {
|
||||
int ifix = modify->find_fix(ids[i]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix ave/histo does not exist");
|
||||
@ -360,7 +350,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix for fix ave/histo not computed at compatible time");
|
||||
|
||||
} else if (which[i] == FIX && kind == PERATOM) {
|
||||
} else if (which[i] == ArgInfo::FIX && kind == PERATOM) {
|
||||
int ifix = modify->find_fix(ids[i]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix ave/histo does not exist");
|
||||
@ -381,7 +371,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix for fix ave/histo not computed at compatible time");
|
||||
|
||||
} else if (which[i] == FIX && kind == LOCAL) {
|
||||
} else if (which[i] == ArgInfo::FIX && kind == LOCAL) {
|
||||
int ifix = modify->find_fix(ids[i]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix ave/histo does not exist");
|
||||
@ -401,7 +391,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix for fix ave/histo not computed at compatible time");
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == GLOBAL && mode == SCALAR) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == GLOBAL && mode == SCALAR) {
|
||||
int ivariable = input->variable->find(ids[i]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Variable name for fix ave/histo does not exist");
|
||||
@ -410,7 +400,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (argindex[i] && input->variable->vectorstyle(ivariable) == 0)
|
||||
error->all(FLERR,"Fix ave/histo variable is not vector-style variable");
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == GLOBAL && mode == VECTOR) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == GLOBAL && mode == VECTOR) {
|
||||
int ivariable = input->variable->find(ids[i]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Variable name for fix ave/histo does not exist");
|
||||
@ -419,7 +409,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (argindex[i])
|
||||
error->all(FLERR,"Fix ave/histo variable cannot be indexed");
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||
int ivariable = input->variable->find(ids[i]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Variable name for fix ave/histo does not exist");
|
||||
@ -546,19 +536,19 @@ void FixAveHisto::init()
|
||||
// set current indices for all computes,fixes,variables
|
||||
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (which[i] == COMPUTE) {
|
||||
if (which[i] == ArgInfo::COMPUTE) {
|
||||
int icompute = modify->find_compute(ids[i]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix ave/histo does not exist");
|
||||
value2index[i] = icompute;
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
int ifix = modify->find_fix(ids[i]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix ave/histo does not exist");
|
||||
value2index[i] = ifix;
|
||||
|
||||
} else if (which[i] == VARIABLE) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||
int ivariable = input->variable->find(ids[i]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Variable name for fix ave/histo does not exist");
|
||||
@ -619,16 +609,16 @@ void FixAveHisto::end_of_step()
|
||||
|
||||
// atom attributes
|
||||
|
||||
if (which[i] == X)
|
||||
if (which[i] == ArgInfo::X)
|
||||
bin_atoms(&atom->x[0][j],3);
|
||||
else if (which[i] == V)
|
||||
else if (which[i] == ArgInfo::V)
|
||||
bin_atoms(&atom->v[0][j],3);
|
||||
else if (which[i] == F)
|
||||
else if (which[i] == ArgInfo::F)
|
||||
bin_atoms(&atom->f[0][j],3);
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
if (which[i] == COMPUTE) {
|
||||
if (which[i] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[m];
|
||||
|
||||
if (kind == GLOBAL && mode == SCALAR) {
|
||||
@ -686,7 +676,7 @@ void FixAveHisto::end_of_step()
|
||||
|
||||
// access fix fields, guaranteed to be ready
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
|
||||
Fix *fix = modify->fix[m];
|
||||
|
||||
@ -717,7 +707,7 @@ void FixAveHisto::end_of_step()
|
||||
|
||||
// evaluate equal-style or vector-style or atom-style variable
|
||||
|
||||
} else if (which[i] == VARIABLE) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||
if (kind == GLOBAL && mode == SCALAR) {
|
||||
if (j == 0) bin_one(input->variable->compute_equal(m));
|
||||
else {
|
||||
@ -732,7 +722,7 @@ void FixAveHisto::end_of_step()
|
||||
int nvec = input->variable->compute_vector(m,&varvec);
|
||||
bin_vector(nvec,varvec,1);
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vector);
|
||||
maxatom = atom->nmax;
|
||||
|
||||
Reference in New Issue
Block a user