summaryrefslogtreecommitdiff
path: root/src/particles/superParticleSystem3D.h
blob: 4fe9a2b3d9279466c5886d5740ca731a4acedb5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2016 Thomas Henn, Mathias J. Krause
 *  E-mail contact: info@openlb.net
 *  The most recent release of OpenLB can be downloaded at
 *  <http://www.openlb.net/>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA  02110-1301, USA.
 */

#ifndef SUPERPARTICLESYSTEM_3D_H
#define SUPERPARTICLESYSTEM_3D_H

#define shadows

#include <set>
#include <vector>
#include <list>
#include <deque>
#include <memory>
#include "boundary/boundary3D.h"
#include "communication/loadBalancer.h"
#include "communication/mpiManager.h"
#include "core/superLattice3D.h"
#include "forces/force3D.h"
#include "functors/analytical/indicator/indicatorBaseF3D.h"
#include "functors/analytical/analyticalF.h"
#include "geometry/cuboidGeometry3D.h"
#include "geometry/superGeometry3D.h"
#include "particleSystem3D.h"
#include "superParticleSysVTUout.h"
#include "functors/lattice/superLatticeLocalF3D.h"
#include "twoWayCouplings/twoWayCouplings3D.h"

namespace olb {

template<typename T, template<typename U> class PARTICLETYPE>
class SuperParticleSysVtuWriter;

template<typename T>
class SuperParticleSysVtuWriterMag;

template<typename T, template<typename U> class PARTICLETYPE>
class Force3D;

template<typename T, template<typename U> class PARTICLETYPE>
class Boundary3D;

template <typename T, typename DESCRIPTOR>
class SuperLatticeInterpVelocity3D;

/**
 *  The class superParticleSystem is the basis for particulate flows within OpenLB.
 *  Use one of the constructors to instantiate a superParticleSystem. This creates
 *  one particleSystem for each cuboid according to the structure found in
 *  cuboid Geometry.
 *  <UL>
 *  <LI>Add single or several particles using one of the addParticle() functions.</LI>
 *  <LI>Add forces acting on the particles using the addForce() function.</LI>
 *  <LI>Add particle boundaries using the addBoundary() function.</LI>
 *  <LI>Finally compute one timestep using the simulate() function.</LI>
 *  </UL>
 */

template<typename T, template<typename U> class PARTICLETYPE>
class SuperParticleSystem3D : public SuperStructure3D<T> {

public:
  time_t _stopSorting;

  /// Constructor for SuperParticleSystem
  SuperParticleSystem3D(CuboidGeometry3D<T>& cuboidGeometry,
                        LoadBalancer<T>& loadBalancer, SuperGeometry3D<T>&);
  SuperParticleSystem3D(SuperGeometry3D<T>&);

  /// Copy Constructor for SuperParticleSystem
  SuperParticleSystem3D(SuperParticleSystem3D<T, PARTICLETYPE>& spSys);
  SuperParticleSystem3D(SuperParticleSystem3D<T, PARTICLETYPE> const& spSys);

  /// Move Constructor for SuperParticleSystem
  SuperParticleSystem3D(SuperParticleSystem3D<T, PARTICLETYPE> && spSys);
  /// Destructor
  ~SuperParticleSystem3D() override {};

  /// Add a Particle to SuperParticleSystem
  void addParticle(PARTICLETYPE<T> &p);

  /// Add a number of identical particles randomly distributed in a given IndicatorF3D
  void addParticle(IndicatorF3D<T>& ind, T mas, T rad, int no = 1, std::vector<T> vel = {0., 0., 0.});
  void addParticle(IndicatorF3D<T>& ind, T mas, T rad, int no, int id,
                   std::vector<T> vel, std::vector<T> dMoment, std::vector<T> aVel,
                   std::vector<T> torque, T magnetisation, int sActivity)
  {
    addParticle(ind, mas, rad, no, vel);
  };

  /// Add a number of identical Pprticles randomly distributed in a given IndicatorF3D
  /// and in given Material Number
  void addParticle(IndicatorF3D<T>& ind, std::set<int>  material, T mas, T rad, int no = 1,
                   std::vector<T> vel = {0., 0., 0.});
  void addParticle(IndicatorF3D<T>& ind,  std::set<int>  material, T mas, T rad, int no, int id,
                   std::vector<T> vel, std::vector<T> dMoment, std::vector<T> aVel,
                   std::vector<T> torque, T magnetisation, int sActivity)
  {
    addParticle(ind, material, mas, rad, no, vel);
  };

  /// Add a number of identical particles randomly distributed in a given Material Number
  void addParticle(std::set<int>  material, int no, T mas, T rad, std::vector<T> vel = {0., 0., 0.});

  /// Add a number of identical particles equally distributed in a given Material Number
  void addParticleEquallyDistributed(IndicatorCuboid3D<T>& cuboid, T pMass,
                                     T pRad,/* number of particles on x, y, z axis*/
                                     int nox, int noy, int noz, std::vector<T> vel = {0., 0., 0.});

  void addParticleEquallyDistributed(IndicatorCuboid3D<T>& cuboid, int nox, int noy, int noz, PARTICLETYPE<T>& p);

  /// Generates particle at a circle shaped inlet, amount given by mass concentration in feedstream.
  /// It is taken care that the particles do not overlap during initialization, therefore they are
  /// saved in posDeq with size deqSize.
  /// The parameters particlesPerPhyTimeStep and inletVec are initialized for iT = 0 and given back
  /// by reference. They can be defined by an arbitrary value.
  template<typename DESCRIPTOR>
  void generateParticlesCircleInletMassConcentration(
    IndicatorCircle3D<T>& indicatorCircle, T particleMassConcentration, T charPhysVelocity,
    T conversionFactorTime, SuperLatticeInterpPhysVelocity3D<T, DESCRIPTOR>& getVel,
    PARTICLETYPE<T>& p, std::set<int> material, int iT, T& particlesPerPhyTimeStep,
    std::vector<T>& inletVec, std::deque<std::vector<T>>& posDeq, int deqSize);

  /// Add particles form a File. Save using saveToFile(std::string name)
  void addParticlesFromFile(std::string name, T mass, T radius);
  /// Add a number of particles with a certain ID (TracerParticle) equally distributed in a given IndicatorF3D
  void addTracerParticle(IndicatorF3D<T>& ind, T idTP, T mas, T rad, int noTP = 1, std::vector<T> vel = {0., 0., 0.});

  /// Add a number of unidentical particles with normally distributed radius (Box-Muller Method) in a given IndicatorF3D
  /// with specific appearance probability
  void addParticleBoxMuller(IndicatorF3D<T>& ind, T partRho, T mu, T sigma, int no = 1, T appProb = 1., std::vector<T> vel
                            = {0., 0., 0.});

  /// Removes all particles from System
  void clearParticles();

  /// Generates particles with specific volume concentration conc equally
  /// and randomly distributed in given IndicatorCuboid maintaining a minimum
  /// distance between each other.
  /// Be aware that long calculation time can occur because of minDist check.
  void addParticleWithDistance(IndicatorCuboid3D<T>& ind,
                               T pMass, T pRad, std::vector<T> vel,
                               T conc, // volume concentration of particles, noP*vol_1p/volF = conc
                               T minDist, // minimum distance between each particle
                               bool checkDist // check whether minDist is choosen too large
                              );

  /// Integrate on Timestep dT, scale = true keeps the particle velocity in stable range
  void simulate(T dT, bool scale = false);
  // multiple collision models
  void simulate(T dT, std::set<int> sActivityOfFreeParticle, bool scale = false)
  {
    simulate(dT, scale);
  };
  /// Integrate on Timestep dT with two-way coupling, scale = true keeps the particle velocity in stable range
  void simulateWithTwoWayCoupling_Mathias ( T dT,
                                    ForwardCouplingModel<T,PARTICLETYPE>& forwardCoupling,
                                    BackCouplingModel<T,PARTICLETYPE>& backCoupling,
                                    int material, int subSteps = 1, bool resetExternalField = true, bool scale = false );
  void simulateWithTwoWayCoupling_Davide ( T dT,
                                    ForwardCouplingModel<T,PARTICLETYPE>& forwardCoupling,
                                    BackCouplingModel<T,PARTICLETYPE>& backCoupling,
                                    int material, int subSteps = 1, bool resetExternalField = true, bool scale = false );

  /// Gives random velocity to all particles
  void setParticlesVelRandom(T velFactor);
  /// Changes particle positions randomly
  void setParticlesPosRandom(T posFactor);
  void setParticlesPosRandom(T posFactorX, T posFactorY, T posFactorZ);
  /// Gives random dipolemoment orientation to all MagneticParticle3D
  void setMagneticParticlesdMomRandom() {};
  /// Gives specific attributes to all MagneticParticle3D
  void setMagneticParticles(std::vector<T> dMoment, std::vector<T> vel, std::vector<T>