MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WallHandler Class Reference

Container to store all BaseWall. More...

#include <WallHandler.h>

+ Inheritance diagram for WallHandler:

Public Member Functions

 WallHandler ()
 Default constructor, it creates an empty WallHandler. More...
 
 WallHandler (const WallHandler &BH)
 Constructor that copies a pointer to the DPMBase and all BaseWall in the given WallHandler. More...
 
WallHandler operator= (const WallHandler &rhs)
 Assignment operator that copies the pointer to the DPMBase and all BaseWall in the given WallHandler. More...
 
 ~WallHandler ()
 Destructor, it destructs the WallHandler and all BaseWall it contains. More...
 
void addObject (BaseWall *W)
 Adds a BaseWall to the WallHandler. More...
 
void readObject (std::istream &is)
 Reads BaseWall into the WallHandler from restart data. More...
 
void readOldObject (std::istream &is)
 Reads a BaseWall into the WallHandler from old-style restart data. More...
 
std::string getName () const
 Returns the name of the handler, namely the string "WallHandler". More...
 
- Public Member Functions inherited from BaseHandler< BaseWall >
 BaseHandler ()
 Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More...
 
 BaseHandler (const BaseHandler< BaseWall > &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< BaseWall > &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...
 
BaseWallgetObjectById (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler. More...
 
BaseWallgetObject (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler. More...
 
const BaseWallgetObject (const unsigned int id) const
 Gets a constant pointer to the Object at the specified index in the BaseHandler. More...
 
BaseWallgetLastObject ()
 Gets a pointer to the last Object in this BaseHandler. More...
 
const BaseWallgetLastObject () 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< BaseWall * >
::const_iterator 
begin () const
 Gets the begin of the const_iterator over all Object in this BaseHandler. More...
 
const std::vector< BaseWall * >
::iterator 
begin ()
 Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More...
 
const std::vector< BaseWall * >
::const_iterator 
end () const
 Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More...
 
const std::vector< BaseWall * >
::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< BaseWall >
std::vector< BaseWall * > objects_
 The actual list of Object pointers. More...
 

Detailed Description

Container to store all BaseWall.

The WallHandler is a container to store all BaseWall. It is implemented by a vector of pointers to BaseWall.

Definition at line 42 of file WallHandler.h.

Constructor & Destructor Documentation

WallHandler::WallHandler ( )

Default constructor, it creates an empty WallHandler.

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

Definition at line 41 of file WallHandler.cc.

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

42 {
43  clear();
44  logger(DEBUG, "WallHandler::WallHandler() finished");
45 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
WallHandler::WallHandler ( const WallHandler WH)

Constructor that copies a pointer to the DPMBase and all BaseWall in the given WallHandler.

Parameters
[in]WHThe WallHandler that has to be copied.

This is not a copy constructor! It only copies the pointer to the DPMBase and the BaseWall in objects_, it sets the other data members to 0 or nullptr.

Definition at line 53 of file WallHandler.cc.

References BaseHandler< BaseWall >::clear(), BaseHandler< BaseWall >::copyContentsFromOtherHandler(), DEBUG, BaseHandler< T >::getDPMBase(), logger, and BaseHandler< BaseWall >::setDPMBase().

54 {
55  clear();
56  setDPMBase(WH.getDPMBase());
58  logger(DEBUG, "WallHandler::WallHandler(const WallHandler &PH) finished");
59 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
void copyContentsFromOtherHandler(const BaseHandler< BaseWall > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
WallHandler::~WallHandler ( )

Destructor, it destructs the WallHandler and all BaseWall it contains.

Definition at line 81 of file WallHandler.cc.

References DEBUG, and logger.

82 {
83 #ifdef DEBUG_DESTRUCTOR
84  logger(DEBUG, "WallHandler::~WallHandler() finished");
85 #endif
86 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

void WallHandler::addObject ( BaseWall W)
virtual

Adds a BaseWall to the WallHandler.

Parameters
[in]WA pointer to the BaseWall (or derived class) that has to be added.

First the new BaseWall is added to the vector of BaseWall, then it is told that this is its handler.

Reimplemented from BaseHandler< BaseWall >.

Definition at line 93 of file WallHandler.cc.

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

94 {
95  //\todo I diasbled the MERCURY_DEPRECATED attribute until we actually fixed the deprecation issue. This will scare users away.
96  // if (W->getSpecies() == nullptr)
97  // {
98  // logger(WARN, "WARNING: The wall with ID % that is added in WallHandler::addObject "
99  // "does not have a species yet. Please make sure that you have "
100  // "set the species somewhere in the driver code.", W->getId());
101  // }
102  //Puts the wall in the Wall list
104  //set the particleHandler pointer
105  W->setHandler(this);
106 }
void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:76
virtual void addObject(T *O)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:284
std::string WallHandler::getName ( ) const
virtual

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

Returns
The string "WallHandler".

Implements BaseHandler< BaseWall >.

Definition at line 210 of file WallHandler.cc.

211 {
212  return "WallHandler";
213 }
WallHandler WallHandler::operator= ( const WallHandler rhs)

Assignment operator that copies the pointer to the DPMBase and all BaseWall in the given WallHandler.

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

This is not a copy assignment operator! It only copies the pointer to the DPMBase and the BaseWall in objects_, it sets the other data members to 0 or nullptr.

Definition at line 67 of file WallHandler.cc.

References BaseHandler< BaseWall >::clear(), BaseHandler< BaseWall >::copyContentsFromOtherHandler(), DEBUG, BaseHandler< T >::getDPMBase(), logger, and BaseHandler< BaseWall >::setDPMBase().

68 {
69  if(this != &rhs)
70  {
71  clear();
72  setDPMBase(rhs.getDPMBase());
74  }
75 #ifdef DEBUG_CONSTRUCTOR
76  logger(DEBUG, "WallHandler::operator = (const WallHandler& rhs) finished");
77 #endif
78  return *this;
79 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
void copyContentsFromOtherHandler(const BaseHandler< BaseWall > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
void WallHandler::readObject ( std::istream &  is)
virtual

Reads BaseWall into the WallHandler from restart data.

Parameters
[in]isThe input stream from which the information is read.

Implements BaseHandler< BaseWall >.

Definition at line 111 of file WallHandler.cc.

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

Referenced by DPMBase::read().

112 {
113  std::string type;
114  is >> type;
115  if (type == "CylindricalWall")
116  {
117  CylindricalWall cylindricalWall;
118  is >> cylindricalWall;
119  copyAndAddObject(cylindricalWall);
120  }
121  else if (type == "AxisymmetricIntersectionOfWalls")
122  {
123  AxisymmetricIntersectionOfWalls axisymmetricIntersectionOfWalls;
124  is >> axisymmetricIntersectionOfWalls;
125  copyAndAddObject(axisymmetricIntersectionOfWalls);
126  }
127  else if (type == "IntersectionOfWalls")
128  {
129  IntersectionOfWalls intersectionOfWalls;
130  is >> intersectionOfWalls;
131  copyAndAddObject(intersectionOfWalls);
132  }
133  else if (type == "InfiniteWall")
134  {
135  InfiniteWall infiniteWall;
136  is >> infiniteWall;
137  copyAndAddObject(infiniteWall);
138  }
139  else if (type == "InfiniteWallWithHole")
140  {
141  InfiniteWallWithHole infiniteWallWithHole;
142  is >> infiniteWallWithHole;
143  copyAndAddObject(infiniteWallWithHole);
144  }
145  else if (type == "Screw")
146  {
147  Screw screw;
148  is >> screw;
149  copyAndAddObject(screw);
150  }
151  else if (type == "Coil")
152  {
153  Coil coil;
154  is >> coil;
155  copyAndAddObject(coil);
156  }
157  //for backward compatibility (before svnversion ~2360)
158  else if (type == "numFiniteWalls")
159  {
160  readOldObject(is);
161  }
162  else
163  {
164  logger(ERROR, "Wall type: % not understood in restart file", type);
165  }
166 }
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
This function defines an Archimedes' screw in the z-direction from a (constant) starting point...
Definition: Screw.h:38
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void readOldObject(std::istream &is)
Reads a BaseWall into the WallHandler from old-style restart data.
Definition: WallHandler.cc:175
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
A AxisymmetricIntersectionOfWalls is a axisymmetric wall, defined by rotating a twodimensional Inters...
This is a class defining walls.
Definition: InfiniteWall.h:43
This class defines a coil in the z-direction from a (constant) starting point, a (constant) length L...
Definition: Coil.h:40
void WallHandler::readOldObject ( std::istream &  is)

Reads a BaseWall into the WallHandler from old-style restart data.

Parameters
[in]isThe input stream from which the information is read.

First determine whether or not the wall is an infinite wall. If it is an infinite wall, read the normal and position and add the wall to the handler. If it is a finite wall, read the normal and position of each part and construct an IntersectionOfWalls from it, which can then be added to the handler.

Definition at line 175 of file WallHandler.cc.

References IntersectionOfWalls::addObject(), BaseHandler< BaseWall >::copyAndAddObject(), helpers::getLineFromStringStream(), logger, InfiniteWall::set(), and VERBOSE.

Referenced by readObject().

176 {
177  //read in next line
178  std::stringstream line(std::stringstream::in | std::stringstream::out);
180  logger(VERBOSE, line.str());
181 
182  std::string dummy;
183  unsigned int numWalls;
184  Mdouble position;
185  Vec3D normal;
186  line >> numWalls;
187 
188  if (numWalls == 0)
189  {
190  InfiniteWall infiniteWall;
191  line >> dummy >> normal >> dummy >> position;
192  infiniteWall.set(normal, position*normal);
193  copyAndAddObject(infiniteWall);
194  }
195  else
196  {
197  IntersectionOfWalls intersectionOfWalls;
198  for (unsigned int i = 0; i < numWalls; ++i)
199  {
200  line >> dummy >> normal >> dummy >> position;
201  intersectionOfWalls.addObject(normal, position*normal);
202  }
203  copyAndAddObject(intersectionOfWalls);
204  }
205 }
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given an outward normal vector s.t. normal*x=normal*point.
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
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:70
This is a class defining walls.
Definition: InfiniteWall.h:43
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45

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