convert some more files

This commit is contained in:
Axel Kohlmeyer
2021-01-31 21:47:55 -05:00
parent 03136ed3e3
commit 0f49ce81c7
6 changed files with 134 additions and 212 deletions

View File

@ -13,6 +13,7 @@
#include "compute_slice.h"
#include "arg_info.h"
#include "error.h"
#include "fix.h"
#include "input.h"
@ -21,12 +22,8 @@
#include "update.h"
#include "variable.h"
#include <cstring>
using namespace LAMMPS_NS;
enum{COMPUTE,FIX,VARIABLE};
#define INVOKED_VECTOR 2
#define INVOKED_ARRAY 4
@ -56,38 +53,21 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
nvalues = 0;
for (int iarg = 6; iarg < narg; iarg++) {
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;
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_dim();
ids[nvalues] = argi.copy_name();
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Illegal compute slice 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);
nvalues++;
delete [] suffix;
} else error->all(FLERR,"Illegal compute slice command");
if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE)
|| (argindex[nvalues] > 1))
error->all(FLERR,"Illegal compute slice command");
}
// setup and 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 compute slice does not exist");
@ -111,7 +91,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
} else error->all(FLERR,"Compute slice compute does not calculate "
"global vector or array");
} 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 compute slice does not exist");
@ -132,7 +112,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
} else error->all(FLERR,"Compute slice fix does not calculate "
"global vector or array");
} 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 compute slice does not exist");
@ -152,7 +132,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
size_vector = (nstop-nstart) / nskip;
memory->create(vector,size_vector,"slice:vector");
if (which[0] == COMPUTE) {
if (which[0] == ArgInfo::COMPUTE) {
int icompute = modify->find_compute(ids[0]);
if (argindex[0] == 0) {
extvector = modify->compute[icompute]->extvector;
@ -163,7 +143,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
extlist[j++] = modify->compute[icompute]->extlist[i-1];
}
} else extvector = modify->compute[icompute]->extarray;
} else if (which[0] == FIX) {
} else if (which[0] == ArgInfo::FIX) {
int ifix = modify->find_fix(ids[0]);
if (argindex[0] == 0) {
extvector = modify->fix[ifix]->extvector;
@ -174,7 +154,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
extlist[j++] = modify->fix[ifix]->extlist[i-1];
}
} else extvector = modify->fix[ifix]->extarray;
} else if (which[0] == VARIABLE) {
} else if (which[0] == ArgInfo::VARIABLE) {
extvector = 0;
}
@ -186,7 +166,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
extarray = 0;
for (int i = 0; i < nvalues; i++) {
if (which[i] == COMPUTE) {
if (which[i] == ArgInfo::COMPUTE) {
int icompute = modify->find_compute(ids[i]);
if (argindex[i] == 0) {
if (modify->compute[icompute]->extvector == 1) extarray = 1;
@ -197,7 +177,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
} else {
if (modify->compute[icompute]->extarray) extarray = 1;
}
} else if (which[i] == FIX) {
} else if (which[i] == ArgInfo::FIX) {
int ifix = modify->find_fix(ids[i]);
if (argindex[i] == 0) {
if (modify->fix[ifix]->extvector == 1) extarray = 1;
@ -208,7 +188,7 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) :
} else {
if (modify->fix[ifix]->extarray) extarray = 1;
}
} else if (which[i] == VARIABLE) {
} else if (which[i] == ArgInfo::VARIABLE) {
// variable is always intensive, does not change extarray
}
}
@ -237,17 +217,17 @@ void ComputeSlice::init()
// set indices and check validity of all computes,fixes
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 compute slice does not exist");
value2index[m] = icompute;
} 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 compute slice 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 compute slice does not exist");
@ -286,7 +266,7 @@ void ComputeSlice::extract_one(int m, double *vec, int stride)
// invoke the appropriate compute if needed
if (which[m] == COMPUTE) {
if (which[m] == ArgInfo::COMPUTE) {
Compute *compute = modify->compute[value2index[m]];
if (argindex[m] == 0) {
@ -317,7 +297,7 @@ void ComputeSlice::extract_one(int m, double *vec, int stride)
// access fix fields, check if fix frequency is a match
} else if (which[m] == FIX) {
} else if (which[m] == ArgInfo::FIX) {
if (update->ntimestep % modify->fix[value2index[m]]->global_freq)
error->all(FLERR,"Fix used in compute slice not "
"computed at compatible time");
@ -340,7 +320,7 @@ void ComputeSlice::extract_one(int m, double *vec, int stride)
// invoke vector-style variable
} else if (which[m] == VARIABLE) {
} else if (which[m] == ArgInfo::VARIABLE) {
double *varvec;
int nvec = input->variable->compute_vector(value2index[m],&varvec);
if (nvec < nstop)