MercuryDPM  Beta
 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...
 
U * copyAndAddObject (const U &O)
 Creates a copy of a Object and adds it to the BaseHandler. More...
 
U * copyAndAddObject (U *O)
 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...
 
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...
 

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 *O)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:284
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 182 of file BoundaryHandler.cc.

183 {
184  return "BoundaryHandler";
185 }
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(), 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  if (type == "AngledPeriodicBoundary")
103  {
105  is >> AngledPeriodicBoundary;
106  copyAndAddObject(AngledPeriodicBoundary);
107  }
108  else if (type == "ChuteInsertionBoundary")
109  {
110  ChuteInsertionBoundary chuteInsertionBoundary;
111  is >> chuteInsertionBoundary;
112  copyAndAddObject(chuteInsertionBoundary);
113  }
114  else if (type == "CubeInsertionBoundary")
115  {
116  CubeInsertionBoundary cubeInsertionBoundary;
117  is >> cubeInsertionBoundary;
118  copyAndAddObject(cubeInsertionBoundary);
119  }
120  else if (type == "CircularPeriodicBoundary")
121  {
122  CircularPeriodicBoundary circularPeriodicBoundary;
123  is >> circularPeriodicBoundary;
124  copyAndAddObject(circularPeriodicBoundary);
125  }
126  else if (type == "DeletionBoundary")
127  {
128  DeletionBoundary deletionBoundary;
129  is >> deletionBoundary;
130  copyAndAddObject(deletionBoundary);
131  }
132  else if (type == "HopperInsertionBoundary")
133  {
134  HopperInsertionBoundary hopperInsertionBoundary;
135  is >> hopperInsertionBoundary;
136  copyAndAddObject(hopperInsertionBoundary);
137  }
138  else if (type == "PeriodicBoundary")
139  {
140  PeriodicBoundary periodicBoundary;
141  is >> periodicBoundary;
142  copyAndAddObject(periodicBoundary);
143  }
144  else if (type.compare("LeesEdwardsBoundary") == 0)
145  {
146  LeesEdwardsBoundary leesEdwardsBoundary;
147  is >> leesEdwardsBoundary;
148  copyAndAddObject(leesEdwardsBoundary);
149  }
150  //for backward compatibility (before svnversion ~2360)
151  else if (type == "normal")
152  {
153  readOldObject(is);
154  }
155  else
156  {
157  logger(ERROR, "Boundary type: % not understood in restart file.", type);
158  }
159 }
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...
U * copyAndAddObject(const U &O)
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 165 of file BoundaryHandler.cc.

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

Referenced by readObject().

166 {
167  //read in next line
168  std::stringstream line(std::stringstream::in | std::stringstream::out);
170 
171  std::string dummy;
172  Vec3D normal;
173  Mdouble positionLeft, positionRight;
174 
175  PeriodicBoundary periodicBoundary;
176  line >> normal >> dummy >> positionLeft >> dummy >> positionRight;
177  periodicBoundary.set(normal, positionLeft, positionRight);
178  copyAndAddObject(periodicBoundary);
179 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
double Mdouble
Defines a pair of periodic walls. Inherits from BaseBoundary.
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
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:389
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45

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