BaseWall Class Referenceabstract

Basic class for walls. More...

#include <BaseWall.h>

+ Inheritance diagram for BaseWall:

Public Member Functions

 BaseWall ()
 Default constructor. More...
 
 BaseWall (const BaseWall &w)
 Copy constructor. More...
 
 ~BaseWall () override
 Default destructor. More...
 
virtual BaseWallcopy () const =0
 Pure virtual function that can be overwritten in inherited classes in order to copy a BaseWall. More...
 
void read (std::istream &is) override
 Function that reads a BaseWall from an input stream, usually a restart file. More...
 
void write (std::ostream &os) const override
 Function that writes a BaseWall to an output stream, usually a restart file. More...
 
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 normal of this wall if there is a collision. 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)
 
virtual void writeVTK (VTKContainer &vtk) const
 
void getVTK (std::vector< Vec3D > &points, std::vector< std::vector< double >> &triangleStrips)
 
const Vec3D getAxis () const
 
BaseInteractiongetInteractionWith (BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
 Returns the interaction between this wall and a given particle, nullptr if there is no interaction. More...
 
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 std::string getName () const =0
 A purely virtual function. 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
 

Static Public Member Functions

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...
 

Private Attributes

WallHandlerhandler_
 
bool vtkVisibility_ = true
 
std::vector< BaseWall * > renderedWalls_
 

Detailed Description

Basic class for walls.

Class from which all walls inherit. Please note the getVelocity can for some walls be dependent on which point on the wall is meant.

Constructor & Destructor Documentation

◆ BaseWall() [1/2]

BaseWall::BaseWall ( )

Default constructor.

Default constructor for the BaseWall class. Simply creates an empty BaseWall. Note that it also, by default, sets the handler to a null pointer - i.e. does not automatically assign the current object a given WallHandler.

16 {
17  handler_ = nullptr;
18  logger(DEBUG, "BaseWall::BaseWall() finished");
19 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG
WallHandler * handler_
Definition: BaseWall.h:227

References DEBUG, handler_, and logger.

◆ BaseWall() [2/2]

BaseWall::BaseWall ( const BaseWall w)

Copy constructor.

An existing wall (i.e. a BaseWall type object), w, is passed as an argument. A copy of this object is then created. The BaseWall class is relatively low-level, and this copy constructor simply acts to provide a pointer to the WallHandler belonging to w, i.e. assigning the new wall to the same handler as the original. (A derived class' copy constructor calls this, but does all of the other work.)

Parameters
[in]w- The existing BaseWall object to be copied.
31 {
32  //sets the current handler to that belonging to the existing wall, w
33  handler_ = w.handler_;
34  renderedWalls_.reserve(w.renderedWalls_.capacity());
35  vtkVisibility_ = w.vtkVisibility_;
36  for (auto* const r : w.renderedWalls_)
37  renderedWalls_.push_back(r->copy());
38  logger(DEBUG, "BaseWall::BaseWall(const BaseWall &p) finished");
39 }
RowVector3d w
Definition: Matrix_resize_int.cpp:3
BaseInteractable()
Default BaseInteractable constructor.
Definition: BaseInteractable.cc:20
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:240
bool vtkVisibility_
Definition: BaseWall.h:235
r
Definition: UniformPSDSelfTest.py:20

References DEBUG, handler_, logger, UniformPSDSelfTest::r, renderedWalls_, vtkVisibility_, and w.

◆ ~BaseWall()

BaseWall::~BaseWall ( )
override

Default destructor.

Note that this is a virtual destructor, ensuring that derived classes can be deleted easily and safely.

46 {
47  logger(DEBUG, "BaseWall::~BaseWall() finished");
49 }
void removeRenderedWalls()
Definition: BaseWall.cc:541

References DEBUG, logger, and removeRenderedWalls().

Member Function Documentation

◆ actionsAfterParticleGhostUpdate()

virtual void BaseWall::actionsAfterParticleGhostUpdate ( )
inlinevirtual

No implementation but can be overidden in its derived classes.

This function is called by WallHandler::actionsAfterParticleGhostUpdate, which 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).

Reimplemented in MeshTriangle.

172 {}

◆ actionsOnRestart()

virtual void BaseWall::actionsOnRestart ( )
inlinevirtual

No implementation but can be overidden in its derived classes.

This function is called by DPMBase::solve, if the simulation is restarted.

Reimplemented in MeshTriangle.

163 {}

◆ addParticlesAtWall()

void BaseWall::addParticlesAtWall ( unsigned  numElements = 50)
598 {
599  auto& speciesHandler = getHandler()->getDPMBase()->speciesHandler;
600  logger.assert_always(speciesHandler.getSize()>0,"addParticlesAtWall: You need to define at least one species");
601 
604  double h = Vec3D::min(max-min)/numElements;
605  double r = 0.5*h;
606 
607  auto& particleHandler = getHandler()->getDPMBase()->particleHandler;
608  double numParticles0 = particleHandler.getSize();
610  p.setSpecies(speciesHandler.getObject(0));
611  Vec3D pos;
612  for (pos.X = min.X; pos.X <= max.X; pos.X += h)
613  for (pos.Y = min.Y; pos.Y <= max.Y; pos.Y += h)
614  for (pos.Z = min.Z; pos.Z <= max.Z; pos.Z += h)
615  {
616  Vec3D normal;
617  Mdouble distance;
618  p.setRadius(2.0*r);
619  p.setPosition(pos);
620  //if touching the wall
621  if (getDistanceAndNormal(p, distance, normal) && distance>=0)
622  {
623  p.setRadius(r);
624  p.setPosition(pos+(distance-r)*normal);
625  particleHandler.copyAndAddObject(p);
626  }
627  }
628  logger(INFO,"Inserted % particles that touch wall %", particleHandler.getNumberOfObjects()-numParticles0, getIndex());
629 }
@ INFO
float * p
Definition: Tutorial_Map_using.cpp:9
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:663
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:97
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:113
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...
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:16
Definition: Kernel/Math/Vector.h:30
Mdouble Y
Definition: Kernel/Math/Vector.h:45
Mdouble Z
Definition: Kernel/Math/Vector.h:45
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:82
Mdouble X
the vector components
Definition: Kernel/Math/Vector.h:45
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65

References getDistanceAndNormal(), BaseHandler< T >::getDPMBase(), getHandler(), BaseObject::getIndex(), DPMBase::getMax(), DPMBase::getMin(), BaseHandler< T >::getSize(), INFO, logger, max, min, Vec3D::min(), WallFunction::normal(), p, DPMBase::particleHandler, UniformPSDSelfTest::r, DPMBase::speciesHandler, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by AxisymmetricWallSelfTest::setupInitialConditions().

◆ addRenderedWall()

void BaseWall::addRenderedWall ( BaseWall w)
537 {
538  renderedWalls_.push_back(w);
539 }

References renderedWalls_, and w.

◆ addToVTK()

void BaseWall::addToVTK ( const std::vector< Vec3D > &  points,
VTKContainer vtk 
)
static

Takes the points provided and adds a triangle strip connecting these points to the vtk container.

454 {
455  if (!points.empty())
456  {
457  //all all values in myPoints to points
458  vtk.points.insert(vtk.points.end(), points.begin(), points.end());
459 
460  // create one cell object containing all indices of the added points (created a triangle strip connecting these points)
461  std::vector<double> cell;
462  cell.reserve(vtk.points.size() + 1);
463  cell.push_back(vtk.points.size() - 1);
464  for (unsigned i = vtk.points.size() - points.size(); i < vtk.points.size(); i++)
465  {
466  cell.push_back((double) i);
467  }
468 
469  //add this triangle strip to the vtk file
470  vtk.triangleStrips.push_back(cell);
471  }
472 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:19
std::vector< Vec3D > points
Definition: BaseWall.h:18

References i, VTKContainer::points, and VTKContainer::triangleStrips.

Referenced by LevelSetWall::createVTK(), and InfiniteWall::writeVTK().

◆ checkInteractions()

virtual void BaseWall::checkInteractions ( InteractionHandler interactionHandler,
unsigned int  timeStamp 
)
inlinevirtual

Check if all interactions are valid.

This function is called by DPMBase::computeAllForces. It may be used by a wall to check and modify interactions previously created during contact detection.

Reimplemented in MeshTriangle.

199 {}

◆ computeWear()

virtual void BaseWall::computeWear ( )
inlinevirtual

◆ copy()

◆ getAxis()

const Vec3D BaseWall::getAxis ( ) const

This functions returns a axis for a wall using it Quaternion descriptions. At the moment Quaternion are not implemented for a wall; so this is currently a workaround for the non-implementation Quaternion for the walls. In the future this functions will be replaced.

Returns
A Vec3D which is the axis of the wall
486 {
488  Vec3D axis;
489  axis.X = Q.q1;
490  axis.Y = Q.q2;
491  axis.Z = Q.q3;
492  return axis;
493 }
MatrixXf Q
Definition: HouseholderQR_householderQ.cpp:1
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:209
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Kernel/Math/Quaternion.h:42

References BaseInteractable::getOrientation(), Q, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by ScrewsymmetricIntersectionOfWalls::computeDeltaZ().

◆ getDistanceAndNormal()

virtual bool BaseWall::getDistanceAndNormal ( const BaseParticle P,
Mdouble distance,
Vec3D normal_return 
) const
pure virtual

Pure virtual function that computes the distance of a BaseParticle to this wall and returns the normal of this wall if there is a collision.

Beware, the distance and normal are output parameters, not return values!

Parameters
[in]PReference to the BaseParticle we want to compute the distance to the BaseWall of.
[out]distanceDistance of the BaseParticle to the BaseWall.
[out]normal_returnThe normal of the wall. Is only given if there is a collision.
Returns
A boolean which indicates if there is a collision between the BaseParticle and the wall.

Implemented in VChute, TriangulatedWall, TriangleWall, TriangleMeshWall, SphericalWall, SineWall, SimpleDrumSuperquadrics, RestrictedWall, ParabolaChute, MeshTriangle, LevelSetWall, IntersectionOfWalls, InfiniteWallWithHole, InfiniteWall, CylindricalWall, Combtooth, Coil, BasicUnionOfWalls, BasicIntersectionOfWalls, ScrewsymmetricIntersectionOfWalls, Screw, NurbsWall, HorizontalScrew, HorizontalBaseScrew, AxisymmetricIntersectionOfWalls, and ArcWall.

Referenced by addParticlesAtWall(), ChuteWithContraction::ChuteWithContraction(), ChuteWithPeriodicInflowAndContraction::ChuteWithPeriodicInflowAndContraction(), ContractionWithPeriodicInflow::ContractionWithPeriodicInflow(), Domain::findNewMPIInteractions(), RestrictedWall::getDistanceAndNormal(), and getDistanceNormalOverlap().

◆ getDistanceNormalOverlap()

bool BaseWall::getDistanceNormalOverlap ( const BaseParticle P,
Mdouble distance,
Vec3D normal_return,
Mdouble overlap 
) const
virtual
507 {
508  if (P.isSphericalParticle())
509  {
510  bool isInContact = getDistanceAndNormal(P, distance, normal_return);
511  overlap = P.getRadius() - distance;
512  return isInContact;
513  }
514  else
515  {
516  auto superQuadric = dynamic_cast<const SuperQuadricParticle*>(&P);
517  return getDistanceNormalOverlapSuperquadric(*superQuadric, distance, normal_return, overlap);
518  }
519 }
virtual bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:522
Definition: SuperQuadricParticle.h:36
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77

References getDistanceAndNormal(), getDistanceNormalOverlapSuperquadric(), and Global_Physical_Variables::P.

Referenced by getInteractionWith().

◆ getDistanceNormalOverlapSuperquadric()

bool BaseWall::getDistanceNormalOverlapSuperquadric ( const SuperQuadricParticle p,
Mdouble distance,
Vec3D normal_return,
Mdouble overlap 
) const
virtual

Reimplemented in SimpleDrumSuperquadrics, and InfiniteWall.

524 {
525  logger(ERROR, "Generic wall-superquadric interactions not implemented yet.");
526  return false;
527 }
@ ERROR

References ERROR, and logger.

Referenced by getDistanceNormalOverlap().

◆ getFurthestPointSuperQuadric()

Vec3D BaseWall::getFurthestPointSuperQuadric ( const Vec3D normalBodyFixed,
const Vec3D axes,
Mdouble  eps1,
Mdouble  eps2 
) const
virtual

Reimplemented in SimpleDrumSuperquadrics, and InfiniteWall.

530 {
531  logger(ERROR, "Generic wall-superquadric interactions not implemented yet.");
532  return {};
533 }

References ERROR, and logger.

Referenced by getInteractionWith().

◆ getHandler()

◆ getInteractionWith()

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

Returns the interaction between this wall and a given particle, nullptr if there is no interaction.

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 BaseWall and the BaseParticle at the timeStamp.

Implements BaseInteractable.

Reimplemented in VChute, TriangulatedWall, TriangleMeshWall, SineWall, RestrictedWall, ParabolaChute, MeshTriangle, and Combtooth.

347 {
348  Mdouble distance;
349  Vec3D normal;
350  Mdouble overlap;
351 
352  if (getDistanceNormalOverlap(*p, distance, normal, overlap))
353  {
354  #ifdef MERCURYDPM_TRIANGLE_WALL_CORRECTION
355  // look for an existing interaction, or create a new one
356  BaseInteraction *c = nullptr;
357  // This if-statement deals with groups of walls. If a particle has multiple contacts with a group of walls, and if the contact areas of these contacts overlap, then we keep only the biggest of the overlapping contacts.
358  if (getGroupId() > 0 && p->getInteractions().size() > 0) {
359  // if there is a contact with a group of walls, and if p had at least one previously detected contact (in the last timestep or the current)
360  for (const auto i : p->getInteractions()) {
361  if (i->getI() == (BaseInteractable *) this) {
362  // if there is an existing interaction with this wall, keep it
363  i->setTimeStamp(timeStamp);
364  c = i;
365  break;
366  }
367  if (i->getI()->getGroupId() == getGroupId()) {
368  // update contact, otherwise the distance comparison iis not correct
369  // (note this is costly and we should replace this with a quicker algorithm if possible)
370  if (i->getTimeStamp() < timeStamp) {
371  double distance, overlap;
372  Vec3D normal;
373  static_cast<BaseWall*>(i->getI())->getDistanceNormalOverlap(*p, distance, normal, overlap);
374  i->setNormal(-normal);
375  i->setDistance(distance);
376  i->setOverlap(overlap);
377  }
378  // if another interaction with a wall of the same group is found
379  double proj = Vec3D::dot(-normal, i->getNormal());
380  // if the two contacts share a contact area, keep only the contact with the minimum distance
381  if (distance >= i->getDistance()) {
382  // if that other contact is closer to the particle than this one
383  if (proj * distance > (1.0-1e-12) * i->getDistance()) {
384  //if one contact point is in the contact area of the other point
385  //(I take the vector a=radius*n, project it onto the other normal ni: b=(a.ni)ni, and check that |a|>(r-delta_i), which is equivalent to checking whether position+a is a distance less than the contact radius from the normal vector ni )
386  //logger(INFO,"Ignoring contact with % because contact with % is closer",getId(),i->getI()->getId());
387  return nullptr;
388  }
389  //else, continue to compute this contact
390  } else {
391  // if this contact is closer to the particle than the other one
392  if (proj * i->getDistance() >= (1.0-1e-12) * distance) {
393  //if the other contact point is in the contact area of this point, replace the other contact with this one
394  i->setI(this);
395  c = i;
396  // if the contact force has already been computed (with the other wall), undo the force/torque computation
397  if (i->getTimeStamp() == timeStamp) {
398  p->addForce(-i->getForce());
399  this->addForce(i->getForce());
400  if (getHandler()->getDPMBase()->getRotation()) {
401  p->addTorque(-i->getTorque() + Vec3D::cross(p->getPosition() - i->getContactPoint(), i->getForce()));
402  this->addTorque(i->getTorque() - Vec3D::cross(this->getPosition() - i->getContactPoint(), i->getForce()));
403  }
404  }
405  i->setTimeStamp(timeStamp);
406  break;
407  }
408  }
409  }
410  }
411  }
412  if (c == nullptr) {
413  // look for an existing interaction, or create a new one
414  c = interactionHandler->getInteraction(p, this, timeStamp);
415  }
416  #else
417  BaseInteraction* c = interactionHandler->getInteraction(p, this, timeStamp);
418  #endif
419 
420  c->setNormal(-normal);
421  c->setDistance(distance);
422  c->setOverlap(overlap);
423  if (p->isSphericalParticle())
424  {
425  // Set the contact point half the overlap away from the wall.
426  // This choice is made to be consistent with \ref BaseParticle::getInteractionWith
427  // for the case of a collision with a particle of infinite radius.
428  c->setContactPoint(p->getPosition() - (p->getRadius() - 0.5 * c->getOverlap()) * c->getNormal());
429  }
430  else
431  {
432  Vec3D normalBodyFixed = normal;
433  p->getOrientation().rotateBack(normalBodyFixed);
434  auto furthestPoint = getFurthestPointSuperQuadric(normalBodyFixed, p->getAxes(),
435  p->getExponentEps1(), p->getExponentEps2());
436  Vec3D overlapBody = overlap * normalBodyFixed;
437  Vec3D contactPoint = furthestPoint - overlapBody / 2;
438  p->getOrientation().rotate(contactPoint);
439  contactPoint += p->getPosition();
440  c->setContactPoint(contactPoint);
441  }
442  logger(DEBUG, "Particle contact with wall at %", c->getContactPoint());
443  return c;
444  }
445  return nullptr;
446 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Defines the basic properties that a interactable object can have.
Definition: BaseInteractable.h:34
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
Definition: BaseInteractable.cc:110
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
Definition: BaseInteractable.cc:94
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:39
unsigned getGroupId() const
Definition: BaseObject.h:116
Basic class for walls.
Definition: BaseWall.h:28
virtual Vec3D getFurthestPointSuperQuadric(const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
Definition: BaseWall.cc:529
virtual bool getDistanceNormalOverlap(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:505
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
Definition: InteractionHandler.cc:126
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:143
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56
int c
Definition: calibrate.py:100

References BaseInteractable::addForce(), BaseInteractable::addTorque(), calibrate::c, Vec3D::cross(), DEBUG, Vec3D::dot(), e(), getDistanceNormalOverlap(), getFurthestPointSuperQuadric(), BaseObject::getGroupId(), getHandler(), InteractionHandler::getInteraction(), i, logger, WallFunction::normal(), and p.

Referenced by MeshTriangle::getInteractionWith(), RestrictedWall::getInteractionWith(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), ContactDetectionWithWallTester::testEllipsoidsContact(), and ContactDetectionWithWallTester::testSpheresContact().

◆ getInteractionWithSuperQuad()

BaseInteraction * BaseWall::getInteractionWithSuperQuad ( SuperQuadricParticle p,
unsigned  timeStamp,
InteractionHandler interactionHandler 
)
virtual
Todo:
make it work with screw, coil and other weird walls

Reimplemented in SimpleDrumSuperquadrics.

478 {
479  logger(ERROR, "Generic wall-superquad interactions not implemented yet.");
480  return nullptr;
481 }

References ERROR, and logger.

Referenced by SimpleDrumSuperquadrics::getInteractionWithSuperQuad().

◆ getLinePlaneIntersect()

bool BaseWall::getLinePlaneIntersect ( Vec3D intersect,
const Vec3D p0,
const Vec3D p1,
const Vec3D n,
const Vec3D p 
)
184 {
185  // t = (p-p0).n / (p1-p0).n
186  //first compute the denominator
187  Mdouble denominator = Vec3D::dot(p1 - p0, n);
188  if (fabs(denominator) >= 1e-10)
189  {
190  Mdouble t = Vec3D::dot(p - p0, n) / denominator;
191  if (t < 1 + 1e-12 && t > -1e-12)
192  intersect = p0 + t * (p1 - p0);
193  return true;
194  }
195  return false;
196 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Vector3f p0
Definition: MatrixBase_all.cpp:2
Vector3f p1
Definition: MatrixBase_all.cpp:2
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
t
Definition: plotPSD.py:36

References Vec3D::dot(), e(), boost::multiprecision::fabs(), n, p, p0, p1, and plotPSD::t.

◆ getRenderedWall()

BaseWall * BaseWall::getRenderedWall ( size_t  i) const
548 {
549  return renderedWalls_[i];
550 }

References i, and renderedWalls_.

◆ getRenderedWalls()

std::vector< BaseWall * > BaseWall::getRenderedWalls ( ) const
553 {
554  return renderedWalls_;
555 }

References renderedWalls_.

◆ getVTK()

void BaseWall::getVTK ( std::vector< Vec3D > &  points,
std::vector< std::vector< double >> &  triangleStrips 
)
inline
150  {}

◆ getVTKVisibility()

bool BaseWall::getVTKVisibility ( ) const
496 {
497  return vtkVisibility_;
498 }

References vtkVisibility_.

Referenced by renderWall().

◆ handleParticleAddition()

virtual void BaseWall::handleParticleAddition ( unsigned int  id,
BaseParticle p 
)
inlinevirtual

Handles the addition of particles to the particleHandler.

This function is called by DPMBase::handleParticleAddition, whenever a particle is added to the particleHandler. It may be used to update stored pointers to particles

Parameters
[in]idThe id of the removed particle.
[in]pA pointer to the particle.

Reimplemented in MeshTriangle.

182 {}

◆ handleParticleRemoval()

virtual void BaseWall::handleParticleRemoval ( unsigned int  id)
inlinevirtual

Handles the addition of particles to the particleHandler.

This function is called by DPMBase::handleParticleRemoval whenever a (ghost-)particle is removed from the particleHandler. It may be used to update stored pointers to particles

Parameters
[in]idThe id of the removed particle.

Reimplemented in MeshTriangle.

191 {}

◆ intersectVTK()

void BaseWall::intersectVTK ( std::vector< Vec3D > &  points,
Vec3D  normal,
Vec3D  position 
) const

Intersects a of set VTK points representing a wall with a half-space defined by position and normal; This is used in createVTK to restrict the VTK points representing a wall to the inside of the domain.

Checks if a set of VTK points is inside a half-space defined by position and normal; all points outside the half-space are projected onto the half-space boundary. Thus, if the old set of points represented a wall object, the new set of points is represents the intersection of the wall with the half-space.

221 {
222  // find first point in Wall
223  std::vector<Vec3D>::iterator firstIn = points.begin();
224  for (; firstIn != points.end(); firstIn++)
225  {
226  //stop if points[first] is in domain
227  if (isInsideWallVTK(*firstIn, normal, position))
228  {
229  break;
230  }
231  }
232 
233  //if all points are out of the wall
234  if (firstIn == points.end())
235  {
236  logger(DEBUG, "BaseWall::intersectVTK: all points out of wall");
237  return;
238  }
239 
240  // find first point out of the wall after firstIn
241  std::vector<Vec3D>::iterator firstOut = firstIn + 1;
242  for (; firstOut != points.end(); firstOut++)
243  {
244  if (!isInsideWallVTK(*firstOut, normal, position))
245  {
246  break;
247  }
248  }
249 
250  //if all points are in the wall
251  if (firstOut == points.end() && firstIn == points.begin())
252  {
253  logger(DEBUG, "BaseWall::intersectVTK: points completely in wall; removing points");
254  points.clear();
255  return;
256  }
257 
258  //if the sequence starts with a point out of the wall
259  //Several cases have to be distinguished, multiple points in the wall the last point in or out of the wall: ooiiioo, ooioo, ooiii, or ooi
260  //In addition, we add the case iiioo and ioo
261  if (firstIn != points.begin() || !isInsideWallVTK(points.back(), normal, position))
262  {
263  // remove unnessesary points in the wall
264  // ooiiioo -> ooiioo, ooiii -> ooii, iiioo -> iioo
265  if (firstOut - firstIn > 2)
266  {
267  logger(DEBUG, "BaseWall::intersectVTK: remove unnessesary points in the wall");
268  //necessary reset of firstOut, as erase invalidates iterators after erase point
269  points.erase(firstIn + 1, firstOut - 1); //note: erase does not delete the last point
270  firstOut = firstIn + 2;
271  }
272 
273  // if there is only one point in the wall, make it two
274  // ooioo -> ooiioo, ooi -> ooii
275  if (firstOut == firstIn + 1)
276  {
277  logger(DEBUG, "BaseWall::intersectVTK: there is only one point in the wall, make it two");
278  //necessary reset of firstIn, firstOut, as insert invalidates iterators
279  unsigned in = firstIn - points.begin();
280  points.insert(firstIn + 1, *firstIn);
281  firstIn = points.begin() + in;//necessary, unless capacity is set right
282  firstOut = firstIn + 2;
283  }
284 
285  // three cases remain: ooiioo, ooii, iioo
286 
287  //move both points onto the surface of the wall
288  if (firstIn != points.begin())
289  {
290  logger(DEBUG, "BaseWall::intersectVTK: move first point onto the surface of the wall");
291  projectOntoWallVTK(*firstIn, *(firstIn - 1), normal, position);
292  }
293  else
294  {
295  logger(DEBUG,
296  "BaseWall::intersectVTK: move first point (at the beginning of the list) onto the surface of the wall");
297  projectOntoWallVTK(points.front(), points.back(), normal, position);
298  }
299 
300  if (firstOut != points.end())
301  {
302  logger(DEBUG, "BaseWall::intersectVTK: move second point onto the surface of the wall");
303  projectOntoWallVTK(*(firstOut - 1), *firstOut, normal, position);
304  }
305  else
306  {
307  logger(DEBUG,
308  "BaseWall::intersectVTK: move second point (at the end of the list) onto the surface of the wall");
309  projectOntoWallVTK(points.back(), points.front(), normal, position);
310  }
311  //if sequence starts and ends with a point in the wall: iiiooiii
312  }
313  else
314  {
315  logger(DEBUG, "BaseWall::intersectVTK: sequence starts and ends with a point in the wall");
316 
317  // find first point in wall after firstOut
318  for (firstIn = firstOut + 1; firstIn != points.end(); firstIn++)
319  {
320  if (isInsideWallVTK(*firstIn, normal, position))
321  {
322  break;
323  }
324  }
325 
326  // remove unnessesary points in the wall
327  // iiiooiii -> iooi
328  points.erase(firstIn + 1, points.end());
329  points.erase(points.begin(),
330  firstOut - 1); //note: erase does not delete the last point //note iterators are invalid now
331 
332  //move both points onto the surface of the wall: iooi
333  projectOntoWallVTK(points.front(), *(points.begin() + 1), normal, position);
334  projectOntoWallVTK(points.back(), *(points.end() - 2), normal, position);
335  }
336 }
void projectOntoWallVTK(Vec3D &point0, const Vec3D &point1, const Vec3D &normal, const Vec3D &position) const
Definition: BaseWall.cc:210
bool isInsideWallVTK(const Vec3D &point, const Vec3D &normal, const Vec3D &position) const
Definition: BaseWall.cc:199

References DEBUG, isInsideWallVTK(), logger, WallFunction::normal(), and projectOntoWallVTK().

Referenced by InfiniteWall::createVTK(), HorizontalBaseScrew::writeVTK(), IntersectionOfWalls::writeVTK(), ScrewsymmetricIntersectionOfWalls::writeVTK(), and AxisymmetricIntersectionOfWalls::writeVTK().

◆ isFixed()

bool BaseWall::isFixed ( ) const
overridevirtual

Sets all walls (unlike particles) to be inherently fixed - i.e. the bool "is fixed" will by definition return "true" when called for a wall (i.e. any BaseWall tyope object).

Implements BaseInteractable.

166 {
167  return true;
168 }

◆ isInsideWallVTK()

bool BaseWall::isInsideWallVTK ( const Vec3D point,
const Vec3D normal,
const Vec3D position 
) const

Checks if point is in wall (if close to the wall, the point is assumed out of the wall)

200 {
201  return Vec3D::dot(position - point, normal) < -1e-12;
202 }

References Vec3D::dot(), e(), and WallFunction::normal().

Referenced by intersectVTK().

◆ isLocal()

virtual bool BaseWall::isLocal ( Vec3D min,
Vec3D max 
) const
inlinevirtual

if isLocal returns true and the DPM class derived from MercuryBase, the hGrid will be used to find wall-particle contacts, using min/max.

Reimplemented in TriangleWall, TriangleMeshWall, and MeshTriangle.

118  { return false; }

◆ projectOntoWallVTK()

void BaseWall::projectOntoWallVTK ( Vec3D point0,
const Vec3D point1,
const Vec3D normal,
const Vec3D position 
) const

Moves point0 onto the surface of the wallsuch that the direction of the edge from point0 to point1 is preserved.

intersectVTK = point[i] + t*(point[i-1]-point[i]) and (intersectVTK - position) normal_=0. => (position-point[i]-t(point[i-1]-point[i]))*normal_=0 t=(position-point[i]))*normal_ / (point[i-1]-point[i]))*normal_

211 {
212  Vec3D dPoint = point1 - point0;
213  point0 += Vec3D::dot(position - point0, normal) / Vec3D::dot(dPoint, normal) * dPoint;
214 }

References Vec3D::dot(), and WallFunction::normal().

Referenced by intersectVTK().

◆ read()

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

Function that reads a BaseWall from an input stream, usually a restart file.

The BaseWall takes no more information than for a BaseInteractable. (A derived class' read method does most of the work.)

Parameters
[in]is- The input stream from which the BaseWall is read.

Reimplemented from BaseInteractable.

Reimplemented in WearableTriangulatedWall, WearableTriangleMeshWall, WearableNurbsWall, VChute, TriangulatedWall, TriangleWall, TriangleMeshWall, SphericalWall, SineWall, Screw, RestrictedWall, ParabolaChute, NurbsWall, MeshTriangle, LevelSetWall, IntersectionOfWalls, InfiniteWallWithHole, InfiniteWall, HorizontalScrew, CylindricalWall, Combtooth, Coil, BasicUnionOfWalls, BasicIntersectionOfWalls, SimpleDrumSuperquadrics, ScrewsymmetricIntersectionOfWalls, and HorizontalBaseScrew.

58 {
60  unsigned size;
62  if (helpers::isNext(is,"vtkVisibility")) {
63  is >> vtkVisibility_;
64  }
65  if (helpers::isNext(is,"renderedWalls")) {
66  is >> size;
67  for (unsigned i = 0; i < size; i++)
68  {
69  is >> type;
71  wall->setHandler(getHandler());
72  wall->read(is);
73  renderedWalls_.push_back(wall);
74  renderedWalls_.back()->setId(renderedWalls_.size());
75  }
76  }
77 }
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
void read(std::istream &is) override
Reads a BaseInteractable from an input stream.
Definition: BaseInteractable.cc:222
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:104
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:57
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
type
Definition: compute_granudrum_aor.py:141
bool isNext(std::istream &is, const std::string &name)
Checks if the next argument in the input stream equals a certain string. When true,...
Definition: StringHelpers.cc:57
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References WallHandler::createObject(), getHandler(), i, helpers::isNext(), BaseInteractable::read(), read(), renderedWalls_, setHandler(), size, oomph::Global_string_for_annotation::string(), compute_granudrum_aor::type, and vtkVisibility_.

Referenced by SimpleDrumSuperquadrics::read(), ArcWall::read(), read(), BasicIntersectionOfWalls::read(), BasicUnionOfWalls::read(), Coil::read(), Combtooth::read(), CylindricalWall::read(), HorizontalScrew::read(), InfiniteWall::read(), InfiniteWallWithHole::read(), IntersectionOfWalls::read(), LevelSetWall::read(), MeshTriangle::read(), NurbsWall::read(), RestrictedWall::read(), Screw::read(), SineWall::read(), SphericalWall::read(), TriangleMeshWall::read(), TriangleWall::read(), and VChute::read().

◆ removeRenderedWalls()

void BaseWall::removeRenderedWalls ( )
541  {
542  for (auto* const r : renderedWalls_)
543  delete r;
544  renderedWalls_.clear();
545 }

References UniformPSDSelfTest::r, and renderedWalls_.

Referenced by IntersectionOfWalls::clear(), and ~BaseWall().

◆ renderWall()

void BaseWall::renderWall ( VTKContainer vtk)
558 {
559  if (getVTKVisibility())
560  {
561  if (renderedWalls_.empty())
562  {
563  writeVTK(vtk);
564  }
565  else
566  {
567  const Mdouble time = getHandler()->getDPMBase()->getTime();
568  const Mdouble timeStep = getHandler()->getDPMBase()->getTimeStep();
569  const int saveCount = getHandler()->getDPMBase()->dataFile.getSaveCount();
570  for (const auto& r: renderedWalls_)
571  {
572  // First write...
573  r->writeVTK(vtk);
574 
575  // Then update the position and orientation for time steps that were skipped.
576  // We have to use a loop, as doing it at once like so:
577  // r->integrateBeforeForceComputation(time - timeStep * (saveCount - 1), timeStep * saveCount);
578  // r->integrateAfterForceComputation(time - timeStep * (saveCount - 1), timeStep * saveCount);
579  // gives small deviations which add up quickly to give very different results.
580  for (int i = 0; i < saveCount; i++)
581  {
582  r->integrateBeforeForceComputation(time - timeStep * (saveCount - i - 1), timeStep);
583  r->integrateAfterForceComputation(time - timeStep * (saveCount - i - 1), timeStep);
584  }
585  }
586  }
587  }
588 }
virtual void writeVTK(VTKContainer &vtk) const
Definition: BaseWall.cc:448
bool getVTKVisibility() const
Definition: BaseWall.cc:495
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1241
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1484
unsigned int getSaveCount() const
Gets File::saveCount_.
Definition: File.cc:233

References DPMBase::dataFile, BaseHandler< T >::getDPMBase(), getHandler(), File::getSaveCount(), DPMBase::getTime(), DPMBase::getTimeStep(), getVTKVisibility(), i, UniformPSDSelfTest::r, renderedWalls_, and writeVTK().

◆ setForceControl()

void BaseWall::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.

Parameters
[in]forceGoal- the desired force on the wall
[in]gainFactor- the rate at which the velocity of the wall should be adjusted
[in]baseVelocity- the velocity that the wall should travel at when the forceGoal is reached
175  {
176  setPrescribedVelocity([this, forceGoal, gainFactor, baseVelocity] (double time){
177  auto dForce = getForce()-forceGoal;
178  return baseVelocity + gainFactor.multiplyElementwise(dForce);
179  });
180 }
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:105
void setPrescribedVelocity(const std::function< Vec3D(double)> &prescribedVelocity)
Allows the velocity of an infinite mass interactable to be prescribed.
Definition: BaseInteractable.cc:422
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Kernel/Math/Vector.h:129

References BaseInteractable::getForce(), Vec3D::multiplyElementwise(), and BaseInteractable::setPrescribedVelocity().

◆ setHandler()

void BaseWall::setHandler ( WallHandler handler)
virtual

A function which sets the WallHandler for this BaseWall.

Setting the WallHandler also sets the DPMBase and therefore the SpeciesHandler for the species. This wall's species pointer is updated to the new SpeciesHandler.

Parameters
[in]handler- A pointer to the WallHandler that we want to handle this wall.

Reimplemented in IntersectionOfWalls, and MeshTriangle.

105 {
106  handler_ = handler;
107  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
108 }
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:621
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
Definition: BaseInteractable.h:67
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:148

References getHandler(), BaseInteractable::getIndSpecies(), BaseHandler< T >::getObject(), handler_, and setSpecies().

Referenced by read(), BasicIntersectionOfWalls::read(), BasicUnionOfWalls::read(), WallHandler::readAndCreateObject(), MeshTriangle::setHandler(), IntersectionOfWalls::setHandler(), and setSpecies().

◆ setIndSpecies()

void BaseWall::setIndSpecies ( unsigned int  indSpecies)
overridevirtual

Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase.

Deprecated:
TW: this function should be taken out and replaced by setSpecies
Parameters
[in]indSpeciesThe index of the species of this BaseWall in the SpeciesHandler.

Reimplemented from BaseInteractable.

122 {
123  if (handler_ != nullptr)
124  {
125  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
126  }
127  else
128  {
130  logger(ERROR, "setIndSpecies called on a particle with no particle handler.\n"
131  "Therefore I can't request the given species from the species handler.\n"
132  " PartID = %", getId());
133  }
134 }
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
Definition: BaseInteractable.h:77
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:104

References ERROR, getHandler(), BaseObject::getId(), BaseInteractable::getIndSpecies(), BaseHandler< T >::getObject(), handler_, logger, BaseInteractable::setIndSpecies(), and setSpecies().

◆ setSpecies()

void BaseWall::setSpecies ( const ParticleSpecies species)

Defines the species of the current wall.

Firstly, calls the "BaseInteractable" version of the setSpecies function (BaseInteractable::setSpecies()) which actually sets the species_ of the particle (i.e. provides a pointer to the ParticleSpecies which stores the relevant material properties which we wish to assign to out wall) as well as assigning the relevant species index (indSpecies_) as well as performing relevant error checks.

Secondly, sets a pointer to the relevant handler, which is needed to retrieve species information.

Parameters
[in]species- The pointer to the species whose properties we want to assign to the current wall - i.e. the species we want to "give" the wall.
Todo:
TW: this function should also check if the particle is the correct particle for the species type.
149 {
151  //Checks if the current wall currently belongs to a defined wallHandler...
152  if (getHandler() == nullptr)
153  {
154  //and if not:
155  //Creates a pointer to the handler to which the chosen species belongs
156  SpeciesHandler* sH = species->getHandler();
157  //Creates a pointer back to the DPMBase class
158  DPMBase* dB = sH->getDPMBase();
159  //If this is not a null pointer, assigns the current wall to the relevant wallHandler.
160  if (dB != nullptr)
161  setHandler(&dB->wallHandler);
162  }
163 }
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
Definition: BaseInteractable.cc:163
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:78
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:56
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1453
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:15

References BaseHandler< T >::getDPMBase(), BaseSpecies::getHandler(), getHandler(), setHandler(), BaseInteractable::setSpecies(), and DPMBase::wallHandler.

Referenced by ShiftingConstantMassFlowMaserBoundarySelfTest::actionsAfterTimeStep(), ShiftingMaserBoundarySelfTest::actionsAfterTimeStep(), Chute::createBottom(), MercuryProblem::createTriangleWall(), SCoupling< M, O >::createTriangleWall(), GranuDrum::GranuDrum(), HorizontalScrew::HorizontalScrew(), InfiniteWall::InfiniteWall(), InitialConditions< SpeciesType >::InitialConditions(), LevelSetWall::LevelSetWall(), main(), MercuryCGSelfTest::MercuryCGSelfTest(), FileReader::read(), WallHandler::readAndCreateObject(), WallHandler::readAndCreateOldObject(), DPMBase::readParAndIniFiles(), WallHandler::readTriangleWall(), TriangleMeshWall::refineTriangle(), RestrictedWall::set(), TriangleMeshWall::set(), setHandler(), setIndSpecies(), IntersectionOfWalls::setSpecies(), TriangleMeshWall::setSpecies(), T_protectiveWall::setupInitialConditions(), LawinenBox::setupInitialConditions(), MercuryLogo::setupInitialConditions(), SmoothChute::setupInitialConditions(), ChangingTOIParticle::setupInitialConditions(), VerticalMixer::setupInitialConditions(), Binary::setupInitialConditions(), FreeCooling2DinWallsDemo::setupInitialConditions(), FreeCooling3DinWallsDemo::setupInitialConditions(), HeaterBoundaryTest::setupInitialConditions(), HourGlass2D::setupInitialConditions(), HourGlass::setupInitialConditions(), MinimalExampleDrum::setupInitialConditions(), ShiftingConstantMassFlowMaserBoundarySelfTest::setupInitialConditions(), ShiftingMaserBoundarySelfTest::setupInitialConditions(), SilbertPeriodic::setupInitialConditions(), GetDistanceAndNormalForScrew::setupInitialConditions(), GetDistanceAndNormalForTriangleWall::setupInitialConditions(), Drum::setupInitialConditions(), HertzSelfTest::setupInitialConditions(), MindlinSelfTest::setupInitialConditions(), Penetration::setupInitialConditions(), Silo::setupInitialConditions(), Chutebelt::setupInitialConditions(), ConstantMassFlowMaserBoundaryMixedSpeciesSelfTest::setupInitialConditions(), ConstantMassFlowMaserSelfTest::setupInitialConditions(), DistributionPhiNormalSelfTest::setupInitialConditions(), InsertionBoundarySelfTest::setupInitialConditions(), PolydisperseInsertionBoundarySelfTest::setupInitialConditions(), CGHandlerSelfTest::setupInitialConditions(), NewtonsCradleSelftest::setupInitialConditions(), SquarePacking::setupInitialConditions(), ChargedBondedParticleUnitTest::setupInitialConditions(), WallParticleCollision::setupInitialConditions(), my_problem_HGRID::setupInitialConditions(), FreeFallInteractionSelfTest::setupInitialConditions(), FreeFallSelfTest::setupInitialConditions(), LiquidMigrationSelfTest::setupInitialConditions(), ObliqueImpactSelfTest::setupInitialConditions(), TwoBondedParticleElasticCollision::setupInitialConditions(), TwoParticleBagheriCollision::setupInitialConditions(), TwoParticleClassicalWilletCollision::setupInitialConditions(), TwoParticleCollisionInteraction::setupInitialConditions(), TwoParticleElasticCollisionInteraction::setupInitialConditions(), TwoParticleElasticCollision::setupInitialConditions(), CoilSelfTest::setupInitialConditions(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), RollingOverTriangleWalls::setupInitialConditions(), UnionOfWalls::setupInitialConditions(), DrumRot::setupInitialConditions(), RotatingDrum::setupInitialConditions(), BouncingSuperQuadric::setupInitialConditions(), EllipsoidsBouncingOnWallDemo::setupInitialConditions(), GranularCollapse::setupInitialConditions(), EllipticalSuperQuadricCollision::setupInitialConditions(), protectiveWall::setupInitialConditions(), Tutorial11::setupInitialConditions(), Tutorial12::setupInitialConditions(), Tutorial3::setupInitialConditions(), Tutorial4::setupInitialConditions(), Tutorial7::setupInitialConditions(), Tutorial8::setupInitialConditions(), Tutorial9::setupInitialConditions(), EvaporationAndHeatTest::setupInitialConditions(), ExtremeOverlapWithWallsUnitTest::setupInitialConditions(), FreeFallHertzMindlinUnitTest::setupInitialConditions(), FreeFall::setupInitialConditions(), FullRestartTest::setupInitialConditions(), my_problem::setupInitialConditions(), InclinedPlane::setupInitialConditions(), MpiMaserChuteTest::setupInitialConditions(), MultiParticlesInsertion::setupInitialConditions(), MpiPeriodicBoundaryUnitTest::setupInitialConditions(), SetDistributionPhiNormalSelfTest::setupInitialConditions(), WallSpecies::setupInitialConditions(), AreaVTK::setupInitialConditions(), ChuteBottom::setupInitialConditions(), ContactDetectionWithWallTester::setupParticleAndWall(), Chute::setupSideWalls(), and TriangulatedWall::TriangulatedWall().

◆ setVelocityControl()

void BaseWall::setVelocityControl ( Vec3D  forceGoal,
Vec3D  gainFactor,
Vec3D  baseVelocity 
)
590  {
591  setPrescribedVelocity([this, forceGoal, gainFactor, baseVelocity] (double time){
592  auto dForce = getForce()-forceGoal;
593  return baseVelocity + gainFactor.multiplyElementwise(dForce);
594  });
595 }

References BaseInteractable::getForce(), Vec3D::multiplyElementwise(), and BaseInteractable::setPrescribedVelocity().

◆ setVTKVisibility()

void BaseWall::setVTKVisibility ( bool  vtkVisibility)
501 {
502  vtkVisibility_ = vtkVisibility;
503 }

References vtkVisibility_.

Referenced by main().

◆ write()

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

Function that writes a BaseWall to an output stream, usually a restart file.

Reimplemented from BaseInteractable.

Reimplemented in WearableTriangulatedWall, WearableTriangleMeshWall, WearableNurbsWall, VChute, TriangulatedWall, TriangleWall, TriangleMeshWall, SphericalWall, SineWall, Screw, RestrictedWall, ParabolaChute, NurbsWall, MeshTriangle, IntersectionOfWalls, InfiniteWallWithHole, HorizontalScrew, CylindricalWall, Combtooth, Coil, BasicUnionOfWalls, BasicIntersectionOfWalls, SimpleDrumSuperquadrics, ScrewsymmetricIntersectionOfWalls, and HorizontalBaseScrew.

80 {
82  if (vtkVisibility_==false)
83  {
84  os << " vtkVisibility " << vtkVisibility_;
85  }
86  if (renderedWalls_.size()>0)
87  {
88  os << " renderedWalls " << renderedWalls_.size();
89  for (auto w : renderedWalls_)
90  {
91  os << " ";
92  w->write(os);
93  }
94  }
95 }
void write(std::ostream &os) const override
Write a BaseInteractable to an output stream.
Definition: BaseInteractable.cc:252

References renderedWalls_, vtkVisibility_, w, and BaseInteractable::write().

Referenced by SimpleDrumSuperquadrics::write(), ArcWall::write(), BasicIntersectionOfWalls::write(), BasicUnionOfWalls::write(), Coil::write(), Combtooth::write(), CylindricalWall::write(), HorizontalScrew::write(), InfiniteWallWithHole::write(), IntersectionOfWalls::write(), MeshTriangle::write(), NurbsWall::write(), RestrictedWall::write(), Screw::write(), SineWall::write(), SphericalWall::write(), TriangleMeshWall::write(), TriangleWall::write(), and VChute::write().

◆ writeVTK()

void BaseWall::writeVTK ( VTKContainer vtk) const
virtual

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 in TriangulatedWall, TriangleWall, TriangleMeshWall, ScrewsymmetricIntersectionOfWalls, Screw, RestrictedWall, NurbsWall, MeshTriangle, LevelSetWall, IntersectionOfWalls, InfiniteWall, HorizontalScrew, HorizontalBaseScrew, BasicUnionOfWalls, and AxisymmetricIntersectionOfWalls.

449 {
450  logger(WARN, "Walls % of type % have no vtk writer defined", getIndex(), getName());
451 }
@ WARN
virtual std::string getName() const =0
A purely virtual function.

References BaseObject::getIndex(), BaseObject::getName(), logger, and WARN.

Referenced by renderWall(), and RestrictedWall::writeVTK().

◆ writeWallDetailsVTK()

virtual void BaseWall::writeWallDetailsVTK ( VTKData data) const
inlinevirtual

Reimplemented in WearableNurbsWall, and NurbsWall.

225 { };

Member Data Documentation

◆ handler_

WallHandler* BaseWall::handler_
private

A pointer to the WallHandler that handles this BaseWall.

Referenced by BaseWall(), getHandler(), setHandler(), and setIndSpecies().

◆ renderedWalls_

std::vector<BaseWall*> BaseWall::renderedWalls_
private

A vector of walls that gets rendered instead of the actual wall

Referenced by addRenderedWall(), BaseWall(), getRenderedWall(), getRenderedWalls(), read(), removeRenderedWalls(), renderWall(), and write().

◆ vtkVisibility_

bool BaseWall::vtkVisibility_ = true
private

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