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...
 
virtual void removeObjects (std::vector< unsigned int > indices)
 
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.

30 {
31  writeVTK_ = false;
32  logger(DEBUG, "BoundaryHandler::BoundaryHandler() finished");
33 }
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:64

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.

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

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.

67 {
68  logger(DEBUG, "BoundaryHandler::~BoundaryHandler() finished");
69 }

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.
74 {
75  //Puts the boundary in the Boundary list
77  //set the handler pointer
78  P->setHandler(this);
79 
80 #ifdef MERCURYDPM_USE_MPI
81  //Different manner of treating periodic boundaries in MPI: hence there is a periodicBoundaryHandler
82  BasePeriodicBoundary* upcast = dynamic_cast<BasePeriodicBoundary*>(P);
83  if (upcast != nullptr)
84  {
86  }
87 #endif
88 
89 }
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:412
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
Definition: BasePeriodicBoundary.h:20
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1463
void addObject(BasePeriodicBoundary *P) override
Adds a BasePeriodicBoundary to the PeriodicBoundaryHandler.
Definition: PeriodicBoundaryHandler.cc:68
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77

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 ( )
241 {
242  for (BaseBoundary* b : objects_)
243  {
244  b->actionsBeforeTimeLoop();
245  }
246 }
Scalar * b
Definition: benchVecAdd.cpp:17
Definition: BaseBoundary.h:28
std::vector< BaseBoundary * > objects_
The actual list of Object pointers.
Definition: BaseHandler.h:283

References b, and BaseHandler< BaseBoundary >::objects_.

Referenced by DPMBase::initialiseSolve().

◆ createObject()

BaseBoundary * BoundaryHandler::createObject ( const std::string &  type)
static
92 {
93  //Note that compare returns 0 if the strings are the same.
94  if (type == "AngledPeriodicBoundary")
95  {
96  return new AngledPeriodicBoundary;
97  }
98  else if (type == "ChuteInsertionBoundary")
99  {
100  return new ChuteInsertionBoundary;
101  }
102  else if (type == "CubeInsertionBoundary")
103  {
104  return new CubeInsertionBoundary;
105  }
106  else if (type == "CubeDeletionBoundary")
107  {
108  return new CubeDeletionBoundary;
109  }
110  else if (type == "CircularPeriodicBoundary")
111  {
112  return new CircularPeriodicBoundary;
113  }
114  else if (type == "DeletionBoundary")
115  {
116  return new DeletionBoundary;
117  }
118  else if (type == "HopperInsertionBoundary")
119  {
120  return new HopperInsertionBoundary;
121  }
122  else if (type == "PeriodicBoundary")
123  {
124  return new PeriodicBoundary;
125  }
126  else if (type == "ConstantMassFlowMaserBoundary" || type == "MaserBoundary")
127  {
129  }
130  else if (type == "SubcriticalMaserBoundary")
131  {
132  return new SubcriticalMaserBoundary;
133  }
134  else if (type == "SubcriticalMaserBoundaryTEST")
135  {
136  return new SubcriticalMaserBoundaryTEST;
137  }
138  else if (type == "LeesEdwardsBoundary")
139  {
140  return new LeesEdwardsBoundary;
141  }
142  else if (type == "MPIDomainBoundary")
143  {
144  return new PeriodicBoundary;
145  }
146  else if (type == "FluxBoundary")
147  {
148  return new FluxBoundary;
149  }
150  else if (type == "HeaterBoundary")
151  {
152  return new HeaterBoundary;
153  }
154  else if (type == "StressStrainControlBoundary")
155  {
156  return new StressStrainControlBoundary;
157  }
158  else if (type == "BaseClusterInsertionBoundary")
159  {
160  return new BaseClusterInsertionBoundary;
161  }
162  else if (type == "RandomClusterInsertionBoundary")
163  {
165  }
166  else if (type == "FixedClusterInsertionBoundary")
167  {
169  }
170  else if (type == "DropletBoundary")
171  {
172  return new DropletBoundary;
173  }
174  else if (type == "normal") //for backward compatibility (before svnversion ~2360)
175  {
176  return new PeriodicBoundary;
177  }
178  else
179  {
180  logger(WARN, "Boundary type: % not understood in restart file.", type);
181  return nullptr;
182  }
183 }
@ WARN
Definition: AngledPeriodicBoundary.h:25
Definition: BaseClusterInsertionBoundary.h:26
Used for modeling chute inflow. Inherits from InsertionBoundary.
Definition: ChuteInsertionBoundary.h:20
used to create a circular periodic boundary
Definition: CircularPeriodicBoundary.h:19
Variation on the PeriodicBoundary which also has an outflow part.
Definition: ConstantMassFlowMaserBoundary.h:70
Definition: CubeDeletionBoundary.h:17
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Definition: CubeInsertionBoundary.h:21
Used for removing particles from the problem. Inherits from BaseBoundary. By default,...
Definition: DeletionBoundary.h:23
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
Definition: DropletBoundary.h:30
Definition: FixedClusterInsertionBoundary.h:18
Used for measuring flow rates through a given plane; acts like a pair of scales Inherits from BaseBou...
Definition: FluxBoundary.h:23
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
Definition: HeaterBoundary.h:29
Inherits from InsertionBoundary Some images are useful to better understand the structure of both the...
Definition: HopperInsertionBoundary.h:28
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Definition: LeesEdwardsBoundary.h:26
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:20
Definition: RandomClusterInsertionBoundary.h:18
A cuboid box consists of periodic boundaries that can be strain/stress controlled and achieve differe...
Definition: StressStrainControlBoundary.h:34
Definition: SubcriticalMaserBoundaryTEST.h:14
Variation on the PeriodicBoundary which also has an outflow part.
Definition: SubcriticalMaserBoundary.h:56
type
Definition: compute_granudrum_aor.py:141

References logger, compute_granudrum_aor::type, 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 >.

236 {
237  return "BoundaryHandler";
238 }

◆ getWriteVTK()

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

References writeVTK_.

Referenced by DPMBase::initialiseVTK(), 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.

54 {
55  if (this != &rhs)
56  {
57  clear();
59  }
60  logger(DEBUG, "BoundaryHandler BoundaryHandler::operator =(const BoundaryHandler& rhs)");
61 
62  return *this;
63 }
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:536

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

189 {
190  //Note that compare returns 0 if the strings are the same.
192  is >> type;
193  logger(VERBOSE, "BoundaryHandler::readAndAddObject(is): restarting a boundary of type %.", type);
194  if (type == "normal")
195  {
196  readOldObject(is);
197  }
198  else
199  {
200  BaseBoundary* boundary = createObject(type);
201  if (boundary == nullptr)
202  {
204  getline(is, line);
205  logger(WARN, "This boundary could not be read and is ignored:\n%%", type, line);
206  return;
207  }
208  boundary->setHandler(this);
209  is >> *boundary;
210  addObject(boundary);
211  }
212 }
@ VERBOSE
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:113
void addObject(BaseBoundary *P) final
Adds a BaseBoundary to the BoundaryHandler.
Definition: BoundaryHandler.cc:73
static BaseBoundary * createObject(const std::string &type)
Definition: BoundaryHandler.cc:91
void readOldObject(std::istream &is)
Reads a periodic boundary from old-style restart data.
Definition: BoundaryHandler.cc:218
line
Definition: calibrate.py:103
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References addObject(), createObject(), calibrate::line, logger, readOldObject(), BaseBoundary::setHandler(), oomph::Global_string_for_annotation::string(), compute_granudrum_aor::type, 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.
219 {
220  //read in next line
221  std::stringstream line;
223 
224  std::string dummy;
225  Vec3D normal;
226  Mdouble positionLeft, positionRight;
227 
228  PeriodicBoundary periodicBoundary;
229  line >> normal >> dummy >> positionLeft >> dummy >> positionRight;
230  periodicBoundary.set(normal, positionLeft, positionRight);
231  copyAndAddObject(periodicBoundary);
232 }
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:360
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:63
Definition: Kernel/Math/Vector.h:30
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
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:41

References BaseHandler< BaseBoundary >::copyAndAddObject(), helpers::getLineFromStringStream(), calibrate::line, WallFunction::normal(), PeriodicBoundary::set(), and oomph::Global_string_for_annotation::string().

Referenced by readAndAddObject().

◆ setWriteVTK()

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

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

Referenced by main(), 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: