MercuryDPM  Beta
 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 ()
 Default constructor: set everything to 0/nullptr. More...
 
 InsertionBoundary (const InsertionBoundary &other)
 Copy constructor (with deep copy) More...
 
virtual ~InsertionBoundary ()
 Destructor: delete the particle that has to be copied at every insertion. More...
 
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. More...
 
virtual BaseParticlegenerateParticle (RNG &random)=0
 Purely virtual function that generates one particle. More...
 
virtual void checkBoundaryBeforeTimeStep (DPMBase *md)
 Fills the boundary with particles. More...
 
unsigned int getNumberOfParticlesInserted () const
 Gets the number of particles inserted by the boundary. More...
 
void setMaxFailed (unsigned int maxFailed)
 Sets the number of times that the wall may fail to insert a particle. More...
 
unsigned int getMaxFailed () const
 Gets the number of times that the boundary may fail to insert a particle. More...
 
void setParticleToCopy (BaseParticle *particleToCopy)
 Sets the particle that will be inserted through the insertion boundary. More...
 
BaseParticlegetParticleToCopy () const
 Gets the particle that will be inserted through the insertion boundary. More...
 
void read (std::istream &is)
 Reads the boundary's id_ and maxFailed_. More...
 
void write (std::ostream &os) const
 Writes the boundary's id_ and maxFailed_. More...
 
- Public Member Functions inherited from BaseBoundary
 BaseBoundary ()
 default constructor. More...
 
 BaseBoundary (const BaseBoundary &b)
 copy constructor More...
 
virtual ~BaseBoundary ()
 destructor More...
 
virtual BaseBoundarycopy () const =0
 Used to create a copy of the object NB: purely virtual function. More...
 
virtual void createPeriodicParticles (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
 Creates periodic copies of given particle in case of periodic boundaries. More...
 
virtual bool checkBoundaryAfterParticleMoved (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
 Checks if given particle passed the boundary. More...
 
virtual void checkBoundaryBeforeTimeStep (DPMBase *md UNUSED)
 Fills a (3D) boundary with particles. More...
 
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 constructor. More...
 
 BaseObject (const BaseObject &p)
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()
 virtual destructor More...
 
virtual std::string getName () const =0
 A purely virtual function. More...
 
virtual void moveInHandler (const unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (const unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (const unsigned int 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...
 

Private Attributes

BaseParticleparticleToCopy_
 Particle that will be inserted through the insertion boundary. 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...
 

Detailed Description

Boundary structure for boundaries used for insertion of particles.

Todo:
IFCD: Should operator= be implemented here and in the derived classes?

Definition at line 39 of file InsertionBoundary.h.

Constructor & Destructor Documentation

InsertionBoundary::InsertionBoundary ( )

Default constructor: set everything to 0/nullptr.

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

Definition at line 33 of file InsertionBoundary.cc.

References maxFailed_, numberOfParticlesInserted_, and particleToCopy_.

34 {
36  particleToCopy_ = nullptr;
37  maxFailed_ = 0;
38 }
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
InsertionBoundary::InsertionBoundary ( const InsertionBoundary other)

Copy constructor (with deep copy)

Copy constructor

Definition at line 43 of file InsertionBoundary.cc.

References BaseParticle::copy(), maxFailed_, numberOfParticlesInserted_, and particleToCopy_.

44 {
46  maxFailed_ = other.maxFailed_;
48 }
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
InsertionBoundary::~InsertionBoundary ( )
virtual

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 54 of file InsertionBoundary.cc.

References particleToCopy_.

55 {
56  delete particleToCopy_;
57 }
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.

Member Function Documentation

void InsertionBoundary::checkBoundaryBeforeTimeStep ( DPMBase md)
virtual

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"?

Definition at line 77 of file InsertionBoundary.cc.

References DPMBase::checkParticleForInteraction(), BaseHandler< T >::copyAndAddObject(), generateParticle(), maxFailed_, numberOfParticlesInserted_, DPMBase::particleHandler, and DPMBase::random.

78 {
79  unsigned int failed = 0;
80  BaseParticle* p0;
81  //try max_failed times to find new insertable particle
82  while (failed <= maxFailed_)
83  {
84  p0 = generateParticle(md->random);
85  //std::cout<<"Trying "<<*p0<<std::endl;
86 
87  if (md->checkParticleForInteraction(*p0))
88  {
90  failed = 0;
92  //std::cout<<"succes"<<std::endl;
93  }
94  else
95  {
96  failed++;
97  //std::cout<<"failure"<<std::endl;
98  }
99  //Irana: got rid of the delete, since it is not made with new (particle on stack instead of heap)
100  //delete p0;
101  }
102 }
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
virtual bool checkParticleForInteraction(const BaseParticle &P)
Checks if the particle having any interaction with walls or other particles.
Definition: DPMBase.cc:2353
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
virtual BaseParticle * generateParticle(RNG &random)=0
Purely virtual function that generates one particle.
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:873
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
virtual BaseParticle* InsertionBoundary::generateParticle ( RNG random)
pure virtual

Purely virtual function that generates one particle.

Parameters
[in]randomRandom number generator that can be used for initial positions and velocities
Todo:
(AT) think about implementation of this method here instead of in the children, since the checkBoundaryBeforeTimeStep (i.e., the actual insertion of particles) is also defined here. Current problem with this: boundary dimensions, which are needed for the particle placement, are now defined in the children, and depend heavily on its shape.

Implemented in HopperInsertionBoundary, CubeInsertionBoundary, and ChuteInsertionBoundary.

Referenced by checkBoundaryBeforeTimeStep().

unsigned int InsertionBoundary::getMaxFailed ( ) const

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

Return maxFailed_ (see InsertionBoundary::setMaxFailed).

Returns
the maximum number of particle insertion trials

Definition at line 127 of file InsertionBoundary.cc.

References maxFailed_.

128 {
129  return maxFailed_;
130 }
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 108 of file InsertionBoundary.cc.

References numberOfParticlesInserted_.

Referenced by Chute::write().

109 {
111 }
unsigned int numberOfParticlesInserted_
Number of particles that are already inserted.
BaseParticle * InsertionBoundary::getParticleToCopy ( ) const

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

returns pointer to the particle copies of which are to be inserted

Definition at line 144 of file InsertionBoundary.cc.

References particleToCopy_.

Referenced by ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), and HopperInsertionBoundary::generateParticle().

145 {
146  return particleToCopy_;
147 }
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.
void InsertionBoundary::read ( std::istream &  is)
virtual

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

Implements BaseBoundary.

Definition at line 153 of file InsertionBoundary.cc.

References maxFailed_, and BaseBoundary::read().

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

154 {
155  BaseBoundary::read(is);
156  std::string dummy;
157  is >> dummy >> maxFailed_;
158 }
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
void read(std::istream &is)=0
Reads the object's id_ from given istream NB: purely virtual function.
Definition: BaseBoundary.cc:67
void InsertionBoundary::set ( BaseParticle particleToCopy,
unsigned int  maxFailed 
)

Sets the particle that will be inserted and the maximum number of times for which insertion may fail.

Sets the particle that will be inserted and the maximum number of times for which insertion may fail.

Parameters
[in]particleToCopyParticle that will be copied and inserted in the domain
[in]maxFailedNumber of times that the wall may fail to insert a particle

Definition at line 65 of file InsertionBoundary.cc.

References BaseParticle::copy(), maxFailed_, and particleToCopy_.

66 {
67  particleToCopy_ = particleToCopy->copy();
68  maxFailed_ = maxFailed;
69 }
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
void InsertionBoundary::setMaxFailed ( unsigned int  maxFailed)

Sets the number of times that the wall may fail to insert a particle.

Sets the maximum number of times InsertionBoundary::checkBoundaryBeforeTimeStep() may try to insert a particle and fail, before the insertion of particles stops.

Parameters
[in]maxFailedthe maximum number of particle insertion trials

Definition at line 118 of file InsertionBoundary.cc.

References maxFailed_.

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

119 {
120  maxFailed_=maxFailed;
121 }
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.
void InsertionBoundary::setParticleToCopy ( BaseParticle particleToCopy)

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

Sets the pointer to the particle, copies of which are inserted

Parameters
[in]particleToCopypointer to the particle to be inserted

Definition at line 136 of file InsertionBoundary.cc.

References BaseParticle::copy(), and particleToCopy_.

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

137 {
138  particleToCopy_ = particleToCopy->copy();
139 }
BaseParticle * particleToCopy_
Particle that will be inserted through the insertion boundary.
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
void InsertionBoundary::write ( std::ostream &  os) const
virtual

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.

Definition at line 164 of file InsertionBoundary.cc.

References maxFailed_, and BaseBoundary::write().

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

165 {
167  os << " maxFailed " << maxFailed_;
168 }
void write(std::ostream &os) const =0
Adds object's id_ to given ostream NB: purely virtual function.
Definition: BaseBoundary.cc:76
unsigned int maxFailed_
Number of times that the wall may fail to insert a particle.

Member Data Documentation

unsigned int InsertionBoundary::maxFailed_
private

Number of times that the wall may fail to insert a particle.

Definition at line 122 of file InsertionBoundary.h.

Referenced by checkBoundaryBeforeTimeStep(), getMaxFailed(), InsertionBoundary(), read(), set(), setMaxFailed(), and write().

unsigned int InsertionBoundary::numberOfParticlesInserted_
private

Number of particles that are already inserted.

Definition at line 127 of file InsertionBoundary.h.

Referenced by checkBoundaryBeforeTimeStep(), getNumberOfParticlesInserted(), and InsertionBoundary().

BaseParticle* InsertionBoundary::particleToCopy_
private

Particle that will be inserted through the insertion boundary.

Definition at line 117 of file InsertionBoundary.h.

Referenced by getParticleToCopy(), InsertionBoundary(), set(), setParticleToCopy(), and ~InsertionBoundary().


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