OpenLB 1.7
Loading...
Searching...
No Matches
superParticleSystem3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2016 Thomas Henn, Mathias J. Krause, Davide Dapelo
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#ifndef SUPERPARTICLESYSTEM_3D_H
25#define SUPERPARTICLESYSTEM_3D_H
26
27#define shadows
28
29#include <set>
30#include <vector>
31#include <list>
32#include <deque>
33#include <memory>
34#include "boundary/boundary3D.h"
37
38#include "forces/force3D.h"
43#include "particleSystem3D.h"
47
48namespace olb {
49
50template<typename T, template<typename U> class PARTICLETYPE>
51class SuperParticleSysVtuWriter;
52
53template<typename T>
54class SuperParticleSysVtuWriterMag;
55
56template<typename T, template<typename U> class PARTICLETYPE>
57class Force3D;
58
59template<typename T, template<typename U> class PARTICLETYPE>
60class Boundary3D;
61
62template <typename T, typename DESCRIPTOR>
64
78template<typename T, template<typename U> class PARTICLETYPE>
80
81public:
83
86 LoadBalancer<T>& loadBalancer, SuperGeometry<T,3>&);
88
92
97 while(!_pSystems.empty()) delete _pSystems.back(), _pSystems.pop_back();
98 };
99
101 void addParticle(PARTICLETYPE<T> &p);
102
104 void addParticle(IndicatorF3D<T>& ind, T mas, T rad, int no = 1, std::vector<T> vel = {0., 0., 0.});
105 void addParticle(IndicatorF3D<T>& ind, T mas, T rad, int no, int id,
106 std::vector<T> vel, std::vector<T> dMoment, std::vector<T> aVel,
107 std::vector<T> torque, T magnetisation, int sActivity)
108 {
109 addParticle(ind, mas, rad, no, vel);
110 };
111
114 void addParticle(IndicatorF3D<T>& ind, std::set<int> material, T mas, T rad, int no = 1,
115 std::vector<T> vel = {0., 0., 0.});
116 void addHL3DParticle(IndicatorF3D<T>& ind, std::set<int> material, T mas, T rad, int no = 1,
117 std::vector<T> vel = {0., 0., 0.}, T surface=1., T volume=1.);
118 void addParticle(IndicatorF3D<T>& ind, std::set<int> material, T mas, T rad, int no, int id,
119 std::vector<T> vel, std::vector<T> dMoment, std::vector<T> aVel,
120 std::vector<T> torque, T magnetisation, int sActivity)
121 {
122 addParticle(ind, material, mas, rad, no, vel);
123 };
124
126 void addParticle(std::set<int> material, int no, T mas, T rad, std::vector<T> vel = {0., 0., 0.});
127
129 void addParticleEquallyDistributed(IndicatorCuboid3D<T>& cuboid, T pMass,
130 T pRad,/* number of particles on x, y, z axis*/
131 int nox, int noy, int noz, std::vector<T> vel = {0., 0., 0.});
132
133 void addParticleEquallyDistributed(IndicatorCuboid3D<T>& cuboid, int nox, int noy, int noz, PARTICLETYPE<T>& p);
134
140 template<typename DESCRIPTOR>
142 IndicatorCircle3D<T>& indicatorCircle, T particleMassConcentration, T charPhysVelocity,
143 T conversionFactorTime, SuperLatticeInterpPhysVelocity3D<T, DESCRIPTOR>& getVel,
144 PARTICLETYPE<T>& p, std::set<int> material, int iT, T& particlesPerPhyTimeStep,
145 std::vector<T>& inletVec, std::deque<std::vector<T>>& posDeq, int deqSize);
146
148 void addParticlesFromFile(std::string name, T mass, T radius);
149
150
152 void addParticlesFromParaviewFile(std::string name);
153
155 void addTracerParticle(IndicatorF3D<T>& ind, int idTP, T mas, T rad, int noTP = 1, std::vector<T> vel = {0., 0., 0.});
156
159 void addParticleBoxMuller(IndicatorF3D<T>& ind, T partRho, T mu, T sigma, int no = 1, T appProb = 1., std::vector<T> vel
160 = {0., 0., 0.});
161
163 void clearParticles();
164
169 void addParticleWithDistance(IndicatorCuboid3D<T>& ind,
170 T pMass, T pRad, std::vector<T> vel,
171 T conc, // volume concentration of particles, noP*vol_1p/volF = conc
172 T minDist, // minimum distance between each particle
173 bool checkDist // check whether minDist is chosen too large
174 );
175
177 void simulate(T dT, bool scale = false);
178 // multiple collision models
179 void simulate(T dT, std::set<int> sActivityOfFreeParticle, bool scale = false)
180 {
181 simulate(dT, scale);
182 };
187 int material, int subSteps = 1, bool resetExternalField = true, bool scale = false );
191 int material, int subSteps = 1, bool resetExternalField = true, bool scale = false );
192
194 void setParticlesVelRandom(T velFactor);
196 void setParticlesPosRandom(T posFactor);
197 void setParticlesPosRandom(T posFactorX, T posFactorY, T posFactorZ);
201 void setMagneticParticles(std::vector<T> dMoment, std::vector<T> vel, std::vector<T> aVel, std::vector<T> torque,
202 T magnetisation) {};
203 void setMagneticParticles(std::vector<T> dMoment, std::vector<T> vel, std::vector<T> aVel, std::vector<T> torque,
204 T magnetisation, int sActivity) {};
205
212 void findAgglomerates(int iT, int itVtkOutputMagParticles) {};
213
215 bool particleSActivityTest(int sActivity)
216 {
217 return 0;
218 };
219
222 void setOverlap(T);
224 T getOverlap();
225
227 void saveToFile(std::string name);
228
236 int rankNumOfParticles();
245
247 std::vector<ParticleSystem3D<T, PARTICLETYPE>*> getParticleSystems();
249 std::vector<ParticleSystem3D<T, PARTICLETYPE>*>& getPSystems();
253 std::vector<int> numOfForces();
254
256 int numOfPSystems();
257
259 int countMaterial(int mat);
260
262 void addForce(std::shared_ptr<Force3D<T, PARTICLETYPE> > f);
264 void addBoundary(std::shared_ptr<Boundary3D<T, PARTICLETYPE> > b);
267
269 template<typename DESCRIPTOR>
271
274
278 void setContactDetectionForPSys(ContactDetection<T, PARTICLETYPE>& contactDetection, int pSysNr);
279
280 void print();
281
282 void printDeep(std::string message="");
283
285 void print(std::list<int> mat);
286
288 void captureEscapeRate(std::list<int> mat);
289
294 void diffEscapeRate(std::list<int> mat, int& globalPSum, int& pSumOutlet, T& diffEscapeRate, T& maxDiffEscapeRate,
295 int iT, int iTConsole, T genPartPerTimeStep = 0);
296 void diffEscapeRate(std::list<int> mat, int& globalPSum, int& pSumOutlet, T& diffEscapeRate, T& maxDiffEscapeRate,
297 int iT, int iTConsole, T genPartPerTimeStep,
298 T& avDiffEscapeRate, T latticeTimeStart, T latticeTimeEnd);
299
302 void getOutput(std::string filename, int iT, T conversionFactorTime,
303 unsigned short particleProperties);
304
306 template<typename DESCRIPTOR>
308 {
309 return pRho * util::pow(2.*rad, 2) * conv.getCharPhysVelocity() / (18.*conv.getCharPhysLength() *
310 (conv.getPhysViscosity() * conv.getPhysDensity()));
311 };
312
313 friend class SuperParticleSysVtuWriter<T, PARTICLETYPE> ;
314 friend class SuperParticleSysVtuWriterMag<T> ;
315
317 : unsigned short {position = 1, velocity = 2, radius = 4, mass = 8,
318 force = 16, storeForce = 32
319 };
320
321protected:
323
325 void init();
328public:
330 bool findCuboid(PARTICLETYPE<T>&, int overlap);
331 bool findCuboid(PARTICLETYPE<T>&);
333 // TODO overlap caste to int
334 bool checkCuboid(PARTICLETYPE<T>& p, T overlap);
335 bool checkCuboid(PARTICLETYPE<T>& p, T overlap, int iC);
336 // Get Rank of neighbours
337 std::list<int>& getRankNeighbours()
338 {
339 return _rankNeighbours;
340 }
341protected:
342 int countLocMaterial(int mat);
343
345 void addShadowParticle(PARTICLETYPE<T> &p);
346
348 std::vector<ParticleSystem3D<T, PARTICLETYPE>*> _pSystems;
352 std::list<int> _rankNeighbours;
354 std::vector<std::vector<int> > _cuboidNeighbours;
355 // TODO: !attention! here T _overlap; class SuperStructure<T,3> has int _overlap
356 // but superParticleSystem<T, PARTICLETYPE<T>> overlap is of type T
359 std::map<int, std::vector<double> > _send_buffer;
360 std::multimap<int, PARTICLETYPE<T> > _relocate;
361 std::multimap<int, PARTICLETYPE<T> > _relocateShadow;
362};
363
364// Magnetic particle type
365template<>
367 double rad, int no, int id,
368 std::vector<double> vel, std::vector<double> dMoment, std::vector<double> aVel,
369 std::vector<double> torque, double magnetisation, int sActivity);
370template<>
372 double rad, int no, int id,
373 std::vector<double> vel, std::vector<double> dMoment, std::vector<double> aVel,
374 std::vector<double> torque, double magnetisation, int sActivity);
375template<>
377 std::set<int> material, double mas, double rad, int no, int id,
378 std::vector<double> vel, std::vector<double> dMoment, std::vector<double> aVel,
379 std::vector<double> torque, double magnetisation, int sActivity);
380
381template<>
383template<>
385 std::vector<double> vel, std::vector<double> aVel,
386 std::vector<double> torque, double magnetisation, int sActivity);
387template<>
389template<>
391template<>
393template<>
395template<>
396void SuperParticleSystem3D<double, MagneticParticle3D>::simulate(double dT, std::set<int> sActivityOfFreeParticle, bool scale) ;
397template<>
401 int material, int subSteps, bool resetExternalField, bool scale );
402template<>
406 int material, int subSteps, bool resetExternalField, bool scale );
407
408
409} //namespace olb
410
411#endif /* SUPERPARTICLESYSTEM_3D_H */
Groups all the 3D include files in the boundaryConditions directory.
AnalyticalConst: DD -> XD, where XD is defined by value.size()
Definition analyticalF.h:78
Abstact base class for BaseBackCouplingModel.
Prototype for all particle boundaries.
Definition boundary3D.h:43
A cuboid geometry represents a voxel mesh.
Prototype for all particle forces.
Definition force3D.h:43
Abstact base class for all the forward-coupling models Its raison d'etre consists of not being temple...
IndicatorF3D is an application from .
Base class for all LoadBalancer.
class for marking output with some text
Representation of a statistic for a parallel 2D geometry.
The class superParticleSystem is the basis for particulate flows within OpenLB.
void addParticleOperation(std::shared_ptr< ParticleOperation3D< T, PARTICLETYPE > > o)
Add an operation to system.
void saveToFile(std::string name)
Save Particles to file. Add using addParticlesFromFile(std::string name, T mass, T radius);.
std::vector< std::vector< int > > _cuboidNeighbours
Numbers of neighboring cuboids.
void setMagneticParticles(std::vector< T > dMoment, std::vector< T > vel, std::vector< T > aVel, std::vector< T > torque, T magnetisation, int sActivity)
void setParticlesPosRandom(T posFactor)
Changes particle positions randomly.
void setMagneticParticlesdMomRandom()
Gives random dipolemoment orientation to all MagneticParticle3D.
void addBoundary(std::shared_ptr< Boundary3D< T, PARTICLETYPE > > b)
Add a boundary to system.
void setOverlap(T)
Set overlap of ParticleSystems, overlap has to be in lattice units particle system _overlap+1 <= _sup...
void clearParticles()
Removes all particles from System.
void simulate(T dT, std::set< int > sActivityOfFreeParticle, bool scale=false)
void updateParticleDistribution()
Redistribute particles on compute nodes.
int globalNumOfShadowParticles()
Get global number of shadow particles (particles hold in overlap)
void setParticlesVelRandom(T velFactor)
Gives random velocity to all particles.
void addParticleEquallyDistributed(IndicatorCuboid3D< T > &cuboid, T pMass, T pRad, int nox, int noy, int noz, std::vector< T > vel={0., 0., 0.})
Add a number of identical particles equally distributed in a given Material Number.
std::vector< ParticleSystem3D< T, PARTICLETYPE > * > & getPSystems()
Get ParticleSystems.
T getOverlap()
Get overlap of ParticleSystems.
void printDeep(std::string message="")
void simulateWithTwoWayCoupling_Davide(T dT, ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling, BackCouplingModel< T, PARTICLETYPE > &backCoupling, int material, int subSteps=1, bool resetExternalField=true, bool scale=false)
void addParticle(PARTICLETYPE< T > &p)
Add a Particle to SuperParticleSystem.
void init()
Init the SuperParticleSystem.
~SuperParticleSystem3D() override
Destructor.
void addForce(std::shared_ptr< Force3D< T, PARTICLETYPE > > f)
Add a force to system.
void prepareAgglomerates()
Agglomerate detection functions: Todo: enable for parallel mode Initializes an empty agglomerate list...
int rankNumOfShadowParticles()
Get number of shadow particles computed on this node.
void addParticlesFromParaviewFile(std::string name)
Add particles form a File. Save using saveToFile(std::string name)
void addParticleWithDistance(IndicatorCuboid3D< T > &ind, T pMass, T pRad, std::vector< T > vel, T conc, T minDist, bool checkDist)
Generates particles with specific volume concentration conc equally and randomly distributed in given...
void captureEscapeRate(std::list< int > mat)
console output of escape (E), capture (C) rate for material numbers mat
std::multimap< int, PARTICLETYPE< T > > _relocateShadow
void findAgglomerates(int iT, int itVtkOutputMagParticles)
Detects and manages particle agglomerates.
bool checkCuboid(PARTICLETYPE< T > &p, T overlap)
Check if particle is still on cuboid.
void setVelToAnalyticalVel(AnalyticalConst3D< T, T > &)
Set particle velocity to analytical velocity (e.g. as initial condition.
bool findCuboid(PARTICLETYPE< T > &, int overlap)
Find the cuboid the particle is on.
SuperGeometry< T, 3 > & _superGeometry
The superGeometry.
std::list< int > & getRankNeighbours()
std::vector< ParticleSystem3D< T, PARTICLETYPE > * > _pSystems
The particleSystems. One per cuboid.
void addParticleBoxMuller(IndicatorF3D< T > &ind, T partRho, T mu, T sigma, int no=1, T appProb=1., std::vector< T > vel={0., 0., 0.})
Add a number of nonidentical particles with normally distributed radius (Box-Muller Method) in a give...
void getOutput(std::string filename, int iT, T conversionFactorTime, unsigned short particleProperties)
Get Output of particleMovement Write the data of the particle movement into an txtFile.
int globalNumOfActiveParticles()
Get global number of active particles.
std::list< int > _rankNeighbours
Rank of neighboring cuboids.
void diffEscapeRate(std::list< int > mat, int &globalPSum, int &pSumOutlet, T &diffEscapeRate, T &maxDiffEscapeRate, int iT, int iTConsole, T genPartPerTimeStep=0)
Console output of differential escape rate for material numbers mat (e.g.
std::map< int, std::vector< double > > _send_buffer
temporary variables
void addShadowParticle(PARTICLETYPE< T > &p)
Add a shadow particle to system.
T getStokes(UnitConverter< T, DESCRIPTOR > &conv, T pRho, T rad)
returns the Stokes number
int countMaterial(int mat)
Get number of particles in the vicinity of material number mat.
void simulateWithTwoWayCoupling_Mathias(T dT, ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling, BackCouplingModel< T, PARTICLETYPE > &backCoupling, int material, int subSteps=1, bool resetExternalField=true, bool scale=false)
Integrate on Timestep dT with two-way coupling, scale = true keeps the particle velocity in stable ra...
int rankNumOfParticles()
Get number of particles computed on this node.
void addTracerParticle(IndicatorF3D< T > &ind, int idTP, T mas, T rad, int noTP=1, std::vector< T > vel={0., 0., 0.})
Add a number of particles with a certain ID (TracerParticle) equally distributed in a given Indicator...
void setVelToFluidVel(SuperLatticeInterpPhysVelocity3D< T, DESCRIPTOR > &)
Set particle velocity to fluid velocity (e.g. as initial condition.
void simulate(T dT, bool scale=false)
Integrate on Timestep dT, scale = true keeps the particle velocity in stable range.
int rankNumOfTracerParticles()
Get number of TracerParticles computed on this node.
void setMagneticParticles(std::vector< T > dMoment, std::vector< T > vel, std::vector< T > aVel, std::vector< T > torque, T magnetisation)
Gives specific attributes to all MagneticParticle3D.
bool particleSActivityTest(int sActivity)
Tests if particles with specific sActivity exist.
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)
int globalNumOfTracerParticles()
Get number of TracerParticles computed on this node.
std::vector< int > numOfForces()
Get number of linked Forces.
std::vector< ParticleSystem3D< T, PARTICLETYPE > * > getParticleSystems()
Get ParticleSystems.
SuperParticleSystem3D(CuboidGeometry3D< T > &cuboidGeometry, LoadBalancer< T > &loadBalancer, SuperGeometry< T, 3 > &)
Constructor for SuperParticleSystem.
int rankNumOfActiveParticles()
Get number of active particles computed on this node.
ParticleSystem3D< T, PARTICLETYPE > & operator[](int i)
Get a ParticleSystem.
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)
Generates particle at a circle shaped inlet, amount given by mass concentration in feedstream.
void setContactDetection(ContactDetection< T, PARTICLETYPE > &contactDetection)
Set contact detection algorithm for particle-particle contact. Not yet implemented.
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)
int globalNumOfParticles()
Get global number of particles.
void addParticlesFromFile(std::string name, T mass, T radius)
Add particles form a File. Save using saveToFile(std::string name)
void addHL3DParticle(IndicatorF3D< T > &ind, std::set< int > material, T mas, T rad, int no=1, std::vector< T > vel={0., 0., 0.}, T surface=1., T volume=1.)
std::multimap< int, PARTICLETYPE< T > > _relocate
void setContactDetectionForPSys(ContactDetection< T, PARTICLETYPE > &contactDetection, int pSysNr)
Set contact detection algorithm for particle-particle contact. Not yet implemented.
void initAggloParticles()
Adds new generated particles to the list of non agglomerated Particles.
int numOfPSystems()
Get number of ParticleSystems.
Conversion between physical and lattice units, as well as discretization.
constexpr T getCharPhysLength() const
return characteristic length in physical units
constexpr T getPhysDensity() const
return density in physical units
constexpr T getPhysViscosity() const
return viscosity in physical units
constexpr T getCharPhysVelocity() const
return characteristic velocity in physical units
The description of a vector of 3D cuboid – header file.
Wrapper functions that simplify the use of MPI.
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
Top level namespace for all of OpenLB.
Representation of a parallel 2D geometry – header file.