Commit 3a346267 authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13301 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 1f6a1f4a
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -299,7 +299,6 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
  // increment lock counter in compute chunk/atom
  // only if nrepeat > 1 or ave = RUNNING/WINDOW,
  //   so that locking spans multiple timesteps 
  // set lock here for ave = RUN/WINDOW or in end_of_step() for nrepeat > 1

  int icompute = modify->find_compute(idchunk);
  if (icompute < 0)
@@ -309,10 +308,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
    error->all(FLERR,"Fix ave/chunk does not use chunk/atom compute");

  if (nrepeat > 1 || ave == RUNNING || ave == WINDOW) cchunk->lockcount++;
  if (ave == RUNNING || ave == WINDOW) {
    nchunk = cchunk->setup_chunks();
    cchunk->lock(this,update->ntimestep,-1);
  }
  lockforever = 0;

  // print file comment lines

@@ -523,7 +519,11 @@ void FixAveChunk::end_of_step()
  // zero out arrays that accumulate over many samples, but not across epochs
  // invoke setup_chunks() to determine current nchunk
  //   re-allocate per-chunk arrays if needed
  // invoke lock() so nchunk cannot change until Nfreq epoch is over
  // invoke lock() in two cases:
  //   if nrepeat > 1: so nchunk cannot change until Nfreq epoch is over,
  //     will be unlocked on last repeat of this Nfreq
  //   if ave = RUNNING/WINDOW and not yet locked:
  //     set forever, will be unlocked in fix destructor
  // wrap setup_chunks in clearstep/addstep b/c it may invoke computes
  //   both nevery and nfreq are future steps, 
  //   since call below to cchunk->ichunk() 
@@ -539,6 +539,10 @@ void FixAveChunk::end_of_step()
    allocate();
    if (nrepeat > 1 && ave == ONE)
      cchunk->lock(this,ntimestep,ntimestep+(nrepeat-1)*nevery);
    else if ((ave == RUNNING || ave == WINDOW) && !lockforever) {
      cchunk->lock(this,update->ntimestep,-1);
      lockforever = 1;
    }
    for (m = 0; m < nchunk; m++) {
      count_many[m] = count_sum[m] = 0.0;
      for (i = 0; i < nvalues; i++) values_many[m][i] = 0.0;
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ class FixAveChunk : public Fix {
  int nchunk,maxchunk;
  char *idchunk;
  class ComputeChunkAtom *cchunk;
  int lockforever;

  long filepos;

+23 −16
Original line number Diff line number Diff line
@@ -276,9 +276,6 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
  // enable locking of row count by this fix for computes of variable length
  // only if nrepeat > 1 or ave = RUNNING/WINDOW,
  //   so that locking spans multiple timesteps 
  // trigger lock_length here for ave = RUN/WINDOW
  //   or in end_of_step() for nrepeat > 1,
  //   so that row count = number of chunks is set

  if (any_variable_length && 
      (nrepeat > 1 || ave == RUNNING || ave == WINDOW)) {
@@ -286,11 +283,8 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
      if (varlen[i]) {
        int icompute = modify->find_compute(ids[i]);
        modify->compute[icompute]->lock_enable();
        if (ave == RUNNING || ave == WINDOW) {
          modify->compute[icompute]->lock_length();
          modify->compute[icompute]->lock(this,update->ntimestep,-1);
        }
      }
    lockforever = 0;
  }
    
  // print file comment lines
@@ -435,7 +429,8 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
  }

  // initializations
  // set vector_total/array_total to zero since it accumulates
  // set vector_total to zero since it accumulates
  // array_total already zeroed in allocate_arrays

  irepeat = 0;
  iwindow = window_limit = 0;
@@ -443,9 +438,6 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :

  if (mode == SCALAR)
    for (int i = 0; i < nvalues; i++) vector_total[i] = 0.0;
  else
    for (int i = 0; i < nrows; i++)
      for (int j = 0; j < nvalues; j++) array_total[i][j] = 0.0;

  // nvalid = next step on which end_of_step does something
  // add nvalid to all computes that store invocation times
@@ -718,16 +710,16 @@ void FixAveTime::invoke_vector(bigint ntimestep)
  // zero out arrays that accumulate over many samples, but not across epochs
  // invoke setup_chunks() to determine current nchunk
  //   re-allocate per-chunk arrays if needed
  // then invoke lock() so nchunk cannot change until Nfreq epoch is over
  //   use final arg = -1 for infinite-time window
  // invoke lock() in two cases:
  //   if nrepeat > 1: so nchunk cannot change until Nfreq epoch is over,
  //     will be unlocked on last repeat of this Nfreq
  //   if ave = RUNNING/WINDOW and not yet locked:
  //     set forever, will be unlocked in fix destructor
  // wrap setup_chunks in clearstep/addstep b/c it may invoke computes
  //   both nevery and nfreq are future steps, 
  //   since call below to cchunk->ichunk() 
  //     does not re-invoke internal cchunk compute on this same step

  // first sample within single Nfreq epoch
  // zero if first step

  if (irepeat == 0) {
    if (any_variable_length) {
      modify->clearstep_compute();
@@ -743,13 +735,19 @@ void FixAveTime::invoke_vector(bigint ntimestep)
      }

      bigint ntimestep = update->ntimestep;
      int lockforever_flag = 0;
      for (i = 0; i < nvalues; i++) {
        if (!varlen[i]) continue;
        if (nrepeat > 1 && ave == ONE) {
          Compute *compute = modify->compute[value2index[i]];
          compute->lock(this,ntimestep,ntimestep+(nrepeat-1)*nevery);
        } else if ((ave == RUNNING || ave == WINDOW) && !lockforever) {
          Compute *compute = modify->compute[value2index[i]];
          compute->lock(this,update->ntimestep,-1);
          lockforever_flag = 1;
        }
      }
      if (lockforever_flag) lockforever = 1;
    }

    for (i = 0; i < nrows; i++)
@@ -894,6 +892,10 @@ void FixAveTime::invoke_vector(bigint ntimestep)
      fprintf(fp,"\n");
    }
    fflush(fp);
    if (overwrite) {
      long fileend = ftell(fp);
      ftruncate(fileno(fp),fileend);
    }
  }
}

@@ -1107,6 +1109,11 @@ void FixAveTime::allocate_arrays()
    memory->destroy(array_list);
    memory->create(array_list,nwindow,nrows,nvalues,"ave/time:array_list");
  }

  // reinitialize regrown array_total since it accumulates

  for (int i = 0; i < nrows; i++)
    for (int j = 0; j < nvalues; j++) array_total[i][j] = 0.0;
}

/* ----------------------------------------------------------------------
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ class FixAveTime : public Fix {
  int nrows;
  int any_variable_length;
  int all_variable_length;
  int lockforever;

  int ave,nwindow,startstep,mode;
  int noff,overwrite;