MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InsertionBoundary Class Referenceabstract

Boundary structure for boundaries used for insertion of particles. More...

#include <InsertionBoundary.h>

+ Inheritance diagram for InsertionBoundary:

Public Member Functions

 InsertionBoundary ()
 Defines a custom particle size distribution; distribution_ will always be used, unless particleSizeDistributionVector_ is non-empty. More...
 
 InsertionBoundary (const InsertionBoundary &other)
 Copy constructor (with deep copy) More...
 
 ~InsertionBoundary () override
 Destructor: delete the particle that has to be copied at every insertion. More...
 
virtual BaseParticlegenerateParticle (RNG &random)
 Sets the properties of the InsertionBoundary for mutliple different particle types. More...
 
virtual void placeParticle (BaseParticle *p, RNG &random)=0
 Purely virtual function that generates the extrinsic properties (position, velocity) of a particle. More...
 
void checkBoundaryBeforeTimeStep (DPMBase *md) override
 Fills the boundary with particles. More...
 
void insertParticles (DPMBase *md)
 Fill a certain domain with particles. More...
 
unsigned int getNumberOfParticlesInserted () const
 Gets the number of particles inserted by the boundary. More...
 
Mdouble getMassOfParticlesInserted () const
 Gets the mass of particles inserted by the boundary. More...
 
Mdouble getVolumeOfParticlesInserted () const
 Gets the volume of particles inserted by the boundary. More...
 
void reset ()
 resets particle property counter variables. More...
 
void activate ()
 Turns on the InsertionBoundary. More...
 
void deactivate ()
 Turns off the InsertionBoundary. More...
 
bool isActivated ()
 Returns whether the InsertionBoundary is activated. More...
 
unsigned int getMaxFailed () const
 Gets the number of times that the boundary may fail to insert a particle. More...
 
void setParticleToCopy (std::vector< BaseParticle * > particleToCopy)
 Sets multiple different particles that will be inserted through the insertion boundary. More...
 
void setParticleToCopy (BaseParticle *particleToCopy)
 Sets the particle that will be inserted through the insertion boundary. More...
 
std::vector< BaseParticle * > getParticleToCopy ()
 Gets the particles that will be inserted through the insertion boundary. More...
 
void read (std::istream &is) override
 Reads the boundary's id_ and maxFailed_. More...
 
void write (std::ostream &os) const override
 Writes the boundary's id_ and maxFailed_. More...
 
Mdouble getVolumeFlowRate () const
 Gets the volume flow rate of the insertion routine. More...
 
void setVolumeFlowRate (Mdouble volumeFlowRate_)
 Sets the volume flow rate of the insertion routine. More...
 
Mdouble getInitialVolume () const
 Gets the initialVolume() . More...
 
void setInitialVolume (Mdouble initialVolume)
 Gets the Volume which should be inserted by the insertion routine. More...
 
void setPSD (const PSD psd)
 Sets the range of particle radii that may be generated from a user defined PSD. More...
 
void setPSD (std::vector< PSD > psd, std::vector< Mdouble > probability)
 Sets the ranges of particle radii that may be generated from user defined PSDs. More...
 
std::vector< PSDgetPSD ()
 Gets the particle size distributions set by the user. More...
 
void setVariableVolumeFlowRate (const std::vector< Mdouble > &variableCumulativeVolumeFlowRate, Mdouble samplingInterval)
 Sets a variable volume flow rate. More...
 
bool insertParticle (Mdouble time)
 Checks the inserted total volume and returns if a particle is still allowed to be inserted. More...
 
bool getCheckParticleForInteraction () const
 Gets the variable that checks if a particle has an interaction. More...
 
void setCheckParticleForInteraction (bool checkParticleForInteraction)
 Sets the variable that checks if a particle has an interaction. More...
 
void setManualInsertion (bool manualInsertion)
 Set the flag for a manual PSD insertion routine. More...
 
- Public Member Functions inherited from BaseBoundary
 BaseBoundary ()
 default constructor. More...
 
 BaseBoundary (const BaseBoundary &b)
 copy constructor More...
 
 ~BaseBoundary () override
 destructor More...
 
virtual BaseBoundarycopy () const =0
 Used to create a copy of the object NB: purely virtual function. More...
 
virtual void createPeriodicParticle (BaseParticle *p UNUSED, ParticleHandler &pH UNUSED)
 Creates a periodic particle in case of periodic boundaries in serial build. More...
 
virtual void createPeriodicParticles (ParticleHandler &pH UNUSED)
 Creates periodic copies of given particle in case of periodic boundaries. More...
 
virtual void checkBoundaryAfterParticlesMove (ParticleHandler &pH)
 Virtual function that does things to particles, each time step after particles have moved. More...
 
virtual void actionsBeforeTimeLoop ()
 Virtual function that does something after DPMBase::setupInitialConditions but before the first time step. More...
 
virtual void modifyGhostAfterCreation (BaseParticle *particle, int i)
 
virtual void writeVTK (std::fstream &file)
 
void setHandler (BoundaryHandler *handler)
 Sets the boundary's BoundaryHandler. More...
 
BoundaryHandlergetHandler () const
 Returns the boundary's BoundaryHandler. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual std::string getName () const =0
 A purely virtual function. More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Protected Attributes

std::vector< BaseParticle * > particleToCopy_
 write Distribution class to file. More...
 
unsigned int maxFailed_
 Number of times that the wall may fail to insert a particle. More...
 
unsigned int numberOfParticlesInserted_
 Number of particles that are already inserted. More...
 
Mdouble massInserted_
 Total mass of particles inserted. More...
 
Mdouble volumeInserted_
 Total volume of particles inserted. More...
 
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). More...
 
Mdouble volumeFlowRate_
 
Mdouble initialVolume_
 
std::vector< MdoublevariableCumulativeVolumeFlowRate_
 
Mdouble samplingInterval_
 
bool checkParticleForInteraction_
 Checks if a particle has an interaction with a wall or other particles. More...
 
std::vector< PSDparticleSizeDistributionVector_
 Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector_ is empty, distribution_ is used instead. More...
 
Vec3D velMin_
 Minimum and maximum velocity of the particles to be inserted. More...
 
Vec3D velMax_
 
bool isManuallyInserting_
 A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE. More...
 
std::vector< Mdoubleprobability_
 vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions. More...
 

Detailed Description

Boundary structure for boundaries used for insertion of particles.

To cite the InsertionBoundary algorithm: A. R. Thornton, D. Krijgsman, A. Te Voortwis, V. Ogarko, S. Luding, R. Fransen, S. Gonzalez, O. Bokhove, O. Imole, and T. Weinhart. A review of recent work on the discrete particle method at the University of Twente: An introduction to the open-source package MercuryDPM. DEM6 - International Conference on DEMs, 2013.

Definition at line 49 of file InsertionBoundary.h.

Constructor & Destructor Documentation

InsertionBoundary::InsertionBoundary ( )

Defines a custom particle size distribution; distribution_ will always be used, unless particleSizeDistributionVector_ is non-empty.

Todo:
think about making both possible; a discrete distribution and a continuous which is more accurate

Default constructor: set everything to 0/nullptr.

Default constructor, sets all data members to 0 or default.

Definition at line 38 of file InsertionBoundary.cc.

References checkParticleForInteraction_, constants::inf, initialVolume_, isActivated_, isManuallyInserting_, massInserted_, maxFailed_, numberOfParticlesInserted_, particleSizeDistributionVector_, samplingInterval_, velMax_, velMin_, volumeFlowRate_, and volumeInserted_.

38  : BaseBoundary()
39 {
41  massInserted_ = 0;
42  volumeInserted_ = 0;
43  maxFailed_ = 0;
44  isActivated_ = true;
46  initialVolume_ = 0;
49  velMin_ = Vec3D(0.0, 0.0, 0.0);
50  velMax_ = Vec3D(0.0, 0.0, 0.0);
52  isManuallyInserting_ = false;
53 }
bool isManuallyInserting_
A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE.
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other 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.
const Mdouble inf
Definition: GeneralDefine.h:44
Mdouble volumeInserted_
Total volume of particles inserted.
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Definition: Vector.h:49
Mdouble massInserted_
Total mass of particles inserted.
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
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).
InsertionBoundary::InsertionBoundary ( const InsertionBoundary other)

Copy constructor (with deep copy)

Copy constructor

Definition at line 58 of file InsertionBoundary.cc.

References checkParticleForInteraction_, constants::i, initialVolume_, isActivated_, isManuallyInserting_, massInserted_, maxFailed_, numberOfParticlesInserted_, particleSizeDistributionVector_, particleToCopy_, probability_, samplingInterval_, variableCumulativeVolumeFlowRate_, velMax_, velMin_, volumeFlowRate_, and volumeInserted_.

59  : BaseBoundary(other)
60 {
64  maxFailed_ = other.maxFailed_;
65  isActivated_ = other.isActivated_;
72  probability_ = other.probability_;
73  velMin_ = other.velMin_;
74  velMax_ = other.velMax_;
76 
77  for (int i = 0; i < other.particleToCopy_.size(); i++)
78  {
79  particleToCopy_.resize(other.particleToCopy_.size());
80  particleToCopy_[i] = other.particleToCopy_[i]->copy();
81  }
82 }
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.
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
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.
Mdouble volumeInserted_
Total volume of particles inserted.
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Mdouble massInserted_
Total mass of particles inserted.
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
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).
InsertionBoundary::~InsertionBoundary ( )
override

Destructor: delete the particle that has to be copied at every insertion.

Destructor that deletes the BaseParticle that is copied and inserted at every insertion.

Definition at line 88 of file InsertionBoundary.cc.

References particleToCopy_.

89 {
90  for (auto& particleToCopy: particleToCopy_)
91  {
92  delete particleToCopy;
93  }
94 
95 }
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.

Member Function Documentation

void InsertionBoundary::activate ( )

Turns on the InsertionBoundary.

Turns on the InsertionBoundary by setting the boolean to TRUE.

Definition at line 368 of file InsertionBoundary.cc.

References isActivated_.

369 {
370  isActivated_ = true;
371 }
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).
void InsertionBoundary::checkBoundaryBeforeTimeStep ( DPMBase md)
overridevirtual

Fills the boundary with particles.

Is used to fill the insides of the boundary with particles until it is filled up.

Parameters
[in,out]mdthe problem's DPMBase object
Todo:
rename to something like "insertUntilMaxFailed"?

HERE

Todo:
create a definition for zero-size particles. Right now the zero-size particle is only used as a stop criterion for the manual PSD insertion

HERE

Reimplemented from BaseBoundary.

Reimplemented in RandomClusterInsertionBoundary.

Definition at line 182 of file InsertionBoundary.cc.

References MPIContainer::broadcast(), DPMBase::checkParticleForInteraction(), checkParticleForInteraction_, BaseHandler< T >::copyAndAddObject(), copyDataFromMPIParticleToParticle(), MPISphericalParticle::copyDataFromParticleToMPIParticle(), generateParticle(), DPMBase::getNextTime(), insertParticle(), MPIContainer::Instance(), isActivated_, logger, massInserted_, maxFailed_, NUMBER_OF_PROCESSORS, numberOfParticlesInserted_, PARTICLE, DPMBase::particleHandler, placeParticle(), PROCESSOR_ID, DPMBase::random, VERBOSE, and volumeInserted_.

Referenced by insertParticles().

183 {
184  logger(VERBOSE, "In InsertionBoundary::checkBoundaryBeforeTimeStep\n");
185 
186  if (!isActivated_)
187  {
188  return;
189  }
190 
191  /* Each timestep, the InsertionBoundary attempts to fill up a region with
192  * particles.
193  *
194  * It first calls generateParticle() to get a randomised particle, subject
195  * to a specified distribution over sizes and species. (The basic class
196  * supports size dispersity only but PolydisperseInsertionBoundary will
197  * support species dispersity.)
198  * Then it repeatedly calls placeParticle(), which gives the particle a
199  * random location (and possibly velocity) in a specified,
200  * geometry-dependent bound. Each time, it checks whether the new particle
201  * would have an interaction with another particle or a wall.
202  *
203  * If it manages to do that within maxFailed_ tries, then:
204  * * the new particle is inserted,
205  * * the failure counter is reset, and
206  * the processes is repeated with a new generateParticle().
207  *
208  * Otherwise, the processes terminates for this timestep.
209  * */
210 
211  // Keep count of how many successive times we have failed to place a new
212  // particle.
213  unsigned int failed = 0;
214  while (failed <= maxFailed_ && insertParticle(md->getNextTime())) // 'generating' loop
215  {
216  /* Generate random *intrinsic* properties for the new particle. */
217  logger(VERBOSE, "about to call generateParticle\n");
218 
219 
220 
221 
223 
224 
225  auto p0 = generateParticle(md->random);
226  // Important for particle generation with a particle size distribution as it generates a particle with zero
227  // radius. If a particle is not allowed to be inserted by the PSD criteria it will generate a particle with
228  // zero diameter. This if statement prevents inserting particles with zero radius, which would else be a problem.
230  if (p0->getRadius() == 0)
231  {
232  logger(VERBOSE, "The PSD for the specified volume is fully set");
233  // free up memory space
234  delete p0;
235  // out of the 'placing' loop
236  failed = maxFailed_ + 1;
237  continue;
238  }
239  logger(VERBOSE, "generated a particle with intrinsics %", p0);
240 
241  while (true) // 'placing' loop
242  {
243  /* Generate extrinsic properties (position and velocity) for this
244  * new particle. */
245 
246 
247 
249 
250 
251 
252 
253  placeParticle(p0, md->random);
254  logger(VERBOSE, "attempting to place particle at %, vel %", p0->getPosition(), p0->getVelocity());
255 
256 #ifdef MERCURY_USE_MPI
257  /* Communicate the new particle's properties by setHandler (note
258  * that this doesn't actually add the particle to the handler). */
259  if (NUMBER_OF_PROCESSORS > 1)
260  {
261  MPIParticle particle;
262  // //Every domain generates a particle (to get the species right etc)
263 
264  //Send particle data from root to other processors to sync the particle properties
265  if (PROCESSOR_ID == 0)
266  {
268  }
269 
271 
272  //Process the received data
273  if (PROCESSOR_ID != 0)
274  {
275  copyDataFromMPIParticleToParticle(&particle, p0, &(md->particleHandler));
276  }
277  }
278 #endif
279  p0->setHandler(&md->particleHandler);
280  /* Check whether the particle has any interactions. */
282  {
283  //Note: in parallel only one of the domains will actually add the particle
284  auto p = md->particleHandler.copyAndAddObject(p0);
285  failed = 0;
286 
288  const double volume = p0->getVolume();
289  volumeInserted_ += volume;
290  massInserted_ += p0->getSpecies()->getDensity() * volume;
291  logger(VERBOSE, "successfully placed a particle %, with position: % after % fails.", p0,
292  p0->getPosition(), failed);
293  /* JMFT: The generateParticle() routine allocates memory, so we should
294  * free it here. (Don't worry, the particle will have been copied to the
295  * particleHandler by this point iff we want it.) */
296  delete p0;
297 
298  break; // out of the 'placing' loop
299  }
300  else
301  {
302  failed++;
303  logger(VERBOSE, "failed to place a particle; have failed % times", failed);
304  }
305 
306  if (failed > maxFailed_)
307  {
308  logger(VERBOSE, "failed too many times; giving up");
309  break; // out of the 'placing' loop (and will leave the 'generating' loop too
310  }
311  }
312  logger(VERBOSE, "failed % times, so breaking out of InsertionBoundary loop for this timestep.", failed);
313  }
314  // logger(INFO, "volumeInserted_ = %", volumeInserted_);
315 }
void copyDataFromParticleToMPIParticle(BaseParticle *p)
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
bool insertParticle(Mdouble time)
Checks the inserted total volume and returns if a particle is still allowed to be inserted...
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
void copyDataFromMPIParticleToParticle(MPIParticle *bP, BaseParticle *p, ParticleHandler *particleHandler)
Copies data from an MPIParticle class to a BaseParticle and sets the particleHandler and species...
virtual void placeParticle(BaseParticle *p, RNG &random)=0
Purely virtual function that generates the extrinsic properties (position, velocity) of a particle...
virtual bool checkParticleForInteraction(const BaseParticle &P)
Checks whether a particle P has any interaction with walls or other particles.
Definition: DPMBase.cc:4638
Mdouble volumeInserted_
Total volume of particles inserted.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1395
Data class to send a particle over MPI.
Definition: MpiDataClass.h:81
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1390
std::enable_if< std::is_scalar< T >::value, void >::type broadcast(T &t, int fromProcessor=0)
Broadcasts a scalar from the root to all other processors.
Definition: MpiContainer.h:441
virtual BaseParticle * generateParticle(RNG &random)
Sets the properties of the InsertionBoundary for mutliple different particle types.
Mdouble getNextTime() const
Returns the current simulation time.
Definition: DPMBase.cc:813
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Mdouble massInserted_
Total mass of particles inserted.
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).
void InsertionBoundary::deactivate ( )

Turns off the InsertionBoundary.

Turns off the InsertionBoundary by setting the boolean to FALSE.

Definition at line 376 of file InsertionBoundary.cc.

References isActivated_.

377 {
378  isActivated_ = false;
379 }
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).
BaseParticle * InsertionBoundary::generateParticle ( RNG random)
virtual

Sets the properties of the InsertionBoundary for mutliple different particle types.

Sets the properties of the InsertionBoundary for a single particle type

Virtual function that generates the intrinsic properties (species, radius) of one particle.

Parameters
[in]randomRandom number generator

The default behaviour will be to return particleToCopy_, but this can be overridden by the children (to get size or species dispersity).

Reimplemented in PolydisperseInsertionBoundary, FixedClusterInsertionBoundary, and BidisperseCubeInsertionBoundary.

Definition at line 101 of file InsertionBoundary.cc.

References helpers::check(), BaseBoundary::getHandler(), BaseParticle::getRadius(), RNG::getRandomNumber(), getVolumeFlowRate(), constants::i, INFO, initialVolume_, isManuallyInserting_, logger, particleSizeDistributionVector_, particleToCopy_, probability_, and BaseParticle::setRadius().

Referenced by RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and checkBoundaryBeforeTimeStep().

102 {
103  double check = random.getRandomNumber(0, 1);
104  int chosenSpecies = 0;
105  for (int i = 0; i < probability_.size(); i++)
106  {
107  if (check < probability_[i])
108  {
109  chosenSpecies = i;
110  break;
111  }
112  else
113  {
114  check -= probability_[i];
115  }
116  }
117  BaseParticle* P = particleToCopy_[chosenSpecies]->copy();
118  if (particleSizeDistributionVector_[chosenSpecies].getParticleSizeDistribution().empty())
119  {
120  particleSizeDistributionVector_[chosenSpecies].setDistributionUniform(P->getRadius(), P->getRadius(), 50);
121  logger(INFO, "Assembling a discrete uniform particle size distribution (50 bins) with the radius set for the "
122  "InsertionBoundary.");
123  }
124  // manual insertion routine to insert PSDs as accurate as possible into a given volume
126  {
127  logger.assert_debug(initialVolume_ > 0.0, "Use setInitialVolume to define the particle insertion volume");
128  Mdouble radius;
129  // getVolumeFlowRate() * time + initialVolume_ - volumeInserted_ lead to more inaccurate results, therfore
130  // -volumeInserted was removed.
131  radius = particleSizeDistributionVector_[chosenSpecies].insertManuallyByVolume(getVolumeFlowRate() *
132  getHandler()->getDPMBase()->getTime() +
134  P->setRadius(radius);
135  }
136  Mdouble radius;
137  radius = particleSizeDistributionVector_[chosenSpecies].drawSample();
138  P->setRadius(radius);
139  return P;
140 }
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.
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Mdouble getVolumeFlowRate() const
Gets the volume flow rate of the insertion routine.
void check(double real, double ideal, double error, std::string errorMessage)
Definition: Helpers.cc:911
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
bool InsertionBoundary::getCheckParticleForInteraction ( ) const

Gets the variable that checks if a particle has an interaction.

Gets the variable that checks if a particle has an interaction with a wall or another particle.

Returns
if TRUE the particle has an interaction and if FALSE the particle has no interaction.

Definition at line 711 of file InsertionBoundary.cc.

References checkParticleForInteraction_.

712 {
714 }
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
Mdouble InsertionBoundary::getInitialVolume ( ) const

Gets the initialVolume() .

Gets the volume to be inserted by the insertion routine.

Returns
A double which corresponds to volume to be inserted by the insertion routines

Definition at line 627 of file InsertionBoundary.cc.

References initialVolume_.

628 {
629  return initialVolume_;
630 }
Mdouble InsertionBoundary::getMassOfParticlesInserted ( ) const

Gets the mass of particles inserted by the boundary.

Returns the mass of particles inserted in the boundary

Returns
the mass of particles inserted

Definition at line 340 of file InsertionBoundary.cc.

References massInserted_.

341 {
342  return massInserted_;
343 }
Mdouble massInserted_
Total mass of particles inserted.
unsigned int InsertionBoundary::getMaxFailed ( ) const

Gets the number of times that the boundary may fail to insert a particle.

Return maxFailed_ (see InsertionBoundary::set).

Returns
the maximum number of particle insertion trials

Definition at line 394 of file InsertionBoundary.cc.

References maxFailed_.

395 {
396  return maxFailed_;
397 }
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
unsigned int InsertionBoundary::getNumberOfParticlesInserted ( ) const

Gets the number of particles inserted by the boundary.

Returns the number of particles inserted in the boundary

Returns
the number of particles inserted

Definition at line 331 of file InsertionBoundary.cc.

References numberOfParticlesInserted_.

Referenced by insertParticles(), and Chute::write().

332 {
334 }
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
std::vector< BaseParticle * > InsertionBoundary::getParticleToCopy ( )

Gets the particles that will be inserted through the insertion boundary.

returns pointer to the particle copies which are to be inserted

Definition at line 451 of file InsertionBoundary.cc.

References ERROR, logger, and particleToCopy_.

452 {
453  if (particleToCopy_.empty())
454  {
455  logger(ERROR, "particleToCopy not set");
456  }
457  return particleToCopy_;
458 }
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
std::vector< PSD > InsertionBoundary::getPSD ( )

Gets the particle size distributions set by the user.

gets the user defined particle size distributions

Returns
a vector of PSD class objects containing containing the differnt user defined particle size distributions

Definition at line 693 of file InsertionBoundary.cc.

References particleSizeDistributionVector_.

694 {
696 }
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
Mdouble InsertionBoundary::getVolumeFlowRate ( ) const

Gets the volume flow rate of the insertion routine.

Gets the volumetric flow rate of the insertion routine.

Returns
A double which corresponds to the flow rate of the insertion routine

Definition at line 610 of file InsertionBoundary.cc.

References volumeFlowRate_.

Referenced by generateParticle(), and insertParticle().

611 {
612  return volumeFlowRate_;
613 }
Mdouble InsertionBoundary::getVolumeOfParticlesInserted ( ) const

Gets the volume of particles inserted by the boundary.

Returns the volume of particles inserted in the boundary

Returns
the volume of particles inserted

Definition at line 349 of file InsertionBoundary.cc.

References volumeInserted_.

350 {
351  return volumeInserted_;
352 }
Mdouble volumeInserted_
Total volume of particles inserted.
bool InsertionBoundary::insertParticle ( Mdouble  time)

Checks the inserted total volume and returns if a particle is still allowed to be inserted.

Checks the inserted total volume by the flowrate and initialVolume and returns if a particle is allowed to be inserted.

Returns
TRUE if the inserted volume is lower than the total volume and FALSE if the inserted volume is higher than the total volume.

Definition at line 148 of file InsertionBoundary.cc.

References getVolumeFlowRate(), constants::i, initialVolume_, logger, samplingInterval_, variableCumulativeVolumeFlowRate_, volumeInserted_, and WARN.

Referenced by RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and checkBoundaryBeforeTimeStep().

149 {
150  // check if the flow rate limit has been reached
152  {
154  }
155  else
156  {
157  const Mdouble iMax = (Mdouble) variableCumulativeVolumeFlowRate_.size() - 2;
158  const Mdouble i = std::min(time / samplingInterval_, iMax);
159  if (i == iMax)
160  {
161  static unsigned count = 0;
162  if (count == 0)
163  {
164  logger(WARN, "Reached end of volume flowrate function");
165  }
166  ++count;
167  }
168  const size_t id = i;
169  const Mdouble allowedVolume = variableCumulativeVolumeFlowRate_[id] +
171  variableCumulativeVolumeFlowRate_[id]) * (i - id);
172  return volumeInserted_ < allowedVolume;
173  }
174 }
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getVolumeFlowRate() const
Gets the volume flow rate of the insertion routine.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble volumeInserted_
Total volume of particles inserted.
void InsertionBoundary::insertParticles ( DPMBase md)

Fill a certain domain with particles.

calls the function checkBoundaryBeforeTimeStep() to fill a domain with particles; also reports how many particles where inserted at the end of the routine.

Definition at line 321 of file InsertionBoundary.cc.

References checkBoundaryBeforeTimeStep(), getNumberOfParticlesInserted(), INFO, and logger.

Referenced by DPMBase::fillDomainWithParticles().

322 {
324  logger(INFO, "Inserted % particles", getNumberOfParticlesInserted());
325 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
unsigned int getNumberOfParticlesInserted() const
Gets the number of particles inserted by the boundary.
bool InsertionBoundary::isActivated ( )

Returns whether the InsertionBoundary is activated.

checks the activation status of the InsertionBoundary by checking the respective boolean variable.

Returns
TRUE for an activated InsertionBoundary and FALSE for a deactivated InsertionBoundary

Definition at line 385 of file InsertionBoundary.cc.

References isActivated_.

386 {
387  return isActivated_;
388 }
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).
virtual void InsertionBoundary::placeParticle ( BaseParticle p,
RNG random 
)
pure virtual

Purely virtual function that generates the extrinsic properties (position, velocity) of a particle.

Parameters
[in]pThe particle to be placed
[in]randomRandom number generator

This should be implemented by the children such as CubeInsertionBoundary, as the implementation will be geometry-dependent.

Implemented in BaseClusterInsertionBoundary, CubeInsertionBoundary, PolydisperseInsertionBoundary, RandomClusterInsertionBoundary, HopperInsertionBoundary, FixedClusterInsertionBoundary, and ChuteInsertionBoundary.

Referenced by checkBoundaryBeforeTimeStep().

void InsertionBoundary::read ( std::istream &  is)
overridevirtual

Reads the boundary's id_ and maxFailed_.

reads the boundary's id_ and maxFailed_ from the given istream

Parameters
[in,out]isstream the data members are read from
Todo:
make theses reads non-optional

Implements BaseBoundary.

Reimplemented in PolydisperseInsertionBoundary.

Definition at line 464 of file InsertionBoundary.cc.

References checkParticleForInteraction_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseHandler< T >::getObject(), constants::i, initialVolume_, isActivated_, massInserted_, maxFailed_, numberOfParticlesInserted_, DPMBase::particleHandler, particleSizeDistributionVector_, particleToCopy_, probability_, PSD::RadiusAndProbability::radius, BaseBoundary::read(), ParticleHandler::readAndCreateObject(), helpers::readOptionalVariable(), samplingInterval_, BaseParticle::setSpecies(), variableCumulativeVolumeFlowRate_, volumeFlowRate_, and volumeInserted_.

Referenced by ChuteInsertionBoundary::read(), HopperInsertionBoundary::read(), PolydisperseInsertionBoundary::read(), CubeInsertionBoundary::read(), and BaseClusterInsertionBoundary::read().

465 {
466  BaseBoundary::read(is);
467  std::string dummy, type;
468  is >> dummy >> maxFailed_ >> dummy;
469  if (dummy == "volumeFlowRate")
470  {
471  is >> volumeFlowRate_ >> dummy;
472  }
473  is >> massInserted_;
474  is >> dummy >> volumeInserted_;
475  is >> dummy >> numberOfParticlesInserted_;
476  is >> dummy >> isActivated_;
477  size_t psdVectorSize;
478  is >> dummy >> psdVectorSize;
480  particleSizeDistributionVector_.resize(psdVectorSize);
481  for (auto& particleSizeDistributionVector: particleSizeDistributionVector_)
482  {
483  size_t psdSize;
484  PSD::RadiusAndProbability radiusAndProbability{};
485  std::vector<PSD::RadiusAndProbability> particleSizeDistribution{};
486  is >> dummy >> psdSize;
487  particleSizeDistribution.clear();
488  particleSizeDistribution.reserve(psdSize);
489  for (size_t i = 0; i < psdSize; i++)
490  {
491  is >> radiusAndProbability.radius;
492  is >> radiusAndProbability.probability;
493  particleSizeDistribution.push_back(radiusAndProbability);
494  }
495  particleSizeDistributionVector.setParticleSizeDistribution(particleSizeDistribution);
496  }
497  if (psdVectorSize > 1)
498  {
499  is >> dummy;
500  Mdouble psdRatio;
501  probability_.clear();
502  probability_.reserve(psdVectorSize);
503  for (size_t i = 0; i < psdVectorSize; i++)
504  {
505  is >> psdRatio;
506  probability_.push_back(psdRatio);
507  }
508  }
509 
511  helpers::readOptionalVariable(is, "checkParticleForInteraction", checkParticleForInteraction_);
512  helpers::readOptionalVariable(is, "initialVolume", initialVolume_);
513  if (helpers::readOptionalVariable(is, "samplingInterval", samplingInterval_))
514  {
515  size_t n;
516  Mdouble flowRate;
517  is >> dummy >> n;
518  //variableCumulativeVolumeFlowRate_.clear();
520  for (size_t i = 0; i < n; ++i)
521  {
522  is >> flowRate;
523  variableCumulativeVolumeFlowRate_.push_back(flowRate);
524  }
525  }
526  is >> dummy;
527  if (dummy != "noParticleToCopy")
528  {
529  size_t particleToCopySize;
530  for (auto& particleToCopy: particleToCopy_)
531  {
532  delete particleToCopy;
533  }
534  is >> particleToCopySize;
535  particleToCopy_.resize(particleToCopySize);
536  for (auto& particleToCopy: particleToCopy_)
537  {
538  particleToCopy = getHandler()->getDPMBase()->particleHandler.readAndCreateObject(is);
539  // The .restart file records the index of the particle's species, but
540  // doesn't record the pointer, i.e. the memory address of the species within
541  // the speciesHandler. The latter needs to be reset now.
542  particleToCopy->setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(
543  particleToCopy->getIndSpecies()));
544  }
545  }
546 }
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.
Class which stores radii and probabilities of a PSD. This class should be used as a vector
Definition: PSD.h:86
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.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
void setSpecies(const ParticleSpecies *species)
void read(std::istream &is) override=0
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:61
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
Mdouble volumeInserted_
Total volume of particles inserted.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1395
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
bool readOptionalVariable(std::istream &is, const std::string &name, T &variable)
Reads optional variables in the restart file.
Definition: Helpers.h:247
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble massInserted_
Total mass of particles inserted.
BaseParticle * readAndCreateObject(std::istream &is)
Create a new particle, based on the information provided in a restart file.
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).
void InsertionBoundary::reset ( )

resets particle property counter variables.

set all particle property counter variables to zero. reset() does not activate or deactivate the InsertionBoundary.

Definition at line 358 of file InsertionBoundary.cc.

References massInserted_, numberOfParticlesInserted_, and volumeInserted_.

359 {
361  massInserted_ = 0;
362  volumeInserted_ = 0;
363 }
Mdouble volumeInserted_
Total volume of particles inserted.
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Mdouble massInserted_
Total mass of particles inserted.
void InsertionBoundary::setCheckParticleForInteraction ( bool  checkParticleForInteraction)

Sets the variable that checks if a particle has an interaction.

Sets the distribution type from the Distribution class.

Parameters
[in]checkParticleForInteractionboolean which determines if a particle has an interaction.

Definition at line 720 of file InsertionBoundary.cc.

References checkParticleForInteraction_.

721 {
722  checkParticleForInteraction_ = checkParticleForInteraction;
723 }
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
void InsertionBoundary::setInitialVolume ( Mdouble  initialVolume)

Gets the Volume which should be inserted by the insertion routine.

Sets the volume to be inserted by the insertion routine. (Total volume to insert = getVolumeFlowRate() * time + initialVolume_)

Definition at line 636 of file InsertionBoundary.cc.

References initialVolume_, and volumeFlowRate_.

637 {
638  initialVolume_ = initialVolume;
639  if (!std::isfinite(volumeFlowRate_))
640  {
641  volumeFlowRate_ = 0;
642  }
643 }
void InsertionBoundary::setManualInsertion ( bool  isManuallyInserting)

Set the flag for a manual PSD insertion routine.

sets the isManuallyInserting_ to TRUE, resulting in a top-down class-by-class insertion routine to insert PSDs as accurate as possible.

Definition at line 702 of file InsertionBoundary.cc.

References isManuallyInserting_.

703 {
704  isManuallyInserting_ = isManuallyInserting;
705 }
bool isManuallyInserting_
A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE.
void InsertionBoundary::setParticleToCopy ( std::vector< BaseParticle * >  particleToCopy)

Sets multiple different particles that will be inserted through the insertion boundary.

Sets the vector of pointers to particles which will be inserted by the insertion boundary. This is mainly used to insert particles with different intrinsic properties (such as PSD, mechanical properties, etc.)

Parameters
[in]particleToCopyvector of pointers to the particles which are to be inserted

Definition at line 404 of file InsertionBoundary.cc.

References ERROR, constants::i, logger, and particleToCopy_.

Referenced by ChuteInsertionBoundary::set(), RandomClusterInsertionBoundary::set(), FixedClusterInsertionBoundary::set(), HopperInsertionBoundary::set(), and CubeInsertionBoundary::set().

405 {
406  if (particleToCopy.empty())
407  {
408  logger(ERROR, "Setting particleToCopy to be empty?");
409  }
410  if (!particleToCopy_.empty())
411  {
412  for (auto& ParticleToCopy: particleToCopy_)
413  {
414  delete ParticleToCopy;
415  }
416  }
417  for (int i = 0; i < particleToCopy.size(); i++)
418  {
419  particleToCopy_.resize(particleToCopy.size());
420  particleToCopy_[i] = particleToCopy[i]->copy();
421  }
422 }
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
void InsertionBoundary::setParticleToCopy ( BaseParticle particleToCopy)

Sets the particle that will be inserted through the insertion boundary.

Sets the vector of pointers to particles which will be inserted by the insertion boundary.

Parameters
[in]particleToCopypointer to the particle to be inserted

Definition at line 428 of file InsertionBoundary.cc.

References BaseParticle::copy(), ERROR, logger, and particleToCopy_.

429 {
430  if (particleToCopy == nullptr)
431  {
432  logger(ERROR, "Setting particleToCopy to be a null pointer?");
433  }
434  else
435  {
436  if (!particleToCopy_.empty())
437  {
438  for (auto& particleToCopy: particleToCopy_)
439  {
440  delete particleToCopy;
441  }
442  }
443  particleToCopy_.resize(1);
444  particleToCopy_[0] = particleToCopy->copy();
445  }
446 }
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
void InsertionBoundary::setPSD ( const PSD  psd)

Sets the range of particle radii that may be generated from a user defined PSD.

Sets the range of particle radii that may be generated to a PSD defined by the user.

Todo:
TP: Consider std::move instead of a set function. This would result in a speedup + no one has to set the PSD for insertionBoundaries again as it is set when a PSD is inserted.

Definition at line 668 of file InsertionBoundary.cc.

Referenced by CubeInsertionBoundary::set(), Chute::setupInitialConditions(), and ChuteWithHopper::setupInitialConditions().

669 {
672 }
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
void InsertionBoundary::setPSD ( std::vector< PSD psd,
std::vector< Mdouble psdRatio 
)

Sets the ranges of particle radii that may be generated from user defined PSDs.

Sets the ranges of particle radii that may be generated by different PSDs defined by the user.

Todo:
TP: Consider std::move instead of a set function. This would result in a speedup + no one has to set the PSD for insertionBoundaries again as it is set when a PSD is inserted.

Definition at line 678 of file InsertionBoundary.cc.

679 {
680  particleSizeDistributionVector_.resize(psd.size());
682  logger.assert_always(std::accumulate(psdRatio.begin(), psdRatio.end(), 0.0) == 1.0, "Please make sure that the sum of "
683  "psdRatios adds up to unity");
684  probability_.resize(psdRatio.size());
685  probability_ = psdRatio;
686 
687 }
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
void InsertionBoundary::setVariableVolumeFlowRate ( const std::vector< Mdouble > &  variableCumulativeVolumeFlowRate,
Mdouble  samplingInterval 
)

Sets a variable volume flow rate.

See also
variableCumulativeVolumeFlowRate_

Sets a variable volume flow rate taken at fixed sampling intervals; the values are cumulative; thus, we need to ensure the volume inserted before time t=n*samplingInterval is less than variableCumulativeVolumeFlowRate[n].

See also
variableCumulativeVolumeFlowRate_

Definition at line 651 of file InsertionBoundary.cc.

References BaseBoundary::getHandler(), INFO, logger, samplingInterval_, and variableCumulativeVolumeFlowRate_.

653 {
654  logger.assert_debug(samplingInterval > 0, "sampling interval needs to be positive");
655  const Mdouble endTime = variableCumulativeVolumeFlowRate.size() * samplingInterval;
656  logger(INFO, "variable flowrate is defined up to %", endTime);
657  logger.assert_always(getHandler()->getDPMBase()->getTimeMax() < endTime,
658  "variable flowrate is defined up to %, but tMax is set to %", endTime,
659  getHandler()->getDPMBase()->getTimeMax());
660  variableCumulativeVolumeFlowRate_ = variableCumulativeVolumeFlowRate;
661  samplingInterval_ = samplingInterval;
662 }
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
void InsertionBoundary::setVolumeFlowRate ( Mdouble  volumeFlowRate)

Sets the volume flow rate of the insertion routine.

Sets the volumetric flow rate of the insertion routine.

Definition at line 618 of file InsertionBoundary.cc.

References volumeFlowRate_.

619 {
620  volumeFlowRate_ = volumeFlowRate;
621 }
void InsertionBoundary::write ( std::ostream &  os) const
overridevirtual

Writes the boundary's id_ and maxFailed_.

adds the boundary's id_ and maxFailed_ to the given ostream

Parameters
[in,out]isstream the data members are to be added to

Implements BaseBoundary.

Reimplemented in PolydisperseInsertionBoundary.

Definition at line 552 of file InsertionBoundary.cc.

References checkParticleForInteraction_, initialVolume_, isActivated_, logger, massInserted_, maxFailed_, numberOfParticlesInserted_, particleSizeDistributionVector_, particleToCopy_, probability_, samplingInterval_, variableCumulativeVolumeFlowRate_, VERBOSE, volumeFlowRate_, volumeInserted_, and BaseBoundary::write().

Referenced by ChuteInsertionBoundary::write(), HopperInsertionBoundary::write(), PolydisperseInsertionBoundary::write(), CubeInsertionBoundary::write(), and BaseClusterInsertionBoundary::write().

553 {
554  logger(VERBOSE, "In InsertionBoundary::write\n");
556  os << " maxFailed " << maxFailed_;
557  if (std::isfinite(volumeFlowRate_))
558  os << " volumeFlowRate " << volumeFlowRate_;
559  os << " massInserted " << massInserted_;
560  os << " volumeInserted " << volumeInserted_;
561  os << " numberOfParticlesInserted " << numberOfParticlesInserted_;
562  os << " isActivated " << isActivated_;
563  os << " psdCount " << particleSizeDistributionVector_.size();
564  for (auto& particleSizeDistribution: particleSizeDistributionVector_)
565  {
566  os << " psd " << particleSizeDistribution.getParticleSizeDistribution().size();
567  for (auto p: particleSizeDistribution.getParticleSizeDistribution())
568  {
569  os << " " << p.radius
570  << " " << p.probability;
571  }
572  }
573  if (!probability_.empty())
574  {
575  os << " psdRatio";
576  for (auto& psdRatio: probability_)
577  {
578  os << " " << psdRatio;
579  }
580  }
582  {
583  os << " checkParticleForInteraction " << checkParticleForInteraction_;
584  }
585  os << " initialVolume " << initialVolume_;
586  os << " samplingInterval " << samplingInterval_;
587  os << " variableCumulativeVolumeFlowRate " << variableCumulativeVolumeFlowRate_.size();
588  for (const auto flowRate: variableCumulativeVolumeFlowRate_)
589  {
590  os << ' ' << flowRate;
591  }
592  if (!particleToCopy_.empty())
593  {
594  os << " particleToCopy " << particleToCopy_.size();
595  for (auto& particleToCopy: particleToCopy_)
596  {
597  os << " " << *particleToCopy;
598  }
599  }
600  else
601  {
602  os << " noParticleToCopy";
603  }
604 }
std::vector< Mdouble > variableCumulativeVolumeFlowRate_
std::vector< BaseParticle * > particleToCopy_
write Distribution class to file.
std::vector< Mdouble > probability_
vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
bool checkParticleForInteraction_
Checks if a particle has an interaction with a wall or other particles.
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
Mdouble volumeInserted_
Total volume of particles inserted.
void write(std::ostream &os) const override=0
Adds object's id_ to given ostream NB: purely virtual function, overriding the version of BaseObject...
Definition: BaseBoundary.cc:70
std::vector< PSD > particleSizeDistributionVector_
Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector...
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
Mdouble massInserted_
Total mass of particles inserted.
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).

Member Data Documentation

bool InsertionBoundary::checkParticleForInteraction_
protected

Checks if a particle has an interaction with a wall or other particles.

Definition at line 323 of file InsertionBoundary.h.

Referenced by checkBoundaryBeforeTimeStep(), getCheckParticleForInteraction(), InsertionBoundary(), read(), setCheckParticleForInteraction(), and write().

Mdouble InsertionBoundary::initialVolume_
protected
bool InsertionBoundary::isActivated_
protected

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).

Todo:
JMFT: This is currently not saved to .restart files.

Definition at line 293 of file InsertionBoundary.h.

Referenced by activate(), FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), checkBoundaryBeforeTimeStep(), deactivate(), InsertionBoundary(), isActivated(), read(), and write().

bool InsertionBoundary::isManuallyInserting_
protected

A flag to enable a top-down class-by-class manual insertion of a PSD; default is FALSE.

Definition at line 339 of file InsertionBoundary.h.

Referenced by generateParticle(), InsertionBoundary(), and setManualInsertion().

unsigned int InsertionBoundary::numberOfParticlesInserted_
protected
std::vector<PSD> InsertionBoundary::particleSizeDistributionVector_
protected

Defines a particle size distribution as an object of the PSD class; if particleSizeDistributionVector_ is empty, distribution_ is used instead.

Definition at line 329 of file InsertionBoundary.h.

Referenced by generateParticle(), getPSD(), InsertionBoundary(), read(), and write().

std::vector<BaseParticle*> InsertionBoundary::particleToCopy_
protected

write Distribution class to file.

read Distribution class from file.

Particle that will be inserted through the insertion boundary.

Definition at line 265 of file InsertionBoundary.h.

Referenced by FixedClusterInsertionBoundary::generateParticle(), generateParticle(), getParticleToCopy(), InsertionBoundary(), read(), setParticleToCopy(), write(), and ~InsertionBoundary().

std::vector<Mdouble> InsertionBoundary::probability_
protected

vector of probabilities in range [0,1] which determine the mixing ratio of partice size distributions.

Definition at line 344 of file InsertionBoundary.h.

Referenced by generateParticle(), InsertionBoundary(), read(), and write().

Mdouble InsertionBoundary::samplingInterval_
protected
std::vector<Mdouble> InsertionBoundary::variableCumulativeVolumeFlowRate_
protected

Defines a variable volume flow rate, taken at fixed sampling intervals; the values are cumulative; thus, we need to ensure the volume inserted before time t=n*samplingInterval is less than variableCumulativeVolumeFlowRate[n].

By default, this vector is empty; in that case, a constant volume flow rate will be used.

See also
volumeFlowRate_.

Definition at line 315 of file InsertionBoundary.h.

Referenced by InsertionBoundary(), insertParticle(), read(), setVariableVolumeFlowRate(), and write().

Vec3D InsertionBoundary::velMin_
protected
Mdouble InsertionBoundary::volumeFlowRate_
protected

The inflow can be controlled by setting a volume flow rate and an initial volume thus, this ensures the volume V inserted before time t is less than V = initialVolume_+volumeFlowRate_*t

The default value is volumeFlowRate_=inf, i.e. the volume is not controlled.

See also
To set a variable flow rate instead, see variableCumulativeVolumeFlowRate_.

Definition at line 304 of file InsertionBoundary.h.

Referenced by getVolumeFlowRate(), InsertionBoundary(), read(), setInitialVolume(), setVolumeFlowRate(), and write().


The documentation for this class was generated from the following files: