MercuryDPM  Alpha
 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...
 
void writeVTKFile (const VTKContainer vtk) const
 Writes the data collected in writeVTK into vtk files, one per timestep. More...
 
void writeVTKBoundingBox () const
 Writes a bounding box around the domain into a vtk file. More...
 
void writeVTK () const
 Writes all walls into a vtk format, consisting of points (edges) and cells (faces). 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...
 
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...
 
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...
 
void setId (BaseWall *object, unsigned int id)
 This function sets the id and ensures that nextId is a bigger value than id. 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...
 
virtual void writeVTK ()
 Over written in WallHandler and ParticleHandler. 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 an empty WallHandler.

Todo:
why is this being done?

Definition at line 42 of file WallHandler.cc.

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

43 {
45  clear();
46  logger(DEBUG, "WallHandler::WallHandler() finished");
47 }
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.

Todo:
why is this being done?

Definition at line 55 of file WallHandler.cc.

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

56 {
58  clear();
59  setDPMBase(WH.getDPMBase());
61  logger(DEBUG, "WallHandler::WallHandler(const WallHandler &WH) finished");
62 }
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:543
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 82 of file WallHandler.cc.

References DEBUG, and logger.

83 {
84  logger(DEBUG, "WallHandler::~WallHandler() finished");
85 }
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 92 of file WallHandler.cc.

References BaseHandler< T >::addObject(), BaseObject::getId(), BaseInteractable::getSpecies(), logger, BaseWall::setHandler(), and WARN.

93 {
94  if (W->getSpecies() == nullptr)
95  {
96  logger(WARN, "WARNING: The wall with ID % that is added in WallHandler::addObject "
97  "does not have a species yet. Please make sure that you have "
98  "set the species somewhere in the driver code.", W->getId());
99  }
100  //Puts the wall in the Wall list
102  //set the particleHandler pointer
103  W->setHandler(this);
104 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.cc:116
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:76
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:313
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 227 of file WallHandler.cc.

228 {
229  return "WallHandler";
230 }
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 70 of file WallHandler.cc.

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

71 {
72  if(this != &rhs)
73  {
74  clear();
75  setDPMBase(rhs.getDPMBase());
77  }
78  logger(DEBUG, "WallHandler::operator = (const WallHandler& rhs) finished");
79  return *this;
80 }
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:543
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 109 of file WallHandler.cc.

References BaseHandler< BaseWall >::copyAndAddObject(), DEBUG, ERROR, BaseHandler< BaseWall >::getDPMBase(), BaseHandler< T >::getObject(), logger, readOldObject(), IntersectionOfWalls::setSpecies(), BaseWall::setSpecies(), DPMBase::speciesHandler, and WARN.

Referenced by DPMBase::read().

110 {
111  std::string type;
112  is >> type;
113 
114  logger.log(Log::DEBUG, "WallHandler::readObject(is): reading type %.", type);
116 
117  if (type == "CylindricalWall")
118  {
119  CylindricalWall wall;
120  is >> wall;
121  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
122  copyAndAddObject(wall);
123  }
124  else if (type == "AxisymmetricIntersectionOfWalls")
125  {
127  is >> wall;
128  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
129  copyAndAddObject(wall);
130  }
131  else if (type == "IntersectionOfWalls")
132  {
133  IntersectionOfWalls wall;
134  is >> wall;
135  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
136  copyAndAddObject(wall);
137  }
138  else if (type == "InfiniteWall")
139  {
140  InfiniteWall wall;
141  is >> wall;
142  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
143  copyAndAddObject(wall);
144  }
145  else if (type == "InfiniteWallWithHole")
146  {
148  is >> wall;
149  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
150  copyAndAddObject(wall);
151  }
152  else if (type == "Screw")
153  {
154  Screw wall;
155  is >> wall;
156  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
157  copyAndAddObject(wall);
158  }
159  else if (type == "Coil")
160  {
161  Coil wall;
162  is >> wall;
163  wall.setSpecies(sH.getObject(wall.getIndSpecies()));
164  copyAndAddObject(wall);
165  }
166  //for backward compatibility (before svnversion ~2360)
167  else if (type == "numFiniteWalls")
168  {
169  readOldObject(is);
170  }
171  else if (type == "TriolietScrew"||type == "TriolietBaseScrew"||type=="RestrictedWall") {
172  logger(WARN, "Wall type: % cannot be restarted and is ignored", type);
173  InfiniteWall wall;
174  wall.setSpecies(sH.getObject(0));
175  copyAndAddObject(wall);
176  }
177  else if (!getDPMBase()->readUserDefinedWall(type,is))
178  {
179  logger(ERROR, "Wall type: % not understood in restart file", type);
180  }
181 }
Container to store all ParticleSpecies.
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:190
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:451
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.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:991
A AxisymmetricIntersectionOfWalls is an axisymmetric wall, defined by rotating a twodimensional Inter...
This is a class defining walls.
Definition: InfiniteWall.h:47
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
This class defines a coil in the z-direction from a (constant) starting point, a (constant) length L...
Definition: Coil.h:40
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113
void WallHandler::readOldObject ( std::istream &  is)

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

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.

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

Definition at line 190 of file WallHandler.cc.

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

Referenced by readObject().

191 {
192  //read in next line
193  std::stringstream line(std::stringstream::in | std::stringstream::out);
195  logger(VERBOSE, line.str());
196 
197  std::string dummy;
198  unsigned int numWalls;
199  Mdouble position;
200  Vec3D normal;
201  line >> numWalls;
202 
203  if (numWalls == 0)
204  {
205  InfiniteWall wall;
206  wall.setSpecies(getDPMBase()->speciesHandler.getObject(0));
207  line >> dummy >> normal >> dummy >> position;
208  wall.set(normal, position*normal);
209  copyAndAddObject(wall);
210  }
211  else
212  {
213  IntersectionOfWalls wall;
214  wall.setSpecies(getDPMBase()->speciesHandler.getObject(0));
215  for (unsigned int i = 0; i < numWalls; ++i)
216  {
217  line >> dummy >> normal >> dummy >> position;
218  wall.addObject(normal, position*normal);
219  }
220  copyAndAddObject(wall);
221  }
222 }
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.
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
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:396
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.
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:79
This is a class defining walls.
Definition: InfiniteWall.h:47
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:113
void WallHandler::writeVTK ( ) const

Writes all walls into a vtk format, consisting of points (edges) and cells (faces).

Writes the VTK file for all walls: it asks every wall for its points and cells, which they will append in their output parameters. Cells are lists of point indices that will be visualised in form of triangle strips (vtk type 6).

Todo:
Check if the documentation is correct

Definition at line 239 of file WallHandler.cc.

References DEBUG, logger, VTKContainer::points, VTKContainer::triangleStrips, and writeVTKFile().

Referenced by main(), and DPMBase::writeVTK().

240 {
241  VTKContainer vtk;
242 
243  //set capacity of points and cells based on the previous time step
244  static unsigned int capacityPoints = 0;
245  static unsigned int capacityTriangleStrips = 0;
246 
247  vtk.triangleStrips.reserve(capacityPoints);
248  vtk.points.reserve(capacityTriangleStrips);
249 
250  //add all wall data to the point and cell arrays
251  for (const auto& w: *this)
252  {
253  w->writeVTK(vtk);
254  logger(DEBUG, "points: %, cells: ", vtk.points.size(), vtk.triangleStrips.size());
255  }
256 
257  //write
258  writeVTKFile(vtk);
259 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void writeVTKFile(const VTKContainer vtk) const
Writes the data collected in writeVTK into vtk files, one per timestep.
Definition: WallHandler.cc:267
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:36
std::vector< Vec3D > points
Definition: BaseWall.h:35
void WallHandler::writeVTKBoundingBox ( ) const

Writes a bounding box around the domain into a vtk file.

Writes a box around all the data to a vtk file. The filename is hard-coded and depends on the DPMBase. Note that there is no static counter that makes sure new files don't have the same name as the old ones.

Todo:
Check that this should indeed be WARN

000 001 010 011 ...

Definition at line 341 of file WallHandler.cc.

References BaseHandler< BaseWall >::getDPMBase(), DPMBase::getMax(), DPMBase::getMin(), Files::getName(), INFO, logger, WARN, X, Y, and Z.

342 {
343  const std::string fileName = getDPMBase()->getName() + "BoundingBox.vtu";
344  logger(INFO, "% writing vtk file for bounding box: %",
345  getDPMBase()->getTime(), fileName);
346  std::fstream file;
347  file.open(fileName.c_str(), std::ios::out);
348  if (file.fail())
349  {
351  logger(WARN, "Error in writeToFile: file could not be opened");
352  }
353  file << "<?xml version=\"1.0\"?>\n\n";
354  file << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
355  file << "<UnstructuredGrid>\n";
356  file << "<Piece NumberOfPoints=\"8\" NumberOfCells=\"1\">\n";
357  file << "<Points>\n";
358  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
359  Vec3D P[2] = {getDPMBase()->getMax(), getDPMBase()->getMin()};
360  for (unsigned i = 0; i < 2; i++)
361  {
362  for (unsigned j = 0; j < 2; j++)
363  {
364  for (unsigned k = 0; k < 2; k++)
365  {
366  Vec3D p = Vec3D(P[i].X, P[j].Y, P[k].Z);
367  file << '\t' << p << '\n';
368  }
369  }
370  }
372  file << " </DataArray>\n";
373  file << "</Points>\n";
374  file << "<Cells>\n";
375  file <<
376  " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
377  file << "\t0 1 3 2 0 4 5 1 5 7 3 7 6 2 6 4\n";
378  file << " </DataArray>\n";
379  file << " <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
380  file <<
381  "\t16\n"; //offset into the connectivity array for the end of each cell.
382  file << " </DataArray>\n";
383  file << " <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
384  file << "\t4\n";
385  file << " </DataArray>\n";
386  file << "</Cells>\n";
387  file << "</Piece>\n";
388  file << "</UnstructuredGrid>\n";
389  file << "</VTKFile>\n";
390  file.close();
391 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Vec3D getMin() const
Return the "bottom left" corner of the domain, a vector with xMin_, yMin_ and zMin_.
Definition: DPMBase.h:330
Vec3D getMax() const
Return the "upper right" corner of the domain, a vector with xMin_, yMin_ and zMin_.
Definition: DPMBase.h:335
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: Files.cc:132
void WallHandler::writeVTKFile ( const VTKContainer  vtk) const

Writes the data collected in writeVTK into vtk files, one per timestep.

Writes all points ans cells to a file in the VTK format. The filename is hard-coded in this method, and is based on the name of the DPMBase and has a unique counter in it to ensure there are no two files with the same name.

Todo:
Check if this should indeed be a WARN

Definition at line 267 of file WallHandler.cc.

References BaseHandler< BaseWall >::getDPMBase(), Files::getName(), BaseHandler< BaseWall >::getNumberOfObjects(), INFO, logger, VTKContainer::points, helpers::to_string(), VTKContainer::triangleStrips, and WARN.

Referenced by writeVTK().

268 {
269 // logger(INFO, "%, writing vtk file, points: %, cells: %",
270 // getDPMBase()->getTime(), vtk.points.size(), vtk.triangleStrips.size());
271  static unsigned fileCounter = 0;
272  const std::string fileName = getDPMBase()->getName() + "Wall_" +
273  std::to_string(fileCounter++) + ".vtu";
274  logger(INFO, "writing % (t=%, N=%)", fileName, getDPMBase()->getTime(), this->getNumberOfObjects());
275 
276  std::fstream file;
277  file.open(fileName.c_str(), std::ios::out);
278  if (file.fail())
279  {
281  logger(WARN, "Error in writeToFile: file % could not be opened", fileName);
282  }
283  file << "<?xml version=\"1.0\"?>\n\n";
284  file << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
285  file << "<UnstructuredGrid>\n";
286  file << "<Piece NumberOfPoints=\"" << vtk.points.size() << "\" NumberOfCells=\"" << vtk.triangleStrips.size() << "\">\n";
287  file << "<Points>\n";
288  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
289  for (const Vec3D& p : vtk.points)
290  {
291  file << '\t' << p << '\n';
292  }
293  file << " </DataArray>\n";
294  file << "</Points>\n";
295  file << "<Cells>\n";
296  file << " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
297  for (const std::vector<double>& c : vtk.triangleStrips)
298  {
299  file << '\t';
300  for (const double& i : c)
301  {
302  file << i << ' ';
303  }
304  file << '\n';
305  }
306  file << " </DataArray>\n";
307  file << " <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
308  unsigned count = 0;
309  for (const std::vector<double>& c : vtk.triangleStrips)
310  {
311  count += c.size();
312  file << '\t' << count << '\n';
313  }
314  file << " </DataArray>\n";
315  file << " <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
316  for (const std::vector<double>& c : vtk.triangleStrips)
317  {
318  if (c.front()==c.back())
319  {
320  //polygon
321  file << "\t7\n";
322  } else
323  {
324  //triangle strips
325  file << "\t6\n";
326  }
327  }
328  file << " </DataArray>\n";
329  file << "</Cells>\n";
330  file << "</Piece>\n";
331  file << "</UnstructuredGrid>\n";
332  file << "</VTKFile>\n";
333  file.close();
334 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:36
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
std::string to_string(const T &n)
Definition: Helpers.h:203
std::vector< Vec3D > points
Definition: BaseWall.h:35
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: Files.cc:132

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