diff --git a/src/fix_ave_atom.cpp b/src/fix_ave_atom.cpp index a543b95224..eb8cf19b22 100644 --- a/src/fix_ave_atom.cpp +++ b/src/fix_ave_atom.cpp @@ -187,21 +187,12 @@ FixAveAtom::FixAveAtom(LAMMPS *lmp, int narg, char **arg) : array[i][m] = 0.0; // nvalid = next step on which end_of_step does something - // can be this timestep if multiple of peratom_freq and nrepeat = 1 - // else backup from next multiple of peratom_freq - - irepeat = 0; - nvalid = (update->ntimestep/peratom_freq)*peratom_freq + peratom_freq; - if (nvalid-peratom_freq == update->ntimestep && nrepeat == 1) - nvalid = update->ntimestep; - else - nvalid -= (nrepeat-1)*nevery; - if (nvalid < update->ntimestep) nvalid += peratom_freq; - // add nvalid to all computes that store invocation times // since don't know a priori which are invoked by this fix // once in end_of_step() can set timestep for ones actually invoked + irepeat = 0; + nvalid = nextvalid(); modify->addstep_compute_all(nvalid); } @@ -258,6 +249,14 @@ void FixAveAtom::init() } else value2index[m] = -1; } + + // need to reset nvalid if nvalid < ntimestep b/c minimize was performed + + if (nvalid < update->ntimestep) { + irepeat = 0; + nvalid = nextvalid(); + modify->addstep_compute_all(nvalid); + } } /* ---------------------------------------------------------------------- @@ -429,3 +428,20 @@ int FixAveAtom::unpack_exchange(int nlocal, double *buf) for (int m = 0; m < nvalues; m++) array[nlocal][m] = buf[m]; return nvalues; } + +/* ---------------------------------------------------------------------- + calculate nvalid = next step on which end_of_step does something + can be this timestep if multiple of nfreq and nrepeat = 1 + else backup from next multiple of nfreq +------------------------------------------------------------------------- */ + +int FixAveAtom::nextvalid() +{ + int nvalid = (update->ntimestep/peratom_freq)*peratom_freq + peratom_freq; + if (nvalid-peratom_freq == update->ntimestep && nrepeat == 1) + nvalid = update->ntimestep; + else + nvalid -= (nrepeat-1)*nevery; + if (nvalid < update->ntimestep) nvalid += peratom_freq; + return nvalid; +} diff --git a/src/fix_ave_atom.h b/src/fix_ave_atom.h index 8c5de51814..7ab406b815 100644 --- a/src/fix_ave_atom.h +++ b/src/fix_ave_atom.h @@ -47,6 +47,8 @@ class FixAveAtom : public Fix { char **ids; double **array; + + int nextvalid(); }; } diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index 43d12e0b8f..941970e521 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -280,10 +280,6 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg): save_corr[i][j] = corr[i][j] = 0.0; } - lastindex = -1; - firstindex = 0; - nsample = 0; - // this fix produces a global array array_flag = 1; @@ -292,17 +288,14 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg): extarray = 0; // nvalid = next step on which end_of_step does something - // this step if multiple of nevery, else next multiple - // startstep is lower bound - - nvalid = update->ntimestep; - if (startstep > nvalid) nvalid = startstep; - if (nvalid % nevery) nvalid = (nvalid/nevery)*nevery + nevery; - // add nvalid to all computes that store invocation times // since don't know a priori which are invoked by this fix // once in end_of_step() can set timestep for ones actually invoked + lastindex = -1; + firstindex = 0; + nsample = 0; + nvalid = nextvalid(); modify->addstep_compute_all(nvalid); } @@ -360,6 +353,16 @@ void FixAveCorrelate::init() value2index[i] = ivariable; } } + + // need to reset nvalid if nvalid < ntimestep b/c minimize was performed + + if (nvalid < update->ntimestep) { + lastindex = -1; + firstindex = 0; + nsample = 0; + nvalid = nextvalid(); + modify->addstep_compute_all(nvalid); + } } /* ---------------------------------------------------------------------- @@ -575,3 +578,17 @@ double FixAveCorrelate::compute_array(int i, int j) else if (save_count[i]) return save_corr[i][j-2]; return 0.0; } + +/* ---------------------------------------------------------------------- + nvalid = next step on which end_of_step does something + this step if multiple of nevery, else next multiple + startstep is lower bound +------------------------------------------------------------------------- */ + +int FixAveCorrelate::nextvalid() +{ + int nvalid = update->ntimestep; + if (startstep > nvalid) nvalid = startstep; + if (nvalid % nevery) nvalid = (nvalid/nevery)*nevery + nevery; + return nvalid; +} diff --git a/src/fix_ave_correlate.h b/src/fix_ave_correlate.h index f2e95b756a..faacf6eabb 100644 --- a/src/fix_ave_correlate.h +++ b/src/fix_ave_correlate.h @@ -58,6 +58,7 @@ class FixAveCorrelate : public Fix { double **save_corr; void accumulate(); + int nextvalid(); }; } diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 24e5eb254c..d04fea1c36 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -477,20 +477,11 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : for (int i = 0; i < nbins; i++) bin_total[i] = 0.0; // nvalid = next step on which end_of_step does something - // can be this timestep if multiple of nfreq and nrepeat = 1 - // else backup from next multiple of nfreq - - nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; - if (nvalid-nfreq == update->ntimestep && nrepeat == 1) - nvalid = update->ntimestep; - else - nvalid -= (nrepeat-1)*nevery; - if (nvalid < update->ntimestep) nvalid += nfreq; - // add nvalid to all computes that store invocation times // since don't know a priori which are invoked by this fix // once in end_of_step() can set timestep for ones actually invoked + nvalid = nextvalid(); modify->addstep_compute_all(nvalid); } @@ -550,6 +541,14 @@ void FixAveHisto::init() value2index[i] = ivariable; } } + + // need to reset nvalid if nvalid < ntimestep b/c minimize was performed + + if (nvalid < update->ntimestep) { + irepeat = 0; + nvalid = nextvalid(); + modify->addstep_compute_all(nvalid); + } } /* ---------------------------------------------------------------------- @@ -983,3 +982,20 @@ void FixAveHisto::allocate_values(int n) "ave/time:value2index"); ids = (char **) memory->srealloc(ids,n*sizeof(char *),"ave/time:ids"); } + +/* ---------------------------------------------------------------------- + calculate nvalid = next step on which end_of_step does something + can be this timestep if multiple of nfreq and nrepeat = 1 + else backup from next multiple of nfreq +------------------------------------------------------------------------- */ + +int FixAveHisto::nextvalid() +{ + int nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; + if (nvalid-nfreq == update->ntimestep && nrepeat == 1) + nvalid = update->ntimestep; + else + nvalid -= (nrepeat-1)*nevery; + if (nvalid < update->ntimestep) nvalid += nfreq; + return nvalid; +} diff --git a/src/fix_ave_histo.h b/src/fix_ave_histo.h index 570e4c8109..64903a973c 100644 --- a/src/fix_ave_histo.h +++ b/src/fix_ave_histo.h @@ -65,6 +65,7 @@ class FixAveHisto : public Fix { void bin_atoms(double *, int); void options(int, char **); void allocate_values(int); + int nextvalid(); }; } diff --git a/src/fix_ave_spatial.cpp b/src/fix_ave_spatial.cpp index 4510558d91..7b562052aa 100644 --- a/src/fix_ave_spatial.cpp +++ b/src/fix_ave_spatial.cpp @@ -372,20 +372,11 @@ FixAveSpatial::FixAveSpatial(LAMMPS *lmp, int narg, char **arg) : values_list = NULL; // nvalid = next step on which end_of_step does something - // can be this timestep if multiple of nfreq and nrepeat = 1 - // else backup from next multiple of nfreq - - nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; - if (nvalid-nfreq == update->ntimestep && nrepeat == 1) - nvalid = update->ntimestep; - else - nvalid -= (nrepeat-1)*nevery; - if (nvalid < update->ntimestep) nvalid += nfreq; - // add nvalid to all computes that store invocation times // since don't know a priori which are invoked by this fix // once in end_of_step() can set timestep for ones actually invoked + nvalid = nextvalid(); modify->addstep_compute_all(nvalid); } @@ -474,6 +465,14 @@ void FixAveSpatial::init() } else value2index[m] = -1; } + + // need to reset nvalid if nvalid < ntimestep b/c minimize was performed + + if (nvalid < update->ntimestep) { + irepeat = 0; + nvalid = nextvalid(); + modify->addstep_compute_all(nvalid); + } } /* ---------------------------------------------------------------------- @@ -1263,6 +1262,23 @@ double FixAveSpatial::compute_array(int i, int j) return values_total[i][j]/norm; } +/* ---------------------------------------------------------------------- + calculate nvalid = next step on which end_of_step does something + can be this timestep if multiple of nfreq and nrepeat = 1 + else backup from next multiple of nfreq +------------------------------------------------------------------------- */ + +int FixAveSpatial::nextvalid() +{ + int nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; + if (nvalid-nfreq == update->ntimestep && nrepeat == 1) + nvalid = update->ntimestep; + else + nvalid -= (nrepeat-1)*nevery; + if (nvalid < update->ntimestep) nvalid += nfreq; + return nvalid; +} + /* ---------------------------------------------------------------------- memory usage of varatom and bins ------------------------------------------------------------------------- */ diff --git a/src/fix_ave_spatial.h b/src/fix_ave_spatial.h index 620db5442c..66dec3eaac 100644 --- a/src/fix_ave_spatial.h +++ b/src/fix_ave_spatial.h @@ -72,6 +72,7 @@ class FixAveSpatial : public Fix { void atom2bin1d(); void atom2bin2d(); void atom2bin3d(); + int nextvalid(); }; } diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index 93c4667d3d..2edc58074a 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -415,20 +415,11 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) : for (int j = 0; j < nvalues; j++) array_total[i][j] = 0.0; // nvalid = next step on which end_of_step does something - // can be this timestep if multiple of nfreq and nrepeat = 1 - // else backup from next multiple of nfreq - - nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; - if (nvalid-nfreq == update->ntimestep && nrepeat == 1) - nvalid = update->ntimestep; - else - nvalid -= (nrepeat-1)*nevery; - if (nvalid < update->ntimestep) nvalid += nfreq; - // add nvalid to all computes that store invocation times // since don't know a priori which are invoked by this fix // once in end_of_step() can set timestep for ones actually invoked + nvalid = nextvalid(); modify->addstep_compute_all(nvalid); } @@ -490,6 +481,14 @@ void FixAveTime::init() value2index[i] = ivariable; } } + + // need to reset nvalid if nvalid < ntimestep b/c minimize was performed + + if (nvalid < update->ntimestep) { + irepeat = 0; + nvalid = nextvalid(); + modify->addstep_compute_all(nvalid); + } } /* ---------------------------------------------------------------------- @@ -914,3 +913,20 @@ void FixAveTime::allocate_values(int n) offcol = (int *) memory->srealloc(offcol,n*sizeof(int),"ave/time:offcol"); ids = (char **) memory->srealloc(ids,n*sizeof(char *),"ave/time:ids"); } + +/* ---------------------------------------------------------------------- + calculate nvalid = next step on which end_of_step does something + can be this timestep if multiple of nfreq and nrepeat = 1 + else backup from next multiple of nfreq +------------------------------------------------------------------------- */ + +int FixAveTime::nextvalid() +{ + int nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; + if (nvalid-nfreq == update->ntimestep && nrepeat == 1) + nvalid = update->ntimestep; + else + nvalid -= (nrepeat-1)*nevery; + if (nvalid < update->ntimestep) nvalid += nfreq; + return nvalid; +} diff --git a/src/fix_ave_time.h b/src/fix_ave_time.h index f37785e542..286511ea26 100644 --- a/src/fix_ave_time.h +++ b/src/fix_ave_time.h @@ -63,6 +63,7 @@ class FixAveTime : public Fix { void invoke_vector(int); void options(int, char **); void allocate_values(int); + int nextvalid(); }; }