MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InsertionBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 
346 };
347 
348 #endif
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
bool isManuallyInserting_
A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE.
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:75
Mdouble getMassOfParticlesInserted() const
Gets the mass of particles inserted by the boundary.
void reset()
resets particle property counter variables.
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
double Mdouble
Definition: GeneralDefine.h:34
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
InsertionBoundary()
Defines a custom particle size distribution; distribution_ will always be used, unless particleSizeDi...
Mdouble getVolumeFlowRate() const
Gets the volume flow rate of the insertion routine.
unsigned int getMaxFailed() const
Gets the number of times that the boundary may fail to insert a particle.
bool insertParticle(Mdouble time)
Checks the inserted total volume and returns if a particle is still allowed to be inserted...
void setCheckParticleForInteraction(bool checkParticleForInteraction)
Sets the variable that checks if a particle has an interaction.
void insertParticles(DPMBase *md)
Fill a certain domain with particles.
Vec3D velMin_
Minimum and maximum velocity of the particles to be inserted.
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
void setPSD(const PSD psd)
Sets the range of particle radii that may be generated from a user defined PSD.
Boundary structure for boundaries used for insertion of particles.
bool getCheckParticleForInteraction() const
Gets the variable that checks if a particle has an interaction.
This is a class that generates random numbers i.e. named the Random Number Generator (RNG)...
Definition: RNG.h:52
virtual void placeParticle(BaseParticle *p, RNG &random)=0
Purely virtual function that generates the extrinsic properties (position, velocity) of a particle...
std::vector< BaseParticle * > getParticleToCopy()
Gets the particles that will be inserted through the insertion boundary.
Mdouble getVolumeOfParticlesInserted() const
Gets the volume of particles inserted by the boundary.
Mdouble volumeInserted_
Total volume of particles inserted.
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
void setParticleToCopy(std::vector< BaseParticle * > particleToCopy)
Sets multiple different particles that will be inserted through the insertion boundary.
unsigned int getNumberOfParticlesInserted() const
Gets the number of particles inserted by the boundary.
void write(std::ostream &os) const override
Writes the boundary's id_ and maxFailed_.
void setVolumeFlowRate(Mdouble volumeFlowRate_)
Sets the volume flow rate of the insertion routine.
void activate()
Turns on the InsertionBoundary.
void setManualInsertion(bool manualInsertion)
Set the flag for a manual PSD insertion routine.
~InsertionBoundary() override
Destructor: delete the particle that has to be copied at every insertion.
std::vector< PSD > getPSD()
Gets the particle size distributions set by the user.
virtual BaseParticle * generateParticle(RNG &random)
Sets the properties of the InsertionBoundary for mutliple different particle types.
void deactivate()
Turns off the InsertionBoundary.
Contains a vector with radii and probabilities of a user defined particle size distribution (PSD) ...
Definition: PSD.h:62
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
void setInitialVolume(Mdouble initialVolume)
Gets the Volume which should be inserted by the insertion routine.
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Definition: Vector.h:49
Mdouble getInitialVolume() const
Gets the initialVolume() .
Mdouble massInserted_
Total mass of particles inserted.
void setVariableVolumeFlowRate(const std::vector< Mdouble > &variableCumulativeVolumeFlowRate, Mdouble samplingInterval)
Sets a variable volume flow rate.
bool isActivated()
Returns whether the InsertionBoundary is activated.
void read(std::istream &is) override
Reads the boundary's id_ and maxFailed_.
bool isActivated_
The InsertionBoundary is activated by default. If the InsertionBoundary is deactivated, then it introduces no particles (useful for trying to maintain a certain insertion rate).