MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BoundaryHandler Class Reference

Container to store pointers to all BaseBoundary objects. More...

#include <BoundaryHandler.h>

+ Inheritance diagram for BoundaryHandler:

Public Member Functions

 BoundaryHandler ()
 Default constructor, it creates an empty BoundaryHandler. More...
 
 BoundaryHandler (const BoundaryHandler &BH)
 Constructor that copies all BaseBoundary it contains and sets the other variables to 0/nullptr. More...
 
BoundaryHandler operator= (const BoundaryHandler &rhs)
 Assignment operator, copies only the vector of BaseBoundary and sets the other variables to 0/nullptr. More...
 
 ~BoundaryHandler ()
 Destructor, it destructs the BoundaryHandler and all BaseBoundary it contains. More...
 
void addObject (BaseBoundary *P)
 Adds a BaseBoundary to the BoundaryHandler. More...
 
void readObject (std::istream &is)
 Reads BaseBoundary into the BoundaryHandler from restart data. More...
 
void readOldObject (std::istream &is)
 Reads a periodic boundary from old-style restart data. More...
 
std::string getName () const
 Returns the name of the handler, namely the string "BoundaryHandler". More...
 
- Public Member Functions inherited from BaseHandler< BaseBoundary >
 BaseHandler ()
 Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More...
 
 BaseHandler (const BaseHandler< BaseBoundary > &BH)
 Constructor that copies the objects of the given handler into itself and sets other variables to 0/nullptr. More...
 
virtual ~BaseHandler ()
 Destructor, it destructs the BaseHandler and all Object it contains. More...
 
void copyContentsFromOtherHandler (const BaseHandler< BaseBoundary > &BH)
 Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handler (container) to the other. More...
 
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. More...
 
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. More...
 
virtual void removeObject (unsigned const int id)
 Removes an Object from the BaseHandler. More...
 
void removeLastObject ()
 Removes the last Object from the BaseHandler. More...
 
void clear ()
 Empties the whole BaseHandler by removing all Objects and setting all other variables to 0. More...
 
void read (std::istream &is)
 Reads all objects from restart data. More...
 
BaseBoundarygetObjectById (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler. More...
 
BaseBoundarygetObject (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler. More...
 
const BaseBoundarygetObject (const unsigned int id) const
 Gets a constant pointer to the Object at the specified index in the BaseHandler. More...
 
BaseBoundarygetLastObject ()
 Gets a pointer to the last Object in this BaseHandler. More...
 
const BaseBoundarygetLastObject () const
 Gets a constant pointer to the last Object in this BaseHandler. More...
 
unsigned int getNumberOfObjects () const
 Gets the number of Object in this BaseHandler. More...
 
unsigned int getStorageCapacity () const
 Gets the storage capacity of this BaseHandler. More...
 
void setStorageCapacity (const unsigned int N)
 Sets the storage capacity of this BaseHandler. More...
 
const std::vector
< BaseBoundary * >
::const_iterator 
begin () const
 Gets the begin of the const_iterator over all Object in this BaseHandler. More...
 
const std::vector
< BaseBoundary * >::iterator 
begin ()
 Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More...
 
const std::vector
< BaseBoundary * >
::const_iterator 
end () const
 Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More...
 
const std::vector
< BaseBoundary * >::iterator 
end ()
 Gets the end of the iterator over all BaseBoundary in this BaseHandler. More...
 
void setDPMBase (DPMBase *DPMBase)
 Sets the problem that is solved using this handler. More...
 
void setId (BaseBoundary *object, unsigned int id)
 This function sets the id and ensures that nextId is a bigger value than id. More...
 
DPMBasegetDPMBase ()
 Gets the problem that is solved using this handler. More...
 
DPMBasegetDPMBase () const
 Gets the problem that is solved using this handler and does not change the class. More...
 
virtual void writeVTK ()
 Over written in WallHandler and ParticleHandler. More...
 

Additional Inherited Members

- Protected Attributes inherited from BaseHandler< BaseBoundary >
std::vector< BaseBoundary * > objects_
 The actual list of Object pointers. More...
 

Detailed Description

Container to store pointers to all BaseBoundary objects.

The BoundaryHandler is a container to store all BaseBoundary. It is implemented by a vector of pointers to BaseBoundary.

Definition at line 38 of file BoundaryHandler.h.

Constructor & Destructor Documentation

BoundaryHandler::BoundaryHandler ( )

Default constructor, it creates an empty BoundaryHandler.

Constructor of the ParticleHandler class. It creates and empty ParticleHandler.

Definition at line 45 of file BoundaryHandler.cc.

References DEBUG, and logger.

46 {
47  logger(DEBUG, "BoundaryHandler::BoundaryHandler() finished");
48 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
BoundaryHandler::BoundaryHandler ( const BoundaryHandler BH)

Constructor that copies all BaseBoundary it contains and sets the other variables to 0/nullptr.

Parameters
[in]BHThe BoundaryHandler that has to be copied.

This is not a copy constructor! It just copies all BaseBoundary from the other handler into this handler, and clears all other variables.

Definition at line 55 of file BoundaryHandler.cc.

References BaseHandler< BaseBoundary >::copyContentsFromOtherHandler(), DEBUG, and logger.

57 {
59  logger(DEBUG, "BoundaryHandler::BoundaryHandler(const BoundaryHandler &BH) finished");
60 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void copyContentsFromOtherHandler(const BaseHandler< BaseBoundary > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
BoundaryHandler::~BoundaryHandler ( )

Destructor, it destructs the BoundaryHandler and all BaseBoundary it contains.

Default destructor. Note that the delete for all boundaries is done in the BaseHandler.

Definition at line 79 of file BoundaryHandler.cc.

References DEBUG, and logger.

80 {
81  logger(DEBUG, "BoundaryHandler::~BoundaryHandler() finished");
82 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

void BoundaryHandler::addObject ( BaseBoundary P)
virtual

Adds a BaseBoundary to the BoundaryHandler.

Parameters
[in]PA pointer to the BaseBoundary (or derived class) that has to be added. Add the object and tell the object that this is his handler.

Reimplemented from BaseHandler< BaseBoundary >.

Definition at line 86 of file BoundaryHandler.cc.

References BaseHandler< T >::addObject(), and BaseBoundary::setHandler().

87 {
88  //Puts the particle in the Particle list
90  //set the particleHandler pointer
91  P->setHandler(this);
92 }
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:313
std::string BoundaryHandler::getName ( ) const
virtual

Returns the name of the handler, namely the string "BoundaryHandler".

Returns
The string "BoundaryHandler"

Implements BaseHandler< BaseBoundary >.

Definition at line 183 of file BoundaryHandler.cc.

184 {
185  return "BoundaryHandler";
186 }
BoundaryHandler BoundaryHandler::operator= ( const BoundaryHandler rhs)

Assignment operator, copies only the vector of BaseBoundary and sets the other variables to 0/nullptr.

Parameters
[in]rhsThe BoundaryHandler on the right hand side of the assignment.

This is not a copy assignment operator! It just copies all BaseBoundary from the other handler into this handler, and clears all other variables.

Definition at line 67 of file BoundaryHandler.cc.

References BaseHandler< BaseBoundary >::clear(), BaseHandler< BaseBoundary >::copyContentsFromOtherHandler(), DEBUG, and logger.

68 {
69  if (this != &rhs)
70  {
71  clear();
73  }
74  logger(DEBUG, "BoundaryHandler BoundaryHandler::operator =(const BoundaryHandler& rhs)");
75  return *this;
76 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void copyContentsFromOtherHandler(const BaseHandler< BaseBoundary > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
void BoundaryHandler::readObject ( std::istream &  is)
virtual

Reads BaseBoundary into the BoundaryHandler from restart data.

Parameters
[in]isThe input stream from which the information is read. First read the type of boundary, then compare the type to all existing types. When the correct type is found, read it with the >> operator, copy it and add it to the handler.

Implements BaseHandler< BaseBoundary >.

Definition at line 97 of file BoundaryHandler.cc.

References BaseHandler< BaseBoundary >::copyAndAddObject(), DEBUG, ERROR, logger, and readOldObject().

Referenced by DPMBase::read().

98 {
99  //Note that compare returns 0 if the strings are the same.
100  std::string type;
101  is >> type;
102  logger.log(Log::DEBUG, "BoundaryHandler::readObject(is): restarting a boundary of type %.", type);
103  if (type == "AngledPeriodicBoundary")
104  {
106  is >> AngledPeriodicBoundary;
107  copyAndAddObject(AngledPeriodicBoundary);
108  }
109  else if (type == "ChuteInsertionBoundary")
110  {
111  ChuteInsertionBoundary chuteInsertionBoundary;
112  is >> chuteInsertionBoundary;
113  copyAndAddObject(chuteInsertionBoundary);
114  }
115  else if (type == "CubeInsertionBoundary")
116  {
117  CubeInsertionBoundary cubeInsertionBoundary;
118  is >> cubeInsertionBoundary;
119  copyAndAddObject(cubeInsertionBoundary);
120  }
121  else if (type == "CircularPeriodicBoundary")
122  {
123  CircularPeriodicBoundary circularPeriodicBoundary;
124  is >> circularPeriodicBoundary;
125  copyAndAddObject(circularPeriodicBoundary);
126  }
127  else if (type == "DeletionBoundary")
128  {
129  DeletionBoundary deletionBoundary;
130  is >> deletionBoundary;
131  copyAndAddObject(deletionBoundary);
132  }
133  else if (type == "HopperInsertionBoundary")
134  {
135  HopperInsertionBoundary hopperInsertionBoundary;
136  is >> hopperInsertionBoundary;
137  copyAndAddObject(hopperInsertionBoundary);
138  }
139  else if (type == "PeriodicBoundary")
140  {
141  PeriodicBoundary periodicBoundary;
142  is >> periodicBoundary;
143  copyAndAddObject(periodicBoundary);
144  }
145  else if (type.compare("LeesEdwardsBoundary") == 0)
146  {
147  LeesEdwardsBoundary leesEdwardsBoundary;
148  is >> leesEdwardsBoundary;
149  copyAndAddObject(leesEdwardsBoundary);
150  }
151  //for backward compatibility (before svnversion ~2360)
152  else if (type == "normal")
153  {
154  readOldObject(is);
155  }
156  else
157  {
158  logger(ERROR, "Boundary type: % not understood in restart file.", type);
159  }
160 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void readOldObject(std::istream &is)
Reads a periodic boundary from old-style restart data.
Used for removing particles from the problem. Inherits from BaseBoundary.
used to create a circular periodic boundary
Defines a pair of periodic walls. Inherits from BaseBoundary.
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
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.
Inherits from InsertionBoundary Some images are useful to better understand the structure of both the...
Used for modeling chute inflow. Inherits from InsertionBoundary.
void BoundaryHandler::readOldObject ( std::istream &  is)

Reads a periodic boundary from old-style restart data.

Parameters
[in]isThe input stream from which the information is read. Get the normal, position left and position right for a periodic boundary from the stream is, and construct a new periodic boundary from it. The boundaries that are written like that are outdated, this function is there for backward compatability.

Definition at line 166 of file BoundaryHandler.cc.

References BaseHandler< BaseBoundary >::copyAndAddObject(), helpers::getLineFromStringStream(), and PeriodicBoundary::set().

Referenced by readObject().

167 {
168  //read in next line
169  std::stringstream line(std::stringstream::in | std::stringstream::out);
171 
172  std::string dummy;
173  Vec3D normal;
174  Mdouble positionLeft, positionRight;
175 
176  PeriodicBoundary periodicBoundary;
177  line >> normal >> dummy >> positionLeft >> dummy >> positionRight;
178  periodicBoundary.set(normal, positionLeft, positionRight);
179  copyAndAddObject(periodicBoundary);
180 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
double Mdouble
Defines a pair of periodic walls. Inherits from BaseBoundary.
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
Definition: Helpers.cc:396
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.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45

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