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.

37 {
38  handler_ = nullptr;
39  logger(DEBUG, "BaseWall::BaseWall() finished");
40 }
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:248

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.
51  : BaseInteractable(w)
52 {
53  //sets the current handler to that belonging to the existing wall, w
54  handler_ = w.handler_;
55  renderedWalls_.reserve(w.renderedWalls_.capacity());
57  for (auto* const r : w.renderedWalls_)
58  renderedWalls_.push_back(r->copy());
59  logger(DEBUG, "BaseWall::BaseWall(const BaseWall &p) finished");
60 }
BaseInteractable()
Default BaseInteractable constructor.
Definition: BaseInteractable.cc:42
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:261
bool vtkVisibility_
Definition: BaseWall.h:256

References DEBUG, handler_, logger, renderedWalls_, and vtkVisibility_.

◆ ~BaseWall()

BaseWall::~BaseWall ( )
override

Default destructor.

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

67 {
68  logger(DEBUG, "BaseWall::~BaseWall() finished");
70 }
void removeRenderedWalls()
Definition: BaseWall.cc:589

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.

193 {}

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

184 {}

◆ addParticlesAtWall()

void BaseWall::addParticlesAtWall ( unsigned  numElements = 50)
646 {
647  auto& speciesHandler = getHandler()->getDPMBase()->speciesHandler;
648  logger.assert_always(speciesHandler.getSize()>0,"addParticlesAtWall: You need to define at least one species");
649 
650  Vec3D max = getHandler()->getDPMBase()->getMax();
651  Vec3D min = getHandler()->getDPMBase()->getMin();
652  double h = Vec3D::min(max-min)/numElements;
653  double r = 0.5*h;
654 
655  auto& particleHandler = getHandler()->getDPMBase()->particleHandler;
656  double numParticles0 = particleHandler.getSize();
658  p.setSpecies(speciesHandler.getObject(0));
659  Vec3D pos;
660  for (pos.X = min.X; pos.X <= max.X; pos.X += h)
661  for (pos.Y = min.Y; pos.Y <= max.Y; pos.Y += h)
662  for (pos.Z = min.Z; pos.Z <= max.Z; pos.Z += h)
663  {
664  Vec3D normal;
665  Mdouble distance;
666  p.setRadius(2.0*r);
667  p.setPosition(pos);
668  //if touching the wall
669  if (getDistanceAndNormal(p, distance, normal) && distance>=0)
670  {
671  p.setRadius(r);
672  p.setPosition(pos+(distance-r)*normal);
673  particleHandler.copyAndAddObject(p);
674  }
675  }
676  logger(INFO,"Inserted % particles that touch wall %", particleHandler.getNumberOfObjects()-numParticles0, getIndex());
677 }
double Mdouble
Definition: GeneralDefine.h:34
@ INFO
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:134
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:1427
Vec3D getMax() const
Definition: DPMBase.h:670
Vec3D getMin() const
Definition: DPMBase.h:664
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:102
Mdouble X
the vector components
Definition: Vector.h:66

References getDistanceAndNormal(), BaseHandler< T >::getDPMBase(), getHandler(), BaseObject::getIndex(), DPMBase::getMax(), DPMBase::getMin(), BaseHandler< T >::getSize(), INFO, logger, Vec3D::min(), DPMBase::particleHandler, BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), DPMBase::speciesHandler, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by AxisymmetricWallSelfTest::setupInitialConditions().

◆ addRenderedWall()

void BaseWall::addRenderedWall ( BaseWall w)
585 {
586  renderedWalls_.push_back(w);
587 }

References renderedWalls_.

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

502 {
503  if (!points.empty())
504  {
505  //all all values in myPoints to points
506  vtk.points.insert(vtk.points.end(), points.begin(), points.end());
507 
508  // create one cell object containing all indices of the added points (created a triangle strip connecting these points)
509  std::vector<double> cell;
510  cell.reserve(vtk.points.size() + 1);
511  cell.push_back(vtk.points.size() - 1);
512  for (unsigned i = vtk.points.size() - points.size(); i < vtk.points.size(); i++)
513  {
514  cell.push_back((double) i);
515  }
516 
517  //add this triangle strip to the vtk file
518  vtk.triangleStrips.push_back(cell);
519  }
520 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:40
std::vector< Vec3D > points
Definition: BaseWall.h:39

References constants::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.

220 {}

Referenced by DPMBase::computeAllForces().

◆ 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
534 {
536  Vec3D axis;
537  axis.X = Q.q1;
538  axis.Y = Q.q2;
539  axis.Z = Q.q3;
540  return axis;
541 }
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Quaternion.h:63
Mdouble q1
the first component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:73
Mdouble q3
the third component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:81
Mdouble q2
the second component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:77

References BaseInteractable::getOrientation(), Quaternion::q1, Quaternion::q2, Quaternion::q3, 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
555 {
556  if (P.isSphericalParticle())
557  {
558  bool isInContact = getDistanceAndNormal(P, distance, normal_return);
559  overlap = P.getRadius() - distance;
560  return isInContact;
561  }
562  else
563  {
564  auto superQuadric = dynamic_cast<const SuperQuadricParticle*>(&P);
565  return getDistanceNormalOverlapSuperquadric(*superQuadric, distance, normal_return, overlap);
566  }
567 }
virtual bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:570
Definition: SuperQuadricParticle.h:57
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73

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.

572 {
573  logger(ERROR, "Generic wall-superquadric interactions not implemented yet.");
574  return false;
575 }
@ 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.

578 {
579  logger(ERROR, "Generic wall-superquadric interactions not implemented yet.");
580  return {};
581 }

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

Implements BaseInteractable.

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

368 {
369  Mdouble distance;
370  Vec3D normal;
371  Mdouble overlap;
372 
373  if (getDistanceNormalOverlap(*p, distance, normal, overlap))
374  {
375  // look for an existing interaction, or create a new one
376  BaseInteraction *c = nullptr;
377 
378  #ifndef MERCURYDPM_TRIANGLE_WALL_CORRECTION
379  // 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.
380  if (getGroupId() > 0 && p->getInteractions().size() > 0) {
381  // 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)
382  for (const auto i : p->getInteractions()) {
383  if (i->getI() == (BaseInteractable *) this) {
384  // if there is an existing interaction with this wall, keep it
385  i->setTimeStamp(timeStamp);
386  c = i;
387  break;
388  }
389  if (i->getI()->getGroupId() == getGroupId()) {
390  // update contact, otherwise the distance comparison iis not correct
391  // (note this is costly and we should replace this with a quicker algorithm if possible)
392  if (i->getTimeStamp() < timeStamp) {
393  double distance, overlap;
394  Vec3D normal;
395  static_cast<BaseWall*>(i->getI())->getDistanceNormalOverlap(*p, distance, normal, overlap);
396  i->setNormal(-normal);
397  i->setDistance(distance);
398  i->setOverlap(overlap);
399  }
400  // if another interaction with a wall of the same group is found
401  double proj = Vec3D::dot(-normal, i->getNormal());
402  // if the two contacts share a contact area, keep only the contact with the minimum distance
403  if (distance >= i->getDistance()) {
404  // if that other contact is closer to the particle than this one
405  if (proj * distance > (1.0-1e-12) * i->getDistance()) {
406  //if one contact point is in the contact area of the other point
407  //(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 )
408  //logger(INFO,"Ignoring contact with % because contact with % is closer",getId(),i->getI()->getId());
409  return nullptr;
410  }
411  //else, continue to compute this contact
412  } else {
413  // if this contact is closer to the particle than the other one
414  if (proj * i->getDistance() >= (1.0-1e-12) * distance) {
415  //if the other contact point is in the contact area of this point, replace the other contact with this one
416  i->setI(this);
417  c = i;
418  // if the contact force has already been computed (with the other wall), undo the force/torque computation
419  if (i->getTimeStamp() == timeStamp) {
420  p->addForce(-i->getForce());
421  this->addForce(i->getForce());
422  if (getHandler()->getDPMBase()->getRotation()) {
423  p->addTorque(-i->getTorque() + Vec3D::cross(p->getPosition() - i->getContactPoint(), i->getForce()));
424  this->addTorque(i->getTorque() - Vec3D::cross(this->getPosition() - i->getContactPoint(), i->getForce()));
425  }
426  }
427  i->setTimeStamp(timeStamp);
428  break;
429  }
430  }
431  }
432  }
433  }
434  #else
435  // 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.
436  if (getGroupId() > 0) {
437  // 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)
438  for (const auto i : p->getInteractions()) {
439  const BaseInteractable* q = i->getI();
440  if (q->getGroupId() == getGroupId() and i->getTimeStamp() == timeStamp) {
441  if (not(isFaceContact(normal) and q->isFaceContact(i->getNormal())))
442  {
444  if (overlap > i->getOverlap()) {
445  p->addForce(-i->getForce());
446  this->addForce(i->getForce());
447  if (getHandler()->getDPMBase()->getRotation()) {
448  p->addTorque(-i->getTorque() +
449  Vec3D::cross(p->getPosition() - i->getContactPoint(), i->getForce()));
450  this->addTorque(i->getTorque() -
451  Vec3D::cross(this->getPosition() - i->getContactPoint(),
452  i->getForce()));
453  }
454  i->setI(this);
455  c = i;
456  } else {
457  return nullptr;
458  }
459  }
460  }
461  }
462  }
463  #endif
464 
465  if (c == nullptr) {
466  // look for an existing interaction, or create a new one
467  c = interactionHandler->getInteraction(p, this, timeStamp);
468  }
469 
470  c->setNormal(-normal);
471  c->setDistance(distance);
472  c->setOverlap(overlap);
473  if (p->isSphericalParticle())
474  {
476  c->setContactPoint(p->getPosition() - (p->getRadius() - 0.5 * c->getOverlap()) * c->getNormal());
477  }
478  else
479  {
480  Vec3D normalBodyFixed = normal;
481  p->getOrientation().rotateBack(normalBodyFixed);
482  auto furthestPoint = getFurthestPointSuperQuadric(normalBodyFixed, p->getAxes(),
483  p->getExponentEps1(), p->getExponentEps2());
484  Vec3D overlapBody = overlap * normalBodyFixed;
485  Vec3D contactPoint = furthestPoint - overlapBody / 2;
486  p->getOrientation().rotate(contactPoint);
487  contactPoint += p->getPosition();
488  c->setContactPoint(contactPoint);
489  }
490  logger(DEBUG, "Particle contact with wall at %", c->getContactPoint());
491  return c;
492  }
493  return nullptr;
494 }
Defines the basic properties that a interactable object can have.
Definition: BaseInteractable.h:55
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
Definition: BaseInteractable.cc:132
virtual bool isFaceContact(const Vec3D &normal) const
Definition: BaseInteractable.h:417
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
Definition: BaseInteractable.h:277
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
Definition: BaseInteractable.cc:116
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
Definition: BaseInteraction.cc:221
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Definition: BaseInteraction.h:234
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
Definition: BaseInteraction.cc:240
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
Definition: BaseInteraction.h:226
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
Definition: BaseInteraction.cc:212
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
Definition: BaseInteraction.h:240
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
Definition: BaseInteraction.cc:231
unsigned getGroupId() const
Definition: BaseObject.h:137
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
virtual Mdouble getExponentEps2() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Definition: BaseParticle.cc:862
virtual Mdouble getExponentEps1() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Definition: BaseParticle.cc:859
virtual bool isSphericalParticle() const =0
virtual Vec3D getAxes() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Definition: BaseParticle.cc:856
Basic class for walls.
Definition: BaseWall.h:49
virtual Vec3D getFurthestPointSuperQuadric(const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
Definition: BaseWall.cc:577
virtual bool getDistanceNormalOverlap(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:553
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
Definition: InteractionHandler.cc:146
void rotate(Vec3D &position) const
Definition: Quaternion.cc:563
void rotateBack(Vec3D &position) const
Definition: Quaternion.cc:610
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76

References BaseInteractable::addForce(), BaseInteractable::addTorque(), Vec3D::cross(), DEBUG, Vec3D::dot(), BaseParticle::getAxes(), BaseInteraction::getContactPoint(), getDistanceNormalOverlap(), BaseParticle::getExponentEps1(), BaseParticle::getExponentEps2(), getFurthestPointSuperQuadric(), BaseObject::getGroupId(), getHandler(), InteractionHandler::getInteraction(), BaseInteractable::getInteractions(), BaseInteraction::getNormal(), BaseInteractable::getOrientation(), BaseInteraction::getOverlap(), BaseInteractable::getPosition(), BaseParticle::getRadius(), constants::i, BaseInteractable::isFaceContact(), BaseParticle::isSphericalParticle(), logger, Quaternion::rotate(), Quaternion::rotateBack(), BaseInteraction::setContactPoint(), BaseInteraction::setDistance(), BaseInteraction::setNormal(), and BaseInteraction::setOverlap().

Referenced by DropletBoundary::checkBoundaryAfterParticlesMove(), DPMBase::computeForcesDueToWalls(), Mercury3Dclump::computeForcesDueToWalls(), MeshTriangle::getInteractionWith(), RestrictedWall::getInteractionWith(), PeriodicBoundaryHandler::processLocalInteractionData(), 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.

526 {
527  logger(ERROR, "Generic wall-superquad interactions not implemented yet.");
528  return nullptr;
529 }

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 
)
205 {
206  // t = (p-p0).n / (p1-p0).n
207  //first compute the denominator
208  Mdouble denominator = Vec3D::dot(p1 - p0, n);
209  if (fabs(denominator) >= 1e-10)
210  {
211  Mdouble t = Vec3D::dot(p - p0, n) / denominator;
212  if (t < 1 + 1e-12 && t > -1e-12)
213  intersect = p0 + t * (p1 - p0);
214  return true;
215  }
216  return false;
217 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32

References Vec3D::dot(), and n.

◆ getRenderedWall()

BaseWall * BaseWall::getRenderedWall ( size_t  i) const
596 {
597  return renderedWalls_[i];
598 }

References constants::i, and renderedWalls_.

◆ getRenderedWalls()

std::vector< BaseWall * > BaseWall::getRenderedWalls ( ) const
601 {
602  return renderedWalls_;
603 }

References renderedWalls_.

◆ getVTK()

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

◆ getVTKVisibility()

bool BaseWall::getVTKVisibility ( ) const
544 {
545  return vtkVisibility_;
546 }

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.

203 {}

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

212 {}

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

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

References DEBUG, isInsideWallVTK(), logger, and projectOntoWallVTK().

Referenced by InfiniteWall::createVTK(), AxisymmetricIntersectionOfWalls::writeVTK(), HorizontalBaseScrew::writeVTK(), IntersectionOfWalls::writeVTK(), and ScrewsymmetricIntersectionOfWalls::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.

187 {
188  return true;
189 }

◆ 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)

221 {
222  return Vec3D::dot(position - point, normal) < -1e-12;
223 }

References Vec3D::dot().

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.

139  { return false; }

Referenced by Mercury3D::computeWallForces().

◆ 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_

232 {
233  Vec3D dPoint = point1 - point0;
234  point0 += Vec3D::dot(position - point0, normal) / Vec3D::dot(dPoint, normal) * dPoint;
235 }

References Vec3D::dot().

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.

79 {
81  unsigned size;
82  std::string type;
83  if (helpers::isNext(is,"vtkVisibility")) {
84  is >> vtkVisibility_;
85  }
86  if (helpers::isNext(is,"renderedWalls")) {
87  is >> size;
88  for (unsigned i = 0; i < size; i++)
89  {
90  is >> type;
91  BaseWall* wall = getHandler()->createObject(type);
92  wall->setHandler(getHandler());
93  wall->read(is);
94  renderedWalls_.push_back(wall);
95  renderedWalls_.back()->setId(renderedWalls_.size());
96  }
97  }
98 }
void read(std::istream &is) override
Reads a BaseInteractable from an input stream.
Definition: BaseInteractable.cc:244
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:125
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:78
static BaseWall * createObject(const std::string &type)
Create a new wall, with the type given as a string (required for restarting).
Definition: WallHandler.cc:129
bool isNext(std::istream &is, const std::string name)
Definition: StringHelpers.cc:78

References WallHandler::createObject(), getHandler(), constants::i, helpers::isNext(), BaseInteractable::read(), read(), renderedWalls_, setHandler(), 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 ( )
589  {
590  for (auto* const r : renderedWalls_)
591  delete r;
592  renderedWalls_.clear();
593 }

References renderedWalls_.

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

◆ renderWall()

void BaseWall::renderWall ( VTKContainer vtk)
606 {
607  if (getVTKVisibility())
608  {
609  if (renderedWalls_.empty())
610  {
611  writeVTK(vtk);
612  }
613  else
614  {
615  const Mdouble time = getHandler()->getDPMBase()->getTime();
616  const Mdouble timeStep = getHandler()->getDPMBase()->getTimeStep();
617  const int saveCount = getHandler()->getDPMBase()->dataFile.getSaveCount();
618  for (const auto& r: renderedWalls_)
619  {
620  // First write...
621  r->writeVTK(vtk);
622 
623  // Then update the position and orientation for time steps that were skipped.
624  // We have to use a loop, as doing it at once like so:
625  // r->integrateBeforeForceComputation(time - timeStep * (saveCount - 1), timeStep * saveCount);
626  // r->integrateAfterForceComputation(time - timeStep * (saveCount - 1), timeStep * saveCount);
627  // gives small deviations which add up quickly to give very different results.
628  for (int i = 0; i < saveCount; i++)
629  {
630  r->integrateBeforeForceComputation(time - timeStep * (saveCount - i - 1), timeStep);
631  r->integrateAfterForceComputation(time - timeStep * (saveCount - i - 1), timeStep);
632  }
633  }
634  }
635  }
636 }
virtual void writeVTK(VTKContainer &vtk) const
Definition: BaseWall.cc:496
bool getVTKVisibility() const
Definition: BaseWall.cc:543
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
unsigned int getSaveCount() const
Gets File::saveCount_.
Definition: File.cc:255

References DPMBase::dataFile, BaseHandler< T >::getDPMBase(), getHandler(), File::getSaveCount(), DPMBase::getTime(), DPMBase::getTimeStep(), getVTKVisibility(), constants::i, 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
196  {
197  setPrescribedVelocity([this, forceGoal, gainFactor, baseVelocity] (double time){
198  auto dForce = getForce()-forceGoal;
199  return baseVelocity + gainFactor.multiplyElementwise(dForce);
200  });
201 }
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:126
void setPrescribedVelocity(const std::function< Vec3D(double)> &prescribedVelocity)
Allows the velocity of an infinite mass interactable to be prescribed.
Definition: BaseInteractable.cc:444
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Vector.h:148

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.

126 {
127  handler_ = handler;
128  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
129 }
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
Definition: BaseInteractable.h:88
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169

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

Referenced by WallHandler::addObject(), 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.

143 {
144  if (handler_ != nullptr)
145  {
146  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
147  }
148  else
149  {
151  logger(ERROR, "setIndSpecies called on a particle with no particle handler.\n"
152  "Therefore I can't request the given species from the species handler.\n"
153  " PartID = %", getId());
154  }
155 }
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
Definition: BaseInteractable.h:98
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125

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.
170 {
172  //Checks if the current wall currently belongs to a defined wallHandler...
173  if (getHandler() == nullptr)
174  {
175  //and if not:
176  //Creates a pointer to the handler to which the chosen species belongs
177  SpeciesHandler* sH = species->getHandler();
178  //Creates a pointer back to the DPMBase class
179  DPMBase* dB = sH->getDPMBase();
180  //If this is not a null pointer, assigns the current wall to the relevant wallHandler.
181  if (dB != nullptr)
182  setHandler(&dB->wallHandler);
183  }
184 }
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
Definition: BaseInteractable.cc:185
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:37

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

Referenced by ShiftingConstantMassFlowMaserBoundarySelfTest::actionsAfterTimeStep(), ShiftingMaserBoundarySelfTest::actionsAfterTimeStep(), IntersectionOfWalls::addObject(), NautaMixer::addTopWall(), Membrane::buildMesh(), Chute::createBottom(), MercuryProblem::createTriangleWall(), SCoupling< M, O >::createTriangleWall(), CSCWalls::CSCWalls(), GranuDrum::GranuDrum(), HorizontalScrew::HorizontalScrew(), InfiniteWall::InfiniteWall(), InitialConditions< SpeciesType >::InitialConditions(), LevelSetWall::LevelSetWall(), loadingTest(), main(), MercuryCGSelfTest::MercuryCGSelfTest(), MovingWall::MovingWall(), normalAndTangentialLoadingTest(), ParticleCreation::ParticleCreation(), 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(), multiParticleT1::setupInitialConditions(), VerticalMixer::setupInitialConditions(), Binary::setupInitialConditions(), MaserRepeatedOutInMPI2Test::setupInitialConditions(), FreeCooling2DinWallsDemo::setupInitialConditions(), FreeCooling3DinWallsDemo::setupInitialConditions(), HeaterBoundaryTest::setupInitialConditions(), HourGlass2D::setupInitialConditions(), HourGlass::setupInitialConditions(), MinimalExampleDrum::setupInitialConditions(), ShiftingConstantMassFlowMaserBoundarySelfTest::setupInitialConditions(), ShiftingMaserBoundarySelfTest::setupInitialConditions(), SilbertPeriodic::setupInitialConditions(), GetDistanceAndNormalForScrew::setupInitialConditions(), GetDistanceAndNormalForTriangleWall::setupInitialConditions(), MyCoil::setupInitialConditions(), Nurbs::setupInitialConditions(), Drum::setupInitialConditions(), HertzSelfTest::setupInitialConditions(), MindlinSelfTest::setupInitialConditions(), Penetration::setupInitialConditions(), Silo::setupInitialConditions(), Chutebelt::setupInitialConditions(), ConstantMassFlowMaserBoundaryMixedSpeciesSelfTest::setupInitialConditions(), ConstantMassFlowMaserSelfTest::setupInitialConditions(), InsertionBoundarySelfTest::setupInitialConditions(), PolydisperseInsertionBoundarySelfTest::setupInitialConditions(), CGHandlerSelfTest::setupInitialConditions(), NewtonsCradleSelftest::setupInitialConditions(), NewtonsCradleSelfTest::setupInitialConditions(), SquarePacking::setupInitialConditions(), ChargedBondedParticleUnitTest::setupInitialConditions(), WallParticleCollision::setupInitialConditions(), my_problem_HGRID::setupInitialConditions(), FreeFallInteractionSelfTest::setupInitialConditions(), FreeFallSelfTest::setupInitialConditions(), LiquidMigrationSelfTest::setupInitialConditions(), DPM::setupInitialConditions(), ObliqueImpactSelfTest::setupInitialConditions(), TwoBondedParticleElasticCollision::setupInitialConditions(), TwoParticleElasticCollisionInteraction::setupInitialConditions(), TwoParticleElasticCollision::setupInitialConditions(), CoilSelfTest::setupInitialConditions(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), RollingOverTriangleWalls::setupInitialConditions(), UnionOfWalls::setupInitialConditions(), DrumRot::setupInitialConditions(), RotatingDrum::setupInitialConditions(), Wall::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(), ParticleWallInteraction::setupInitialConditions(), EvaporationAndHeatTest::setupInitialConditions(), ExtremeOverlapWithWallsUnitTest::setupInitialConditions(), FreeFallHertzMindlinUnitTest::setupInitialConditions(), FreeFall::setupInitialConditions(), FullRestartTest::setupInitialConditions(), my_problem::setupInitialConditions(), InclinedPlane::setupInitialConditions(), MpiMaserChuteTest::setupInitialConditions(), MovingWalls::setupInitialConditions(), MultiParticlesInsertion::setupInitialConditions(), MpiPeriodicBoundaryUnitTest::setupInitialConditions(), WallSpecies::setupInitialConditions(), AreaVTK::setupInitialConditions(), ChuteBottom::setupInitialConditions(), ContactDetectionWithWallTester::setupParticleAndWall(), Chute::setupSideWalls(), and TriangulatedWall::TriangulatedWall().

◆ setVelocityControl()

void BaseWall::setVelocityControl ( Vec3D  forceGoal,
Vec3D  gainFactor,
Vec3D  baseVelocity 
)
638  {
639  setPrescribedVelocity([this, forceGoal, gainFactor, baseVelocity] (double time){
640  auto dForce = getForce()-forceGoal;
641  return baseVelocity + gainFactor.multiplyElementwise(dForce);
642  });
643 }

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

◆ setVTKVisibility()

void BaseWall::setVTKVisibility ( bool  vtkVisibility)
549 {
550  vtkVisibility_ = vtkVisibility;
551 }

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.

101 {
103  if (vtkVisibility_==false)
104  {
105  os << " vtkVisibility " << vtkVisibility_;
106  }
107  if (renderedWalls_.size()>0)
108  {
109  os << " renderedWalls " << renderedWalls_.size();
110  for (auto w : renderedWalls_)
111  {
112  os << " ";
113  w->write(os);
114  }
115  }
116 }
void write(std::ostream &os) const override
Write a BaseInteractable to an output stream.
Definition: BaseInteractable.cc:274

References renderedWalls_, vtkVisibility_, 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.

497 {
498  logger(WARN, "Walls % of type % have no vtk writer defined", getIndex(), getName());
499 }
@ 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.

246 { };

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: