continue adding ArgInfo support
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
#include "fix_halt.h"
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "error.h"
|
||||
@ -56,16 +57,22 @@ FixHalt::FixHalt(LAMMPS *lmp, int narg, char **arg) :
|
||||
strcpy(dlimit_path,".");
|
||||
} else if (strcmp(arg[iarg],"bondmax") == 0) {
|
||||
attribute = BONDMAX;
|
||||
} else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
} else {
|
||||
ArgInfo argi(arg[iarg],ArgInfo::VARIABLE);
|
||||
|
||||
if ((argi.get_type() == ArgInfo::UNKNOWN)
|
||||
|| (argi.get_type() == ArgInfo::NONE)
|
||||
|| (argi.get_dim() != 0))
|
||||
error->all(FLERR,"Invalid fix halt attribute");
|
||||
|
||||
attribute = VARIABLE;
|
||||
int n = strlen(arg[iarg]);
|
||||
idvar = new char[n];
|
||||
strcpy(idvar,&arg[iarg][2]);
|
||||
idvar = argi.copy_name();
|
||||
ivar = input->variable->find(idvar);
|
||||
|
||||
if (ivar < 0) error->all(FLERR,"Could not find fix halt variable name");
|
||||
if (input->variable->equalstyle(ivar) == 0)
|
||||
error->all(FLERR,"Fix halt variable is not equal-style variable");
|
||||
} else error->all(FLERR,"Invalid fix halt attribute");
|
||||
}
|
||||
|
||||
++iarg;
|
||||
if (strcmp(arg[iarg],"<") == 0) operation = LT;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include "fix_store_state.h"
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "domain.h"
|
||||
@ -30,9 +31,6 @@
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{KEYWORD,COMPUTE,FIX,VARIABLE,DNAME,INAME};
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
||||
@ -62,7 +60,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int iarg = 4;
|
||||
while (iarg < narg) {
|
||||
which[nvalues] = KEYWORD;
|
||||
which[nvalues] = ArgInfo::KEYWORD;
|
||||
ids[nvalues] = nullptr;
|
||||
|
||||
if (strcmp(arg[iarg],"id") == 0) {
|
||||
@ -222,38 +220,19 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
||||
"Fix store/state for atom property that isn't allocated");
|
||||
pack_choice[nvalues++] = &FixStoreState::pack_tqz;
|
||||
|
||||
} else if (strncmp(arg[iarg],"c_",2) == 0 ||
|
||||
strncmp(arg[iarg],"d_",2) == 0 ||
|
||||
strncmp(arg[iarg],"f_",2) == 0 ||
|
||||
strncmp(arg[iarg],"i_",2) == 0 ||
|
||||
strncmp(arg[iarg],"v_",2) == 0) {
|
||||
cfv_any = 1;
|
||||
if (arg[iarg][0] == 'c') which[nvalues] = COMPUTE;
|
||||
else if (arg[iarg][0] == 'd') which[nvalues] = DNAME;
|
||||
else if (arg[iarg][0] == 'f') which[nvalues] = FIX;
|
||||
else if (arg[iarg][0] == 'i') which[nvalues] = INAME;
|
||||
else if (arg[iarg][0] == 'v') which[nvalues] = VARIABLE;
|
||||
} else {
|
||||
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
if (argi.get_type() == ArgInfo::NONE) break;
|
||||
if ((argi.get_type() == ArgInfo::UNKNOWN) || (argi.get_dim() > 1))
|
||||
error->all(FLERR,"Illegal fix store/state command");
|
||||
argindex[nvalues] = atoi(ptr+1);
|
||||
*ptr = '\0';
|
||||
} else argindex[nvalues] = 0;
|
||||
|
||||
n = strlen(suffix) + 1;
|
||||
ids[nvalues] = new char[n];
|
||||
strcpy(ids[nvalues],suffix);
|
||||
which[nvalues] = argi.get_type();
|
||||
argindex[nvalues] = argi.get_index1();
|
||||
ids[nvalues] = argi.copy_name();
|
||||
nvalues++;
|
||||
delete [] suffix;
|
||||
|
||||
} else break;
|
||||
|
||||
}
|
||||
iarg++;
|
||||
}
|
||||
|
||||
@ -274,7 +253,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
||||
// error check
|
||||
|
||||
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 store/state does not exist");
|
||||
@ -294,21 +273,21 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix store/state compute array is accessed out-of-range");
|
||||
|
||||
} else if (which[i] == INAME) {
|
||||
} else if (which[i] == ArgInfo::INAME) {
|
||||
int icustom,iflag;
|
||||
icustom = atom->find_custom(ids[i],iflag);
|
||||
if ((icustom < 0) || (iflag != 0))
|
||||
error->all(FLERR,
|
||||
"Custom integer vector for fix store/state does not exist");
|
||||
|
||||
} else if (which[i] == DNAME) {
|
||||
} else if (which[i] == ArgInfo::DNAME) {
|
||||
int icustom,iflag;
|
||||
icustom = atom->find_custom(ids[i],iflag);
|
||||
if ((icustom < 0) || (iflag != 1))
|
||||
error->all(FLERR,
|
||||
"Custom floating point vector for fix store/state does not exist");
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
int ifix = modify->find_fix(ids[i]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,
|
||||
@ -329,7 +308,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix for fix store/state not computed at compatible time");
|
||||
|
||||
} 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 store/state does not exist");
|
||||
@ -406,13 +385,13 @@ void FixStoreState::init()
|
||||
if (!firstflag && nevery == 0) return;
|
||||
|
||||
for (int m = 0; m < nvalues; m++) {
|
||||
if (which[m] == COMPUTE) {
|
||||
if (which[m] == ArgInfo::COMPUTE) {
|
||||
int icompute = modify->find_compute(ids[m]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for fix store/state does not exist");
|
||||
value2index[m] = icompute;
|
||||
|
||||
} else if (which[m] == INAME) {
|
||||
} else if (which[m] == ArgInfo::INAME) {
|
||||
int icustom,iflag;
|
||||
icustom = atom->find_custom(ids[m],iflag);
|
||||
if ((icustom < 0) || (iflag != 0))
|
||||
@ -420,7 +399,7 @@ void FixStoreState::init()
|
||||
"Custom integer vector for fix store/state does not exist");
|
||||
value2index[m] = icustom;
|
||||
|
||||
} else if (which[m] == DNAME) {
|
||||
} else if (which[m] == ArgInfo::DNAME) {
|
||||
int icustom,iflag;
|
||||
icustom = atom->find_custom(ids[m],iflag);
|
||||
if ((icustom < 0) || (iflag != 1))
|
||||
@ -428,13 +407,13 @@ void FixStoreState::init()
|
||||
"Custom floating point vector for fix store/state does not exist");
|
||||
value2index[m] = icustom;
|
||||
|
||||
} else if (which[m] == FIX) {
|
||||
} else if (which[m] == ArgInfo::FIX) {
|
||||
int ifix = modify->find_fix(ids[m]);
|
||||
if (ifix < 0)
|
||||
error->all(FLERR,"Fix ID for fix store/state does not exist");
|
||||
value2index[m] = ifix;
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
} else if (which[m] == ArgInfo::VARIABLE) {
|
||||
int ivariable = input->variable->find(ids[m]);
|
||||
if (ivariable < 0)
|
||||
error->all(FLERR,"Variable name for fix store/state does not exist");
|
||||
@ -481,7 +460,7 @@ void FixStoreState::end_of_step()
|
||||
else vbuf = nullptr;
|
||||
|
||||
for (int m = 0; m < nvalues; m++) {
|
||||
if (which[m] == KEYWORD && kflag) (this->*pack_choice[m])(m);
|
||||
if (which[m] == ArgInfo::KEYWORD && kflag) (this->*pack_choice[m])(m);
|
||||
|
||||
else if (cfv_flag) {
|
||||
n = value2index[m];
|
||||
@ -492,7 +471,7 @@ void FixStoreState::end_of_step()
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
if (which[m] == COMPUTE) {
|
||||
if (which[m] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[n];
|
||||
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
|
||||
compute->compute_peratom();
|
||||
@ -512,7 +491,7 @@ void FixStoreState::end_of_step()
|
||||
|
||||
// access fix fields, guaranteed to be ready
|
||||
|
||||
} else if (which[m] == FIX) {
|
||||
} else if (which[m] == ArgInfo::FIX) {
|
||||
if (j == 0) {
|
||||
double *fix_vector = modify->fix[n]->vector_atom;
|
||||
for (i = 0; i < nlocal; i++)
|
||||
@ -526,19 +505,19 @@ void FixStoreState::end_of_step()
|
||||
|
||||
// access custom atom property fields
|
||||
|
||||
} else if (which[m] == INAME) {
|
||||
} else if (which[m] == ArgInfo::INAME) {
|
||||
int *ivector = atom->ivector[n];
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) values[i][m] = ivector[i];
|
||||
|
||||
} else if (which[m] == DNAME) {
|
||||
} else if (which[m] == ArgInfo::DNAME) {
|
||||
double *dvector = atom->dvector[n];
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) values[i][m] = dvector[i];
|
||||
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
} else if (which[m] == ArgInfo::VARIABLE) {
|
||||
input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include "fix_vector.h"
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "compute.h"
|
||||
#include "error.h"
|
||||
#include "input.h"
|
||||
@ -26,7 +27,6 @@
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{COMPUTE,FIX,VARIABLE};
|
||||
enum{ONE,RUNNING,WINDOW};
|
||||
enum{SCALAR,VECTOR};
|
||||
|
||||
@ -50,27 +50,16 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
nvalues = 0;
|
||||
for (int iarg = 4; iarg < narg; iarg++) {
|
||||
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 error->all(FLERR,"Illegal fix vector command");
|
||||
ArgInfo argi(arg[iarg]);
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
which[nvalues] = argi.get_type();
|
||||
argindex[nvalues] = argi.get_index1();
|
||||
ids[nvalues] = argi.copy_name();
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
if ((argi.get_type() == ArgInfo::UNKNOWN)
|
||||
|| (argi.get_type() == ArgInfo::NONE)
|
||||
|| (argi.get_dim() > 1))
|
||||
error->all(FLERR,"Illegal fix vector command");
|
||||
argindex[nvalues] = atoi(ptr+1);
|
||||
*ptr = '\0';
|
||||
} else argindex[nvalues] = 0;
|
||||
|
||||
n = strlen(suffix) + 1;
|
||||
ids[nvalues] = new char[n];
|
||||
strcpy(ids[nvalues],suffix);
|
||||
delete [] suffix;
|
||||
|
||||
nvalues++;
|
||||
}
|
||||
@ -79,7 +68,7 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
|
||||
// for fix inputs, check that fix frequency is acceptable
|
||||
|
||||
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 vector does not exist");
|
||||
@ -91,7 +80,7 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix vector compute vector is accessed out-of-range");
|
||||
|
||||
} 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 vector does not exist");
|
||||
@ -105,7 +94,7 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,
|
||||
"Fix for fix vector not computed at compatible time");
|
||||
|
||||
} 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 vector does not exist");
|
||||
@ -121,16 +110,16 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int value,finalvalue;
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (which[i] == COMPUTE) {
|
||||
if (which[i] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[modify->find_compute(ids[i])];
|
||||
if (argindex[0] == 0) value = compute->extscalar;
|
||||
else if (compute->extvector >= 0) value = compute->extvector;
|
||||
else value = compute->extlist[argindex[0]-1];
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
Fix *fix = modify->fix[modify->find_fix(ids[i])];
|
||||
if (argindex[i] == 0) value = fix->extvector;
|
||||
else value = fix->extarray;
|
||||
} else if (which[i] == VARIABLE) value = 0;
|
||||
} else if (which[i] == ArgInfo::VARIABLE) value = 0;
|
||||
if (i == 0) finalvalue = value;
|
||||
else if (value != finalvalue)
|
||||
error->all(FLERR,"Fix vector cannot set output array "
|
||||
@ -201,19 +190,19 @@ void FixVector::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 vector 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 vector 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 vector does not exist");
|
||||
@ -265,7 +254,7 @@ void FixVector::end_of_step()
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
if (which[i] == COMPUTE) {
|
||||
if (which[i] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[m];
|
||||
|
||||
if (argindex[i] == 0) {
|
||||
@ -284,7 +273,7 @@ void FixVector::end_of_step()
|
||||
|
||||
// access fix fields, guaranteed to be ready
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
if (argindex[i] == 0)
|
||||
result[i] = modify->fix[m]->compute_scalar();
|
||||
else
|
||||
@ -292,7 +281,7 @@ void FixVector::end_of_step()
|
||||
|
||||
// evaluate equal-style or vector-style variable
|
||||
|
||||
} else if (which[i] == VARIABLE) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||
if (argindex[i] == 0)
|
||||
result[i] = input->variable->compute_equal(m);
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user