add option to compute chunk/atom to access the number of chunks as a global scalar

This commit is contained in:
Axel Kohlmeyer
2020-07-03 22:19:44 -04:00
parent 558d2eb84f
commit 14321d1fa0
3 changed files with 23 additions and 4 deletions

View File

@ -64,6 +64,8 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
if (narg < 4) error->all(FLERR,"Illegal compute chunk/atom command");
peratom_flag = 1;
scalar_flag = 1;
extscalar = 0;
size_peratom_cols = 0;
create_attribute = 1;
@ -639,6 +641,20 @@ void ComputeChunkAtom::compute_peratom()
for (int i = 0; i < nlocal; i++) chunk[i] = ichunk[i];
}
/* ----------------------------------------------------------------------
to return the number of chunks, we first need to make certain
that compute_peratom() has been called.
------------------------------------------------------------------------- */
double ComputeChunkAtom::compute_scalar()
{
if (invoked_peratom != update->ntimestep)
compute_peratom();
invoked_scalar = update->ntimestep;
return (scalar = nchunk);
}
/* ----------------------------------------------------------------------
set lock, so that nchunk will not change from startstep to stopstep
called by fix for duration of time it requires lock