Commit e39ba20e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

Merge branch 'collected-small-changes' into collected-post-stable-patches

parents 0ed4da0b 5b0c4310
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@

using namespace LAMMPS_NS;

enum{SUM,SUMSQ,MINN,MAXX,AVE,AVESQ};             // also in ReduceRegion
enum{X,V,F,COMPUTE,FIX,VARIABLE};
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
@@ -92,6 +92,10 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
  flavor = new int[nargnew];
  ids = new char*[nargnew];
  value2index = new int[nargnew];
  for (int i=0; i < nargnew; ++i) {
    which[i] = argindex[i] = flavor[i] = value2index[i] = UNKNOWN;
    ids[i] = NULL;
  }
  nvalues = 0;

  iarg = 0;
@@ -345,7 +349,7 @@ void ComputeReduce::init()
        error->all(FLERR,"Variable name for compute reduce does not exist");
      value2index[m] = ivariable;

    } else value2index[m] = -1;
    } else value2index[m] = UNKNOWN;
  }

  // set index and check validity of region
@@ -468,8 +472,16 @@ double ComputeReduce::compute_one(int m, int flag)

  index = -1;
  int vidx = value2index[m];
  int aidx = argindex[m];

  // 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) {
    init();
    vidx = value2index[m];
  }

  int aidx = argindex[m];
  int *mask = atom->mask;
  int nlocal = atom->nlocal;

+55 −42
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
using namespace LAMMPS_NS;

enum{SUM,MINN,MAXX};
enum{COMPUTE,FIX,VARIABLE};
enum{UNKNOWN=-1,COMPUTE,FIX,VARIABLE};

#define INVOKED_PERATOM 8

@@ -74,6 +74,10 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
  argindex = new int[nargnew];
  ids = new char*[nargnew];
  value2index = new int[nargnew];
  for (int i=0; i < nargnew; ++i) {
    which[i] = argindex[i] = value2index[i] = UNKNOWN;
    ids[i] = NULL;
  }
  nvalues = 0;

  iarg = 0;
@@ -354,10 +358,19 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
  int *mask = atom->mask;
  int nlocal = atom->nlocal;

  int index;
  int index = -1;
  int vidx = value2index[m];

  // 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) {
    init();
    vidx = value2index[m];
  }

  if (which[m] == COMPUTE) {
    Compute *compute = modify->compute[value2index[m]];
    Compute *compute = modify->compute[vidx];

    if (!(compute->invoked_flag & INVOKED_PERATOM)) {
      compute->compute_peratom();
@@ -386,7 +399,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) {
    Fix *fix = modify->fix[value2index[m]];
    Fix *fix = modify->fix[vidx];
    if (update->ntimestep % fix->peratom_freq)
      error->all(FLERR,"Fix used in compute reduce/chunk not "
                 "computed at compatible time");
@@ -419,7 +432,7 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
      memory->create(varatom,maxatom,"reduce/chunk:varatom");
    }

    input->variable->compute_atom(value2index[m],igroup,varatom,1,0);
    input->variable->compute_atom(vidx,igroup,varatom,1,0);
    for (int i = 0; i < nlocal; i++) {
      if (!(mask[i] & groupbit)) continue;
      index = ichunk[i]-1;
+11 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
using namespace LAMMPS_NS;

enum{SUM,SUMSQ,MINN,MAXX,AVE,AVESQ};             // also in ComputeReduce
enum{X,V,F,COMPUTE,FIX,VARIABLE};
enum{UNKNOWN=-1,X,V,F,COMPUTE,FIX,VARIABLE};
enum{PERATOM,LOCAL};

#define INVOKED_VECTOR 2
@@ -70,6 +70,15 @@ double ComputeReduceRegion::compute_one(int m, int flag)
  int nlocal = atom->nlocal;

  int n = value2index[m];

  // initialization in case it has not yet been run,
  // e.g. when invoked
  if (n == UNKNOWN) {
    init();
    n = value2index[m];
  }

  int aidx = argindex[m];
  int j = argindex[m];

  double one = 0.0;