InsertionBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef BOUNDARIES_INSERTIONBOUNDARY_H
27 #define BOUNDARIES_INSERTIONBOUNDARY_H
28 
29 #include "BaseBoundary.h"
30 #include <Math/PSD.h>
31 
32 class MD;
33 
34 class RNG;
35 
36 class PSD;
37 
50 {
51 public:
52 
54 // /*!
55 // * \brief Defines a custom particle size distribution; distribution_ will always be used, unless particleSizeDistributionVector_ is non-empty
56 // */
57 // enum class Distribution
58 // {
59 // Uniform,
60 // Normal_1_5
61 // // TODO add LogNormal distribution
62 // // LogNormal
63 // };
64 
65 
70 
75 
79  ~InsertionBoundary() override;
80 
81 
82 // /*!
83 // * \brief Sets the properties of the InsertionBoundary for mutliple different particle types
84 // */
85 // virtual void set(std::vector<BaseParticle*> particleToCopy, unsigned int maxFailed, Vec3D velMin, Vec3D velMax,
86 // double radMin, double radMax)=0;
87 //
88 // /*!
89 // * \brief Sets the properties of the InsertionBoundary for a single particle type
90 // */
91 // virtual void set(BaseParticle* particleToCopy, unsigned int maxFailed, Vec3D velMin, Vec3D velMax, double radMin,
92 // double radMax)=0;
93 
99  virtual BaseParticle* generateParticle(RNG& random);
100 
109  virtual void placeParticle(BaseParticle* p, RNG& random) = 0;
110 
114  void checkBoundaryBeforeTimeStep(DPMBase* md) override;
115 
119  void insertParticles(DPMBase* md);
120 
124  unsigned int getNumberOfParticlesInserted() const;
125 
130 
135 
139  void reset();
140 
144  void activate();
145 
149  void deactivate();
150 
154  bool isActivated();
155 
156 
157 
161  unsigned int getMaxFailed() const;
162 
166  void setParticleToCopy(std::vector<BaseParticle*> particleToCopy);
167 
171  void setParticleToCopy(BaseParticle* particleToCopy);
172 
176  std::vector<BaseParticle*> getParticleToCopy();
177 
181  void read(std::istream& is) override;
182 
186  void write(std::ostream& os) const override;
187 
191  Mdouble getVolumeFlowRate() const;
192 
197 
201  Mdouble getInitialVolume() const;
202 
206  void setInitialVolume(Mdouble initialVolume);
207 
211  void setPSD(const PSD psd);
212 
216  void setPSD(std::vector<PSD> psd, std::vector<Mdouble> probability);
217 
221  std::vector<PSD> getPSD();
222 
227  void
228  setVariableVolumeFlowRate(const std::vector<Mdouble>& variableCumulativeVolumeFlowRate, Mdouble samplingInterval);
229 
233  bool insertParticle(Mdouble time);
234 
238  bool getCheckParticleForInteraction() const;
239 
243  void setCheckParticleForInteraction(bool checkParticleForInteraction);
244 
248  void setManualInsertion(bool manualInsertion);
249 
250 // /*!
251 // * \brief write Distribution class to file.
252 // */
253 // friend std::ostream& operator<<(std::ostream& os, InsertionBoundary::Distribution type);
254 //
255 // /*!
256 // * \brief read Distribution class from file.
257 // */
258 // friend std::istream& operator>>(std::istream& is, InsertionBoundary::Distribution& type);
259 
260 protected:
261 
265  std::vector<BaseParticle*> particleToCopy_;
266 
270  unsigned int maxFailed_;
271 
276 
281 
286 
294 
305 
308 
315  std::vector<Mdouble> variableCumulativeVolumeFlowRate_;
316 
319 
324 
330 
335 
340 
344  std::vector<Mdouble> probability_;
345 
350 
351 };
352 
353 #endif
Definition: BaseBoundary.h:49
Definition: BaseParticle.h:54
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
Boundary structure for boundaries used for insertion of particles.
Definition: InsertionBoundary.h:50
bool isActivated()
Returns whether the InsertionBoundary is activated.
Definition: InsertionBoundary.cc:392
void activate()
Turns on the InsertionBoundary.
Definition: InsertionBoundary.cc:375
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:634
Mdouble getVolumeOfParticlesInserted() const
Gets the volume of particles inserted by the boundary.
Definition: InsertionBoundary.cc:356
InsertionBoundary()
Definition: InsertionBoundary.cc:38
void setVolumeFlowRate(Mdouble volumeFlowRate_)
Sets the volume flow rate of the insertion routine.
Definition: InsertionBoundary.cc:625
unsigned int getMaxFailed() const
Gets the number of times that the boundary may fail to insert a particle.
Definition: InsertionBoundary.cc:401
Mdouble samplingInterval_
Definition: InsertionBoundary.h:318
int chosenSpecies_
stores the chosen species for each timestep.
Definition: InsertionBoundary.h:349
void setParticleToCopy(std::vector< BaseParticle * > particleToCopy)
Sets multiple different particles that will be inserted through the insertion boundary.
Definition: InsertionBoundary.cc:411
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
Definition: InsertionBoundary.h:270
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Definition: InsertionBoundary.h:275
void setPSD(const PSD psd)
Sets the range of particle radii that may be generated from a user defined PSD.
Definition: InsertionBoundary.cc:675
~InsertionBoundary() override
Destructor: delete the particle that has to be copied at every insertion.
Definition: InsertionBoundary.cc:90
void write(std::ostream &os) const override
Writes the boundary's id_ and maxFailed_.
Definition: InsertionBoundary.cc:559
bool isManuallyInserting_
A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE.
Definition: InsertionBoundary.h:339
bool insertParticle(Mdouble time)
Checks the inserted total volume and returns if a particle is still allowed to be inserted.
Definition: InsertionBoundary.cc:150
void setCheckParticleForInteraction(bool checkParticleForInteraction)
Sets the variable that checks if a particle has an interaction.
Definition: InsertionBoundary.cc:727
Mdouble initialVolume_
Definition: InsertionBoundary.h:307
void reset()
resets particle property counter variables.
Definition: InsertionBoundary.cc:365
bool isActivated_
The InsertionBoundary is activated by default. If the InsertionBoundary is deactivated,...
Definition: InsertionBoundary.h:293
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
Definition: InsertionBoundary.h:323
void deactivate()
Turns off the InsertionBoundary.
Definition: InsertionBoundary.cc:383
unsigned int getNumberOfParticlesInserted() const
Gets the number of particles inserted by the boundary.
Definition: InsertionBoundary.cc:338
Vec3D velMin_
Minimum and maximum velocity of the particles to be inserted.
Definition: InsertionBoundary.h:334
virtual BaseParticle * generateParticle(RNG &random)
Sets the properties of the InsertionBoundary for a single particle type ‍/ virtual void set(BaseParti...
Definition: InsertionBoundary.cc:103
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
Definition: InsertionBoundary.cc:184
std::vector< PSD > getPSD()
Gets the particle size distributions set by the user.
Definition: InsertionBoundary.cc:700
Mdouble getVolumeFlowRate() const
Gets the volume flow rate of the insertion routine.
Definition: InsertionBoundary.cc:617
bool getCheckParticleForInteraction() const
Gets the variable that checks if a particle has an interaction.
Definition: InsertionBoundary.cc:718
Mdouble massInserted_
Total mass of particles inserted.
Definition: InsertionBoundary.h:280
void setInitialVolume(Mdouble initialVolume)
Gets the Volume which should be inserted by the insertion routine.
Definition: InsertionBoundary.cc:643
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
Definition: InsertionBoundary.h:344
void setManualInsertion(bool manualInsertion)
Set the flag for a manual PSD insertion routine.
Definition: InsertionBoundary.cc:709
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
Definition: InsertionBoundary.h:329
Mdouble getMassOfParticlesInserted() const
Gets the mass of particles inserted by the boundary.
Definition: InsertionBoundary.cc:347
std::vector< BaseParticle * > getParticleToCopy()
Gets the particles that will be inserted through the insertion boundary.
Definition: InsertionBoundary.cc:458
void setVariableVolumeFlowRate(const std::vector< Mdouble > &variableCumulativeVolumeFlowRate, Mdouble samplingInterval)
Sets a variable volume flow rate.
Definition: InsertionBoundary.cc:658
std::vector< BaseParticle * > particleToCopy_
read Distribution class from file. ‍/ friend std::istream& operator>>(std::istream& is,...
Definition: InsertionBoundary.h:265
Mdouble volumeFlowRate_
Definition: InsertionBoundary.h:304
Vec3D velMax_
Definition: InsertionBoundary.h:334
Mdouble volumeInserted_
Total volume of particles inserted.
Definition: InsertionBoundary.h:285
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
Definition: InsertionBoundary.h:315
void read(std::istream &is) override
Reads the boundary's id_ and maxFailed_.
Definition: InsertionBoundary.cc:471
void insertParticles(DPMBase *md)
Fill a certain domain with particles.
Definition: InsertionBoundary.cc:328
Contains a vector with radii and probabilities of a user defined particle size distribution (PSD)
Definition: PSD.h:65
This is a class that generates random numbers i.e. named the Random Number Generator (RNG).
Definition: RNG.h:53
Definition: Vector.h:51