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

Container to store all BaseWall. More...

#include <WallHandler.h>

Public Member Functions

 WallHandler ()
 Default WallHandler constructor, it simply creates an empty WallHandler. More...
 
 WallHandler (const WallHandler &BH)
 Copy constructor for the WallHandler class, it copies the WallHandler and all BaseWall it contains. More...
 
WallHandler operator= (const WallHandler &rhs)
 Assigns one WallHandler to another WallHandler. More...
 
 ~WallHandler ()
 Destructor, it simply destructs the WallHandler and all BaseWall it contains. More...
 
void copyAndAddWall (const BaseWall &B)
 Creates a copy of a BaseWall and adds it to the WallHandler. More...
 
void copyAndAddWall (const BaseWall *B)
 Creates a copy of a BaseWall and adds it to the WallHandler. More...
 
void addWall (BaseWall *W)
 Adds a new BaseWall to the WallHandler. More...
 
void removeWall (unsigned const int id)
 Removes a BaseWall from the WallHandler. More...
 
void removeLastWall ()
 Removes the last BaseWall from the WallHandler. More...
 
void clear ()
 Empties the whole WallHandler by removing all BaseWall. More...
 
void readWall (std::istream &is)
 Reads BaseWall into the WallHandler from restart data. More...
 
BaseWallgetWall (const unsigned int id) const
 Gets a pointer to the BaseWall at the specified index in the WallHandler. More...
 
BaseWallgetLastWall () const
 Gets a pointer to the last BaseWall in this WallHandler. More...
 
unsigned int getNumberOfWalls () const
 Gets the number of BaseWalls in this WallHandler. More...
 
unsigned int getStorageCapacity () const
 Gets the storage capacity of this WallHandler. More...
 
void setStorageCapacity (const unsigned int N)
 Sets the storage capacity of this WallHandler. More...
 
const std::vector< BaseWall * >
::const_iterator 
begin () const
 Gets the begin of the const_iterator over all BaseWall in this WallHandler. More...
 
const std::vector< BaseWall * >
::iterator 
begin ()
 Gets the begin of the iterator over all BaseWall in this WallHandler. More...
 
const std::vector< BaseWall * >
::const_iterator 
end () const
 Gets the end of the const_iterator over all BaseWall in this WallHandler. More...
 
const std::vector< BaseWall * >
::iterator 
end ()
 Gets the end of the iterator over all BaseWall in this WallHandler. More...
 

Private Attributes

std::vector< BaseWall * > walls_
 The actual list of Wall 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 36 of file WallHandler.h.

Constructor & Destructor Documentation

WallHandler::WallHandler ( )

Default WallHandler constructor, it simply creates an empty WallHandler.

Definition at line 37 of file WallHandler.cc.

References clear().

38 {
39  clear();
40  #ifdef CONSTUCTOR_OUTPUT
41  std::cout << "WallHandler::WallHandler() finished" << std::endl;
42  #endif
43 }
void clear()
Empties the whole WallHandler by removing all BaseWall.
Definition: WallHandler.cc:127
WallHandler::WallHandler ( const WallHandler WH)

Copy constructor for the WallHandler class, it copies the WallHandler and all BaseWall it contains.

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

Definition at line 46 of file WallHandler.cc.

References addWall(), begin(), clear(), and end().

47 {
48  clear();
49  for (std::vector<BaseWall*>::const_iterator it=WH.begin();it!=WH.end();it++)
50  {
51  addWall((*it)->copy());
52  }
53  #ifdef CONSTUCTOR_OUTPUT
54  std::cout << "WallHandler::WallHandler(const WallHandler &WH) finished" << std::endl;
55  #endif
56 }
const std::vector< BaseWall * >::const_iterator begin() const
Gets the begin of the const_iterator over all BaseWall in this WallHandler.
Definition: WallHandler.cc:242
const std::vector< BaseWall * >::const_iterator end() const
Gets the end of the const_iterator over all BaseWall in this WallHandler.
Definition: WallHandler.cc:254
void addWall(BaseWall *W)
Adds a new BaseWall to the WallHandler.
Definition: WallHandler.cc:97
void clear()
Empties the whole WallHandler by removing all BaseWall.
Definition: WallHandler.cc:127
WallHandler::~WallHandler ( )

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

Definition at line 75 of file WallHandler.cc.

References clear().

76 {
77  clear();
78  #ifdef DESTRUCTOR_OUTPUT
79  std::cout << "WallHandler::~WallHandler() finished" << std::endl;
80  #endif
81 }
void clear()
Empties the whole WallHandler by removing all BaseWall.
Definition: WallHandler.cc:127

Member Function Documentation

void WallHandler::addWall ( BaseWall W)

Adds a new BaseWall to the WallHandler.

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

Definition at line 97 of file WallHandler.cc.

References walls_.

Referenced by copyAndAddWall(), operator=(), and WallHandler().

98 {
99  walls_.push_back(W);
100 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
const std::vector< BaseWall * >::const_iterator WallHandler::begin ( ) const

Gets the begin of the const_iterator over all BaseWall in this WallHandler.

Returns
A const_iterator pointing to the first BaseWall.

Definition at line 242 of file WallHandler.cc.

References walls_.

Referenced by InsertionBoundary::checkBoundaryActionsBeforeTimeStep(), MD::compute_all_forces(), operator=(), WallHandler(), MD::write(), and MD::write_v1().

243 {
244  return walls_.begin();
245 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
const std::vector< BaseWall * >::iterator WallHandler::begin ( )

Gets the begin of the iterator over all BaseWall in this WallHandler.

Returns
An iterator pointing to the first BaseWall.

Definition at line 248 of file WallHandler.cc.

References walls_.

249 {
250  return walls_.begin();
251 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
void WallHandler::clear ( )

Empties the whole WallHandler by removing all BaseWall.

Definition at line 127 of file WallHandler.cc.

References walls_.

Referenced by operator=(), MD::read(), MD::read_v2(), ChuteBottom::setup_particles_initial_conditions(), WallHandler(), and ~WallHandler().

128 {
129  walls_.clear();
130 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
void WallHandler::copyAndAddWall ( const BaseWall W)

Creates a copy of a BaseWall and adds it to the WallHandler.

Parameters
[in]WA reference to the BaseWall that has to be copied.

Definition at line 84 of file WallHandler.cc.

References addWall(), and BaseWall::copy().

Referenced by ChuteWithHopper::add_hopper(), Chute::create_bottom(), MD::load_par_ini_file(), readWall(), Chute::setup_particles_initial_conditions(), and ChuteBottom::setup_particles_initial_conditions().

85 {
86  addWall(W.copy());
87 }
void addWall(BaseWall *W)
Adds a new BaseWall to the WallHandler.
Definition: WallHandler.cc:97
virtual BaseWall * copy() const =0
void WallHandler::copyAndAddWall ( const BaseWall W)

Creates a copy of a BaseWall and adds it to the WallHandler.

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

Definition at line 90 of file WallHandler.cc.

References addWall(), and BaseWall::copy().

91 {
92  addWall(W->copy());
93 }
void addWall(BaseWall *W)
Adds a new BaseWall to the WallHandler.
Definition: WallHandler.cc:97
virtual BaseWall * copy() const =0
const std::vector< BaseWall * >::const_iterator WallHandler::end ( ) const

Gets the end of the const_iterator over all BaseWall in this WallHandler.

Returns
bB A const_iterator pointing to the last BaseWall.

Definition at line 254 of file WallHandler.cc.

References walls_.

Referenced by InsertionBoundary::checkBoundaryActionsBeforeTimeStep(), MD::compute_all_forces(), operator=(), WallHandler(), MD::write(), and MD::write_v1().

255 {
256  return walls_.end();
257 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
const std::vector< BaseWall * >::iterator WallHandler::end ( )

Gets the end of the iterator over all BaseWall in this WallHandler.

Returns
bB An interator pointing to the last BaseWall.

Definition at line 260 of file WallHandler.cc.

References walls_.

261 {
262  return walls_.end();
263 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
BaseWall * WallHandler::getLastWall ( ) const

Gets a pointer to the last BaseWall in this WallHandler.

Returns
A pointer to the last BaseWall in the WallHandler.

Definition at line 218 of file WallHandler.cc.

References walls_.

Referenced by removeLastWall(), and removeWall().

219 {
220  return walls_.back();
221 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
unsigned int WallHandler::getNumberOfWalls ( ) const

Gets the number of BaseWalls in this WallHandler.

Returns
The number of BaseWall in this WallHandler.

Definition at line 224 of file WallHandler.cc.

References walls_.

Referenced by MD::compute_walls(), getWall(), MD::print(), MD::write(), and MD::write_v1().

225 {
226  return walls_.size();
227 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
unsigned int WallHandler::getStorageCapacity ( ) const

Gets the storage capacity of this WallHandler.

Returns
The storage capacity of this WallHandler.

Definition at line 230 of file WallHandler.cc.

References walls_.

231 {
232  return walls_.capacity();
233 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
BaseWall * WallHandler::getWall ( const unsigned int  id) const

Gets a pointer to the BaseWall at the specified index in the WallHandler.

Parameters
[in]idThe index of the requested BaseWall.
Returns
A pointer to the requested BaseWall.

Definition at line 203 of file WallHandler.cc.

References getNumberOfWalls(), and walls_.

Referenced by MD::compute_walls(), MD::print(), and removeWall().

204 {
205  if (id<getNumberOfWalls())
206  {
207  return walls_[id];
208  }
209  else
210  {
211  std::cerr<<"In: BaseWall* WallHandler::getWall(const unsigned int id) const"<<std::endl;
212  std::cerr<<"No BaseWall exist with index "<<id<<" maximum index is "<<getNumberOfWalls()<<std::endl;
213  exit(-1);
214  }
215 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
unsigned int getNumberOfWalls() const
Gets the number of BaseWalls in this WallHandler.
Definition: WallHandler.cc:224
WallHandler WallHandler::operator= ( const WallHandler rhs)

Assigns one WallHandler to another WallHandler.

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

Definition at line 59 of file WallHandler.cc.

References addWall(), begin(), clear(), and end().

60 {
61  if (this != &rhs)
62  {
63  clear();
64  for (std::vector<BaseWall*>::const_iterator it=rhs.begin();it!=rhs.end();it++)
65  {
66  addWall((*it)->copy());
67  }
68  }
69  #ifdef OPERATOR_OUTPUT
70  std::cout << "WallHandler WallHandler::operator = (const WallHandler& rhs) finished" << std::endl;
71  #endif
72  return *this;
73 }
const std::vector< BaseWall * >::const_iterator begin() const
Gets the begin of the const_iterator over all BaseWall in this WallHandler.
Definition: WallHandler.cc:242
const std::vector< BaseWall * >::const_iterator end() const
Gets the end of the const_iterator over all BaseWall in this WallHandler.
Definition: WallHandler.cc:254
void addWall(BaseWall *W)
Adds a new BaseWall to the WallHandler.
Definition: WallHandler.cc:97
void clear()
Empties the whole WallHandler by removing all BaseWall.
Definition: WallHandler.cc:127
void WallHandler::readWall ( std::istream &  is)

Reads BaseWall into the WallHandler from restart data.

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

Definition at line 133 of file WallHandler.cc.

References copyAndAddWall().

Referenced by MD::read(), MD::read_v1(), and MD::read_v2().

134 {
135  std::string type;
136  is >> type;
137  if(type.compare("CylindricalWall")==0)
138  {
139  CylindricalWall cylindricalWall;
140  is>>cylindricalWall;
141  copyAndAddWall(cylindricalWall);
142  }
143  else if(type.compare("FiniteAxisSymmetricWall")==0)
144  {
145  FiniteAxisSymmetricWall finiteAxisSymmetricWall;
146  is>>finiteAxisSymmetricWall;
147  copyAndAddWall(finiteAxisSymmetricWall);
148  }
149  else if(type.compare("FiniteWall")==0)
150  {
151  FiniteWall finiteWall;
152  is>>finiteWall;
153  copyAndAddWall(finiteWall);
154  }
155  else if(type.compare("InfiniteWall")==0)
156  {
157  InfiniteWall infiniteWall;
158  is>>infiniteWall;
159  copyAndAddWall(infiniteWall);
160  }
161  else if(type.compare("InfiniteWallWithHole")==0)
162  {
163  InfiniteWallWithHole infiniteWallWithHole;
164  is>>infiniteWallWithHole;
165  copyAndAddWall(infiniteWallWithHole);
166  }
167  else if(type.compare("Screw")==0)
168  {
169  Screw screw;
170  is>>screw;
171  copyAndAddWall(screw);
172  }
173  else if(type.compare("Coil")==0)
174  {
175  Coil coil;
176  is>>coil;
177  copyAndAddWall(coil);
178  }
179  //for backward compatibility (before svnversion ~2360)
180  else if(type.compare("numFiniteWalls")==0)
181  {
182  int numFiniteWalls;
183  is >> numFiniteWalls;
184  if (numFiniteWalls) {
185  FiniteWall finiteWallInstance;
186  is>>finiteWallInstance;
187  copyAndAddWall(finiteWallInstance);
188  } else {
189  InfiniteWall infiniteWallInstance;
190  is>>infiniteWallInstance;
191  copyAndAddWall(infiniteWallInstance);
192  }
193  }
194  else
195  {
196  std::cerr<<"Wall type: "<<type<<" not understood in restart file"<<std::endl;
197  exit(-1);
198  }
199 }
This function defines a archimedes screw in the z-direction from a (constant) starting point...
Definition: Screw.h:41
void copyAndAddWall(const BaseWall &B)
Creates a copy of a BaseWall and adds it to the WallHandler.
Definition: WallHandler.cc:84
This is a class defining walls.
Definition: InfiniteWall.h:42
This function defines a coil in the z-direction from a (constant) starting point, a (constant) length...
Definition: Coil.h:40
This is a class defining walls.
void WallHandler::removeLastWall ( )

Removes the last BaseWall from the WallHandler.

Definition at line 119 of file WallHandler.cc.

References getLastWall(), and walls_.

120 {
121  //Physically removes Wall
122  delete getLastWall();
123  //Remove the (now double) reference to that last Wall
124  walls_.pop_back();
125 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
BaseWall * getLastWall() const
Gets a pointer to the last BaseWall in this WallHandler.
Definition: WallHandler.cc:218
void WallHandler::removeWall ( unsigned const int  id)

Removes a BaseWall from the WallHandler.

The BaseWall at position id is removed by moving the last BaseWall in the vector to the position of id.

Parameters
[in]idThe index of which BaseWall has to be removed from the WallHandler

Definition at line 104 of file WallHandler.cc.

References getLastWall(), getWall(), and walls_.

105 {
106  //Physically remove Wall
107  delete getWall(id);
108 
109  //If the Wall was the last Wall nothing has to be done, otherwise some additional work is neccesary
110  if (getWall(id) != getLastWall())
111  {
112  //Copy the pointer to the last Wall to position id
113  walls_[id] = getLastWall();
114  }
115  //Remove the (now double) reference to that last Wall
116  walls_.pop_back();
117 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101
BaseWall * getLastWall() const
Gets a pointer to the last BaseWall in this WallHandler.
Definition: WallHandler.cc:218
BaseWall * getWall(const unsigned int id) const
Gets a pointer to the BaseWall at the specified index in the WallHandler.
Definition: WallHandler.cc:203
void WallHandler::setStorageCapacity ( const unsigned int  N)

Sets the storage capacity of this WallHandler.

Parameters
[in]NThe storage capacity the WallHandler will have.

Definition at line 236 of file WallHandler.cc.

References walls_.

Referenced by MD::read_v1().

237 {
238  walls_.reserve(N);
239 }
std::vector< BaseWall * > walls_
The actual list of Wall pointers.
Definition: WallHandler.h:101

Member Data Documentation

std::vector<BaseWall*> WallHandler::walls_
private

The actual list of Wall pointers.

Definition at line 101 of file WallHandler.h.

Referenced by addWall(), begin(), clear(), end(), getLastWall(), getNumberOfWalls(), getStorageCapacity(), getWall(), removeLastWall(), removeWall(), and setStorageCapacity().


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