MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BoundaryHandler Class Referencefinal

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...
 
BoundaryHandleroperator= (const BoundaryHandler &rhs)
 Assignment operator, copies only the vector of BaseBoundary and sets the other variables to 0/nullptr. More...
 
 ~BoundaryHandler () final
 Destructor, it destructs the BoundaryHandler and all BaseBoundary it contains. More...
 
void addObject (BaseBoundary *P) final
 Adds a BaseBoundary to the BoundaryHandler. More...
 
void readAndAddObject (std::istream &is) final
 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 final
 Returns the name of the handler, namely the string "BoundaryHandler". More...
 
void boundaryActionsBeforeTimeLoop ()
 
void setWriteVTK (bool writeVTK)
 
bool getWriteVTK () const
 
- 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...
 
std::enable_if
<!std::is_pointer< U >::value,
U * >::type 
copyAndAddGhostObject (const U &object)
 Creates a copy of a Object and adds it to the BaseHandler. This is one locally for inserting mpi particles, they avoid the global check if the particle can actually be inserted, because the mpi domain already knows that is the case. More...
 
std::enable_if
< std::is_pointer< U >::value,
U >::type 
copyAndAddGhostObject (const U object)
 Creates a copy of a Object and adds it to the BaseHandler. This is one locally for inserting mpi particles, they avoid the global check if the particle can actually be inserted, because the mpi domain already knows that is the case. More...
 
virtual void addExistingObject (BaseBoundary *O)
 Adds an existing object to the BaseHandler without changing the id of the object. More...
 
virtual void addGhostObject (BaseBoundary *O)
 Adds a new Object to the BaseHandler. called by the to avoid increasing the id. More...
 
void removeIf (const std::function< bool(BaseBoundary *)> cond)
 
virtual void removeObject (unsigned const int index)
 Removes an Object from the BaseHandler. More...
 
void removeLastObject ()
 Removes the last Object from the BaseHandler. More...
 
virtual 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...
 
std::vector< BaseBoundary * > getObjectsById (const unsigned int id)
 Gets a vector of pointers to the objects with the specific id. 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...
 
virtual unsigned int getNumberOfObjects () const
 Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) More...
 
unsigned int getSize () const
 Gets the size of the particleHandler (including mpi and periodic particles) 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...
 
void resize (const unsigned int N, const BaseBoundary &obj)
 Resizes the container to contain N elements. 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...
 
void increaseId ()
 
unsigned int getNextId ()
 
void setNextId (unsigned int id)
 
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 () const
 now empty function for writing VTK files. More...
 
unsigned getNextGroupId ()
 Should be called each time you assign a groupId. Returns the value of nextGroupId_ and increases nextGroupId_ by one. More...
 

Static Public Member Functions

static BaseBoundarycreateObject (const std::string &type)
 

Private Attributes

bool writeVTK_
 

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 BoundaryHandler class. It creates and empty BoundaryHandler.

Definition at line 50 of file BoundaryHandler.cc.

References DEBUG, logger, and writeVTK_.

51 {
52  writeVTK_ = false;
53  logger(DEBUG, "BoundaryHandler::BoundaryHandler() finished");
54 }
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 61 of file BoundaryHandler.cc.

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

63 {
64  writeVTK_ = BH.writeVTK_;
66  logger(DEBUG, "BoundaryHandler::BoundaryHandler(const BoundaryHandler &BH) finished");
67 }
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 ( )
final

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 87 of file BoundaryHandler.cc.

References DEBUG, and logger.

88 {
89  logger(DEBUG, "BoundaryHandler::~BoundaryHandler() finished");
90 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

void BoundaryHandler::addObject ( BaseBoundary P)
finalvirtual

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 94 of file BoundaryHandler.cc.

References PeriodicBoundaryHandler::addObject(), BaseHandler< T >::addObject(), BaseHandler< BaseBoundary >::getDPMBase(), DPMBase::periodicBoundaryHandler, and BaseBoundary::setHandler().

Referenced by readAndAddObject().

95 {
96  //Puts the boundary in the Boundary list
98  //set the handler pointer
99  P->setHandler(this);
100 
101 #ifdef MERCURY_USE_MPI
102  //Different manner of treating periodic boundaries in MPI: hence there is a periodicBoundaryHandler
103  BasePeriodicBoundary* upcast = dynamic_cast<BasePeriodicBoundary*>(P);
104  if (upcast != nullptr)
105  {
107  }
108 #endif
109 
110 }
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:431
void addObject(BasePeriodicBoundary *P) override
Adds a BasePeriodicBoundary to the PeriodicBoundaryHandler.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void BoundaryHandler::boundaryActionsBeforeTimeLoop ( )

Definition at line 261 of file BoundaryHandler.cc.

References BaseHandler< BaseBoundary >::objects_.

Referenced by DPMBase::solve().

262 {
263  for (BaseBoundary* b : objects_)
264  {
265  b->actionsBeforeTimeLoop();
266  }
267 }
std::vector< BaseBoundary * > objects_
The actual list of Object pointers.
Definition: BaseHandler.h:302
BaseBoundary * BoundaryHandler::createObject ( const std::string &  type)
static

Definition at line 112 of file BoundaryHandler.cc.

References logger, and WARN.

Referenced by readAndAddObject().

113 {
114  //Note that compare returns 0 if the strings are the same.
115  if (type == "AngledPeriodicBoundary")
116  {
117  return new AngledPeriodicBoundary;
118  }
119  else if (type == "ChuteInsertionBoundary")
120  {
121  return new ChuteInsertionBoundary;
122  }
123  else if (type == "CubeInsertionBoundary")
124  {
125  return new CubeInsertionBoundary;
126  }
127  else if (type == "CubeDeletionBoundary")
128  {
129  return new CubeDeletionBoundary;
130  }
131  else if (type == "CircularPeriodicBoundary")
132  {
133  return new CircularPeriodicBoundary;
134  }
135  else if (type == "DeletionBoundary")
136  {
137  return new DeletionBoundary;
138  }
139  else if (type == "HopperInsertionBoundary")
140  {
141  return new HopperInsertionBoundary;
142  }
143  else if (type == "PeriodicBoundary")
144  {
145  return new PeriodicBoundary;
146  }
147  else if (type == "ConstantMassFlowMaserBoundary" || type == "MaserBoundary")
148  {
150  }
151  else if (type == "SubcriticalMaserBoundary")
152  {
153  return new SubcriticalMaserBoundary;
154  }
155  else if (type == "SubcriticalMaserBoundaryTEST")
156  {
157  return new SubcriticalMaserBoundaryTEST;
158  }
159  else if (type == "LeesEdwardsBoundary")
160  {
161  return new LeesEdwardsBoundary;
162  }
163  else if (type == "MPIDomainBoundary")
164  {
165  return new PeriodicBoundary;
166  }
167  else if (type == "FluxBoundary")
168  {
169  return new FluxBoundary;
170  }
171  else if (type == "HeaterBoundary")
172  {
173  return new HeaterBoundary;
174  }
175  else if (type == "StressStrainControlBoundary")
176  {
177  return new StressStrainControlBoundary;
178  }
179  else if (type == "BaseClusterInsertionBoundary")
180  {
181  return new BaseClusterInsertionBoundary;
182  }
183  else if (type == "RandomClusterInsertionBoundary")
184  {
186  }
187  else if (type == "FixedClusterInsertionBoundary")
188  {
190  }
191  else if (type == "DropletBoundary")
192  {
193  return new DropletBoundary;
194  }
195  else if (type == "normal") //for backward compatibility (before svnversion ~2360)
196  {
197  return new PeriodicBoundary;
198  }
199  else
200  {
201  logger(WARN, "Boundary type: % not understood in restart file.", type);
202  return nullptr;
203  }
204 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Used for removing particles from the problem. Inherits from BaseBoundary. By default, a plane that deletes everything past it, but there are derived classes such as CubeDeletionBoundary.
Variation on the PeriodicBoundary which also has an outflow part.
used to create a circular periodic boundary
Defines a pair of periodic walls. Inherits from BaseBoundary.
Variation on the PeriodicBoundary which also has an outflow part.
Used for measuring flow rates through a given plane; acts like a pair of scales Inherits from BaseBou...
Definition: FluxBoundary.h:41
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
A cuboid box consists of periodic boundaries that can be strain/stress controlled and achieve differe...
Inherits from InsertionBoundary Some images are useful to better understand the structure of both the...
Used for modeling chute inflow. Inherits from InsertionBoundary.
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
std::string BoundaryHandler::getName ( ) const
finalvirtual

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

Returns
The string "BoundaryHandler"

Implements BaseHandler< BaseBoundary >.

Definition at line 256 of file BoundaryHandler.cc.

257 {
258  return "BoundaryHandler";
259 }
bool BoundaryHandler::getWriteVTK ( ) const
inline

Definition at line 90 of file BoundaryHandler.h.

References writeVTK_.

Referenced by DPMBase::writeVTKFiles().

90 { return writeVTK_; }
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 74 of file BoundaryHandler.cc.

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

75 {
76  if (this != &rhs)
77  {
78  clear();
80  }
81  logger(DEBUG, "BoundaryHandler BoundaryHandler::operator =(const BoundaryHandler& rhs)");
82 
83  return *this;
84 }
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...
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
void BoundaryHandler::readAndAddObject ( std::istream &  is)
finalvirtual

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 209 of file BoundaryHandler.cc.

References addObject(), createObject(), logger, readOldObject(), BaseBoundary::setHandler(), VERBOSE, and WARN.

Referenced by DPMBase::read().

210 {
211  //Note that compare returns 0 if the strings are the same.
212  std::string type;
213  is >> type;
214  logger(VERBOSE, "BoundaryHandler::readAndAddObject(is): restarting a boundary of type %.", type);
215  if (type == "normal")
216  {
217  readOldObject(is);
218  }
219  else
220  {
221  BaseBoundary* boundary = createObject(type);
222  if (boundary == nullptr)
223  {
224  std::string line;
225  getline(is, line);
226  logger(WARN, "This boundary could not be read and is ignored:\n%%", type, line);
227  return;
228  }
229  boundary->setHandler(this);
230  is >> *boundary;
231  addObject(boundary);
232  }
233 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void readOldObject(std::istream &is)
Reads a periodic boundary from old-style restart data.
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
static BaseBoundary * createObject(const std::string &type)
void addObject(BaseBoundary *P) final
Adds a BaseBoundary to the BoundaryHandler.
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 239 of file BoundaryHandler.cc.

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

Referenced by readAndAddObject().

240 {
241  //read in next line
242  std::stringstream line;
244 
245  std::string dummy;
246  Vec3D normal;
247  Mdouble positionLeft, positionRight;
248 
249  PeriodicBoundary periodicBoundary;
250  line >> normal >> dummy >> positionLeft >> dummy >> positionRight;
251  periodicBoundary.set(normal, positionLeft, positionRight);
252  copyAndAddObject(periodicBoundary);
253 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
double Mdouble
Definition: GeneralDefine.h:34
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:424
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: Vector.h:49
void BoundaryHandler::setWriteVTK ( bool  writeVTK)
inline

Definition at line 88 of file BoundaryHandler.h.

References BaseHandler< BaseBoundary >::writeVTK(), and writeVTK_.

Referenced by DPMBase::read().

88 { writeVTK_ = writeVTK; }
virtual void writeVTK() const
now empty function for writing VTK files.
Definition: BaseHandler.h:286

Member Data Documentation

bool BoundaryHandler::writeVTK_
private

Definition at line 86 of file BoundaryHandler.h.

Referenced by BoundaryHandler(), getWriteVTK(), and setWriteVTK().


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