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     (if not contributing author is listed, this file has been contributed
36     by the core developer)
37 
38     Copyright 2012-     DCS Computing GmbH, Linz
39     Copyright 2009-2012 JKU Linz
40 ------------------------------------------------------------------------- */
41 
42 #ifdef FIX_CLASS
43 
44 FixStyle(multisphere,FixMultisphere)
45 FixStyle(multisphere/nointegration,FixMultisphere)
46 FixStyle(concave,FixMultisphere)
47 
48 #else
49 
50 #ifndef LMP_FIX_MULTISPHERE_H
51 #define LMP_FIX_MULTISPHERE_H
52 
53 #include "fix.h"
54 #include "math_extra_liggghts.h"
55 #include "multisphere_parallel.h"
56 #include "fix_property_atom.h"
57 #include "fix_remove.h"
58 #include "fix_heat_gran.h"
59 #include "atom.h"
60 #include "comm.h"
61 
62 namespace LAMMPS_NS {
63 
64 enum
65 {
66     MS_COMM_UNDEFINED,
67     MS_COMM_FW_BODY,
68     MS_COMM_FW_IMAGE_DISPLACE,
69     MS_COMM_FW_V_OMEGA,
70     MS_COMM_FW_F_TORQUE,
71     MS_COMM_FW_TEMP,
72     MS_COMM_REV_X_V_OMEGA,
73     MS_COMM_REV_V_OMEGA,
74     MS_COMM_REV_IMAGE,
75     MS_COMM_REV_DISPLACE,
76     MS_COMM_REV_TEMP
77 };
78 
79 class FixMultisphere : public Fix
80 {
81     friend class SetMultisphere;
82 
83      friend class FixMoveMultisphere;
84      public:
85 
86       FixMultisphere(class LAMMPS *, int, char **);
87       virtual ~FixMultisphere();
88 
89       void post_create();
90       void pre_delete(bool unfixflag);
91       virtual int setmask();
92       virtual void init();
93 
94       virtual void setup(int);
95       virtual void setup_pre_force(int);
96       virtual void setup_pre_exchange();
97       virtual void setup_pre_neighbor();
98 
99       virtual double extend_cut_ghost();
100 
101       void initial_integrate(int);
102       virtual void pre_force(int);
103       virtual void pre_final_integrate();
104       void final_integrate();
105       void comm_correct_force(bool setupflag);
106       virtual void calc_force(bool setupflag);
107 
108       void add_body_finalize();
109 
110       double memory_usage();
111       void grow_arrays(int);
112       void copy_arrays(int i, int j, int delflag);
113 
114       void pre_exchange();
115       void pre_neighbor();
116       void set_arrays(int);
117 
118       int size_restart(int nlocal);
119       int maxsize_restart();
120 
121       void write_restart(FILE *fp);
122       void restart(char *buf);
123 
124       int modify_param(int narg, char **arg);
125 
126       // *************************************
127       #include "fix_multisphere_comm_I.h"
128       // *************************************
129 
130       int dof(int);
131       double ** get_dump_ref(int &nb, int &nprop, char* prop);
132       double max_r_bound();
133 
134       void add_remove_callback(FixRemove *ptr);
135 
136       // public inline access
137 
138       void *extract(const char *name, int &len1, int &len2)
139       {
140           if (strcmp(name,"body") == 0)
141           {
142               len1 = atom->tag_max();
143               len2 = 1;
144               return (void *) body_;
145           }
146           return multisphere_.extract(name,len1,len2);
147       }
148 
149       inline class Multisphere& data()
150       { return multisphere_;}
151 
152       inline class FixPropertyAtom* fix_delflag()
153       { return fix_delflag_; }
154 
155       inline int belongs_to(int i) const
156       { return body_[i]; }
157 
158       inline int n_body()
159       { return data().n_body(); }
160 
161       inline int n_body_all()
162       { return data().n_body_all(); }
163 
164       inline int tag_max_body()
165       { return data().tag_max_body(); }
166 
167       inline int ntypes()
168       { return ntypes_; }
169 
170       inline double* vclump()
171       { return Vclump_; }
172 
173       inline double extract_ke()
174       { return data().extract_ke(); }
175 
176       inline double extract_rke()
177       { return data().extract_rke(); }
178 
179       inline double extract_vave()
180       { return data().extract_vave(); }
181 
182       inline double extract_omega_ave()
183       { return data().extract_omega_ave(); }
184 
185       inline void set_v_body_from_atom_index(int iatom,double *vel)
186       {if(body_[iatom] >= 0) multisphere_.set_v_body(body_[iatom],vel); }
187 
188       inline void set_omega_body_from_atom_index(int iatom,double *omega)
189       {if(body_[iatom] >= 0) multisphere_.set_omega_body(body_[iatom],omega); }
190 
191       inline void set_body_displace(int i,double *_displace,int body_id,double volume_weight)
192       {
193         body_[i] = body_id; vectorCopy3D(_displace,displace_[i]);
194         if(fix_volumeweight_ms_)
195             fix_volumeweight_ms_->vector_atom[i] = volume_weight;
196       }
197 
198       int calc_n_steps(int iatom,double *p_ref,double *normalvec,double *v_normal)
199       { return multisphere_.calc_n_steps(iatom,body_[iatom],p_ref,normalvec,v_normal); }
200 
201       void release(int iatom,double *v_toInsert,double *omega_toInsert)
202       { return multisphere_.release(iatom,body_[iatom],v_toInsert,omega_toInsert); }
203 
204       bool allow_group_and_set()
205       { return allow_group_and_set_; }
206 
207       bool use_volumeweight()
208       { return use_volumeweight_ms_; }
209 
210       const FixPropertyAtom *get_volumeweight() const
211       { return fix_volumeweight_ms_; }
212 
213       void scale_displace(int i, double factor)
214       { vectorScalarMult3D(displace_[i],factor); }
215 
216       void set_v_communicate();
217 
218       inline void rev_comm_displace()
219       {
220         rev_comm_flag_ = MS_COMM_REV_DISPLACE;
221         reverse_comm();
222       }
223 
224       void set_add_dragforce(bool value)
225       {
226         add_dragforce_ = value;
227       }
228 
229      protected:
230 
231       void ms_error(const char * file, int line,char const *errmsg);
232 
233       inline int map(int i)
234       { return data().map(i); }
235 
236       inline int tag(int i)
237       { return data().tag(i); }
238 
239       void set_xv();
240       void set_xv(int);
241       void set_v();
242       void set_v(int);
243 
244       bool do_modify_body_forces_torques_;
245       virtual void modify_body_forces_torques() {}
246 
247       class Multisphere &multisphere_;
248       class FixPropertyAtom *fix_corner_ghost_;
249       class FixPropertyAtom *fix_delflag_;
250       class FixPropertyAtom *fix_existflag_;
251       class FixPropertyAtom *fix_volumeweight_ms_;
252       bool use_volumeweight_ms_;
253       class FixGravity *fix_gravity_;
254       FixHeatGran *fix_heat_;
255 
256       //int comm_di_;
257       int fw_comm_flag_;
258       int rev_comm_flag_;
259 
260       // per-atom properties handled by this fix
261       int *body_;                // which body each atom is part of (-1 if none)
262       double **displace_;        // displacement of each atom in body coords
263 
264       double dtv,dtf,dtq;
265 
266       std::vector<FixRemove*> fix_remove_;
267 
268       // MS communication
269       int ntypes_;
270       double *Vclump_;
271 
272       bool allow_group_and_set_;
273       bool allow_heatsource_;
274 
275       double CAdd_;                 //Added mass coefficient
276       double fluidDensity_;         //fluid density
277 
278       bool concave_;
279 
280       bool add_dragforce_;
281 
282       inline int getMask(int ibody)
283       { return 1; }
284 
285 };
286 
287 }
288 
289 #endif
290 #endif
291