OpenLB 1.7
Loading...
Searching...
No Matches
particleSystem3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2015 Thomas Henn, 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 PARTICLE_SYSTEM_3D_H
25#define PARTICLE_SYSTEM_3D_H
26
27// Enables particle collision functions
28// CollisionModels: Can be used as an alternative to a mechanic contact force
29// #define CollisionModels
30// CollisionModelsCombindedWithMechContactForce: Can be used in combination with
31// a mechanic contact force
32// #define CollisionModelsCombindedWithMechContactForce
33
34#include <set>
35#include <vector>
36#include <list>
37#include <deque>
40#include "forces/force3D.h"
46#include "particle3D.h"
48
49namespace olb {
50
51template<typename T, typename DESCRIPTOR>
52class SuperLatticeInterpPhysVelocity3D;
53
54template<typename T, template<typename U> class PARTICLETYPE>
55class Force3D;
56template<typename T, template<typename U> class PARTICLETYPE>
57class Boundary3D;
58template<typename T, template<typename U> class PARTICLETYPE>
59class ParticleSystem3D;
60template<typename T, template<typename U> class PARTICLETYPE>
61class SuperParticleSystem3D;
62template<typename T, template<typename U> class PARTICLETYPE>
63class SuperParticleSysVtuWriter;
64template<typename T>
65class SuperParticleSysVtuWriterMag;
66
67
68
69
70
71
72template<typename T, template<typename U> class PARTICLETYPE>
74private:
76 void eraseInactiveParticles();
77
78public:
79
81 ParticleSystem3D() = default;
83 ParticleSystem3D(int iGeometry, SuperGeometry<T,3>& superGeometry);
90 {
91 delete _contactDetection;
92 }
93
94 virtual void simulate(T deltatime, bool scale = false);
95 virtual void simulateWithTwoWayCoupling_Mathias ( T dT,
98 int material, int subSteps, bool scale );
99 virtual void simulateWithTwoWayCoupling_Davide ( T dT,
102 int material, int subSteps, bool scale );
103 // multiple collision models
104 virtual void simulate(T deltatime, std::set<int> sActivityOfParticle, bool scale = false);
105
106 void printDeep(std::string message="");
107
109 int size();
111 int sizeInclShadow() const;
115 int numOfForces();
117 int countMaterial(int mat = 1);
118
120 void addParticle(PARTICLETYPE<T>& p);
122 void clearParticles();
124 void addForce(std::shared_ptr<Force3D<T, PARTICLETYPE> > pF);
126 void addBoundary(std::shared_ptr<Boundary3D<T, PARTICLETYPE> > pB);
129
132 PARTICLETYPE<T>& operator[](const int i);
133 const PARTICLETYPE<T>& operator[](const int i) const;
134
136 template<typename DESCRIPTOR>
138
141
143 void setPosExt(std::vector<T> physPos, std::vector<T> physExtend);
144
146 const std::vector<T>& getPhysPos();
147 const std::vector<T>& getPhysExtend();
148
150 void saveToFile(std::string name);
151
153 void computeForce();
154 // multiple collision models
155 void computeForce(std::set<int> sActivityOfParticle)
156 {
157 computeForce();
158 };
159
161 void setStoredValues();
162
165 bool operator() (std::pair<size_t, T> i, std::pair<size_t, T> j)
166 {
167 return (i.second < j.second);
168 }
170 void getMinDistParticle (std::vector<std::pair<size_t, T>> ret_matches);
171
173 void computeBoundary();
174
177
181
183 // template<template<typename V> class DESCRIPTOR>
184 // void particleOnFluid(BlockLattice<T, DESCRIPTOR>& bLattice,
185 // Cuboid3D<T>& cuboid, int overlap, T eps,
186 // BlockGeometry<T,3>& bGeometry);
187 // template<template<typename V> class DESCRIPTOR>
188 // void resetFluid(BlockLattice<T, DESCRIPTOR>& bLattice,
189 // Cuboid3D<T>& cuboid, int overlap);
190
191 friend class SuperParticleSystem3D<T, PARTICLETYPE>;
192 friend class SuperParticleSysVtuWriter<T, PARTICLETYPE>;
193 friend class SuperParticleSysVtuWriterMag<T>;
194 friend class SimulateParticles<T, PARTICLETYPE>;
195
196 //std::map<T, int> radiusDistribution();
197
201 void explicitEuler(T dT, bool scale = false);
202 // multiple collision models
203 void explicitEuler(T dT, std::set<int> sActivityOfParticle, bool scale = false)
204 {
205 explicitEuler(dT, scale);
206 };
208 bool executeBackwardCoupling(BackCouplingModel<T,PARTICLETYPE>& backwardCoupling, int material, int subSteps=1);
209
214
216 {
217 return _iGeometry;
218 }
221 std::deque<PARTICLETYPE<T>*> getParticlesPointer();
224 std::deque<PARTICLETYPE<T>*> getAllParticlesPointer();
227 std::deque<PARTICLETYPE<T>*> getShadowParticlesPointer();
228
231 std::deque<PARTICLETYPE<T>>& getParticles()
232 {
233 return _particles;
234 }
235
236 void removeParticle(typename std::deque<PARTICLETYPE<T> >::iterator& p);
237
239 std::list<std::shared_ptr<Force3D<T, PARTICLETYPE> > > getForcesPointer();
240
242 std::deque<std::list<PARTICLETYPE<T>*>> _Agglomerates;
243
244protected:
245 void integrateTorque(T dT);
246 void integrateTorqueMag(T dT) {};
247 // multiple collision models
248 void integrateTorqueMag(T dT, std::set<int> sActivityOfParticle) {};
249 void resetMag() {};
250 // multiple collision models
251 void resetMag(std::set<int> sActivityOfParticle) {};
252
255 void setOverlapZero() {};
260 void partialElasticImpact(T restitutionCoeff) {};
263 void partialElasticImpactV2(T restitutionCoeff) {};
266
271
272 void addShadowParticle(PARTICLETYPE<T>& p);
273
275 int _iGeometry = -1;
279
280 std::deque<PARTICLETYPE<T> > _particles;
281
282 std::deque<PARTICLETYPE<T> > _shadowParticles;
283 std::list<std::shared_ptr<Force3D<T, PARTICLETYPE> > > _forces;
284 std::list<std::shared_ptr<Boundary3D<T, PARTICLETYPE> > > _boundaries;
285 std::list<std::shared_ptr<ParticleOperation3D<T, PARTICLETYPE> > > _particleOperations;
286
287 std::vector<T> _physPos;
288 std::vector<T> _physExtend;
289
290
292 void velocityVerlet1(T dT);
293 void velocityVerlet2(T dT);
294// void implicitEuler(T dT, AnalyticalF<3,T,T>& getvel);
295// void adamBashforth4(T dT);
296// void predictorCorrector1(T dT);
297// void predictorCorrector2(T dT);
298 void rungeKutta4_1(T dt);
299 void rungeKutta4_2(T dt);
300 void rungeKutta4_3(T dt);
301 void rungeKutta4_4(T dt);
302 void rungeKutta4(T dT);
304};
305
306// Magnetic particle type
307template<>
309template<>
310void ParticleSystem3D<double, MagneticParticle3D>::integrateTorqueMag(double dT, std::set<int> sActivityOfParticle);
311template<>
313template<>
315template<>
317template<>
318void ParticleSystem3D<double, MagneticParticle3D>::resetMag(std::set<int> sActivityOfParticle);
319template<>
321template<>
322void ParticleSystem3D<double, MagneticParticle3D>::explicitEuler(double dT, std::set<int> sActivityOfParticle, bool scale);
323
324template<>
326template<>
328template<>
330template<>
332template<>
334template<>
336template<>
338
339} //namespace olb
340#endif /* PARTICLE_SYSTEM_3D_H */
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
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...
class for marking output with some text
bool executeBackwardCoupling(BackCouplingModel< T, PARTICLETYPE > &backwardCoupling, int material, int subSteps=1)
void partialElasticImpact(T restitutionCoeff)
Resets existing particle overlaps in the event of a collision and applies the physics of an partial e...
void clearParticles()
Removes all particles from system.
void setPosExt(std::vector< T > physPos, std::vector< T > physExtend)
Set global coordinates and extends of Particlesystem (SI units)
void setVelToFluidVel(SuperLatticeInterpPhysVelocity3D< T, DESCRIPTOR > &)
Set velocity of all particles to fluid velocity.
void computeForce()
Compute all forces on particles.
std::deque< PARTICLETYPE< T > > & getParticles()
returns deque of particles (no shadow particles) contained in a particleSystem3D
bool executeForwardCoupling(ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling)
std::list< std::shared_ptr< ParticleOperation3D< T, PARTICLETYPE > > > _particleOperations
std::list< std::shared_ptr< Boundary3D< T, PARTICLETYPE > > > _boundaries
std::list< std::shared_ptr< Force3D< T, PARTICLETYPE > > > getForcesPointer()
returns shared pointer of forces
int sizeInclShadow() const
Get number of particles including shadow particles in ParticleSystem.
std::deque< PARTICLETYPE< T > * > getShadowParticlesPointer()
returns deque of pointer to all shadow particles contained in a particleSystem3D
void addParticle(PARTICLETYPE< T > &p)
Add a particle to ParticleSystem.
std::deque< PARTICLETYPE< T > * > getParticlesPointer()
returns deque of pointer to particles (not shadow particles) contained in a particleSystem3D
void setVelToAnalyticalVel(AnalyticalConst3D< T, T > &)
Set particle velocity to analytical velocity (e.g. as initial condition.
void explicitEuler(T dT, bool scale=false)
Integration method: explicit Euler if scale = true, velocity is scaled to maximal velocity maximal ve...
virtual void simulate(T deltatime, bool scale=false)
void setOverlapZero()
Collision models: Todo: enable for parallel mode Resets existing particle overlaps in the event of a ...
void addShadowParticle(PARTICLETYPE< T > &p)
std::deque< PARTICLETYPE< T > * > getAllParticlesPointer()
returns deque of pointer to all particles (incl.
void integrateTorque(T dT)
int numOfForces()
Get number of linked forces in ParticleSystem.
std::vector< T > _physPos
void printDeep(std::string message="")
virtual void simulateWithTwoWayCoupling_Davide(T dT, ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling, BackCouplingModel< T, PARTICLETYPE > &backCoupling, int material, int subSteps, bool scale)
virtual ~ParticleSystem3D()
Destructor for ParticleSystem.
void rungeKutta4_2(T dt)
int size()
Get number of particles in ParticleSystem.
void computeForce(std::set< int > sActivityOfParticle)
void saveToFile(std::string name)
Save particle positions to file.
void partialElasticImpactV2(T restitutionCoeff)
Applies the physics of an partial elastic impact while multiple particle overlapping only to the part...
void resetMag(std::set< int > sActivityOfParticle)
void velocityVerlet1(T dT)
Integration methods, each need a special template particle.
struct olb::ParticleSystem3D::getMinDistPart getMinDistPartObj
void updateParticleDistribution()
std::deque< PARTICLETYPE< T > > _particles
void computeBoundary()
Compute boundary contact.
std::vector< T > _physExtend
void removeParticle(typename std::deque< PARTICLETYPE< T > >::iterator &p)
std::list< std::shared_ptr< Force3D< T, PARTICLETYPE > > > _forces
virtual void simulateWithTwoWayCoupling_Mathias(T dT, ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling, BackCouplingModel< T, PARTICLETYPE > &backCoupling, int material, int subSteps, bool scale)
void addBoundary(std::shared_ptr< Boundary3D< T, PARTICLETYPE > > pB)
Add a boundary to ParticleSystem.
ContactDetection< T, PARTICLETYPE > * _contactDetection
void rungeKutta4_3(T dt)
ParticleSystem3D()=default
Default constructor for ParticleSystem.
void rungeKutta4_4(T dt)
int numOfActiveParticles()
Get number of active particles in ParticleSystem.
void setOverlapZeroForCombinationWithMechContactForce()
For the combined use of setOverlapZero() and a mechanic contact force.
void computeParticleOperation()
Compute operations on particles.
SuperGeometry< T, 3 > & _superGeometry
const std::vector< T > & getPhysPos()
Get global coordinates and extends of Particlesystem (SI units)
void addForce(std::shared_ptr< Force3D< T, PARTICLETYPE > > pF)
Add a force to ParticleSystem.
ContactDetection< T, PARTICLETYPE > * getDetection()
std::deque< PARTICLETYPE< T > > _shadowParticles
std::deque< std::list< PARTICLETYPE< T > * > > _Agglomerates
Deque of Lists of agglomerated particles.
void getMinDistParticle(std::vector< std::pair< size_t, T > > ret_matches)
int countMaterial(int mat=1)
Get number of particles in vicinity of material number mat.
void initAggloParticles()
Adds new generated particles to the list of non agglomerated Particles.
void findAgglomerates()
Detects and manages particle agglomerates.
void setContactDetection(ContactDetection< T, PARTICLETYPE > &contactDetection)
Set boundary detection algorithm (for future features)
void explicitEuler(T dT, std::set< int > sActivityOfParticle, bool scale=false)
PARTICLETYPE< T > & operator[](const int i)
Get reference to a particle in the ParticleSystem runs over all particles incl.
ContactDetection< T, PARTICLETYPE > * getContactDetection()
void setStoredValues()
Stores old particle positions - is used in ..._ActExt.
const std::vector< T > & getPhysExtend()
void rungeKutta4_1(T dt)
void addParticleOperation(std::shared_ptr< ParticleOperation3D< T, PARTICLETYPE > > pO)
Add an operation to ParticleSystem.
SimulateParticles< T, PARTICLETYPE > _sim
void partialElasticImpactForCombinationWithMechContactForce(T restitutionCoeff)
For the combined use of partialElasticImpact() and a mechanic contact force.
void integrateTorqueMag(T dT, std::set< int > sActivityOfParticle)
Representation of a statistic for a parallel 2D geometry.
The class superParticleSystem is the basis for particulate flows within OpenLB.
Top level namespace for all of OpenLB.
Groups all the include .h-files for 3D particles in the particles directory.
Sorts the vector of neighbor Particles by increasing distance.
bool operator()(std::pair< size_t, T > i, std::pair< size_t, T > j)
Representation of a parallel 2D geometry – header file.