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,24 +13,23 @@
#include "compute_reduce_chunk.h"
#include <cstring>
#include "arg_info.h"
#include "atom.h"
#include "update.h"
#include "modify.h"
#include "fix.h"
#include "compute.h"
#include "compute_chunk_atom.h"
#include "input.h"
#include "variable.h"
#include "memory.h"
#include "error.h"
#include "fix.h"
#include "input.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include "variable.h"
#include <cstring>
using namespace LAMMPS_NS;
enum{SUM,MINN,MAXX};
enum{UNKNOWN=-1,COMPUTE,FIX,VARIABLE};
#define INVOKED_PERATOM 8
@ -77,43 +76,23 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
ids = new char*[nargnew];
value2index = new int[nargnew];
for (int i=0; i < nargnew; ++i) {
which[i] = argindex[i] = value2index[i] = UNKNOWN;
which[i] = argindex[i] = value2index[i] = ArgInfo::UNKNOWN;
ids[i] = nullptr;
}
nvalues = 0;
iarg = 0;
while (iarg < nargnew) {
ids[nvalues] = nullptr;
for (iarg = 0; iarg < nargnew; iarg++) {
ArgInfo argi(arg[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;
which[nvalues] = argi.get_type();
argindex[nvalues] = argi.get_dim();
ids[nvalues] = argi.copy_name();
int n = strlen(arg[iarg]);
char *suffix = new char[n];
strcpy(suffix,&arg[iarg][2]);
if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE)
|| (argindex[nvalues] > 1))
error->all(FLERR,"Illegal compute reduce/chunk command");
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Illegal compute reduce/chunk 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 reduce/chunk command");
iarg++;
nvalues++;
}
// if wildcard expansion occurred, free earg memory from expand_args()
@ -126,7 +105,7 @@ ComputeReduceChunk::ComputeReduceChunk(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 compute reduce/chunk does not exist");
@ -145,7 +124,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,
"Compute reduce/chunk compute array 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 compute reduce/chunk does not exist");
@ -163,7 +142,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"Compute reduce/chunk fix array is "
"accessed out-of-range");
} 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 reduce/chunk does not exist");
@ -229,19 +208,19 @@ void ComputeReduceChunk::init()
// set indices of all computes,fixes,variables
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 reduce/chunk 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 reduce/chunk 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 reduce/chunk does not exist");
@ -366,12 +345,12 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
// initialization in case it has not yet been run, e.g. when
// the compute was invoked right after it has been created
if (vidx == UNKNOWN) {
if (vidx == ArgInfo::UNKNOWN) {
init();
vidx = value2index[m];
}
if (which[m] == COMPUTE) {
if (which[m] == ArgInfo::COMPUTE) {
Compute *compute = modify->compute[vidx];
if (!(compute->invoked_flag & INVOKED_PERATOM)) {
@ -400,7 +379,7 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
// access fix fields, check if fix frequency is a match
} else if (which[m] == FIX) {
} else if (which[m] == ArgInfo::FIX) {
Fix *fix = modify->fix[vidx];
if (update->ntimestep % fix->peratom_freq)
error->all(FLERR,"Fix used in compute reduce/chunk not "
@ -427,7 +406,7 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
// evaluate atom-style variable
} else if (which[m] == VARIABLE) {
} else if (which[m] == ArgInfo::VARIABLE) {
if (atom->nmax > maxatom) {
memory->destroy(varatom);
maxatom = atom->nmax;