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 #ifndef LMP_ATOM_VEC_H
15 #define LMP_ATOM_VEC_H
16 
17 #include "pointers.h"    // IWYU pragma: export
18 #include <vector>
19 
20 namespace LAMMPS_NS {
21 
22 class AtomVec : protected Pointers {
23  public:
24   enum { PER_ATOM = 0, PER_TYPE = 1 };
25   int molecular;    // 0 = atomic, 1 = molecular system, 2 = molecular template system
26   int bonds_allow, angles_allow;           // 1 if bonds, angles are used
27   int dihedrals_allow, impropers_allow;    // 1 if dihedrals, impropers used
28   int mass_type;                           // 1 if per-type masses
29   int dipole_type;                         // 1 if per-type dipole moments
30   int forceclearflag;                      // 1 if has forceclear() method
31 
32   int comm_x_only;    // 1 if only exchange x in forward comm
33   int comm_f_only;    // 1 if only exchange f in reverse comm
34 
35   int size_forward;      // # of values per atom in comm
36   int size_reverse;      // # in reverse comm
37   int size_border;       // # in border comm
38   int size_velocity;     // # of velocity based quantities
39   int size_data_atom;    // number of values in Atom line
40   int size_data_vel;     // number of values in Velocity line
41   int xcol_data;         // column (1-N) where x is in Atom line
42   int maxexchange;       // max size of exchanged atom
43                          // only needs to be set if size > BUFEXTRA
44 
45   int bonus_flag;                // 1 if stores bonus data
46   int size_forward_bonus;        // # in forward bonus comm
47   int size_border_bonus;         // # in border bonus comm
48   int size_restart_bonus_one;    // # in restart bonus comm
49   int size_data_bonus;           // number of values in Bonus line
50 
51   class Molecule **onemols;    // list of molecules for style template
52   int nset;                    // # of molecules in list
53 
54   int kokkosable;    // 1 if atom style is KOKKOS-enabled
55 
56   int nargcopy;      // copy of command-line args for atom_style command
57   char **argcopy;    // used when AtomVec is realloced (restart,replicate)
58 
59   // additional list of peratom fields operated on by different methods
60   // set or created by child styles
61 
62   char *fields_grow, *fields_copy;
63   char *fields_comm, *fields_comm_vel, *fields_reverse;
64   char *fields_border, *fields_border_vel;
65   char *fields_exchange, *fields_restart;
66   char *fields_create, *fields_data_atom, *fields_data_vel;
67 
68   // methods
69 
70   AtomVec(class LAMMPS *);
71   virtual ~AtomVec();
72 
73   void store_args(int, char **);
74   virtual void process_args(int, char **);
75   virtual void init();
76 
force_clear(int,size_t)77   virtual void force_clear(int, size_t) {}
78   virtual bigint roundup(bigint);
79 
80   virtual void grow(int);
grow_pointers()81   virtual void grow_pointers() {}
82   virtual void copy(int, int, int);
83 
copy_bonus(int,int,int)84   virtual void copy_bonus(int, int, int) {}
clear_bonus()85   virtual void clear_bonus() {}
86 
87   virtual int pack_comm(int, int *, double *, int, int *);
88   virtual int pack_comm_vel(int, int *, double *, int, int *);
89   virtual void unpack_comm(int, int, double *);
90   virtual void unpack_comm_vel(int, int, double *);
91 
pack_comm_bonus(int,int *,double *)92   virtual int pack_comm_bonus(int, int *, double *) { return 0; }
unpack_comm_bonus(int,int,double *)93   virtual void unpack_comm_bonus(int, int, double *) {}
94 
95   virtual int pack_reverse(int, int, double *);
96   virtual void unpack_reverse(int, int *, double *);
97 
98   virtual int pack_border(int, int *, double *, int, int *);
99   virtual int pack_border_vel(int, int *, double *, int, int *);
100   virtual void unpack_border(int, int, double *);
101   virtual void unpack_border_vel(int, int, double *);
102 
pack_border_bonus(int,int *,double *)103   virtual int pack_border_bonus(int, int *, double *) { return 0; }
unpack_border_bonus(int,int,double *)104   virtual int unpack_border_bonus(int, int, double *) { return 0; }
105 
106   virtual int pack_exchange(int, double *);
107   virtual int unpack_exchange(double *);
108 
pack_exchange_bonus(int,double *)109   virtual int pack_exchange_bonus(int, double *) { return 0; }
unpack_exchange_bonus(int,double *)110   virtual int unpack_exchange_bonus(int, double *) { return 0; }
111 
112   virtual int size_restart();
113   virtual int pack_restart(int, double *);
114   virtual int unpack_restart(double *);
115 
pack_restart_pre(int)116   virtual void pack_restart_pre(int) {}
pack_restart_post(int)117   virtual void pack_restart_post(int) {}
unpack_restart_init(int)118   virtual void unpack_restart_init(int) {}
119 
size_restart_bonus()120   virtual int size_restart_bonus() { return 0; }
pack_restart_bonus(int,double *)121   virtual int pack_restart_bonus(int, double *) { return 0; }
unpack_restart_bonus(int,double *)122   virtual int unpack_restart_bonus(int, double *) { return 0; }
123 
124   virtual void create_atom(int, double *);
create_atom_post(int)125   virtual void create_atom_post(int) {}
126 
127   virtual void data_atom(double *, imageint, char **);
data_atom_post(int)128   virtual void data_atom_post(int) {}
data_atom_bonus(int,char **)129   virtual void data_atom_bonus(int, char **) {}
data_body(int,int,int,int *,double *)130   virtual void data_body(int, int, int, int *, double *) {}
131 
data_bonds_post(int,int,tagint,tagint,tagint)132   virtual void data_bonds_post(int, int, tagint, tagint, tagint) {}
133 
134   virtual void pack_data(double **);
135   virtual void write_data(FILE *, int, double **);
pack_data_pre(int)136   virtual void pack_data_pre(int) {}
pack_data_post(int)137   virtual void pack_data_post(int) {}
138 
139   virtual void data_vel(int, char **);
140   virtual void pack_vel(double **);
141   virtual void write_vel(FILE *, int, double **);
142 
143   virtual int pack_bond(tagint **);
144   virtual void write_bond(FILE *, int, tagint **, int);
145   virtual int pack_angle(tagint **);
146   virtual void write_angle(FILE *, int, tagint **, int);
147   virtual int pack_dihedral(tagint **);
148   virtual void write_dihedral(FILE *, int, tagint **, int);
149   virtual int pack_improper(tagint **);
150   virtual void write_improper(FILE *, int, tagint **, int);
151 
pack_data_bonus(double *,int)152   virtual int pack_data_bonus(double *, int) { return 0; }
write_data_bonus(FILE *,int,double *,int)153   virtual void write_data_bonus(FILE *, int, double *, int) {}
154 
property_atom(char *)155   virtual int property_atom(char *) { return -1; }
pack_property_atom(int,double *,int,int)156   virtual void pack_property_atom(int, double *, int, int) {}
157 
158   virtual double memory_usage();
memory_usage_bonus()159   virtual double memory_usage_bonus() { return 0; }
160 
161   // old hybrid functions, needed by Kokkos package
162 
pack_comm_hybrid(int,int *,double *)163   virtual int pack_comm_hybrid(int, int *, double *) { return 0; }
unpack_comm_hybrid(int,int,double *)164   virtual int unpack_comm_hybrid(int, int, double *) { return 0; }
pack_reverse_hybrid(int,int,double *)165   virtual int pack_reverse_hybrid(int, int, double *) { return 0; }
unpack_reverse_hybrid(int,int *,double *)166   virtual int unpack_reverse_hybrid(int, int *, double *) { return 0; }
pack_border_hybrid(int,int *,double *)167   virtual int pack_border_hybrid(int, int *, double *) { return 0; }
unpack_border_hybrid(int,int,double *)168   virtual int unpack_border_hybrid(int, int, double *) { return 0; }
data_atom_hybrid(int,char **)169   virtual int data_atom_hybrid(int, char **) { return 0; }
data_vel_hybrid(int,char **)170   virtual int data_vel_hybrid(int, char **) { return 0; }
pack_data_hybrid(int,double *)171   virtual int pack_data_hybrid(int, double *) { return 0; }
write_data_hybrid(FILE *,double *)172   virtual int write_data_hybrid(FILE *, double *) { return 0; }
pack_vel_hybrid(int,double *)173   virtual int pack_vel_hybrid(int, double *) { return 0; }
write_vel_hybrid(FILE *,double *)174   virtual int write_vel_hybrid(FILE *, double *) { return 0; }
175 
176  protected:
177   int nmax;             // local copy of atom->nmax
178   int deform_vremap;    // local copy of domain properties
179   int deform_groupbit;
180   double *h_rate;
181 
182   tagint *tag;    // peratom fields common to all styles
183   int *type, *mask;
184   imageint *image;
185   double **x, **v, **f;
186 
187   // standard list of peratom fields always operated on by different methods
188   // common to all styles, so not listed in field strings
189 
190   const char *default_grow, *default_copy;
191   const char *default_comm, *default_comm_vel, *default_reverse;
192   const char *default_border, *default_border_vel;
193   const char *default_exchange, *default_restart;
194   const char *default_create, *default_data_atom, *default_data_vel;
195 
196   struct Method {
197     std::vector<void *> pdata;
198     std::vector<int> datatype;
199     std::vector<int> cols;
200     std::vector<int *> maxcols;
201     std::vector<int> collength;
202     std::vector<void *> plength;
203     std::vector<int> index;
204 
205     void resize(int nfield);
206   };
207 
208   Method mgrow, mcopy;
209   Method mcomm, mcomm_vel, mreverse, mborder, mborder_vel, mexchange, mrestart;
210   Method mcreate, mdata_atom, mdata_vel;
211 
212   int ngrow, ncopy;
213   int ncomm, ncomm_vel, nreverse, nborder, nborder_vel, nexchange, nrestart;
214   int ncreate, ndata_atom, ndata_vel;
215 
216   // thread info for fields that are duplicated over threads
217   // used by fields in grow() and memory_usage()
218 
219   bool *threads;
220 
221   // local methods
222 
223   void grow_nmax();
224   int grow_nmax_bonus(int);
225   void setup_fields();
226   int process_fields(char *, const char *, Method *);
227   void init_method(int, Method *);
228 };
229 
230 }    // namespace LAMMPS_NS
231 
232 #endif
233 
234 /* ERROR/WARNING messages:
235 
236 E: Invalid atom_style command
237 
238 Self-explanatory.
239 
240 E: KOKKOS package requires a kokkos enabled atom_style
241 
242 Self-explanatory.
243 
244 E: Per-processor system is too big
245 
246 The number of owned atoms plus ghost atoms on a single
247 processor must fit in 32-bit integer.
248 
249 E: Invalid atom type in Atoms section of data file
250 
251 Atom types must range from 1 to specified # of types.
252 
253 */
254