MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RestrictedWall Class Reference

This is a class defining walls. 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
 
bool getVTKVisibility () const
 
void setVTKVisibility (bool vtkVisibility)
 
void addRenderedWall (BaseWall *w)
 
BaseWallgetRenderedWall (size_t i) const
 
void removeRenderedWalls ()
 
void renderWall (VTKContainer &vtk)
 
void addParticlesAtWall (unsigned numElements=50)
 
void setVelocityControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
 
- 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...
 
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...
 
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...
 
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
 
- 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

This is a class defining walls.

It defines the interaction of regular walls and periodic walls with particles as defined in Particle Modifications:

Restriction of a wall to the intersection with another wall

Definition at line 42 of file RestrictedWall.h.

Constructor & Destructor Documentation

RestrictedWall::RestrictedWall ( )

Default constructor, the normal is infinitely long.

Definition at line 34 of file RestrictedWall.cc.

References DEBUG, logger, restriction_, and wall_.

Referenced by copy().

35 {
36  wall_ = nullptr;
37  restriction_ = nullptr;
38  logger(DEBUG, "RestrictedWall::RestrictedWall ) finished");
39 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
BaseWall * wall_
InfiniteWall * restriction_
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.

Definition at line 46 of file RestrictedWall.cc.

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

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 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
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...
BaseWall()
Default constructor.
Definition: BaseWall.cc:36
BaseWall * wall_
InfiniteWall * restriction_
RestrictedWall::RestrictedWall ( BaseWall wall,
InfiniteWall restriction 
)

Constructor setting values.

Definition at line 55 of file RestrictedWall.cc.

References restriction_, set(), and wall_.

56 {
57  wall_ = nullptr;
58  restriction_ = nullptr;
59  set(wall, restriction);
60 }
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...
BaseWall * wall_
InfiniteWall * restriction_
RestrictedWall::~RestrictedWall ( )
override

Default destructor.

Definition at line 62 of file RestrictedWall.cc.

References DEBUG, logger, restriction_, and wall_.

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 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
BaseWall * wall_
InfiniteWall * restriction_

Member Function Documentation

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.

Definition at line 80 of file RestrictedWall.cc.

References RestrictedWall().

81 {
82  return new RestrictedWall(*this);
83 }
RestrictedWall()
Default constructor, the normal is infinitely long.
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.

Definition at line 124 of file RestrictedWall.cc.

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

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.
Mdouble getWallInteractionRadius(const BaseWall *wall) const
returns the radius plus the interactionDistance
Definition: BaseParticle.h:383
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...
BaseWall * wall_
InfiniteWall * restriction_
Mdouble getDistance(Vec3D position) const
Returns the distance of the wall to the particle.
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.

Definition at line 170 of file RestrictedWall.cc.

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

171 {
173  {
175  wall_->setIndex(getIndex());
176  return wall_->getInteractionWith(p, timeStamp, interactionHandler);
177  }
178  else
179  {
180  return nullptr;
181  }
182 }
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:64
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
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:369
Mdouble getWallInteractionRadius(const BaseWall *wall) const
returns the radius plus the interactionDistance
Definition: BaseParticle.h:383
BaseWall * wall_
InfiniteWall * restriction_
Mdouble getDistance(Vec3D position) const
Returns the distance of the wall to the particle.
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.

Definition at line 156 of file RestrictedWall.cc.

Referenced by write().

157 {
158  return "RestrictedWall";
159 }
void RestrictedWall::oldRead ( std::istream &  is)

Reads RestrictedWall from an old-style restart file.

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.

Definition at line 135 of file RestrictedWall.cc.

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

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:80
BaseWall * wall_
void read(std::istream &is) override
Reads InfiniteWall from a restart file.
InfiniteWall * restriction_
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.

Definition at line 92 of file RestrictedWall.cc.

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

Referenced by RestrictedWall().

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.
InfiniteWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
BaseWall * wall_
InfiniteWall * restriction_
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:171
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.

Definition at line 144 of file RestrictedWall.cc.

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

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:102
BaseWall * wall_
InfiniteWall * restriction_
std::string getName() const override
Returns the name of the object, in this case the string "RestrictedWall".
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.

Definition at line 184 of file RestrictedWall.cc.

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

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 }
virtual void writeVTK(VTKContainer &vtk) const
Definition: BaseWall.cc:466
double Mdouble
Definition: GeneralDefine.h:34
Vec3D getNormal() const
Access function for normal.
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:39
BaseWall * wall_
std::vector< Vec3D > points
Definition: BaseWall.h:38
InfiniteWall * restriction_
Mdouble getDistance(Vec3D position) const
Returns the distance of the wall to the particle.

Member Data Documentation

InfiniteWall* RestrictedWall::restriction_
private
BaseWall* RestrictedWall::wall_
private

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

Definition at line 114 of file RestrictedWall.h.

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


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