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 
56  enum class Distribution
57  {
58  Uniform,
60  // TODO add LogNormal distribution to generateParticle()
61  // LogNormal
62  };
63 
68 
73 
77  ~InsertionBoundary() override;
78 
82  void set(BaseParticle* particleToCopy, unsigned int maxFailed);
83 
89  virtual BaseParticle* generateParticle(RNG& random);
90 
99  virtual void placeParticle(BaseParticle* p, RNG& random)=0;
100 
104  void checkBoundaryBeforeTimeStep(DPMBase* md) override;
105 
108  logger(INFO,"Inserted % particles",getNumberOfParticlesInserted());
109  }
110 
114  unsigned int getNumberOfParticlesInserted() const;
115 
116  double getMassOfParticlesInserted() const;
117 
118  double getVolumeOfParticlesInserted() const;
119 
120  void reset();
121 
125  void activate();
126 
130  void deactivate();
131 
135  bool isActivated();
136 
140  void setMaxFailed(unsigned int maxFailed);
141 
145  unsigned int getMaxFailed() const;
146 
150  void setParticleToCopy(BaseParticle* particleToCopy);
151 
156 
160  void read(std::istream& is) override;
161 
165  void write(std::ostream& os) const override;
166 
167  Mdouble getVolumeFlowRate() const;
168 
170 
171  Mdouble getInitialVolume() const;
172 
173  void setInitialVolume(Mdouble initialVolume);
174 
178  void setPSD(PSD psd);
179 
180  PSD getPSD();
181 
185  void setDistribution(Distribution distribution);
186 
188 
190  void
191  setVariableVolumeFlowRate(const std::vector<Mdouble>& variableCumulativeVolumeFlowRate, Mdouble samplingInterval);
192 
193  bool insertParticle(Mdouble time);
194 
196  {
198  }
199 
200  void setCheckParticleForInteraction(bool checkParticleForInteraction)
201  {
202  checkParticleForInteraction_ = checkParticleForInteraction;
203  }
204 
208  void setManualInsertion(bool manualInsertion);
209 
213  friend std::ostream& operator<<(std::ostream& os, InsertionBoundary::Distribution type);
214 
218  friend std::istream& operator>>(std::istream& is, InsertionBoundary::Distribution& type);
219 
220 protected:
221 
226 
230  unsigned int maxFailed_;
231 
236 
241 
246 
253 
264 
267 
274  std::vector<Mdouble> variableCumulativeVolumeFlowRate_;
275 
278 
280 
286 
291 
296 
301 };
302 
303 #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.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
double getMassOfParticlesInserted() const
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
InsertionBoundary()
Default constructor: set everything to 0/nullptr.
void setPSD(PSD psd)
Sets the range of particle radii that may be generated from a user defined PSD.
Mdouble getVolumeFlowRate() const
unsigned int getMaxFailed() const
Gets the number of times that the boundary may fail to insert a particle.
bool insertParticle(Mdouble time)
Mdouble radMin_
Minimum and maximum radii of the generated particles.
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.
Distribution
Defines a custom particle size distribution; distribution_ will always be used, unless particleSizeDi...
void setMaxFailed(unsigned int maxFailed)
Sets the number of times that the wall may fail to insert a particle.
void setCheckParticleForInteraction(bool checkParticleForInteraction)
void insertParticles(DPMBase *md)
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
Distribution distribution_
defines a custom particle size distribution, which by default is uniform
Boundary structure for boundaries used for insertion of particles.
bool getCheckParticleForInteraction() const
void setParticleToCopy(BaseParticle *particleToCopy)
Sets the particle that will be inserted through the insertion boundary.
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...
double getVolumeOfParticlesInserted() const
Mdouble volumeInserted_
Total volume of particles inserted.
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
unsigned int getNumberOfParticlesInserted() const
Gets the number of particles inserted by the boundary.
BaseParticle * getParticleToCopy() const
Gets the particle that will be inserted through the insertion boundary.
void set(BaseParticle *particleToCopy, unsigned int maxFailed)
Sets the particle that will be inserted and the maximum number of times for which insertion may fail...
void write(std::ostream &os) const override
Writes the boundary's id_ and maxFailed_.
void setVolumeFlowRate(Mdouble volumeFlowRate_)
void activate()
Turns on the InsertionBoundary.
void setManualInsertion(bool manualInsertion)
Set the flag for a manual PSD insertion routine.
friend std::ostream & operator<<(std::ostream &os, InsertionBoundary::Distribution type)
write Distribution class to file.
~InsertionBoundary() override
Destructor: delete the particle that has to be copied at every insertion.
virtual BaseParticle * generateParticle(RNG &random)
Virtual function that generates the intrinsic properties (species, radius) of one particle...
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
void setInitialVolume(Mdouble initialVolume)
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
friend std::istream & operator>>(std::istream &is, InsertionBoundary::Distribution &type)
read Distribution class from file.
Mdouble getInitialVolume() const
Distribution getDistribution()
Gets the range of particle radii that may be generated.
void setDistribution(Distribution distribution)
Sets the range of particle radii that may be generated to custom distributions.
Mdouble massInserted_
Total mass of particles inserted.
void setVariableVolumeFlowRate(const std::vector< Mdouble > &variableCumulativeVolumeFlowRate, Mdouble samplingInterval)
bool isActivated()
Returns whether the InsertionBoundary is activated.
void read(std::istream &is) override
Reads the boundary's id_ and maxFailed_.
PSD particleSizeDistribution_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistribution_ is e...
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).