MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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...
 
bool getVTKVisibility () const
 
void setVTKVisibility (bool vtkVisibility)
 
void addRenderedWall (BaseWall *w)
 
BaseWallgetRenderedWall (size_t i) const
 
void removeRenderedWalls ()
 
void renderWall (VTKContainer &vtk)
 
void addParticlesAtWall (unsigned numElements=50)
 
void setVelocityControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
 
- Public Member Functions inherited from BaseInteractable
 BaseInteractable ()
 Default BaseInteractable constructor. More...
 
 BaseInteractable (const BaseInteractable &p)
 Copy constructor. More...
 
 ~BaseInteractable () override
 Destructor, it simply destructs the BaseInteractable and all the objects it contains. More...
 
unsigned int getIndSpecies () const
 Returns the index of the species associated with the interactable object. More...
 
const ParticleSpeciesgetSpecies () const
 Returns a pointer to the species of this BaseInteractable. More...
 
void setSpecies (const ParticleSpecies *species)
 Sets the species of this BaseInteractable. More...
 
const Vec3DgetForce () const
 Returns the force on this BaseInteractable. More...
 
const Vec3DgetTorque () const
 Returns the torque on this BaseInteractable. More...
 
void setForce (const Vec3D &force)
 Sets the force on this BaseInteractable. More...
 
void setTorque (const Vec3D &torque)
 Sets the torque on this BaseInteractable. More...
 
void addForce (const Vec3D &addForce)
 Adds an amount to the force on this BaseInteractable. More...
 
void addTorque (const Vec3D &addTorque)
 Adds an amount to the torque on this BaseInteractable. More...
 
void resetForceTorque (int numberOfOMPthreads)
 
void sumForceTorqueOMP ()
 
const Vec3DgetPosition () const
 Returns the position of this BaseInteractable. More...
 
const QuaterniongetOrientation () const
 Returns the orientation of this BaseInteractable. More...
 
void setPosition (const Vec3D &position)
 Sets the position of this BaseInteractable. More...
 
void setOrientationViaNormal (Vec3D normal)
 Sets the orientation of this BaseInteractable by defining the vector that results from the rotation of the (1,0,0) vector. More...
 
void setOrientationViaEuler (Vec3D eulerAngle)
 Sets the orientation of this BaseInteractable by defining the euler angles. More...
 
void setOrientation (const Quaternion &orientation)
 Sets the orientation of this BaseInteractable. More...
 
virtual void move (const Vec3D &move)
 Moves this BaseInteractable by adding an amount to the position. More...
 
virtual void rotate (const Vec3D &angularVelocityDt)
 Rotates this BaseInteractable. More...
 
const std::vector
< BaseInteraction * > & 
getInteractions () const
 Returns a list of interactions which belong to this interactable. More...
 
void addInteraction (BaseInteraction *I)
 Adds an interaction to this BaseInteractable. More...
 
bool removeInteraction (BaseInteraction *I)
 Removes an interaction from this BaseInteractable. More...
 
void copyInteractionsForPeriodicParticles (const BaseInteractable &p)
 Copies interactions to this BaseInteractable whenever a periodic copy made. More...
 
void setVelocity (const Vec3D &velocity)
 set the velocity of the BaseInteractable. More...
 
void setAngularVelocity (const Vec3D &angularVelocity)
 set the angular velocity of the BaseInteractble. More...
 
void addVelocity (const Vec3D &velocity)
 adds an increment to the velocity. More...
 
void addAngularVelocity (const Vec3D &angularVelocity)
 add an increment to the angular velocity. More...
 
virtual const Vec3DgetVelocity () const
 Returns the velocity of this interactable. More...
 
virtual const Vec3DgetAngularVelocity () const
 Returns the angular velocity of this interactable. More...
 
void setPrescribedPosition (const std::function< Vec3D(double)> &prescribedPosition)
 Allows the position of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedPosition (double time)
 Computes the position from the user defined prescribed position function. More...
 
void setPrescribedVelocity (const std::function< Vec3D(double)> &prescribedVelocity)
 Allows the velocity of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedVelocity (double time)
 Computes the velocity from the user defined prescribed velocity function. More...
 
void setPrescribedOrientation (const std::function< Quaternion(double)> &prescribedOrientation)
 Allows the orientation of the infinite mass interactbale to be prescribed. More...
 
void applyPrescribedOrientation (double time)
 Computes the orientation from the user defined prescribed orientation function. More...
 
void setPrescribedAngularVelocity (const std::function< Vec3D(double)> &prescribedAngularVelocity)
 Allows the angular velocity of the infinite mass interactable to be prescribed. More...
 
void applyPrescribedAngularVelocity (double time)
 Computes the angular velocity from the user defined prescribed angular velocity. More...
 
virtual const Vec3D getVelocityAtContact (const Vec3D &contact) const
 Returns the velocity at the contact point, use by many force laws. More...
 
void integrateBeforeForceComputation (double time, double timeStep)
 This is part of integrate routine for objects with infinite mass. More...
 
void integrateAfterForceComputation (double time, double timeStep)
 This is part of the integration routine for objects with infinite mass. More...
 
virtual Mdouble getInvMass () const
 
virtual Mdouble getCurvature (const Vec3D &labFixedCoordinates) const
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual 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.

Definition at line 47 of file BaseWall.h.

Constructor & Destructor Documentation

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.

Definition at line 36 of file BaseWall.cc.

References DEBUG, handler_, and logger.

37 {
38  handler_ = nullptr;
39  logger(DEBUG, "BaseWall::BaseWall() finished");
40 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
WallHandler * handler_
Definition: BaseWall.h:204
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.

Definition at line 50 of file BaseWall.cc.

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

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 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
WallHandler * handler_
Definition: BaseWall.h:204
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
bool vtkVisibility_
Definition: BaseWall.h:206
BaseInteractable()
Default BaseInteractable constructor.
BaseWall::~BaseWall ( )
override

Default destructor.

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

Definition at line 66 of file BaseWall.cc.

References DEBUG, logger, and renderedWalls_.

67 {
68  logger(DEBUG, "BaseWall::~BaseWall() finished");
69  for (auto* const r : renderedWalls_)
70  delete r;
71  renderedWalls_.clear();
72 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211

Member Function Documentation

void BaseWall::addParticlesAtWall ( unsigned  numElements = 50)

Definition at line 598 of file BaseWall.cc.

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.

599 {
600  auto& speciesHandler = getHandler()->getDPMBase()->speciesHandler;
601  logger.assert_always(speciesHandler.getSize()>0,"addParticlesAtWall: You need to define at least one species");
602 
603  Vec3D max = getHandler()->getDPMBase()->getMax();
604  Vec3D min = getHandler()->getDPMBase()->getMin();
605  double h = Vec3D::min(max-min)/numElements;
606  double r = 0.5*h;
607 
608  auto& particleHandler = getHandler()->getDPMBase()->particleHandler;
609  double numParticles0 = particleHandler.getSize();
611  p.setSpecies(speciesHandler.getObject(0));
612  Vec3D pos;
613  for (pos.X = min.X; pos.X <= max.X; pos.X += h)
614  for (pos.Y = min.Y; pos.Y <= max.Y; pos.Y += h)
615  for (pos.Z = min.Z; pos.Z <= max.Z; pos.Z += h)
616  {
617  Vec3D normal;
618  Mdouble distance;
619  p.setRadius(2.0*r);
620  p.setPosition(pos);
621  //if touching the wall
622  if (getDistanceAndNormal(p, distance, normal) && distance>=0)
623  {
624  p.setRadius(r);
625  p.setPosition(pos+(distance-r)*normal);
626  particleHandler.copyAndAddObject(p);
627  }
628  }
629  logger(INFO,"Inserted % particles that touch wall %", particleHandler.getNumberOfObjects()-numParticles0, getIndex());
630 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
Mdouble X
the vector components
Definition: Vector.h:65
A basic particle.
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Vec3D getMin() const
Definition: DPMBase.h:623
void setSpecies(const ParticleSpecies *species)
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:102
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...
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
Vec3D getMax() const
Definition: DPMBase.h:629
Mdouble Y
Definition: Vector.h:65
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: Vector.h:49
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble Z
Definition: Vector.h:65
void BaseWall::addRenderedWall ( BaseWall w)

Definition at line 554 of file BaseWall.cc.

References renderedWalls_.

555 {
556  renderedWalls_.push_back(w);
557 }
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
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.

Definition at line 471 of file BaseWall.cc.

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

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

472 {
473  if (!points.empty())
474  {
475  //all all values in myPoints to points
476  vtk.points.insert(vtk.points.end(), points.begin(), points.end());
477 
478  // create one cell object containing all indices of the added points (created a triangle strip connecting these points)
479  std::vector<double> cell;
480  cell.reserve(vtk.points.size() + 1);
481  cell.push_back(vtk.points.size() - 1);
482  for (unsigned i = vtk.points.size() - points.size(); i < vtk.points.size(); i++)
483  {
484  cell.push_back((double) i);
485  }
486 
487  //add this triangle strip to the vtk file
488  vtk.triangleStrips.push_back(cell);
489  }
490 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:39
std::vector< Vec3D > points
Definition: BaseWall.h:38
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

Definition at line 503 of file BaseWall.cc.

References BaseInteractable::getOrientation(), Quaternion::q1, Quaternion::q2, Quaternion::q3, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by ScrewsymmetricIntersectionOfWalls::computeDeltaZ().

504 {
506  Vec3D axis;
507  axis.X = Q.q1;
508  axis.Y = Q.q2;
509  axis.Z = Q.q3;
510  return axis;
511 }
Implementation of a 3D quaternion (by Vitaliy).
Definition: Quaternion.h:62
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble q2
the second component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:77
Mdouble q3
the third component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:81
Mdouble Y
Definition: Vector.h:65
Definition: Vector.h:49
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Mdouble Z
Definition: Vector.h:65
Mdouble q1
the first component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:73
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 IntersectionOfWalls, AxisymmetricIntersectionOfWalls, ScrewsymmetricIntersectionOfWalls, TriangleWall, InfiniteWall, TriangulatedWall, SphericalWall, InfiniteWallWithHole, LevelSetWall, RestrictedWall, BasicIntersectionOfWalls, BasicUnionOfWalls, SimpleDrumSuperquadrics, Coil, HorizontalBaseScrew, Screw, ArcWall, NurbsWall, HorizontalScrew, CylindricalWall, SineWall, Combtooth, ParabolaChute, and VChute.

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

bool BaseWall::getDistanceNormalOverlap ( const BaseParticle P,
Mdouble distance,
Vec3D normal_return,
Mdouble overlap 
) const
virtual

Definition at line 523 of file BaseWall.cc.

References getDistanceAndNormal(), getDistanceNormalOverlapSuperquadric(), BaseParticle::getRadius(), and BaseParticle::isSphericalParticle().

Referenced by getInteractionWith().

525 {
526  if (P.isSphericalParticle())
527  {
528  bool isInContact = getDistanceAndNormal(P, distance, normal_return);
529  overlap = P.getRadius() - distance;
530  return isInContact;
531  }
532  else
533  {
534  auto superQuadric = dynamic_cast<const SuperQuadricParticle*>(&P);
535  return getDistanceNormalOverlapSuperquadric(*superQuadric, distance, normal_return, overlap);
536  }
537 }
virtual bool isSphericalParticle() const
Definition: BaseParticle.h:642
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...
virtual bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:540
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
bool BaseWall::getDistanceNormalOverlapSuperquadric ( const SuperQuadricParticle p,
Mdouble distance,
Vec3D normal_return,
Mdouble overlap 
) const
virtual

Reimplemented in InfiniteWall, and SimpleDrumSuperquadrics.

Definition at line 540 of file BaseWall.cc.

References ERROR, and logger.

Referenced by getDistanceNormalOverlap().

542 {
543  logger(ERROR, "Generic wall-superquadric interactions not implemented yet.");
544  return false;
545 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Vec3D BaseWall::getFurthestPointSuperQuadric ( const Vec3D normalBodyFixed,
const Vec3D axes,
Mdouble  eps1,
Mdouble  eps2 
) const
virtual

Reimplemented in InfiniteWall, and SimpleDrumSuperquadrics.

Definition at line 547 of file BaseWall.cc.

References ERROR, and logger.

Referenced by getInteractionWith().

548 {
549  logger(ERROR, "Generic wall-superquadric interactions not implemented yet.");
550  return {};
551 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
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:
{DK: What is the contact point for interactions with walls}

Implements BaseInteractable.

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

Definition at line 369 of file BaseWall.cc.

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

Referenced by DPMBase::computeForcesDueToWalls(), RestrictedWall::getInteractionWith(), and PeriodicBoundaryHandler::processLocalInteractionData().

370 {
371  Mdouble distance;
372  Vec3D normal;
373  Mdouble overlap;
374 
375  if (getDistanceNormalOverlap(*p, distance, normal, overlap))
376  {
377  // look for an existing interaction, or create a new one
378  BaseInteraction *c = nullptr;
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 
435  if (c == nullptr) {
436  // look for an existing interaction, or create a new one
437  c = interactionHandler->getInteraction(p, this, timeStamp);
438  }
439 
440  c->setNormal(-normal);
441  c->setDistance(distance);
442  c->setOverlap(overlap);
443  if (p->isSphericalParticle())
444  {
446  c->setContactPoint(p->getPosition() - (p->getRadius() - 0.5 * c->getOverlap()) * c->getNormal());
447  }
448  else
449  {
450  Vec3D normalBodyFixed = normal;
451  p->getOrientation().rotateBack(normalBodyFixed);
452  auto furthestPoint = getFurthestPointSuperQuadric(normalBodyFixed, p->getAxes(),
453  p->getExponentEps1(), p->getExponentEps2());
454  Vec3D overlapBody = overlap * normalBodyFixed;
455  Vec3D contactPoint = furthestPoint - overlapBody / 2;
456  p->getOrientation().rotate(contactPoint);
457  contactPoint += p->getPosition();
458  c->setContactPoint(contactPoint);
459  }
460  logger(DEBUG, "Particle contact with wall at %", c->getContactPoint());
461  return c;
462  }
463  return nullptr;
464 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
virtual Vec3D getFurthestPointSuperQuadric(const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
Definition: BaseWall.cc:547
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
virtual bool isSphericalParticle() const
Definition: BaseParticle.h:642
void rotateBack(Vec3D &position) const
Applies the inverse rotation to a position.
Definition: Quaternion.cc:592
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
double Mdouble
Definition: GeneralDefine.h:34
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
virtual Mdouble getExponentEps1() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
virtual Vec3D getAxes() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
virtual Mdouble getExponentEps2() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
void rotate(Vec3D &position) const
Applies the rotation to a position.
Definition: Quaternion.cc:563
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
Stores information about interactions between two interactable objects; often particles but could be ...
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
Basic class for walls.
Definition: BaseWall.h:47
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
unsigned getGroupId() const
Definition: BaseObject.h:137
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
Defines the basic properties that a interactable object can have.
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
Definition: Vector.h:49
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
Definition: DPMBase.h:545
virtual bool getDistanceNormalOverlap(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:523
BaseInteraction * BaseWall::getInteractionWithSuperQuad ( SuperQuadricParticle p,
unsigned  timeStamp,
InteractionHandler interactionHandler 
)
virtual
Todo:
make it work with screw, coil and other weird walls

Reimplemented in SimpleDrumSuperquadrics.

Definition at line 494 of file BaseWall.cc.

References ERROR, and logger.

Referenced by SimpleDrumSuperquadrics::getInteractionWithSuperQuad().

496 {
497  logger(ERROR, "Generic wall-superquad interactions not implemented yet.");
498  return nullptr;
499 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
bool BaseWall::getLinePlaneIntersect ( Vec3D intersect,
const Vec3D p0,
const Vec3D p1,
const Vec3D n,
const Vec3D p 
)

Definition at line 206 of file BaseWall.cc.

References Vec3D::dot().

207 {
208  // t = (p-p0).n / (p1-p0).n
209  //first compute the denominator
210  Mdouble denominator = Vec3D::dot(p1 - p0, n);
211  if (fabs(denominator) >= 1e-10)
212  {
213  Mdouble t = Vec3D::dot(p - p0, n) / denominator;
214  if (t < 1 + 1e-12 && t > -1e-12)
215  intersect = p0 + t * (p1 - p0);
216  return true;
217  }
218  return false;
219 }
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
BaseWall * BaseWall::getRenderedWall ( size_t  i) const

Definition at line 565 of file BaseWall.cc.

References constants::i, and renderedWalls_.

566 {
567  return renderedWalls_[i];
568 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
void BaseWall::getVTK ( std::vector< Vec3D > &  points,
std::vector< std::vector< double >> &  triangleStrips 
)
inline

Definition at line 169 of file BaseWall.h.

170  {}
bool BaseWall::getVTKVisibility ( ) const

Definition at line 513 of file BaseWall.cc.

References vtkVisibility_.

Referenced by renderWall().

514 {
515  return vtkVisibility_;
516 }
bool vtkVisibility_
Definition: BaseWall.h:206
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.

Definition at line 243 of file BaseWall.cc.

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

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

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

Definition at line 188 of file BaseWall.cc.

189 {
190  return true;
191 }
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)

Definition at line 222 of file BaseWall.cc.

References Vec3D::dot().

Referenced by intersectVTK().

223 {
224  return Vec3D::dot(position - point, normal) < -1e-12;
225 }
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
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.

Definition at line 137 of file BaseWall.h.

Referenced by Mercury3D::computeWallForces().

138  { return false; }
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_

Definition at line 233 of file BaseWall.cc.

References Vec3D::dot().

Referenced by intersectVTK().

234 {
235  Vec3D dPoint = point1 - point0;
236  point0 += Vec3D::dot(position - point0, normal) / Vec3D::dot(dPoint, normal) * dPoint;
237 }
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Definition: Vector.h:49
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 IntersectionOfWalls, ScrewsymmetricIntersectionOfWalls, InfiniteWall, TriangulatedWall, SphericalWall, InfiniteWallWithHole, Screw, HorizontalScrew, TriangleWall, LevelSetWall, Coil, SimpleDrumSuperquadrics, RestrictedWall, BasicIntersectionOfWalls, BasicUnionOfWalls, HorizontalBaseScrew, NurbsWall, CylindricalWall, SineWall, Combtooth, ParabolaChute, and VChute.

Definition at line 80 of file BaseWall.cc.

References WallHandler::createObject(), getHandler(), constants::i, helpers::isNext(), read(), BaseInteractable::read(), renderedWalls_, setHandler(), and vtkVisibility_.

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

81 {
83  unsigned size;
84  std::string type;
85  if (helpers::isNext(is,"vtkVisibility")) {
86  is >> vtkVisibility_;
87  }
88  if (helpers::isNext(is,"renderedWalls")) {
89  is >> size;
90  for (unsigned i = 0; i < size; i++)
91  {
92  is >> type;
93  BaseWall* wall = getHandler()->createObject(type);
94  wall->setHandler(getHandler());
95  wall->read(is);
96  renderedWalls_.push_back(wall);
97  renderedWalls_.back()->setId(renderedWalls_.size());
98  }
99  }
100 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:127
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
static BaseWall * createObject(const std::string &type)
Create a new wall, with the type given as a string (required for restarting).
Definition: WallHandler.cc:122
Basic class for walls.
Definition: BaseWall.h:47
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:80
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
bool vtkVisibility_
Definition: BaseWall.h:206
bool isNext(std::istream &is, const std::string name)
reads next value in stream as a string and compares it with name.
Definition: Helpers.cc:944
void read(std::istream &is) override
Reads a BaseInteractable from an input stream.
void BaseWall::removeRenderedWalls ( )

Definition at line 559 of file BaseWall.cc.

References renderedWalls_.

559  {
560  while (!renderedWalls_.empty()) {
561  renderedWalls_.pop_back();
562  }
563 }
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
void BaseWall::renderWall ( VTKContainer vtk)

Definition at line 570 of file BaseWall.cc.

References BaseHandler< T >::getDPMBase(), getHandler(), DPMBase::getTime(), getVTKVisibility(), renderedWalls_, and writeVTK().

571 {
572  if (getVTKVisibility())
573  {
574  if (renderedWalls_.empty())
575  {
576  writeVTK(vtk);
577  }
578  else
579  {
580  const Mdouble time = getHandler()->getDPMBase()->getTime();
581  for (const auto& r: renderedWalls_)
582  {
583  r->applyPrescribedPosition(time);
584  r->applyPrescribedOrientation(time);
585  r->writeVTK(vtk);
586  }
587  }
588  }
589 }
virtual void writeVTK(VTKContainer &vtk) const
Definition: BaseWall.cc:466
double Mdouble
Definition: GeneralDefine.h:34
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
bool getVTKVisibility() const
Definition: BaseWall.cc:513
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
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

Definition at line 198 of file BaseWall.cc.

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

198  {
199  setPrescribedVelocity([this, forceGoal, gainFactor, baseVelocity] (double time){
200  auto dForce = getForce()-forceGoal;
201  return baseVelocity + gainFactor.multiplyElementwise(dForce);
202  });
203 }
void setPrescribedVelocity(const std::function< Vec3D(double)> &prescribedVelocity)
Allows the velocity of an infinite mass interactable to be prescribed.
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Vector.h:132
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
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.

Definition at line 127 of file BaseWall.cc.

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

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

128 {
129  handler_ = handler;
130  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
131 }
WallHandler * handler_
Definition: BaseWall.h:204
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
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.
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
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.

Definition at line 144 of file BaseWall.cc.

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

145 {
146  if (handler_ != nullptr)
147  {
148  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
149  }
150  else
151  {
153  logger(ERROR, "setIndSpecies called on a particle with no particle handler.\n"
154  "Therefore I can't request the given species from the species handler.\n"
155  " PartID = %", getId());
156  }
157 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
WallHandler * handler_
Definition: BaseWall.h:204
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
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.
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
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.

Definition at line 171 of file BaseWall.cc.

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

Referenced by IntersectionOfWalls::addObject(), Chute::createBottom(), HorizontalScrew::HorizontalScrew(), InfiniteWall::InfiniteWall(), LevelSetWall::LevelSetWall(), helpers::loadingTest(), helpers::normalAndTangentialLoadingTest(), FileReader::read(), WallHandler::readAndCreateObject(), WallHandler::readAndCreateOldObject(), DPMBase::readParAndIniFiles(), WallHandler::readTriangleWall(), RestrictedWall::set(), setHandler(), setIndSpecies(), IntersectionOfWalls::setSpecies(), ChuteBottom::setupInitialConditions(), Chute::setupSideWalls(), and TriangulatedWall::TriangulatedWall().

172 {
174  //Checks if the current wall currently belongs to a defined wallHandler...
175  if (getHandler() == nullptr)
176  {
177  //and if not:
178  //Creates a pointer to the handler to which the chosen species belongs
179  SpeciesHandler* sH = species->getHandler();
180  //Creates a pointer back to the DPMBase class
181  DPMBase* dB = sH->getDPMBase();
182  //If this is not a null pointer, assigns the current wall to the relevant wallHandler.
183  if (dB != nullptr)
184  setHandler(&dB->wallHandler);
185  }
186 }
Container to store all ParticleSpecies.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:127
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void BaseWall::setVelocityControl ( Vec3D  forceGoal,
Vec3D  gainFactor,
Vec3D  baseVelocity 
)

Definition at line 591 of file BaseWall.cc.

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

591  {
592  setPrescribedVelocity([this, forceGoal, gainFactor, baseVelocity] (double time){
593  auto dForce = getForce()-forceGoal;
594  return baseVelocity + gainFactor.multiplyElementwise(dForce);
595  });
596 }
void setPrescribedVelocity(const std::function< Vec3D(double)> &prescribedVelocity)
Allows the velocity of an infinite mass interactable to be prescribed.
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Vector.h:132
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
void BaseWall::setVTKVisibility ( bool  vtkVisibility)

Definition at line 518 of file BaseWall.cc.

References vtkVisibility_.

519 {
520  vtkVisibility_ = vtkVisibility;
521 }
bool vtkVisibility_
Definition: BaseWall.h:206
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 IntersectionOfWalls, ScrewsymmetricIntersectionOfWalls, TriangulatedWall, InfiniteWallWithHole, SphericalWall, Screw, Coil, HorizontalScrew, RestrictedWall, TriangleWall, BasicIntersectionOfWalls, BasicUnionOfWalls, SimpleDrumSuperquadrics, HorizontalBaseScrew, CylindricalWall, NurbsWall, SineWall, Combtooth, ParabolaChute, and VChute.

Definition at line 102 of file BaseWall.cc.

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

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

103 {
105  if (vtkVisibility_==false)
106  {
107  os << " vtkVisibility " << vtkVisibility_;
108  }
109  if (renderedWalls_.size()>0)
110  {
111  os << " renderedWalls " << renderedWalls_.size();
112  for (auto w : renderedWalls_)
113  {
114  os << " ";
115  w->write(os);
116  }
117  }
118 }
void write(std::ostream &os) const override
Write a BaseInteractable to an output stream.
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:211
bool vtkVisibility_
Definition: BaseWall.h:206
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 IntersectionOfWalls, ScrewsymmetricIntersectionOfWalls, AxisymmetricIntersectionOfWalls, InfiniteWall, TriangleWall, RestrictedWall, Screw, HorizontalScrew, LevelSetWall, HorizontalBaseScrew, TriangulatedWall, and NurbsWall.

Definition at line 466 of file BaseWall.cc.

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

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

467 {
468  logger(WARN, "Walls % of type % have no vtk writer defined", getIndex(), getName());
469 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual std::string getName() const =0
A purely virtual function.

Member Data Documentation

WallHandler* BaseWall::handler_
private

A pointer to the WallHandler that handles this BaseWall.

Definition at line 204 of file BaseWall.h.

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

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

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

Definition at line 211 of file BaseWall.h.

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

bool BaseWall::vtkVisibility_ = true
private

Definition at line 206 of file BaseWall.h.

Referenced by BaseWall(), getVTKVisibility(), read(), setVTKVisibility(), and write().


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