convert some more files
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
#include "compute_chunk_spread_atom.h"
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "compute_chunk_atom.h"
|
||||
@ -22,12 +23,8 @@
|
||||
#include "modify.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
enum{COMPUTE,FIX};
|
||||
|
||||
#define INVOKED_VECTOR 2
|
||||
#define INVOKED_ARRAY 4
|
||||
#define INVOKED_PERATOM 8
|
||||
@ -66,36 +63,20 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
value2index = new int[nargnew];
|
||||
nvalues = 0;
|
||||
|
||||
iarg = 0;
|
||||
while (iarg < nargnew) {
|
||||
for (iarg = 0; iarg < nargnew; iarg++) {
|
||||
ids[nvalues] = nullptr;
|
||||
|
||||
if (strncmp(arg[iarg],"c_",2) == 0 ||
|
||||
strncmp(arg[iarg],"f_",2) == 0) {
|
||||
if (arg[iarg][0] == 'c') which[nvalues] = COMPUTE;
|
||||
else if (arg[iarg][0] == 'f') which[nvalues] = FIX;
|
||||
ArgInfo argi(arg[iarg], ArgInfo::COMPUTE|ArgInfo::FIX);
|
||||
|
||||
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] != ']')
|
||||
if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE)
|
||||
|| (argindex[nvalues] > 1))
|
||||
error->all(FLERR,"Illegal compute chunk/spread/atom 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 chunk/spread/atom command");
|
||||
|
||||
iarg++;
|
||||
}
|
||||
|
||||
// if wildcard expansion occurred, free earg memory from expand_args()
|
||||
@ -110,7 +91,7 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
// for fix, assume a global vector or array is per-chunk data
|
||||
|
||||
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 chunk/spread/atom "
|
||||
@ -133,7 +114,7 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
"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 chunk/spread/atom does not exist");
|
||||
@ -190,14 +171,14 @@ void ComputeChunkSpreadAtom::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 chunk/spread/atom "
|
||||
"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 chunk/spread/atom does not exist");
|
||||
@ -271,7 +252,7 @@ void ComputeChunkSpreadAtom::compute_peratom()
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
if (which[m] == COMPUTE) {
|
||||
if (which[m] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[n];
|
||||
|
||||
if (argindex[m] == 0) {
|
||||
@ -308,7 +289,7 @@ void ComputeChunkSpreadAtom::compute_peratom()
|
||||
// are assuming the fix global vector/array is per-chunk data
|
||||
// check if index exceeds fix output length/rows
|
||||
|
||||
} else if (which[m] == FIX) {
|
||||
} else if (which[m] == ArgInfo::FIX) {
|
||||
Fix *fix = modify->fix[n];
|
||||
if (update->ntimestep % fix->global_freq)
|
||||
error->all(FLERR,"Fix used in compute chunk/spread/atom not "
|
||||
|
||||
@ -13,26 +13,20 @@
|
||||
|
||||
#include "compute_reduce.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "group.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
#include "modify.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
enum{SUM,SUMSQ,MINN,MAXX,AVE,AVESQ}; // also in ComputeReduceRegion
|
||||
enum{UNKNOWN=-1,X,V,F,COMPUTE,FIX,VARIABLE};
|
||||
enum{PERATOM,LOCAL};
|
||||
|
||||
#define INVOKED_VECTOR 2
|
||||
#define INVOKED_ARRAY 4
|
||||
#define INVOKED_PERATOM 8
|
||||
@ -92,7 +86,7 @@ ComputeReduce::ComputeReduce(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] = flavor[i] = value2index[i] = UNKNOWN;
|
||||
which[i] = argindex[i] = flavor[i] = value2index[i] = ArgInfo::UNKNOWN;
|
||||
ids[i] = nullptr;
|
||||
}
|
||||
nvalues = 0;
|
||||
@ -102,61 +96,49 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
||||
ids[nvalues] = nullptr;
|
||||
|
||||
if (strcmp(arg[iarg],"x") == 0) {
|
||||
which[nvalues] = X;
|
||||
which[nvalues] = ArgInfo::X;
|
||||
argindex[nvalues++] = 0;
|
||||
} else if (strcmp(arg[iarg],"y") == 0) {
|
||||
which[nvalues] = X;
|
||||
which[nvalues] = ArgInfo::X;
|
||||
argindex[nvalues++] = 1;
|
||||
} else if (strcmp(arg[iarg],"z") == 0) {
|
||||
which[nvalues] = X;
|
||||
which[nvalues] = ArgInfo::X;
|
||||
argindex[nvalues++] = 2;
|
||||
|
||||
} else if (strcmp(arg[iarg],"vx") == 0) {
|
||||
which[nvalues] = V;
|
||||
which[nvalues] = ArgInfo::V;
|
||||
argindex[nvalues++] = 0;
|
||||
} else if (strcmp(arg[iarg],"vy") == 0) {
|
||||
which[nvalues] = V;
|
||||
which[nvalues] = ArgInfo::V;
|
||||
argindex[nvalues++] = 1;
|
||||
} else if (strcmp(arg[iarg],"vz") == 0) {
|
||||
which[nvalues] = V;
|
||||
which[nvalues] = ArgInfo::V;
|
||||
argindex[nvalues++] = 2;
|
||||
|
||||
} else if (strcmp(arg[iarg],"fx") == 0) {
|
||||
which[nvalues] = F;
|
||||
which[nvalues] = ArgInfo::F;
|
||||
argindex[nvalues++] = 0;
|
||||
} else if (strcmp(arg[iarg],"fy") == 0) {
|
||||
which[nvalues] = F;
|
||||
which[nvalues] = ArgInfo::F;
|
||||
argindex[nvalues++] = 1;
|
||||
} else if (strcmp(arg[iarg],"fz") == 0) {
|
||||
which[nvalues] = F;
|
||||
which[nvalues] = ArgInfo::F;
|
||||
argindex[nvalues++] = 2;
|
||||
|
||||
} 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 {
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
ArgInfo argi(arg[iarg]);
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
which[nvalues] = argi.get_type();
|
||||
argindex[nvalues] = argi.get_dim();
|
||||
ids[nvalues] = argi.copy_name();
|
||||
|
||||
if ((which[nvalues] == ArgInfo::UNKNOWN) || (argindex[nvalues] > 1))
|
||||
error->all(FLERR,"Illegal compute reduce 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);
|
||||
if (which[nvalues] == ArgInfo::NONE) break;
|
||||
nvalues++;
|
||||
delete [] suffix;
|
||||
|
||||
} else break;
|
||||
}
|
||||
|
||||
iarg++;
|
||||
}
|
||||
@ -203,10 +185,10 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
||||
// setup and error check
|
||||
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (which[i] == X || which[i] == V || which[i] == F)
|
||||
if (which[i] == ArgInfo::X || which[i] == ArgInfo::V || which[i] == ArgInfo::F)
|
||||
flavor[i] = PERATOM;
|
||||
|
||||
else if (which[i] == COMPUTE) {
|
||||
else if (which[i] == ArgInfo::COMPUTE) {
|
||||
int icompute = modify->find_compute(ids[i]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Compute ID for compute reduce does not exist");
|
||||
@ -239,7 +221,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
||||
} else error->all(FLERR,
|
||||
"Compute reduce compute calculates global values");
|
||||
|
||||
} 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 does not exist");
|
||||
@ -269,7 +251,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,"Compute reduce fix array is accessed out-of-range");
|
||||
} else error->all(FLERR,"Compute reduce fix calculates global values");
|
||||
|
||||
} 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 does not exist");
|
||||
@ -330,25 +312,25 @@ void ComputeReduce::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 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 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 does not exist");
|
||||
value2index[m] = ivariable;
|
||||
|
||||
} else value2index[m] = UNKNOWN;
|
||||
} else value2index[m] = ArgInfo::UNKNOWN;
|
||||
}
|
||||
|
||||
// set index and check validity of region
|
||||
@ -475,7 +457,7 @@ double ComputeReduce::compute_one(int m, int flag)
|
||||
// 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];
|
||||
}
|
||||
@ -488,19 +470,19 @@ double ComputeReduce::compute_one(int m, int flag)
|
||||
if (mode == MINN) one = BIG;
|
||||
if (mode == MAXX) one = -BIG;
|
||||
|
||||
if (which[m] == X) {
|
||||
if (which[m] == ArgInfo::X) {
|
||||
double **x = atom->x;
|
||||
if (flag < 0) {
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) combine(one,x[i][aidx],i);
|
||||
} else one = x[flag][aidx];
|
||||
} else if (which[m] == V) {
|
||||
} else if (which[m] == ArgInfo::V) {
|
||||
double **v = atom->v;
|
||||
if (flag < 0) {
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) combine(one,v[i][aidx],i);
|
||||
} else one = v[flag][aidx];
|
||||
} else if (which[m] == F) {
|
||||
} else if (which[m] == ArgInfo::F) {
|
||||
double **f = atom->f;
|
||||
if (flag < 0) {
|
||||
for (i = 0; i < nlocal; i++)
|
||||
@ -509,7 +491,7 @@ double ComputeReduce::compute_one(int m, int flag)
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
} else if (which[m] == COMPUTE) {
|
||||
} else if (which[m] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[vidx];
|
||||
|
||||
if (flavor[m] == PERATOM) {
|
||||
@ -561,7 +543,7 @@ double ComputeReduce::compute_one(int m, int flag)
|
||||
|
||||
// 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[vidx]->peratom_freq)
|
||||
error->all(FLERR,"Fix used in compute reduce not "
|
||||
"computed at compatible time");
|
||||
@ -605,7 +587,7 @@ double ComputeReduce::compute_one(int m, int flag)
|
||||
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
} else if (which[m] == ArgInfo::VARIABLE) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
@ -628,9 +610,9 @@ bigint ComputeReduce::count(int m)
|
||||
{
|
||||
int vidx = value2index[m];
|
||||
|
||||
if (which[m] == X || which[m] == V || which[m] == F)
|
||||
if (which[m] == ArgInfo::X || which[m] == ArgInfo::V || which[m] == ArgInfo::F)
|
||||
return group->count(igroup);
|
||||
else if (which[m] == COMPUTE) {
|
||||
else if (which[m] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[vidx];
|
||||
if (flavor[m] == PERATOM) {
|
||||
return group->count(igroup);
|
||||
@ -640,7 +622,7 @@ bigint ComputeReduce::count(int m)
|
||||
MPI_Allreduce(&ncount,&ncountall,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||
return ncountall;
|
||||
}
|
||||
} else if (which[m] == FIX) {
|
||||
} else if (which[m] == ArgInfo::FIX) {
|
||||
Fix *fix = modify->fix[vidx];
|
||||
if (flavor[m] == PERATOM) {
|
||||
return group->count(igroup);
|
||||
@ -650,7 +632,7 @@ bigint ComputeReduce::count(int m)
|
||||
MPI_Allreduce(&ncount,&ncountall,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||
return ncountall;
|
||||
}
|
||||
} else if (which[m] == VARIABLE)
|
||||
} else if (which[m] == ArgInfo::VARIABLE)
|
||||
return group->count(igroup);
|
||||
|
||||
bigint dummy = 0;
|
||||
|
||||
@ -26,6 +26,9 @@ namespace LAMMPS_NS {
|
||||
|
||||
class ComputeReduce : public Compute {
|
||||
public:
|
||||
enum {SUM,SUMSQ,MINN,MAXX,AVE,AVESQ};
|
||||
enum {PERATOM,LOCAL};
|
||||
|
||||
ComputeReduce(class LAMMPS *, int, char **);
|
||||
virtual ~ComputeReduce();
|
||||
void init();
|
||||
|
||||
@ -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]);
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE)
|
||||
|| (argindex[nvalues] > 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++;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
@ -13,24 +13,21 @@
|
||||
|
||||
#include "compute_reduce_region.h"
|
||||
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "domain.h"
|
||||
#include "group.h"
|
||||
#include "region.h"
|
||||
#include "fix.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "group.h"
|
||||
#include "input.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
#include "region.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
enum{SUM,SUMSQ,MINN,MAXX,AVE,AVESQ}; // also in ComputeReduce
|
||||
enum{UNKNOWN=-1,X,V,F,COMPUTE,FIX,VARIABLE};
|
||||
enum{PERATOM,LOCAL};
|
||||
|
||||
#define INVOKED_VECTOR 2
|
||||
#define INVOKED_ARRAY 4
|
||||
#define INVOKED_PERATOM 8
|
||||
@ -72,7 +69,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
||||
|
||||
// initialization in case it has not yet been run,
|
||||
// e.g. when invoked
|
||||
if (n == UNKNOWN) {
|
||||
if (n == ArgInfo::UNKNOWN) {
|
||||
init();
|
||||
n = value2index[m];
|
||||
}
|
||||
@ -83,20 +80,20 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
||||
if (mode == MINN) one = BIG;
|
||||
if (mode == MAXX) one = -BIG;
|
||||
|
||||
if (which[m] == X) {
|
||||
if (which[m] == ArgInfo::X) {
|
||||
if (flag < 0) {
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2]))
|
||||
combine(one,x[i][j],i);
|
||||
} else one = x[flag][j];
|
||||
} else if (which[m] == V) {
|
||||
} else if (which[m] == ArgInfo::V) {
|
||||
double **v = atom->v;
|
||||
if (flag < 0) {
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2]))
|
||||
combine(one,v[i][j],i);
|
||||
} else one = v[flag][j];
|
||||
} else if (which[m] == F) {
|
||||
} else if (which[m] == ArgInfo::F) {
|
||||
double **f = atom->f;
|
||||
if (flag < 0) {
|
||||
for (i = 0; i < nlocal; i++)
|
||||
@ -106,7 +103,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
} else if (which[m] == COMPUTE) {
|
||||
} else if (which[m] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[n];
|
||||
|
||||
if (flavor[m] == PERATOM) {
|
||||
@ -160,7 +157,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
||||
|
||||
// check if fix frequency is a match
|
||||
|
||||
} else if (which[m] == FIX) {
|
||||
} else if (which[m] == ArgInfo::FIX) {
|
||||
if (update->ntimestep % modify->fix[n]->peratom_freq)
|
||||
error->all(FLERR,"Fix used in compute reduce not computed at "
|
||||
"compatible time");
|
||||
@ -206,7 +203,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
||||
|
||||
// evaluate atom-style variable
|
||||
|
||||
} else if (which[m] == VARIABLE) {
|
||||
} else if (which[m] == ArgInfo::VARIABLE) {
|
||||
if (atom->nmax > maxatom) {
|
||||
maxatom = atom->nmax;
|
||||
memory->destroy(varatom);
|
||||
@ -230,9 +227,9 @@ bigint ComputeReduceRegion::count(int m)
|
||||
{
|
||||
int n = value2index[m];
|
||||
|
||||
if (which[m] == X || which[m] == V || which[m] == F)
|
||||
if (which[m] == ArgInfo::X || which[m] == ArgInfo::V || which[m] == ArgInfo::F)
|
||||
return group->count(igroup,iregion);
|
||||
else if (which[m] == COMPUTE) {
|
||||
else if (which[m] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[n];
|
||||
if (flavor[m] == PERATOM) {
|
||||
return group->count(igroup,iregion);
|
||||
@ -242,7 +239,7 @@ bigint ComputeReduceRegion::count(int m)
|
||||
MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
return ncountall;
|
||||
}
|
||||
} else if (which[m] == FIX) {
|
||||
} else if (which[m] == ArgInfo::FIX) {
|
||||
Fix *fix = modify->fix[n];
|
||||
if (flavor[m] == PERATOM) {
|
||||
return group->count(igroup,iregion);
|
||||
@ -252,7 +249,7 @@ bigint ComputeReduceRegion::count(int m)
|
||||
MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
return ncountall;
|
||||
}
|
||||
} else if (which[m] == VARIABLE)
|
||||
} else if (which[m] == ArgInfo::VARIABLE)
|
||||
return group->count(igroup,iregion);
|
||||
|
||||
bigint dummy = 0;
|
||||
|
||||
@ -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] != ']')
|
||||
if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE)
|
||||
|| (argindex[nvalues] > 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");
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user