WallHandler Class Referencefinal

Container to store all BaseWall. More...

#include <WallHandler.h>

+ Inheritance diagram for WallHandler:

Public Types

enum class  DetailsVTKOptions { BOUNDINGBOX = 0 , NURBSWALL = 1 , WEARABLENURBSWALL = 2 }
 

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...
 
WallHandleroperator= (const WallHandler &rhs)
 Assignment operator that copies the pointer to the DPMBase and all BaseWall in the given WallHandler. More...
 
 ~WallHandler () final
 Destructor, it destructs the WallHandler and all BaseWall it contains. More...
 
void addObject (BaseWall *W) final
 Adds a BaseWall to the WallHandler. More...
 
BaseWallreadAndCreateObject (std::istream &is)
 Create a new wall, based on the information provided in a restart file. More...
 
void readAndAddObject (std::istream &is) final
 Create a new wall in the WallHandler, based on the information provided in a restart file. More...
 
std::string getName () const final
 Returns the name of the handler, namely the string "WallHandler". More...
 
unsigned readTriangleWall (std::string filename, ParticleSpecies *species, Mdouble scaleFactor=1, Vec3D centerOfRotation={0, 0, 0}, Vec3D velocity={0, 0, 0}, Vec3D angularVelocity={0, 0, 0})
 Reads triangulated walls from vtk or stl files, and converts them into a set of TriangleWalls. More...
 
void actionsAfterParticleGhostUpdate ()
 Calls the method actionsAfterParticleGhostUpdate of every wall in the handler. More...
 
void setWriteVTK (FileType)
 Sets whether walls are written into a VTK file. More...
 
void setWriteVTK (bool)
 Sets whether walls are written into a VTK file. More...
 
FileType getWriteVTK () const
 Returns whether walls are written in a VTK file. More...
 
void setWriteDetailsVTK (DetailsVTKOptions, FileType)
 
void setWriteDetailsVTK (DetailsVTKOptions, bool)
 
FileType getWriteDetailsVTK (DetailsVTKOptions) const
 
bool getWriteDetailsVTKAny () const
 
std::unordered_map< DetailsVTKOptions, FileTypegetWriteWallDetailsVTKAll () const
 
void writeWallDetailsVTKBoundingBox (VTKData &data) const
 
void setWriteWallSurfaceAreaVTK (bool writeWallSurfaceAreaVTK)
 Enables/disables the calculation and writing of the surface area of the cells. More...
 
bool getWriteWallSurfaceAreaVTK () const
 
- 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...
 
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 (BaseWall *O)
 Adds an existing object to the BaseHandler without changing the id of the object. More...
 
virtual void addObject (BaseWall *object)
 Adds a new Object to the BaseHandler. More...
 
virtual void addGhostObject (BaseWall *O)
 Adds a new Object to the BaseHandler. called by the to avoid increasing the id. More...
 
void removeIf (const std::function< bool(BaseWall *)> 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...
 
BaseWallgetObjectById (const unsigned int id)
 Gets a pointer to the Object at the specified index in the BaseHandler. More...
 
std::vector< BaseWall * > getObjectsById (const unsigned int id)
 Gets a vector of pointers to the objects with the specific id. 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...
 
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 BaseWall &obj)
 Resizes the container to contain N elements. 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)
 
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 BaseWallcreateObject (const std::string &type)
 Create a new wall, with the type given as a string (required for restarting). More...
 

Private Member Functions

BaseWallreadAndCreateOldObject (std::istream &is)
 Create a new wall, based on the information from old-style restart data. More...
 

Private Attributes

FileType writeVTK_
 
std::unordered_map< DetailsVTKOptions, FileTypewriteDetailsVTK_
 unordered_map storing the file types corresponding to each of the enum DetailsVTKOptions 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.

Member Enumeration Documentation

◆ DetailsVTKOptions

Enumerator
BOUNDINGBOX 

Writes a bounding box around the domain.

NURBSWALL 

Writes the NURBS control points.

WEARABLENURBSWALL 

Writes the debris.

96  {
97  // Used as keys for an unordered_map.
98  // The actual enum values are written to the restart file and their meaning should therefore never change.
99  // So when adding new options, be sure to hardcode a unique enum value!
100  // The options can be in any order and their values are completely free to choose, as long as they're unique.
101 
105  BOUNDINGBOX = 0,
106 
110  NURBSWALL = 1,
111 
115  WEARABLENURBSWALL = 2
116  };

Constructor & Destructor Documentation

◆ WallHandler() [1/2]

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?
33 {
35  clear();
37 #ifdef DEBUG_CONSTRUCTOR
38  std::cerr << "WallHandler::WallHandler() finished" << std::endl;
39 #endif
40 }
@ NO_FILE
file will not be created/read
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:536
FileType writeVTK_
Definition: WallHandler.h:144

References BaseHandler< BaseWall >::clear(), NO_FILE, and writeVTK_.

◆ WallHandler() [2/2]

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?
49 {
51  clear();
52  setDPMBase(WH.getDPMBase());
54  writeVTK_ = WH.writeVTK_;
55 #ifdef DEBUG_CONSTRUCTOR
56  std::cerr << "WallHandler::WallHandler(const WallHandler&) finished" << std::endl;
57 #endif
58 }
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
Definition: BaseHandler.h:726
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
void copyContentsFromOtherHandler(const BaseHandler< BaseWall > &BH)
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handle...
Definition: BaseHandler.h:348

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

◆ ~WallHandler()

WallHandler::~WallHandler ( )
final

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

82 {
83 #ifdef DEBUG_CONSTRUCTOR
84  std::cerr << "WallHandler::~WallHandler() finished" << std::endl;
85 #endif
86 }

Member Function Documentation

◆ actionsAfterParticleGhostUpdate()

void WallHandler::actionsAfterParticleGhostUpdate ( )

Calls the method actionsAfterParticleGhostUpdate of every wall in the handler.

This function is called by DPMBase::computeOneTimeStep directly after the ghost particle update. It may be used to adjust wall properties based on the changed wall positions (for an example, look e.g. at MeshTriangle).

437 {
438  // #pragma omp parallel for //schedule(dynamic)
439  for (auto w: *this)
440  {
441  w->actionsAfterParticleGhostUpdate();
442  }
443 }
RowVector3d w
Definition: Matrix_resize_int.cpp:3

References w.

Referenced by DPMBase::computeOneTimeStep().

◆ addObject()

void WallHandler::addObject ( BaseWall W)
final

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.

94 {
95  if (W->getSpecies() == nullptr)
96  {
97  logger(WARN, "WARNING: The wall with ID % that is added in WallHandler::addObject "
98  "does not have a species yet. Please make sure that you have "
99  "set the species somewhere in the driver code.", W->getId());
100  }
101  //Puts the wall in the Wall list
103  //set the particleHandler pointer
104  W->setHandler(this);
105 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ WARN
virtual void addObject(T *object)
Adds a new Object to the BaseHandler.
Definition: BaseHandler.h:412
@ W
Definition: quadtree.h:63

References BaseHandler< T >::addObject(), logger, oomph::QuadTreeNames::W, and WARN.

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

◆ createObject()

BaseWall * WallHandler::createObject ( const std::string &  type)
static

Create a new wall, with the type given as a string (required for restarting).

Todo:
Review this line. Problem came up in merging.
108 {
109  if (type == "CylindricalWall")
110  {
111  return new CylindricalWall;
112  }
113  else if (type == "AxisymmetricIntersectionOfWalls")
114  {
116  }
117  else if (type == "ScrewsymmetricIntersectionOfWalls")
118  {
120  }
121  else if (type == "IntersectionOfWalls")
122  {
123  return new IntersectionOfWalls;
124  }
125  else if (type == "BasicIntersectionOfWalls")
126  {
127  return new BasicIntersectionOfWalls;
128  }
129  else if (type == "BasicUnionOfWalls")
130  {
131  return new BasicUnionOfWalls;
132  }
133  else if (type == "InfiniteWall")
134  {
135  return new InfiniteWall;
136  }
137  else if (type == "InfiniteWallWithHole")
138  {
139  return new InfiniteWallWithHole;
140  }
141  else if (type == "Screw")
142  {
143  return new Screw;
144  }
145  else if (type == "Coil")
146  {
147  return new Coil;
148  }
149  else if (type == "TriangleWall")
150  {
151  return new TriangleWall;
152  }
153  else if (type == "MeshTriangle")
154  {
155  return new MeshTriangle;
156  }
157  else if (type == "VChute")
158  {
159  return new VChute;
160  }
161  else if (type == "NurbsWall")
162  {
163  return new NurbsWall();
164  }
165  else if (type == "WearableNurbsWall")
166  {
167  return new WearableNurbsWall();
168  }
169  else if (type == "TriangleMeshWall")
170  {
171  return new TriangleMeshWall;
172  }
173  else if (type == "WearableTriangleMeshWall")
174  {
175  return new WearableTriangleMeshWall;
176  }
177  //for backward compatibility (before svnversion ~2360)
178  else if (type == "numFiniteWalls")
179  {
180  return new BasicIntersectionOfWalls;
181  }
183  // else if (!getDPMBase()->readUserDefinedWall(type,is))
184  else
185  {
186  logger(WARN, "Wall type: % not understood in restart file", type);
187  return nullptr;
188  }
189 }
Use AxisymmetricIntersectionOfWalls to Screw Screw::read Screw::read Screw::read define axisymmetric ...
Definition: AxisymmetricIntersectionOfWalls.h:105
Restriction of a wall to the intersection with another wall.
Definition: BasicIntersectionOfWalls.h:22
Restriction of a wall to the intersection with another wall.
Definition: BasicUnionOfWalls.h:22
This class defines a coil in the z-direction from a (constant) starting point, a (constant) length L,...
Definition: Coil.h:20
Definition: CylindricalWall.h:17
Definition: InfiniteWallWithHole.h:17
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:27
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Definition: IntersectionOfWalls.h:38
MeshTriangle implements a triangle whose vertex positions are defined by three particles.
Definition: MeshTriangle.h:54
This function defines a wall via a NurbsSurface.
Definition: NurbsWall.h:16
This function defines an Archimedes' screw in the z-direction from a (constant) starting point,...
Definition: Screw.h:23
Use ScrewsymmetricIntersectionOfWalls to define screwsymmetric walls, such as cylinders,...
Definition: ScrewsymmetricIntersectionOfWalls.h:105
Definition: TriangleMeshWall.h:12
A TriangleWall is convex polygon defined as an intersection of InfiniteWall's.
Definition: TriangleWall.h:36
Definition: VChute.h:14
Definition: WearableNurbsWall.h:11
Definition: WearableTriangleMeshWall.h:11
type
Definition: compute_granudrum_aor.py:141

References logger, compute_granudrum_aor::type, and WARN.

Referenced by BaseWall::read(), BasicIntersectionOfWalls::read(), BasicUnionOfWalls::read(), and readAndCreateObject().

◆ getName()

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

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

Returns
The string "WallHandler".

Implements BaseHandler< BaseWall >.

289 {
290  return "WallHandler";
291 }

◆ getWriteDetailsVTK()

FileType WallHandler::getWriteDetailsVTK ( DetailsVTKOptions  option) const
473 {
474  // This function has to be marked constant, so accessing by key is not an option, as it will automatically add keys
475  // not present in the map yet.
476 
477  // Try to find the option to see if it's already added to the map or not
478  auto it = writeDetailsVTK_.find(option);
479  // When the iterator does not equal the end, the key has been found
480  if (it != writeDetailsVTK_.end())
481  return it->second;
482  else
483  return FileType::NO_FILE; // Else return a default file type
484 }
std::unordered_map< DetailsVTKOptions, FileType > writeDetailsVTK_
unordered_map storing the file types corresponding to each of the enum DetailsVTKOptions
Definition: WallHandler.h:151

References NO_FILE, and writeDetailsVTK_.

Referenced by WallDetailsVTKWriter::shouldWrite(), and DPMBase::writePythonFileForVTKVisualisation().

◆ getWriteDetailsVTKAny()

bool WallHandler::getWriteDetailsVTKAny ( ) const
487 {
488  // Simple lambda expression to check if any of the file types are not of type NO_FILE
489  return std::any_of(writeDetailsVTK_.begin(), writeDetailsVTK_.end(),
490  [](const auto& p) { return p.second != FileType::NO_FILE; });
491 }
float * p
Definition: Tutorial_Map_using.cpp:9

References p, and writeDetailsVTK_.

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

◆ getWriteVTK()

FileType WallHandler::getWriteVTK ( ) const

Returns whether walls are written in a VTK file.

456 {
457  return writeVTK_;
458 }

References writeVTK_.

Referenced by DPMBase::getWallsWriteVTK(), DPMBase::initialiseVTK(), DPMBase::write(), DPMBase::writePythonFileForVTKVisualisation(), and DPMBase::writeVTKFiles().

◆ getWriteWallDetailsVTKAll()

std::unordered_map< WallHandler::DetailsVTKOptions, FileType > WallHandler::getWriteWallDetailsVTKAll ( ) const
494 {
495  return writeDetailsVTK_;
496 }

References writeDetailsVTK_.

Referenced by DPMBase::write().

◆ getWriteWallSurfaceAreaVTK()

bool WallHandler::getWriteWallSurfaceAreaVTK ( ) const
504 {
506 }
WallVTKWriter & getWallVTKWriter()
Definition: DPMBase.cc:5594
bool getWriteWallSurfaceAreaVTK() const
Definition: WallVTKWriter.cc:209

References BaseHandler< BaseWall >::getDPMBase(), DPMBase::getWallVTKWriter(), and WallVTKWriter::getWriteWallSurfaceAreaVTK().

◆ operator=()

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.

67 {
68  if (this != &rhs)
69  {
70  clear();
71  setDPMBase(rhs.getDPMBase());
73  writeVTK_ = rhs.writeVTK_;
74  }
75  return *this;
76 #ifdef DEBUG_CONSTRUCTOR
77  std::cerr << "WallHandler::operator =(const WallHandler&) finished" << std::endl;
78 #endif
79 }

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

◆ readAndAddObject()

void WallHandler::readAndAddObject ( std::istream &  is)
finalvirtual

Create a new wall in the WallHandler, based on the information provided in a restart file.

As we add the object into the handler, we need to make sure that the object keeps its existing ID. This is not always the same as the index, e.g. if walls have been removed during the simulation.

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

Implements BaseHandler< BaseWall >.

278 {
279  BaseWall* o = readAndCreateObject(is);
280  unsigned int id = o->getId();
281  addObject(o);
282  getLastObject()->setId(id);
283 }
BaseWall * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:104
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:50
Basic class for walls.
Definition: BaseWall.h:28
BaseWall * readAndCreateObject(std::istream &is)
Create a new wall, based on the information provided in a restart file.
Definition: WallHandler.cc:191
void addObject(BaseWall *W) final
Adds a BaseWall to the WallHandler.
Definition: WallHandler.cc:93

References addObject(), BaseObject::getId(), BaseHandler< BaseWall >::getLastObject(), readAndCreateObject(), and BaseObject::setId().

Referenced by DPMBase::read().

◆ readAndCreateObject()

BaseWall * WallHandler::readAndCreateObject ( std::istream &  is)

Create a new wall, based on the information provided in a restart file.

192 {
194  is >> type;
195  logger(DEBUG, "WallHandler::readAndAddObject(is): reading type %.", type);
196 
197  //for backward compatibility (before svnversion ~2360)
198  if (type == "numFiniteWalls")
199  {
200  return readAndCreateOldObject(is);
201  }
202  else
203  {
204  BaseWall* wall = createObject(type);
205  //check if wall is user-defined
206  if (wall == nullptr)
207  {
209  }
210  //throw warning if wall could not be found
211  if (wall == nullptr)
212  {
214  getline(is, line);
215  logger(WARN, "This wall could not be read; dummy wall is inserted instead:\n%%", type, line);
216  BaseWall* wall = new InfiniteWall;
217  wall->setHandler(this);
218  wall->setSpecies(getDPMBase()->speciesHandler.getObject(0));
219  return wall;
220  }
221  wall->setHandler(this);
222  is >> *wall;
223  wall->setSpecies(getDPMBase()->speciesHandler.getObject(wall->getIndSpecies()));
224  return wall;
225  }
226 }
@ DEBUG
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:104
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:148
virtual BaseWall * readUserDefinedWall(const std::string &type) const
Allows you to read in a wall defined in a Driver directory; see USER/Luca/ScrewFiller.
Definition: DPMBase.h:272
BaseWall * readAndCreateOldObject(std::istream &is)
Create a new wall, based on the information from old-style restart data.
Definition: WallHandler.cc:237
static BaseWall * createObject(const std::string &type)
Create a new wall, with the type given as a string (required for restarting).
Definition: WallHandler.cc:107
line
Definition: calibrate.py:103
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References createObject(), DEBUG, BaseHandler< BaseWall >::getDPMBase(), BaseInteractable::getIndSpecies(), calibrate::line, logger, readAndCreateOldObject(), DPMBase::readUserDefinedWall(), BaseWall::setHandler(), BaseWall::setSpecies(), oomph::Global_string_for_annotation::string(), compute_granudrum_aor::type, and WARN.

Referenced by readAndAddObject().

◆ readAndCreateOldObject()

BaseWall * WallHandler::readAndCreateOldObject ( std::istream &  is)
private

Create a new wall, based on the information 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.
Todo:
This is deprecated since r ~2360.
238 {
239  //read in next line
240  std::stringstream line;
242  logger(VERBOSE, line.str());
243 
244  std::string dummy;
245  unsigned int numWalls;
246  Mdouble position;
247  Vec3D normal;
248  line >> numWalls;
249 
250  if (numWalls == 0)
251  {
252  InfiniteWall* wall = new InfiniteWall();
253  wall->setSpecies(getDPMBase()->speciesHandler.getObject(0));
254  line >> dummy >> normal >> dummy >> position;
255  wall->set(normal, position * normal);
256  return wall;
257  }
258  else
259  {
261  wall->setSpecies(getDPMBase()->speciesHandler.getObject(0));
262  for (unsigned int i = 0; i < numWalls; ++i)
263  {
264  line >> dummy >> normal >> dummy >> position;
265  wall->addObject(normal, position * normal);
266  }
267  return wall;
268  }
269 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
@ VERBOSE
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:97
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i....
Definition: IntersectionOfWalls.cc:117
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
Definition: IntersectionOfWalls.cc:51
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 IntersectionOfWalls::addObject(), BaseHandler< BaseWall >::getDPMBase(), helpers::getLineFromStringStream(), i, calibrate::line, logger, WallFunction::normal(), InfiniteWall::set(), BaseWall::setSpecies(), IntersectionOfWalls::setSpecies(), oomph::Global_string_for_annotation::string(), and VERBOSE.

Referenced by readAndCreateObject().

◆ readTriangleWall()

unsigned WallHandler::readTriangleWall ( std::string  filename,
ParticleSpecies species,
Mdouble  scaleFactor = 1,
Vec3D  centerOfRotation = {0,0,0},
Vec3D  velocity = {0,0,0},
Vec3D  angularVelocity = {0,0,0} 
)

Reads triangulated walls from vtk or stl files, and converts them into a set of TriangleWalls.

The stl files have to be binary STL files. If you have ascii files, you need to convert them (use e.g. https://www.meshconvert.com/)

The vtk files need to be of type POLYDATA and contain triangle strips (see see www.cacr.caltech.edu/~slombey)

Parameters
[in]filenamename of vtk input file, e.g. TriangulatedWallSelfTest.vtk
[in]speciespointer to a species in the species handler that will be assigned to the walls
[in]scaleFactorallows the vertex positions to be scaled (necessary if the vtk file is written in different units than the Mercury implementation, e.g. if the stl file is given in mm, but the Mercury implementation uses meters)
320 {
321  const unsigned groupId = getNextGroupId();
322  std::string fileType = filename.substr(filename.find_last_of('.') + 1);
323 
324  //define a default triangle wall
325  TriangleWall triangleWall;
326  triangleWall.setSpecies(species);
327  triangleWall.setVelocity(velocity);
328  triangleWall.setAngularVelocity(angularVelocity);
329  triangleWall.setGroupId(groupId);
330 
331  if (helpers::lower(fileType) == "vtk")
332  {
333  //try open the input file
334  std::fstream file;
335  file.open(filename.c_str(), std::ios::in);
336  logger.assert_always(file.is_open(), "File opening failed: %", filename);
337 
338  //skip the header lines
339  std::string dummy;
340  getline(file, dummy);
341  getline(file, dummy);
342  getline(file, dummy);
343  getline(file, dummy);
344 
345  //read vertices, apply scaling
346  unsigned num;
347  file >> dummy >> num >> dummy;
348  std::vector<Vec3D> vertex;
349  vertex.reserve(num);
350  Vec3D v;
351  for (unsigned i = 0; i < num; i++)
352  {
353  file >> v.X >> v.Y >> v.Z;
354  v *= scaleFactor;
355  vertex.push_back(v);
356  }
357 
358  //read faces
359  unsigned n = getSize();
360  file >> dummy >> num >> dummy;
361  unsigned id0, id1, id2;
362  for (unsigned i = 0; i < num; i++)
363  {
364  file >> dummy >> id0 >> id1 >> id2;
365  triangleWall.setVertices(vertex[id0], vertex[id1], vertex[id2], centerOfRotation);
366  copyAndAddObject(triangleWall);
367  }
368 
369  //close file
370  file.close();
371 
372  logger(INFO, "Read in % walls from %", getSize() - n,filename);
373 
374  }
375  else if (helpers::lower(fileType) == "stl")
376  {
377 
378  BinaryReader file(filename);
379 
380  STLTriangle triangle;
381 
382  std::string header = file.readString(80);
383  unsigned numTriangles = file.readUnsignedInt(4);
384 
385  for (unsigned i = 0; i < numTriangles; i++)
386  {
387  triangle.normal.x() = file.readFloat(4);
388  triangle.normal.y() = file.readFloat(4);
389  triangle.normal.z() = file.readFloat(4);
390 
391 
392  triangle.vertex1.x() = file.readFloat(4);
393  triangle.vertex1.y() = file.readFloat(4);
394  triangle.vertex1.z() = file.readFloat(4);
395 
396  triangle.vertex2.x() = file.readFloat(4);
397  triangle.vertex2.y() = file.readFloat(4);
398  triangle.vertex2.z() = file.readFloat(4);
399 
400 
401  triangle.vertex3.x() = file.readFloat(4);
402  triangle.vertex3.y() = file.readFloat(4);
403  triangle.vertex3.z() = file.readFloat(4);
404 
405  triangle.vertex1 *= scaleFactor;
406  triangle.vertex2 *= scaleFactor;
407  triangle.vertex3 *= scaleFactor;
408 
409  //add to triangle wall
410  triangleWall.setVertices(triangle.vertex1, triangle.vertex2, triangle.vertex3, centerOfRotation);
411  copyAndAddObject(triangleWall);
412 
413  //Now ignore (read) the two dummy characters
414  file.ignoreChar(2);
415 
416  }
417 
418  logger(INFO, "Read in % walls from %", numTriangles,filename);
419 
420  }
421  else
422  {
423 
424  logger(ERROR, "File type of % must be vtk or stl");
425 
426  }
427 
428  return groupId;
429 }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
@ INFO
@ ERROR
unsigned getNextGroupId()
Should be called each time you assign a groupId. Returns the value of nextGroupId_ and increases next...
Definition: BaseHandler.h:274
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
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:663
void setAngularVelocity(const Vec3D &angularVelocity)
set the angular velocity of the BaseInteractble.
Definition: BaseInteractable.cc:338
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:328
void setGroupId(unsigned groupId)
Definition: BaseObject.h:110
This gives functionality to read information from binary formats like STL etc. This class is complete...
Definition: BinaryReader.h:16
Test of the STL reader. The files used is STL file with containing 12 triange that a 1 by 1 by 1 squa...
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:18
Vec3D vertex2
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:41
Vec3D vertex3
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:42
Vec3D vertex1
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:40
Vec3D normal
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:39
void setVertices(Vec3D A, Vec3D B, Vec3D C)
Sets member variables such that the wall represents a triangle with vertices A, B,...
Definition: TriangleWall.cc:144
Mdouble & y()
RW reference to Y.
Definition: Kernel/Math/Vector.h:401
Mdouble & z()
RW reference to Z.
Definition: Kernel/Math/Vector.h:413
Mdouble & x()
RW reference to X.
Definition: Kernel/Math/Vector.h:389
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107
string filename
Definition: MergeRestartFiles.py:39
std::string lower(std::string s)
returns the input string after converting upper-case characters to lower case
Definition: StringHelpers.cc:11

References BaseHandler< BaseWall >::copyAndAddObject(), ERROR, MergeRestartFiles::filename, BaseHandler< BaseWall >::getNextGroupId(), BaseHandler< BaseWall >::getSize(), i, BinaryReader::ignoreChar(), INFO, logger, helpers::lower(), n, STLTriangle::normal, BinaryReader::readFloat(), BinaryReader::readString(), BinaryReader::readUnsignedInt(), BaseInteractable::setAngularVelocity(), BaseObject::setGroupId(), BaseWall::setSpecies(), BaseInteractable::setVelocity(), TriangleWall::setVertices(), oomph::Global_string_for_annotation::string(), v, Jeffery_Solution::velocity(), STLTriangle::vertex1, STLTriangle::vertex2, STLTriangle::vertex3, Vec3D::x(), Vec3D::y(), and Vec3D::z().

Referenced by MarbleRun::loadBigSeesaw(), MarbleRun::loadSmallSeesaw(), MarbleRun::loadSTLFile(), main(), ChangingTOIParticle::setupInitialConditions(), NozzleDemo::setupInitialConditions(), NozzleSelfTest::setupInitialConditions(), and AreaVTK::setupInitialConditions().

◆ setWriteDetailsVTK() [1/2]

void WallHandler::setWriteDetailsVTK ( DetailsVTKOptions  option,
bool  writeVTK 
)
467 {
469  setWriteDetailsVTK(option, fileType);
470 }
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
Definition: File.h:19
@ MULTIPLE_FILES
each time-step will be written into/read from separate files numbered consecutively: name_....
virtual void writeVTK() const
now empty function for writing VTK files.
Definition: BaseHandler.h:267
void setWriteDetailsVTK(DetailsVTKOptions, FileType)
Definition: WallHandler.cc:460

References MULTIPLE_FILES, NO_FILE, setWriteDetailsVTK(), and BaseHandler< BaseWall >::writeVTK().

◆ setWriteDetailsVTK() [2/2]

void WallHandler::setWriteDetailsVTK ( DetailsVTKOptions  option,
FileType  fileType 
)
461 {
462  // Automatically adds option when it doesn't exist in the map yet
463  writeDetailsVTK_[option] = fileType;
464 }

References writeDetailsVTK_.

Referenced by DPMBase::read(), and setWriteDetailsVTK().

◆ setWriteVTK() [1/2]

void WallHandler::setWriteVTK ( bool  writeVTK)

Sets whether walls are written into a VTK file.

References MULTIPLE_FILES, NO_FILE, BaseHandler< BaseWall >::writeVTK(), and writeVTK_.

◆ setWriteVTK() [2/2]

void WallHandler::setWriteVTK ( FileType  fileType)

Sets whether walls are written into a VTK file.

446 {
447  writeVTK_ = fileType;
448 }

References writeVTK_.

Referenced by AxisymmetricWallSelfTest::AxisymmetricWallSelfTest(), HorizontalMixer::HorizontalMixer(), LaserOnLayer::LaserOnLayer(), main(), MaserRepeatedOutInMPI2Test::MaserRepeatedOutInMPI2Test(), protectiveWall::protectiveWall(), DPMBase::read(), RotatingDrumBidisperse::RotatingDrumBidisperse(), Calibration::setOutput(), ChangingTOIParticle::setupInitialConditions(), NautaMixer::setupInitialConditions(), NozzleDemo::setupInitialConditions(), RotatingDrumWet::setupInitialConditions(), VerticalMixer::setupInitialConditions(), MarbleRun::setupInitialConditions(), InitialBed::setupInitialConditions(), MeltableForceLaw2SelfTest::setupInitialConditions(), MeltableForceLawSelfTest::setupInitialConditions(), ThermalConductionSelfTest::setupInitialConditions(), GetDistanceAndNormalForScrew::setupInitialConditions(), GetDistanceAndNormalForTriangleWall::setupInitialConditions(), Drum::setupInitialConditions(), Penetration::setupInitialConditions(), Silo::setupInitialConditions(), NozzleSelfTest::setupInitialConditions(), TwoParticleBagheriCollision::setupInitialConditions(), TwoParticleClassicalWilletCollision::setupInitialConditions(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), RollingOverTriangleWalls::setupInitialConditions(), MovingWalls::setupInitialConditions(), AreaVTK::setupInitialConditions(), MercuryProblem::setupMercuryProblem(), DPMBase::setWallsWriteVTK(), T_protectiveWall::T_protectiveWall(), TangentialSpringEnergyConservationUnitTest::TangentialSpringEnergyConservationUnitTest(), and Tutorial11::Tutorial11().

◆ setWriteWallSurfaceAreaVTK()

void WallHandler::setWriteWallSurfaceAreaVTK ( bool  writeWallSurfaceAreaVTK)

Enables/disables the calculation and writing of the surface area of the cells.

499 {
500  getDPMBase()->getWallVTKWriter().setWriteWallSurfaceAreaVTK(writeWallSurfaceAreaVTK);
501 }
void setWriteWallSurfaceAreaVTK(bool writeWallSurfaceAreaVTK)
Definition: WallVTKWriter.cc:204

References BaseHandler< BaseWall >::getDPMBase(), DPMBase::getWallVTKWriter(), and WallVTKWriter::setWriteWallSurfaceAreaVTK().

Referenced by AreaVTK::setupInitialConditions().

◆ writeWallDetailsVTKBoundingBox()

void WallHandler::writeWallDetailsVTKBoundingBox ( VTKData data) const
294 {
295  Vec3D P[2] = { getDPMBase()->getMax(), getDPMBase()->getMin() };
296  for (const Vec3D& i : P)
297  {
298  for (const Vec3D& j : P)
299  {
300  for (const Vec3D& k : P)
301  {
302  data.addToPoints(Vec3D(i.X, j.Y, k.Z));
303  }
304  }
305  }
306 
307  data.addToConnectivity({ 0, 1, 3, 2, 0, 4, 5, 1, 5, 7, 3, 7, 6, 2, 6, 4 });
308  data.addToTypes(4);
309 }
int data[]
Definition: Map_placement_new.cpp:1
Vec3D getMax() const
Returns the maximum coordinates of the problem domain.
Definition: DPMBase.h:659
Vec3D getMin() const
Returns the minimum coordinates of the problem domain.
Definition: DPMBase.h:653
char char char int int * k
Definition: level2_impl.h:374
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References data, BaseHandler< BaseWall >::getDPMBase(), DPMBase::getMax(), DPMBase::getMin(), i, j, k, and Global_Physical_Variables::P.

Referenced by WallDetailsVTKWriter::writeVTK().

Member Data Documentation

◆ writeDetailsVTK_

std::unordered_map<DetailsVTKOptions, FileType> WallHandler::writeDetailsVTK_
private

unordered_map storing the file types corresponding to each of the enum DetailsVTKOptions

The filetypes are only actually added to the map when setting or getting it. The getter automatically adds the default filetype NO_FILE when the requested options had not yet been added.

Referenced by getWriteDetailsVTK(), getWriteDetailsVTKAny(), getWriteWallDetailsVTKAll(), and setWriteDetailsVTK().

◆ writeVTK_

FileType WallHandler::writeVTK_
private

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