RestrictedWall Class Reference

Restriction of a wall to the intersection with another wall. More...

#include <RestrictedWall.h>

+ Inheritance diagram for RestrictedWall:

Public Member Functions

 RestrictedWall ()
 Default constructor, the normal is infinitely long. More...
 
 RestrictedWall (const RestrictedWall &w)
 Copy constructor, copy the given wall. More...
 
 RestrictedWall (BaseWall *wall, InfiniteWall *restriction)
 Constructor setting values. More...
 
 ~RestrictedWall () override
 Default destructor. More...
 
RestrictedWallcopy () const override
 Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism. More...
 
void set (BaseWall *wall, InfiniteWall *restriction)
 Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the wall. More...
 
bool getDistanceAndNormal (const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
 Compute the distance from the wall for a given BaseParticle and return if there is a collision. If there is a collision, also return the normal vector. More...
 
void read (std::istream &is) override
 Reads RestrictedWall from a restart file. More...
 
void oldRead (std::istream &is)
 Reads RestrictedWall from an old-style restart file. More...
 
void write (std::ostream &os) const override
 Writes the RestrictedWall to an output stream, usually a restart file. More...
 
std::string getName () const override
 Returns the name of the object, in this case the string "RestrictedWall". More...
 
BaseInteractiongetInteractionWith (BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
 Look up the interaction between this wall and a BaseParticle at a certain timeStamp. More...
 
void writeVTK (VTKContainer &vtk) const override
 
- Public Member Functions inherited from BaseWall
 BaseWall ()
 Default constructor. More...
 
 BaseWall (const BaseWall &w)
 Copy constructor. More...
 
 ~BaseWall () override
 Default destructor. More...
 
virtual bool getDistanceNormalOverlap (const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
 
virtual bool getDistanceNormalOverlapSuperquadric (const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
 
virtual Vec3D getFurthestPointSuperQuadric (const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
 
virtual void setHandler (WallHandler *handler)
 A function which sets the WallHandler for this BaseWall. More...
 
WallHandlergetHandler () const
 A function which returns the WallHandler that handles this BaseWall. More...
 
void setIndSpecies (unsigned int indSpecies) override
 Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase. More...
 
void setSpecies (const ParticleSpecies *species)
 Defines the species of the current wall. More...
 
bool isFixed () const override
 
void setForceControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity={0, 0, 0})
 Slowly adjusts the force on a wall towards a specified goal, by adjusting (prescribing) the velocity of the wall. More...
 
virtual bool isLocal (Vec3D &min, Vec3D &max) const
 
bool getLinePlaneIntersect (Vec3D &intersect, const Vec3D &p0, const Vec3D &p1, const Vec3D &n, const Vec3D &p)
 
bool isInsideWallVTK (const Vec3D &point, const Vec3D &normal, const Vec3D &position) const
 
void projectOntoWallVTK (Vec3D &point0, const Vec3D &point1, const Vec3D &normal, const Vec3D &position) const
 
void intersectVTK (std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
 
virtual BaseInteractiongetInteractionWithSuperQuad (SuperQuadricParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler)
 
void getVTK (std::vector< Vec3D > &points, std::vector< std::vector< double >> &triangleStrips)
 
const Vec3D getAxis () const
 
virtual void actionsOnRestart ()
 No implementation but can be overidden in its derived classes. More...
 
virtual void actionsAfterParticleGhostUpdate ()
 No implementation but can be overidden in its derived classes. More...
 
virtual void handleParticleAddition (unsigned int id, BaseParticle *p)
 Handles the addition of particles to the particleHandler. More...
 
virtual void handleParticleRemoval (unsigned int id)
 Handles the addition of particles to the particleHandler. More...
 
virtual void checkInteractions (InteractionHandler *interactionHandler, unsigned int timeStamp)
 Check if all interactions are valid. More...
 
bool getVTKVisibility () const
 
void setVTKVisibility (bool vtkVisibility)
 
void addRenderedWall (BaseWall *w)
 
BaseWallgetRenderedWall (size_t i) const
 
std::vector< BaseWall * > getRenderedWalls () const
 
void removeRenderedWalls ()
 
void renderWall (VTKContainer &vtk)
 
void addParticlesAtWall (unsigned numElements=50)
 
void setVelocityControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
 
virtual void writeWallDetailsVTK (VTKData &data) const
 
virtual void computeWear ()
 
- Public Member Functions inherited from BaseInteractable
 BaseInteractable ()
 Default BaseInteractable constructor. More...
 
 BaseInteractable (const BaseInteractable &p)
 Copy constructor. More...
 
 ~BaseInteractable () override
 Destructor, it simply destructs the BaseInteractable and all the objects it contains. More...
 
unsigned int getIndSpecies () const
 Returns the index of the species associated with the interactable object. More...
 
const ParticleSpeciesgetSpecies () const
 Returns a pointer to the species of this BaseInteractable. More...
 
void setSpecies (const ParticleSpecies *species)
 Sets the species of this BaseInteractable. More...
 
const Vec3DgetForce () const
 Returns the force on this BaseInteractable. More...
 
const Vec3DgetTorque () const
 Returns the torque on this BaseInteractable. More...
 
void setForce (const Vec3D &force)
 Sets the force on this BaseInteractable. More...
 
void setTorque (const Vec3D &torque)
 Sets the torque on this BaseInteractable. More...
 
void addForce (const Vec3D &addForce)
 Adds an amount to the force on this BaseInteractable. More...
 
void addTorque (const Vec3D &addTorque)
 Adds an amount to the torque on this BaseInteractable. More...
 
virtual void resetForceTorque (int numberOfOMPthreads)
 
void sumForceTorqueOMP ()
 
const Vec3DgetPosition () const
 Returns the position of this BaseInteractable. More...
 
const QuaterniongetOrientation () const
 Returns the orientation of this BaseInteractable. More...
 
virtual void setPosition (const Vec3D &position)
 Sets the position of this BaseInteractable. More...
 
void setOrientationViaNormal (Vec3D normal)
 Sets the orientation of this BaseInteractable by defining the vector that results from the rotation of the (1,0,0) vector. More...
 
void setOrientationViaEuler (Vec3D eulerAngle)
 Sets the orientation of this BaseInteractable by defining the euler angles. More...
 
virtual void setOrientation (const Quaternion &orientation)
 Sets the orientation of this BaseInteractable. More...
 
virtual void move (const Vec3D &move)
 Moves this BaseInteractable by adding an amount to the position. More...
 
virtual void rotate (const Vec3D &angularVelocityDt)
 Rotates this BaseInteractable. More...
 
const std::vector< BaseInteraction * > & getInteractions () const
 Returns a list of interactions which belong to this interactable. More...
 
void addInteraction (BaseInteraction *I)
 Adds an interaction to this BaseInteractable. More...
 
bool removeInteraction (BaseInteraction *I)
 Removes an interaction from this BaseInteractable. More...
 
void copyInteractionsForPeriodicParticles (const BaseInteractable &p)
 Copies interactions to this BaseInteractable whenever a periodic copy made. More...
 
void setVelocity (const Vec3D &velocity)
 set the velocity of the BaseInteractable. More...
 
void setAngularVelocity (const Vec3D &angularVelocity)
 set the angular velocity of the BaseInteractble. More...
 
void addVelocity (const Vec3D &velocity)
 adds an increment to the velocity. More...
 
void addAngularVelocity (const Vec3D &angularVelocity)
 add an increment to the angular velocity. More...
 
virtual const Vec3DgetVelocity () const
 Returns the velocity of this interactable. More...
 
virtual const Vec3DgetAngularVelocity () const
 Returns the angular velocity of this interactable. More...
 
void setPrescribedPosition (const std::function< Vec3D(double)> &prescribedPosition)
 Allows the position of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedPosition (double time)
 Computes the position from the user defined prescribed position function. More...
 
void setPrescribedVelocity (const std::function< Vec3D(double)> &prescribedVelocity)
 Allows the velocity of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedVelocity (double time)
 Computes the velocity from the user defined prescribed velocity function. More...
 
void setPrescribedOrientation (const std::function< Quaternion(double)> &prescribedOrientation)
 Allows the orientation of the infinite mass interactbale to be prescribed. More...
 
void applyPrescribedOrientation (double time)
 Computes the orientation from the user defined prescribed orientation function. More...
 
void setPrescribedAngularVelocity (const std::function< Vec3D(double)> &prescribedAngularVelocity)
 Allows the angular velocity of the infinite mass interactable to be prescribed. More...
 
void applyPrescribedAngularVelocity (double time)
 Computes the angular velocity from the user defined prescribed angular velocity. More...
 
virtual const Vec3D getVelocityAtContact (const Vec3D &contact) const
 Returns the velocity at the contact point, use by many force laws. More...
 
void integrateBeforeForceComputation (double time, double timeStep)
 This is part of integrate routine for objects with infinite mass. More...
 
void integrateAfterForceComputation (double time, double timeStep)
 This is part of the integration routine for objects with infinite mass. More...
 
virtual Mdouble getInvMass () const
 
virtual Mdouble getCurvature (const Vec3D &labFixedCoordinates) const
 
virtual bool isFaceContact (const Vec3D &normal) const
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Private Attributes

BaseWallwall_
 
InfiniteWallrestriction_
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseWall
static void addToVTK (const std::vector< Vec3D > &points, VTKContainer &vtk)
 Takes the points provided and adds a triangle strip connecting these points to the vtk container. More...
 

Detailed Description

Restriction of a wall to the intersection with another wall.

This is a class defining walls. It defines the interaction of regular walls and periodic walls with particles as defined in Particle Modifications:

Constructor & Destructor Documentation

◆ RestrictedWall() [1/3]

RestrictedWall::RestrictedWall ( )

Default constructor, the normal is infinitely long.

35 {
36  wall_ = nullptr;
37  restriction_ = nullptr;
38  logger(DEBUG, "RestrictedWall::RestrictedWall ) finished");
39 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG
InfiniteWall * restriction_
Definition: RestrictedWall.h:115
BaseWall * wall_
Definition: RestrictedWall.h:114

References DEBUG, logger, restriction_, and wall_.

Referenced by copy().

◆ RestrictedWall() [2/3]

RestrictedWall::RestrictedWall ( const RestrictedWall w)

Copy constructor, copy the given wall.

Parameters
[in]wRestrictedWall that has to be copied.

First copy the attributes of the BaseWall, then copy the ones that are specific for the RestrictedWall.

47  : BaseWall(w)
48 {
49  wall_ = nullptr;
50  restriction_ = nullptr;
51  set(w.wall_, w.restriction_);
52  logger(DEBUG, "RestrictedWall::RestrictedWall(const RestrictedWall &p) finished");
53 }
BaseWall()
Default constructor.
Definition: BaseWall.cc:36
void set(BaseWall *wall, InfiniteWall *restriction)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: RestrictedWall.cc:92

References DEBUG, logger, restriction_, set(), and wall_.

◆ RestrictedWall() [3/3]

RestrictedWall::RestrictedWall ( BaseWall wall,
InfiniteWall restriction 
)

Constructor setting values.

56 {
57  wall_ = nullptr;
58  restriction_ = nullptr;
59  set(wall, restriction);
60 }

References restriction_, set(), and wall_.

◆ ~RestrictedWall()

RestrictedWall::~RestrictedWall ( )
override

Default destructor.

63 {
64  if (wall_ != nullptr)
65  {
66  delete wall_;
67  wall_ = nullptr;
68  }
69  if (restriction_ != nullptr)
70  {
71  delete restriction_;
72  restriction_ = nullptr;
73  }
74  logger(DEBUG, "RestrictedWall::~RestrictedWall finished");
75 }

References DEBUG, logger, restriction_, and wall_.

Member Function Documentation

◆ copy()

RestrictedWall * RestrictedWall::copy ( ) const
overridevirtual

Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.

Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism

Implements BaseWall.

81 {
82  return new RestrictedWall(*this);
83 }
RestrictedWall()
Default constructor, the normal is infinitely long.
Definition: RestrictedWall.cc:34

References RestrictedWall().

◆ getDistanceAndNormal()

bool RestrictedWall::getDistanceAndNormal ( const BaseParticle p,
Mdouble distance,
Vec3D normal_return 
) const
overridevirtual

Compute the distance from the wall for a given BaseParticle and return if there is a collision. If there is a collision, also return the normal vector.

Parameters
[in]pBaseParticle for which the distance to the wall must be computed.
[out]distanceDistance between the particle and the wall.
[out]normal_returnThe normal of this wall, will only be set if there is a collision.
Returns
A boolean value for whether or not there is a collision.

First the distance is checked. If there is no collision, this function will return false and give the distance. If there is a collision, the function will return true and give the distance and the normal vector of this wall. Since this function should be called before calculating any Particle-Wall interactions, it can also be used to set the normal vector in case of curved walls.

Implements BaseWall.

125 {
127  return wall_->getDistanceAndNormal(p, distance, normal_return);
128  else
129  return false;
130 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Mdouble getWallInteractionRadius(const BaseWall *wall) const
returns the radius plus the interactionDistance
Definition: BaseParticle.h:386
virtual bool getDistanceAndNormal(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const =0
Pure virtual function that computes the distance of a BaseParticle to this wall and returns the norma...
Mdouble getDistance(Vec3D position) const
Returns the distance of the wall to the particle.
Definition: InfiniteWall.cc:151

References InfiniteWall::getDistance(), BaseWall::getDistanceAndNormal(), BaseInteractable::getPosition(), BaseParticle::getWallInteractionRadius(), restriction_, and wall_.

◆ getInteractionWith()

BaseInteraction * RestrictedWall::getInteractionWith ( BaseParticle p,
unsigned  timeStamp,
InteractionHandler interactionHandler 
)
overridevirtual

Look up the interaction between this wall and a BaseParticle at a certain timeStamp.

Parameters
[in]pPointer to the BaseParticle which we want to check the interaction for.
[in]timeStampThe time at which we want to look at the interaction.
[in]interactionHandlerA pointer to the InteractionHandler in which the interaction can be found.
Returns
A pointer to the BaseInteraction that happened between this RestrictedWall and the BaseParticle at the timeStamp.
Todo:
Shouldn't this function be defined in BaseWall?
Todo:
{setting the index of the wall is necessary to get the right index reported in fstat; however, the better way would be to make setIndex virtual.}

Reimplemented from BaseWall.

171 {
173  {
175  wall_->setIndex(getIndex());
176  return wall_->getInteractionWith(p, timeStamp, interactionHandler);
177  }
178  else
179  {
180  return nullptr;
181  }
182 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:64
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Returns the interaction between this wall and a given particle, nullptr if there is no interaction.
Definition: BaseWall.cc:367

References InfiniteWall::getDistance(), BaseObject::getIndex(), BaseWall::getInteractionWith(), BaseInteractable::getPosition(), BaseParticle::getWallInteractionRadius(), restriction_, BaseObject::setIndex(), and wall_.

◆ getName()

std::string RestrictedWall::getName ( ) const
overridevirtual

Returns the name of the object, in this case the string "RestrictedWall".

Returns
The string "RestrictedWall", which is the name of this class.

Implements BaseObject.

157 {
158  return "RestrictedWall";
159 }

Referenced by write().

◆ oldRead()

void RestrictedWall::oldRead ( std::istream &  is)

Reads RestrictedWall from an old-style restart file.

◆ read()

void RestrictedWall::read ( std::istream &  is)
overridevirtual

Reads RestrictedWall from a restart file.

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

Reimplemented from BaseWall.

136 {
137  wall_->read(is);
138  restriction_->read(is);
139 }
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:78
void read(std::istream &is) override
Reads InfiniteWall from a restart file.
Definition: InfiniteWall.cc:180

References BaseWall::read(), InfiniteWall::read(), restriction_, and wall_.

◆ set()

void RestrictedWall::set ( BaseWall wall,
InfiniteWall restriction 
)

Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the wall.

Todo:
TW maybe the Restricted wall should be templated with the wall type such that we don't need to use new and delete.
93 {
94  if (wall_ != nullptr)
95  {
96  delete wall_;
97  wall_ = nullptr;
98  }
99  wall_ = wall->copy();
101 
102  if (restriction_ != nullptr)
103  {
104  delete restriction_;
105  restriction_ = nullptr;
106  }
107  restriction_ = restriction->copy();
108 
109  // std::cout << *this << std::endl;
110 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
Definition: BaseInteractable.h:108
virtual BaseWall * copy() const =0
Pure virtual function that can be overwritten in inherited classes in order to copy a BaseWall.
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169
InfiniteWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: InfiniteWall.cc:105

References BaseWall::copy(), InfiniteWall::copy(), BaseInteractable::getSpecies(), restriction_, BaseWall::setSpecies(), and wall_.

Referenced by RestrictedWall().

◆ write()

void RestrictedWall::write ( std::ostream &  os) const
overridevirtual

Writes the RestrictedWall to an output stream, usually a restart file.

Parameters
[in]osThe output stream the RestrictedWall is written to.

Reimplemented from BaseWall.

145 {
146  //todo check
147  os << getName() << ' ';
148  wall_->write(os);
149  os << ' ';
150  restriction_->write(os);
151 }
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:100
std::string getName() const override
Returns the name of the object, in this case the string "RestrictedWall".
Definition: RestrictedWall.cc:156

References getName(), restriction_, wall_, and BaseWall::write().

◆ writeVTK()

void RestrictedWall::writeVTK ( VTKContainer vtk) const
overridevirtual

adds extra information to the points and triangleStrips vectors needed to plot the wall in vtk format

Parameters
pointsCoordinates of the vertices of the triangulated surfaces (in the VTK file this is called POINTS)
triangleStripsIndices of three vertices forming one triangulated surface (in the VTK file this is called CELL)

Reimplemented from BaseWall.

185 {
186  const size_t size0 = vtk.triangleStrips.size();
187  //write full BaseWall
188  wall_->writeVTK(vtk);
189 
190  //copy out the new triangle strips, so we can modify them
191  std::vector<std::vector<double>> myTriangleStrips;
192  while (vtk.triangleStrips.size() > size0)
193  {
194  myTriangleStrips.push_back(vtk.triangleStrips.back());
195  vtk.triangleStrips.pop_back();
196  }
197 
198  //now remove points that are in restricted area
199  for (const std::vector<double>& myTriangleStrip: myTriangleStrips)
200  {
201  unsigned counter = 0;
202  std::vector<double> cell;
203  //for each triangle
204  for (const double c: myTriangleStrip)
205  {
206  Mdouble distance = restriction_->getDistance(vtk.points[c]);
207  if (distance < 0)
208  {
209  //if the current point is inside the restricted volume, write it
210  cell.push_back(c);
211  counter = 0;
212  }
213  else
214  {
215  if (counter >= 2)
216  {
217  //if the current point is not in restriction, don't write it and flush the cell into the cells array
218  if (cell.size() > 2)
219  vtk.triangleStrips.push_back(cell);
220  cell.clear();
221  counter = 0;
222  }
223  vtk.points[c] += distance * restriction_->getNormal();
224  cell.push_back(c);
225  counter++;
226  }
227  }
228  if (cell.size() > 2)
229  {
230  //if the current point is not in restriction, don't write it and flush the cell into the cells array
231  vtk.triangleStrips.push_back(cell);
232  cell.clear();
233  }
234  }
235 }
double Mdouble
Definition: GeneralDefine.h:34
virtual void writeVTK(VTKContainer &vtk) const
Definition: BaseWall.cc:496
Vec3D getNormal() const
Access function for normal.
Definition: InfiniteWall.cc:213
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:40
std::vector< Vec3D > points
Definition: BaseWall.h:39

References InfiniteWall::getDistance(), InfiniteWall::getNormal(), VTKContainer::points, restriction_, VTKContainer::triangleStrips, wall_, and BaseWall::writeVTK().

Member Data Documentation

◆ restriction_

◆ wall_

BaseWall* RestrictedWall::wall_
private

Outward normal vector. This does not have to be a unit vector.

Referenced by getDistanceAndNormal(), getInteractionWith(), read(), RestrictedWall(), set(), write(), writeVTK(), and ~RestrictedWall().


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