InsertionBoundary.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef BOUNDARIES_INSERTIONBOUNDARY_H
6 #define BOUNDARIES_INSERTIONBOUNDARY_H
7 
8 #include "BaseBoundary.h"
9 #include <Math/PSD.h>
10 
11 class MD;
12 
13 class RNG;
14 
15 class PSD;
16 
29 {
30 public:
31 
33 // /*!
34 // * \brief Defines a custom particle size distribution; distribution_ will always be used, unless particleSizeDistributionVector_ is non-empty
35 // */
36 // enum class Distribution
37 // {
38 // Uniform,
39 // Normal_1_5
40 // // TODO add LogNormal distribution
41 // // LogNormal
42 // };
43 
44 
49 
54 
58  ~InsertionBoundary() override;
59 
60 
61 // /*!
62 // * \brief Sets the properties of the InsertionBoundary for mutliple different particle types
63 // */
64 // virtual void set(std::vector<BaseParticle*> particleToCopy, unsigned int maxFailed, Vec3D velMin, Vec3D velMax,
65 // double radMin, double radMax)=0;
66 //
67 // /*!
68 // * \brief Sets the properties of the InsertionBoundary for a single particle type
69 // */
70 // virtual void set(BaseParticle* particleToCopy, unsigned int maxFailed, Vec3D velMin, Vec3D velMax, double radMin,
71 // double radMax)=0;
72 
78  virtual BaseParticle* generateParticle(RNG& random);
79 
88  virtual void placeParticle(BaseParticle* p, RNG& random) = 0;
89 
96  virtual void shiftBoundary(Vec3D shift);
97 
104  virtual void rotateBoundary(Vec3D angle);
105 
109  void checkBoundaryBeforeTimeStep(DPMBase* md) override;
110 
114  void insertParticles(DPMBase* md);
115 
119  unsigned int getNumberOfParticlesInserted() const;
120 
125 
130 
134  void reset();
135 
139  void activate();
140 
144  void deactivate();
145 
149  bool isActivated();
150 
151 
152 
156  unsigned int getMaxFailed() const;
157 
161  void setParticleToCopy(std::vector<BaseParticle*> particleToCopy);
162 
166  void setParticleToCopy(BaseParticle* particleToCopy);
167 
171  std::vector<BaseParticle*> getParticleToCopy();
172 
176  void read(std::istream& is) override;
177 
181  void write(std::ostream& os) const override;
182 
186  Mdouble getVolumeFlowRate() const;
187 
191  void setVolumeFlowRate(Mdouble volumeFlowRate);
192 
196  Mdouble getInitialVolume() const;
197 
201  void setInitialVolume(Mdouble initialVolume);
202 
206  void setPSD(const PSD psd);
207 
211  void setPSD(std::vector<PSD> psd, std::vector<Mdouble> probability);
212 
216  std::vector<PSD> getPSD();
217 
222  void
223  setVariableVolumeFlowRate(const std::vector<Mdouble>& variableCumulativeVolumeFlowRate, Mdouble samplingInterval);
224 
228  bool insertParticle(Mdouble time);
229 
233  bool getCheckParticleForInteraction() const;
234 
238  void setCheckParticleForInteraction(bool checkParticleForInteraction);
239 
243  void setManualInsertion(bool manualInsertion);
244 
245 // /*!
246 // * \brief write Distribution class to file.
247 // */
248 // friend std::ostream& operator<<(std::ostream& os, InsertionBoundary::Distribution type);
249 //
250 // /*!
251 // * \brief read Distribution class from file.
252 // */
253 // friend std::istream& operator>>(std::istream& is, InsertionBoundary::Distribution& type);
254 
255 protected:
256 
260  std::vector<BaseParticle*> particleToCopy_;
261 
265  unsigned int maxFailed_;
266 
271 
276 
281 
289 
300 
303 
310  std::vector<Mdouble> variableCumulativeVolumeFlowRate_;
311 
314 
319 
325 
330 
335 
339  std::vector<Mdouble> probability_;
340 
345 
349  BaseParticle* p0= nullptr;
350 };
351 
352 #endif
Matrix2d md
Definition: MatrixBase_cast.cpp:1
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseBoundary.h:28
Definition: BaseParticle.h:33
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:56
Boundary structure for boundaries used for insertion of particles.
Definition: InsertionBoundary.h:29
bool isActivated()
Returns whether the InsertionBoundary is activated.
Definition: InsertionBoundary.cc:359
void activate()
Turns on the InsertionBoundary.
Definition: InsertionBoundary.cc:342
virtual void placeParticle(BaseParticle *p, RNG &random)=0
Purely virtual function that generates the extrinsic properties (position, velocity) of a particle.
Mdouble getInitialVolume() const
Gets the initialVolume() .
Definition: InsertionBoundary.cc:611
Mdouble getVolumeOfParticlesInserted() const
Gets the volume of particles inserted by the boundary.
Definition: InsertionBoundary.cc:323
InsertionBoundary()
Definition: InsertionBoundary.cc:17
unsigned int getMaxFailed() const
Gets the number of times that the boundary may fail to insert a particle.
Definition: InsertionBoundary.cc:368
Mdouble samplingInterval_
Definition: InsertionBoundary.h:313
int chosenSpecies_
stores the chosen species for each timestep.
Definition: InsertionBoundary.h:344
void setParticleToCopy(std::vector< BaseParticle * > particleToCopy)
Sets multiple different particles that will be inserted through the insertion boundary.
Definition: InsertionBoundary.cc:378
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
Definition: InsertionBoundary.h:265
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Definition: InsertionBoundary.h:270
void setPSD(const PSD psd)
Sets the range of particle radii that may be generated from a user defined PSD.
Definition: InsertionBoundary.cc:652
~InsertionBoundary() override
Destructor: delete the particle that has to be copied at every insertion.
Definition: InsertionBoundary.cc:69
void write(std::ostream &os) const override
Writes the boundary's id_ and maxFailed_.
Definition: InsertionBoundary.cc:536
bool isManuallyInserting_
A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE.
Definition: InsertionBoundary.h:334
bool insertParticle(Mdouble time)
Checks the inserted total volume and returns if a particle is still allowed to be inserted.
Definition: InsertionBoundary.cc:129
void setCheckParticleForInteraction(bool checkParticleForInteraction)
Sets the variable that checks if a particle has an interaction.
Definition: InsertionBoundary.cc:712
Mdouble initialVolume_
Definition: InsertionBoundary.h:302
void reset()
resets particle property counter variables.
Definition: InsertionBoundary.cc:332
bool isActivated_
The InsertionBoundary is activated by default. If the InsertionBoundary is deactivated,...
Definition: InsertionBoundary.h:288
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
Definition: InsertionBoundary.h:318
void deactivate()
Turns off the InsertionBoundary.
Definition: InsertionBoundary.cc:350
unsigned int getNumberOfParticlesInserted() const
Gets the number of particles inserted by the boundary.
Definition: InsertionBoundary.cc:305
Vec3D velMin_
Minimum and maximum velocity of the particles to be inserted.
Definition: InsertionBoundary.h:329
virtual BaseParticle * generateParticle(RNG &random)
Sets the properties of the InsertionBoundary for a single particle type ‍/ virtual void set(BaseParti...
Definition: InsertionBoundary.cc:82
void setVolumeFlowRate(Mdouble volumeFlowRate)
Sets the volume flow rate of the insertion routine.
Definition: InsertionBoundary.cc:602
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
Definition: InsertionBoundary.cc:163
std::vector< PSD > getPSD()
Gets the particle size distributions set by the user.
Definition: InsertionBoundary.cc:685
Mdouble getVolumeFlowRate() const
Gets the volume flow rate of the insertion routine.
Definition: InsertionBoundary.cc:594
virtual void rotateBoundary(Vec3D angle)
virtual function that rotates the boundary.
Definition: InsertionBoundary.cc:403
bool getCheckParticleForInteraction() const
Gets the variable that checks if a particle has an interaction.
Definition: InsertionBoundary.cc:703
Mdouble massInserted_
Total mass of particles inserted.
Definition: InsertionBoundary.h:275
void setInitialVolume(Mdouble initialVolume)
Gets the Volume which should be inserted by the insertion routine.
Definition: InsertionBoundary.cc:620
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
Definition: InsertionBoundary.h:339
virtual void shiftBoundary(Vec3D shift)
virtual function that shifts the boundary.
Definition: InsertionBoundary.cc:398
void setManualInsertion(bool manualInsertion)
Set the flag for a manual PSD insertion routine.
Definition: InsertionBoundary.cc:694
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
Definition: InsertionBoundary.h:324
Mdouble getMassOfParticlesInserted() const
Gets the mass of particles inserted by the boundary.
Definition: InsertionBoundary.cc:314
std::vector< BaseParticle * > getParticleToCopy()
Gets the particles that will be inserted through the insertion boundary.
Definition: InsertionBoundary.cc:435
void setVariableVolumeFlowRate(const std::vector< Mdouble > &variableCumulativeVolumeFlowRate, Mdouble samplingInterval)
Sets a variable volume flow rate.
Definition: InsertionBoundary.cc:635
BaseParticle * p0
pointer to the next particle that should be inserted (needs to be stored across time steps).
Definition: InsertionBoundary.h:349
std::vector< BaseParticle * > particleToCopy_
read Distribution class from file. ‍/ friend std::istream& operator>>(std::istream& is,...
Definition: InsertionBoundary.h:260
Mdouble volumeFlowRate_
Definition: InsertionBoundary.h:299
Vec3D velMax_
Definition: InsertionBoundary.h:329
Mdouble volumeInserted_
Total volume of particles inserted.
Definition: InsertionBoundary.h:280
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
Definition: InsertionBoundary.h:310
void read(std::istream &is) override
Reads the boundary's id_ and maxFailed_.
Definition: InsertionBoundary.cc:448
void insertParticles(DPMBase *md)
Fill a certain domain with particles.
Definition: InsertionBoundary.cc:295
Contains a vector with radii and probabilities of a user defined particle size distribution (PSD)
Definition: PSD.h:47
This is a class that generates random numbers i.e. named the Random Number Generator (RNG).
Definition: RNG.h:32
Definition: Kernel/Math/Vector.h:30
double angle(const double &t)
Angular position as a function of time t.
Definition: jeffery_orbit.cc:98