add lasttime check to fix pair

This commit is contained in:
Steve Plimpton
2022-09-21 14:03:04 -06:00
parent e745c8aac4
commit 39763444c5
2 changed files with 23 additions and 2 deletions

View File

@ -120,7 +120,8 @@ FixPair::FixPair(LAMMPS *lmp, int narg, char **arg) :
atom->add_callback(Atom::GROW);
// zero the vector/array since dump may access it on timestep 0
// zero the vector/array since a variable may access it before first run
// zero the vector/array since a variable may access it before first ru
// initialize lasttime so step 0 will trigger/extract
int nlocal = atom->nlocal;
@ -132,6 +133,8 @@ FixPair::FixPair(LAMMPS *lmp, int narg, char **arg) :
for (int m = 0; m < ncols; m++)
array[i][m] = 0.0;
}
lasttime = -1;
}
/* ---------------------------------------------------------------------- */
@ -188,6 +191,13 @@ void FixPair::setup(int vflag)
/* ---------------------------------------------------------------------- */
void FixPair::min_setup(int vflag)
{
setup(vflag);
}
/* ---------------------------------------------------------------------- */
void FixPair::setup_pre_force(int vflag)
{
pre_force(vflag);
@ -195,14 +205,18 @@ void FixPair::setup_pre_force(int vflag)
/* ----------------------------------------------------------------------
trigger pair style computation on steps which are multiples of Nevery
lasttime prevents mulitiple triggers by min linesearch on same iteration
------------------------------------------------------------------------- */
void FixPair::pre_force(int /*vflag*/)
{
if (update->ntimestep % nevery) return;
if (update->ntimestep == lasttime) return;
// set pair style triggers
printf("FPAIR preforce: set trigger %ld\n",update->ntimestep);
for (int ifield = 0; ifield < nfield; ifield++)
if (trigger[ifield]) *(triggerptr[ifield]) = 1;
}
@ -215,12 +229,15 @@ void FixPair::min_pre_force(int vflag)
}
/* ----------------------------------------------------------------------
extract results from pair style
extract results from pair style on steps which are multiples of Nevery
lasttime prevents mulitiple extracts by min linesearch on same iteration
------------------------------------------------------------------------- */
void FixPair::post_force(int /*vflag*/)
{
if (update->ntimestep % nevery) return;
if (update->ntimestep == lasttime) return;
lasttime = update->ntimestep;
// extract pair style fields one by one
// store their values in this fix
@ -230,6 +247,8 @@ void FixPair::post_force(int /*vflag*/)
int icol = 0;
int columns;
printf("FPAIR postforce: extract %ld\n",update->ntimestep);
for (int ifield = 0; ifield < nfield; ifield++) {
void *pvoid = pstyle->extract_peratom(fieldname[ifield],columns);
if (pvoid == nullptr)