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 addObject (BaseBoundary *object)
 Adds a new Object to the BaseHandler. 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)
 
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.

Constructor & Destructor Documentation

◆ BoundaryHandler() [1/2]

BoundaryHandler::BoundaryHandler ( )

Default constructor, it creates an empty BoundaryHandler.

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

51 {
52  writeVTK_ = false;
53  logger(DEBUG, "BoundaryHandler::BoundaryHandler() finished");
54 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG
bool writeVTK_
Definition: BoundaryHandler.h:86

References DEBUG, logger, and writeVTK_.

◆ BoundaryHandler() [2/2]

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.

63 {
64  writeVTK_ = BH.writeVTK_;
66  logger(DEBUG, "BoundaryHandler::BoundaryHandler(const BoundaryHandler &BH) finished");
67 }
void copyContentsFromOtherHandler(const BaseHandler< BaseBoundary > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
Definition: BaseHandler.h:367

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

◆ ~BoundaryHandler()

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.

88 {
89  logger(DEBUG, "BoundaryHandler::~BoundaryHandler() finished");
90 }

References DEBUG, and logger.

Member Function Documentation

◆ addObject()

void BoundaryHandler::addObject ( BaseBoundary P)
final

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.
95 {
96  //Puts the boundary in the Boundary list
98  //set the handler pointer
99  P->setHandler(this);
100 
101 #ifdef MERCURYDPM_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 }
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:431
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Definition: BasePeriodicBoundary.h:41
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1457
void addObject(BasePeriodicBoundary *P) override
Adds a BasePeriodicBoundary to the PeriodicBoundaryHandler.
Definition: PeriodicBoundaryHandler.cc:90
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73

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

Referenced by readAndAddObject(), Chutebelt::setupInitialConditions(), and InsertionBoundarySelfTest::setupInitialConditions().

◆ boundaryActionsBeforeTimeLoop()

void BoundaryHandler::boundaryActionsBeforeTimeLoop ( )
262 {
263  for (BaseBoundary* b : objects_)
264  {
265  b->actionsBeforeTimeLoop();
266  }
267 }
Definition: BaseBoundary.h:49
std::vector< BaseBoundary * > objects_
The actual list of Object pointers.
Definition: BaseHandler.h:302

References BaseHandler< BaseBoundary >::objects_.

Referenced by DPMBase::initialiseSolve().

◆ createObject()

BaseBoundary * BoundaryHandler::createObject ( const std::string &  type)
static
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 }
@ WARN
Definition: AngledPeriodicBoundary.h:47
Definition: BaseClusterInsertionBoundary.h:47
Used for modeling chute inflow. Inherits from InsertionBoundary.
Definition: ChuteInsertionBoundary.h:41
used to create a circular periodic boundary
Definition: CircularPeriodicBoundary.h:40
Variation on the PeriodicBoundary which also has an outflow part.
Definition: ConstantMassFlowMaserBoundary.h:92
Definition: CubeDeletionBoundary.h:38
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Definition: CubeInsertionBoundary.h:42
Used for removing particles from the problem. Inherits from BaseBoundary. By default,...
Definition: DeletionBoundary.h:44
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
Definition: DropletBoundary.h:26
Definition: FixedClusterInsertionBoundary.h:39
Used for measuring flow rates through a given plane; acts like a pair of scales Inherits from BaseBou...
Definition: FluxBoundary.h:42
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
Definition: HeaterBoundary.h:50
Inherits from InsertionBoundary Some images are useful to better understand the structure of both the...
Definition: HopperInsertionBoundary.h:49
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Definition: LeesEdwardsBoundary.h:47
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
Definition: RandomClusterInsertionBoundary.h:39
A cuboid box consists of periodic boundaries that can be strain/stress controlled and achieve differe...
Definition: StressStrainControlBoundary.h:55
Definition: SubcriticalMaserBoundaryTEST.h:36
Variation on the PeriodicBoundary which also has an outflow part.
Definition: SubcriticalMaserBoundary.h:78

References logger, and WARN.

Referenced by readAndAddObject().

◆ getName()

std::string BoundaryHandler::getName ( ) const
finalvirtual

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

Returns
The string "BoundaryHandler"

Implements BaseHandler< BaseBoundary >.

257 {
258  return "BoundaryHandler";
259 }

◆ getWriteVTK()

bool BoundaryHandler::getWriteVTK ( ) const
inline
90 { return writeVTK_; }

References writeVTK_.

Referenced by DPMBase::write(), and DPMBase::writeVTKFiles().

◆ operator=()

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.

75 {
76  if (this != &rhs)
77  {
78  clear();
80  }
81  logger(DEBUG, "BoundaryHandler BoundaryHandler::operator =(const BoundaryHandler& rhs)");
82 
83  return *this;
84 }
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:528

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

◆ readAndAddObject()

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

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 }
@ VERBOSE
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:134
void addObject(BaseBoundary *P) final
Adds a BaseBoundary to the BoundaryHandler.
Definition: BoundaryHandler.cc:94
static BaseBoundary * createObject(const std::string &type)
Definition: BoundaryHandler.cc:112
void readOldObject(std::istream &is)
Reads a periodic boundary from old-style restart data.
Definition: BoundaryHandler.cc:239

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

Referenced by DPMBase::read().

◆ readOldObject()

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.
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 }
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
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84
Definition: Vector.h:51
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in.
Definition: StringHelpers.cc:62

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

Referenced by readAndAddObject().

◆ setWriteVTK()

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

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

Referenced by DPMBase::read(), NozzleDemo::setupInitialConditions(), and NozzleSelfTest::setupInitialConditions().

Member Data Documentation

◆ writeVTK_

bool BoundaryHandler::writeVTK_
private

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