forked from lijiext/lammps
add option to compute chunk/atom to access the number of chunks as a global scalar
This commit is contained in:
parent
558d2eb84f
commit
14321d1fa0
|
@ -622,14 +622,16 @@ cylinder, x for a y-axis cylinder, and x for a z-axis cylinder.
|
|||
|
||||
**Output info:**
|
||||
|
||||
This compute calculates a per-atom vector, which can be accessed by
|
||||
any command that uses per-atom values from a compute as input. See
|
||||
the :doc:`Howto output <Howto_output>` doc page for an overview of
|
||||
This compute calculates a per-atom vector (the chunk ID), which can
|
||||
be accessed by any command that uses per-atom values from a compute
|
||||
as input. It also calculates a global scalar (the number of chunks),
|
||||
which can be similarly accessed everywhere outside of a per-atom context.
|
||||
See the :doc:`Howto output <Howto_output>` doc page for an overview of
|
||||
LAMMPS output options.
|
||||
|
||||
The per-atom vector values are unitless chunk IDs, ranging from 1 to
|
||||
*Nchunk* (inclusive) for atoms assigned to chunks, and 0 for atoms not
|
||||
belonging to a chunk.
|
||||
belonging to a chunk. The scalar contains the value of *Nchunk*.
|
||||
|
||||
Restrictions
|
||||
""""""""""""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -39,6 +39,7 @@ class ComputeChunkAtom : public Compute {
|
|||
void init();
|
||||
void setup();
|
||||
void compute_peratom();
|
||||
double compute_scalar();
|
||||
void set_arrays(int);
|
||||
double memory_usage();
|
||||
|
||||
|
|
Loading…
Reference in New Issue