1 /* -*- c++ -*- ----------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3    https://www.lammps.org/, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13 
14 #ifdef COMPUTE_CLASS
15 // clang-format off
16 ComputeStyle(chunk/atom,ComputeChunkAtom);
17 // clang-format on
18 #else
19 
20 #ifndef LMP_COMPUTE_CHUNK_ATOM_H
21 #define LMP_COMPUTE_CHUNK_ATOM_H
22 
23 #include "compute.h"
24 #include <map>
25 
26 namespace LAMMPS_NS {
27 
28 class ComputeChunkAtom : public Compute {
29  public:
30   int nchunk, ncoord, compress, idsflag, lockcount;
31   int computeflag;    // 1 if this compute invokes other computes
32   double chunk_volume_scalar;
33   double *chunk_volume_vec;
34   double **coord;
35   int *ichunk, *chunkID;
36 
37   ComputeChunkAtom(class LAMMPS *, int, char **);
38   ~ComputeChunkAtom();
39   void init();
40   void setup();
41   void compute_peratom();
42   double compute_scalar();
43   void set_arrays(int);
44   double memory_usage();
45 
46   void lock(class Fix *, bigint, bigint);
47   void unlock(class Fix *);
48   int setup_chunks();
49   void compute_ichunk();
50 
51  private:
52   int which, binflag;
53   int regionflag, nchunksetflag, nchunkflag, discard;
54   int limit, limitstyle, limitfirst;
55   int scaleflag, pbcflag;
56   double xscale, yscale, zscale;
57   int argindex;
58   char *cfvid;
59 
60   // xyz spatial bins
61 
62   int ndim;
63   int dim[3], originflag[3], nlayers[3];
64   int minflag[3], maxflag[3];
65   double origin[3], delta[3];
66   double offset[3], invdelta[3];
67   double minvalue[3], maxvalue[3];
68 
69   // spherical spatial bins
70 
71   double sorigin_user[3];
72   double sorigin[3];
73   double sradmin_user, sradmax_user;
74   double sradmin, sradmax, sinvrad;
75   int nsbin;
76 
77   // cylindrical spatial bins
78 
79   double corigin_user[3];
80   double corigin[3];
81   double cradmin_user, cradmax_user;
82   double cradmin, cradmax, cinvrad;
83   int cdim1, cdim2;
84   int ncbin, ncplane;
85 
86   char *idregion;
87   class Region *region;
88 
89   class Compute *cchunk;
90   class Fix *fchunk;
91   int vchunk;
92   int maxvar;
93   double *varatom;
94 
95   char *id_fix;
96   class FixStore *fixstore;
97 
98   class Fix *lockfix;            // ptr to FixAveChunk that is locking out setups
99                                  // null pointer if no lock currently in place
100   bigint lockstart, lockstop;    // timesteps for start and stop of locking
101 
102   bigint invoked_setup;     // last timestep setup_chunks and nchunk calculated
103   bigint invoked_ichunk;    // last timestep ichunk values calculated
104   int nmax, nmaxint;
105   double *chunk;
106 
107   int molcheck;                   // one-time check if all molecule atoms in chunk
108   int *exclude;                   // 1 if atom is not assigned to any chunk
109   std::map<tagint, int> *hash;    // store original chunks IDs before compression
110 
111   // callback function for ring communication
112 
113   static void idring(int, char *, void *);
114 
115   void assign_chunk_ids();
116   void compress_chunk_ids();
117   void check_molecules();
118   int setup_xyz_bins();
119   int setup_sphere_bins();
120   int setup_cylinder_bins();
121   void bin_volumes();
122   void atom2bin1d();
123   void atom2bin2d();
124   void atom2bin3d();
125   void atom2binsphere();
126   void atom2bincylinder();
127   void readdim(int, char **, int, int);
128 };
129 
130 }    // namespace LAMMPS_NS
131 
132 #endif
133 #endif
134 
135 /* ERROR/WARNING messages:
136 
137 E: Illegal ... command
138 
139 Self-explanatory.  Check the input script syntax and compare to the
140 documentation for the command.  You can use -echo screen as a
141 command-line option when running LAMMPS to see the offending line.
142 
143 E: Region ID for compute chunk/atom does not exist
144 
145 Self-explanatory.
146 
147 E: Compute chunk/atom molecule for non-molecular system
148 
149 Self-explanatory.
150 
151 E: Compute chunk/atom without bins cannot use discard mixed
152 
153 That discard option only applies to the binning styles.
154 
155 E: Compute chunk/atom sphere z origin must be 0.0 for 2d
156 
157 Self-explanatory.
158 
159 E: Compute chunk/atom cylinder axis must be z for 2d
160 
161 Self-explanatory.
162 
163 E: Compute ID for compute chunk /atom does not exist
164 
165 Self-explanatory.
166 
167 E: Compute chunk/atom compute does not calculate per-atom values
168 
169 Self-explanatory.
170 
171 E: Compute chunk/atom compute does not calculate a per-atom vector
172 
173 Self-explanatory.
174 
175 E: Compute chunk/atom compute does not calculate a per-atom array
176 
177 Self-explanatory.
178 
179 E: Compute chunk/atom compute array is accessed out-of-range
180 
181 The index for the array is out of bounds.
182 
183 E: Fix ID for compute chunk/atom does not exist
184 
185 Self-explanatory.
186 
187 E: Compute chunk/atom fix does not calculate per-atom values
188 
189 Self-explanatory.
190 
191 E: Compute chunk/atom fix does not calculate a per-atom vector
192 
193 Self-explanatory.
194 
195 E: Compute chunk/atom fix does not calculate a per-atom array
196 
197 Self-explanatory.
198 
199 E: Compute chunk/atom fix array is accessed out-of-range
200 
201 the index for the array is out of bounds.
202 
203 E: Variable name for compute chunk/atom does not exist
204 
205 Self-explanatory.
206 
207 E: Compute chunk/atom variable is not atom-style variable
208 
209 Self-explanatory.
210 
211 E: Compute chunk/atom for triclinic boxes requires units reduced
212 
213 Self-explanatory.
214 
215 E: Compute ID for compute chunk/atom does not exist
216 
217 Self-explanatory.
218 
219 E: Molecule IDs too large for compute chunk/atom
220 
221 The IDs must not be larger than can be stored in a 32-bit integer
222 since chunk IDs are 32-bit integers.
223 
224 E: Compute chunk/atom ids once but nchunk is not once
225 
226 You cannot assign chunks IDs to atom permanently if the number of
227 chunks may change.
228 
229 E: Two fix commands using same compute chunk/atom command in incompatible ways
230 
231 UNDOCUMENTED
232 
233 E: Fix used in compute chunk/atom not computed at compatible time
234 
235 The chunk/atom compute cannot query the output of the fix on a timestep
236 it is needed.
237 
238 W: One or more chunks do not contain all atoms in molecule
239 
240 This may not be what you intended.
241 
242 E: Invalid bin bounds in compute chunk/atom
243 
244 The lo/hi values are inconsistent.
245 
246 E: Compute chunk/atom bin/sphere radius is too large for periodic box
247 
248 Radius cannot be bigger than 1/2 of any periodic dimension.
249 
250 E: Compute chunk/atom bin/cylinder radius is too large for periodic box
251 
252 Radius cannot be bigger than 1/2 of a non-axis  periodic dimension.
253 
254 E: Cannot use compute chunk/atom bin z for 2d model
255 
256 Self-explanatory.
257 
258 U: Two fix ave commands using same compute chunk/atom command in incompatible ways
259 
260 They are both attempting to "lock" the chunk/atom command so that the
261 chunk assignments persist for some number of timesteps, but are doing
262 it in different ways.
263 
264 */
265