1 /* ----------------------------------------------------------------------
2     This is the
3 
4     ██╗     ██╗ ██████╗  ██████╗  ██████╗ ██╗  ██╗████████╗███████╗
5     ██║     ██║██╔════╝ ██╔════╝ ██╔════╝ ██║  ██║╚══██╔══╝██╔════╝
6     ██║     ██║██║  ███╗██║  ███╗██║  ███╗███████║   ██║   ███████╗
7     ██║     ██║██║   ██║██║   ██║██║   ██║██╔══██║   ██║   ╚════██║
8     ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║  ██║   ██║   ███████║
9     ╚══════╝╚═╝ ╚═════╝  ╚═════╝  ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝®
10 
11     DEM simulation engine, released by
12     DCS Computing Gmbh, Linz, Austria
13     http://www.dcs-computing.com, office@dcs-computing.com
14 
15     LIGGGHTS® is part of CFDEM®project:
16     http://www.liggghts.com | http://www.cfdem.com
17 
18     Core developer and main author:
19     Christoph Kloss, christoph.kloss@dcs-computing.com
20 
21     LIGGGHTS® is open-source, distributed under the terms of the GNU Public
22     License, version 2 or later. It is distributed in the hope that it will
23     be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have
25     received a copy of the GNU General Public License along with LIGGGHTS®.
26     If not, see http://www.gnu.org/licenses . See also top-level README
27     and LICENSE files.
28 
29     LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH,
30     the producer of the LIGGGHTS® software and the CFDEM®coupling software
31     See http://www.cfdem.com/terms-trademark-policy for details.
32 
33 -------------------------------------------------------------------------
34     Contributing author and copyright for this file:
35     This file is from LAMMPS, but has been modified. Copyright for
36     modification:
37 
38     Copyright 2012-     DCS Computing GmbH, Linz
39     Copyright 2009-2012 JKU Linz
40 
41     Copyright of original file:
42     LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
43     http://lammps.sandia.gov, Sandia National Laboratories
44     Steve Plimpton, sjplimp@sandia.gov
45 
46     Copyright (2003) Sandia Corporation.  Under the terms of Contract
47     DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
48     certain rights in this software.  This software is distributed under
49     the GNU General Public License.
50 ------------------------------------------------------------------------- */
51 
52 #ifndef LMP_MODIFY_H
53 #define LMP_MODIFY_H
54 
55 #include <stdio.h>
56 #include "pointers.h"
57 #include "fix.h"
58 #include <map>
59 #include <string>
60 
61 namespace LAMMPS_NS {
62 
63 class Modify : protected Pointers {
64   friend class Info;
65  public:
66   int nfix,maxfix;
67   int n_pre_initial_integrate, n_initial_integrate,n_post_integrate,n_pre_exchange,n_pre_neighbor;
68   int n_pre_force,n_post_force;
69   int n_iterate_implicitly, n_pre_final_integrate;
70   int n_final_integrate,n_end_of_step,n_thermo_energy;
71   int n_initial_integrate_respa,n_post_integrate_respa;
72   int n_pre_force_respa,n_post_force_respa,n_final_integrate_respa;
73   int n_min_pre_exchange,n_min_pre_neighbor;
74   int n_min_pre_force,n_min_post_force,n_min_energy;
75 
76   int restart_pbc_any;       // 1 if any fix sets restart_pbc
77   int nfix_restart_global;   // stored fix global info from restart file
78   int nfix_restart_peratom;  // stored fix peratom info from restart file
79 
80   class Fix **fix;           // list of fixes
81   int *fmask;                // bit mask for when each fix is applied
82 
83   int timing;                // 1 if fix calls are timed
84 
85   int ncompute,maxcompute;   // list of computes
86   class Compute **compute;
87 
88   Modify(class LAMMPS *);
89   virtual ~Modify();
90   virtual void init();
91   virtual void setup(int);
92   virtual void setup_pre_exchange();
93   virtual void setup_pre_neighbor();
94   virtual void setup_pre_force(int);
95   virtual void pre_initial_integrate();
96   virtual void initial_integrate(int);
97   virtual void post_integrate();
98   void pre_decide();
99   virtual void pre_exchange();
100   virtual void pre_neighbor();
101   virtual void pre_force(int);
102   virtual void post_force(int);
103   virtual void pre_final_integrate();
104   virtual void final_integrate();
105   virtual bool iterate_implicitly();
106   virtual void end_of_step();
107   virtual double thermo_energy();
108   virtual void post_run();
109 
110   void setup_pre_force_respa(int, int);
111   void initial_integrate_respa(int, int, int);
112   void post_integrate_respa(int, int);
113   void pre_force_respa(int, int, int);
114   void post_force_respa(int, int, int);
115   void final_integrate_respa(int, int);
116 
117   void min_pre_exchange();
118   void min_pre_neighbor();
119   void min_pre_force(int);
120   void min_post_force(int);
121 
122   double min_energy(double *);
123   void min_store();
124   void min_step(double, double *);
125   void min_clearstore();
126   void min_pushstore();
127   void min_popstore();
128   int min_reset_ref();
129   double max_alpha(double *);
130   int min_dof();
131 
132   void add_fix(int, char **, char *suffix = NULL);
133   void modify_fix(int, char **);
134   void delete_fix(const char *,bool unfixflag = false);
135   int find_fix(const char *);
136 
137   class FixPropertyGlobal* add_fix_property_global(int narg,char **arg,const char *);
138   class FixPropertyAtom* add_fix_property_atom(int narg,char **arg,const char *);
139   class Fix* find_fix_property(const char *,const char *,const char *,int ,int,const char * );
140   class Fix* find_fix_property(const char *,const char *,const char *,int ,int,const char *,bool );
141   class Fix* find_fix_id(const char *id);
142   class Compute* find_compute_id(const char *id);
143   class Fix* find_fix_id_style(const char *id,const char *style);
144   class Fix* find_fix_style(const char *style, int rank);
145   class Fix* find_fix_style_strict(const char *style, int rank);
146   class Compute* find_compute_style_strict(const char *style, int rank);
147   int n_fixes_style(const char *style);
148   int n_computes_style(const char *style);
149   int n_fixes_style_strict(const char *style);
150   int n_fixes_property_atom();
151   class FixPropertyAtom* find_fix_property_atom(int rank);
152   int n_fixes_property_atom_not_internal();
153   int dump_size_fixes_property_atom_not_internal();
154   class FixPropertyAtom* find_fix_property_atom_not_internal(int rank);
155   bool i_am_first_of_style(class Fix *fix_to_check);
156   int index_first_fix_of_style(const char *style);
157   int index_last_fix_of_style(const char *style);
158   int my_index(class Fix *fixptr);
159   int index_first_fix_with_function(const int FUNCTION, bool integrate=false);
160   class FixScalarTransportEquation* find_fix_scalar_transport_equation(const char *equation_id);
161   class FixScalarTransportEquation* find_fix_scalar_transport_equation_strict(const char *equation_id);
162   void box_extent(double &xlo,double &xhi,double &ylo,double &yhi,double &zlo,double &zhi);
163 
164   void add_compute(int, char **, char *suffix = NULL);
165   void modify_compute(int, char **);
166   void delete_compute(const char *,bool uncomputeflag = false);
167   int find_compute(const char *);
168   void clearstep_compute();
169   void addstep_compute(bigint);
170   void addstep_compute_all(bigint);
171 
172   void write_restart(FILE *);
173   int read_restart(FILE *);
174   void restart_deallocate();
175 
176   bigint memory_usage();
177 
178   int fix_restart_in_progress();
179   bool have_restart_data(Fix *f);
180   bool have_restart_data_style(const char* _style);
181   int n_restart_data_global_style(const char* _style);
182   char* id_restart_data_global_style(const char* _style,int _rank);
183   void max_min_rad(double &maxrad,double &minrad);
184 
185   void forceMeshExchange();
186 
187   // updates all computes at the end of a run
188   void update_computes_on_run_end();
189 
190  protected:
191 
192   // lists of fixes to apply at different stages of timestep
193 
194   int *list_pre_initial_integrate, *list_initial_integrate,*list_post_integrate;
195   int *list_pre_exchange,*list_pre_neighbor;
196   int *list_pre_force,*list_post_force;
197   int *list_iterate_implicitly, *list_pre_final_integrate;
198   int *list_final_integrate,*list_end_of_step,*list_thermo_energy;
199   int *list_initial_integrate_respa,*list_post_integrate_respa;
200   int *list_pre_force_respa,*list_post_force_respa;
201   int *list_final_integrate_respa;
202   int *list_min_pre_exchange,*list_min_pre_neighbor;
203   int *list_min_pre_force,*list_min_post_force;
204   int *list_min_energy;
205 
206   int *end_of_step_every;
207 
208   int n_timeflag;            // list of computes that store time invocation
209   int *list_timeflag;
210 
211   char **id_restart_global;           // stored fix global info
212   char **style_restart_global;        // from read-in restart file
213   char **state_restart_global;
214 
215   char **id_restart_peratom;          // stored fix peratom info
216   char **style_restart_peratom;       // from read-in restart file
217   int *index_restart_peratom;
218 
219   int index_permanent;        // fix/compute index returned to library call
220 
221   void list_init(int, int &, int *&);
222   void list_init_pre_exchange(int, int &, int *&);
223   void list_init_end_of_step(int, int &, int *&);
224   void list_init_thermo_energy(int, int &, int *&);
225   void list_init_compute();
226 
227 private:
228   inline void call_method_on_fixes(FixMethod method);
229   inline void call_method_on_fixes(FixMethod method, int *& ilist, int & inum);
230   inline void call_method_on_fixes(FixMethodWithVFlag method, int vflag);
231   inline void call_method_on_fixes(FixMethodWithVFlag method, int vflag, int *& ilist, int & inum);
232 
233   inline void call_respa_method_on_fixes(FixMethodRESPA2 method, int arg1, int arg2, int *& ilist, int & inum);
234   inline void call_respa_method_on_fixes(FixMethodRESPA3 method, int arg1, int arg2, int arg3, int *& ilist, int & inum);
235 
236   typedef Compute *(*ComputeCreator)(LAMMPS *, int, int, char **);
237   std::map<std::string,ComputeCreator> *compute_map;
238 
239   typedef Fix *(*FixCreator)(LAMMPS *, int, char **);
240   std::map<std::string,FixCreator> *fix_map;
241 
242   template <typename T> static Compute *compute_creator(LAMMPS *, int, int, char **);
243   template <typename T> static Fix *fix_creator(LAMMPS *, int, char **);
244 };
245 
246 }
247 
248 #endif
249 
250 /* ERROR/WARNING messages:
251 
252 W: One or more atoms are time integrated more than once
253 
254 This is probably an error since you typically do not want to
255 advance the positions or velocities of an atom more than once
256 per timestep.
257 
258 E: Illegal ... command
259 
260 Self-explanatory.  Check the input script syntax and compare to the
261 documentation for the command.  You can use -echo screen as a
262 command-line option when running LAMMPS to see the offending line.
263 
264 E: Fix command before simulation box is defined
265 
266 The fix command cannot be used before a read_data, read_restart, or
267 create_box command.
268 
269 E: Could not find fix group ID
270 
271 A group ID used in the fix command does not exist.
272 
273 E: Replacing a fix, but new style != old style
274 
275 A fix ID can be used a 2nd time, but only if the style matches the
276 previous fix.  In this case it is assumed you with to reset a fix's
277 parameters.  This error may mean you are mistakenly re-using a fix ID
278 when you do not intend to.
279 
280 W: Replacing a fix, but new group != old group
281 
282 The ID and style of a fix match for a fix you are changing with a fix
283 command, but the new group you are specifying does not match the old
284 group.
285 
286 E: Invalid fix style
287 
288 The choice of fix style is unknown.
289 
290 E: Could not find fix_modify ID
291 
292 A fix ID used in the fix_modify command does not exist.
293 
294 E: Could not find fix ID to delete
295 
296 Self-explanatory.
297 
298 E: Reuse of compute ID
299 
300 A compute ID cannot be used twice.
301 
302 E: Invalid compute style
303 
304 Self-explanatory.
305 
306 E: Could not find compute_modify ID
307 
308 Self-explanatory.
309 
310 E: Could not find compute ID to delete
311 
312 Self-explanatory.
313 
314 */
315