MercuryDPM  Beta
BaseInteraction Class Referenceabstract

Stores information about interactions between two interactable objects; often particles but could be walls etc. By info about interactions one means the overlaps, contact point, forces, torques, relative velocities etc. More...

#include <BaseInteraction.h>

Inheritance diagram for BaseInteraction:

## Public Member Functions

BaseInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
A constructor takes the BaseInteractable objects which are interacting (come into contact) and time the interaction starts. More...

BaseInteraction (const BaseInteraction &p)
Copy constructor. More...

virtual ~BaseInteraction ()
The default destructor. More...

virtual void computeForce ()
Virtual function that contains the force law between the two objects interacting. More...

Interaction read function, which accepts an std::istream as input. More...

virtual void write (std::ostream &os) const
Interaction print function, which accepts an std::ostream as input. More...

void writeToFStat (std::ostream &os) const
Writes forces data to the FStat file. More...

virtual std::string getName () const
Virtual function which allows interactions to be named. More...

virtual Mdouble getElasticEnergy () const
Returns a Mdouble which is the current about of Elastic energy in the interaction. More...

void setDistance (Mdouble distance)
Sets the interaction distance between the two interacting objects. More...

void setNormal (Vec3D normal)
Sets the normal vector between the two interacting objects. More...

void setOverlap (Mdouble overlap)
Set the overlap between the two interacting object. More...

void setContactPoint (Vec3D contactPoint)
Set the location of the contact point between the two interacting objects. More...

void setTimeStamp (Mdouble timeStamp)
Updates the time step of the interacting. Note, timesteps used to find completed interactions. More...

void setSpecies (BaseSpecies *species)
Set the Species of the interaction; note this can either be a Species or MixedSpecies. More...

void setP (BaseInteractable *P)
Sets the first object involved in the interaction (normally a particle). More...

void setI (BaseInteractable *I)
Sets the second object involved in the interaction (often particle or wall). More...

void setHandler (InteractionHandler *handler)
Sets the pointer to the interaction hander which is storing this interaction. More...

InteractionHandlergetHandler () const
Gets a point to the interaction handlers to which this interaction belongs. More...

const Vec3DgetForce () const
Gets the current force (vector) between the two interacting objects. More...

const Vec3DgetTorque () const
Gets the current torque (vector) between the two interacting objects. More...

const Vec3DgetNormal () const
Gets the normal vector between the two interacting objects. More...

const Vec3DgetContactPoint () const
Gets constant reference to contact point (vector). More...

Mdouble getOverlap () const
Returns a Mdouble with the current overlap between the two interacting objects. More...

void removeFromHandler ()
Removes this interaction from its interaction hander. More...

void copySwitchPointer (const BaseInteractable *original, BaseInteractable *ghost) const
This copies the interactions of the original particle and replaces the original with the ghost copy. More...

void gatherContactStatistics ()

BaseInteractablegetP ()
Returns a pointer to first object involved in the interaction (normally a particle). More...

BaseInteractablegetI ()

const BaseInteractablegetP () const

const BaseInteractablegetI () const
Returns a constant pointer to the second object involved in the interaction. More...

Mdouble getTimeStamp () const
Returns an Mdouble which is the time stamp of the interaction. More...

virtual void integrate (Mdouble timeStep)
integrates variables of the interaction which need to be integrate e.g. the tangential overlap. More...

virtual Mdouble getTangentialOverlap () const
get the length of the current tangential overlap More...

Mdouble getDistance () const
Returns an Mdouble which is the norm (length) of distance vector. More...

const Vec3DgetRelativeVelocity () const
Returns a constant reference to a vector of relative velocity. More...

Mdouble getNormalRelativeVelocity () const
Returns a double which is the norm (length) of the relative velocity vector. More...

Mdouble getAbsoluteNormalForce () const
Returns the absolute value of the norm (length) of the Normal force vector. More...

virtual BaseInteractioncopy () const =0
Makes a copy of the interaction and returns a pointer to the copy. More...

virtual void rotateHistory (Matrix3D &rotationMatrix)
When periodic particles are used, some interactions need certain history properties rotated (e.g. tangential springs). This is the function for that. More...

Public Member Functions inherited from BaseObject
BaseObject ()
Default constructor. More...

BaseObject (const BaseObject &p)
Copy constructor, copies all the objects BaseObject contains. More...

virtual ~BaseObject ()
virtual destructor More...

virtual void moveInHandler (const unsigned int index)
Except that it is virtual, it does the same thing as setIndex() does. More...

void setIndex (const unsigned int index)
Allows one to assign an index to an object in the handler/container. More...

void setId (const unsigned int 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...

## Protected Member Functions

virtual const Vec3D getTangentialForce () const

Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap) More...

Returns a Mdouble to the effective radius corrected for the overlaps of the particles. More...

add an force increment to the total force. More...

void setForce (Vec3D force)
set total force (this is used by the normal force, tangential forces are added use addForce) More...

void setTorque (Vec3D torque)
set the total force (this is used by the normal force, tangential torques are added use addTorque) More...

void setRelativeVelocity (Vec3D relativeVelocity)
set the relative velocity of the current of the interactions. More...

void setNormalRelativeVelocity (Mdouble normalRelativeVelocit)
set the normal component of the relative velocity. More...

void setAbsoluteNormalForce (Mdouble absoluteNormalForce)
the absolute values of the norm (length) of the normal force More...

const BaseSpeciesgetBaseSpecies () const
Return a constant point to BaseSpecies of the interaction. More...

virtual void reverseHistory ()
When periodic particles some interaction need certain history properties reversing. This is the function for that. More...

## Private Attributes

InteractionHandlerhandler_

BaseInteractableP_

BaseInteractableI_

Vec3D contactPoint_

Vec3D relativeVelocity_

Mdouble normalRelativeVelocity_

Mdouble absoluteNormalForce_

Mdouble distance_

Vec3D force_

Vec3D torque_

Mdouble timeStamp_

Vec3D normal_

Mdouble overlap_

BaseSpeciesspecies_

## Detailed Description

Stores information about interactions between two interactable objects; often particles but could be walls etc. By info about interactions one means the overlaps, contact point, forces, torques, relative velocities etc.

This class is completely a MercuryDPM internal and should not be visible to users. It is also an abstract base class. All possible Mercury interactions are derived from this class. It is basically a policy class that defines what an interaction must have in Mercury. Advanced uses that need to add a new interaction must derive it from here and implement the black functions.

Definition at line 51 of file BaseInteraction.h.

## Constructor & Destructor Documentation

 BaseInteraction::BaseInteraction ( BaseInteractable * P, BaseInteractable * I, Mdouble timeStamp )

A constructor takes the BaseInteractable objects which are interacting (come into contact) and time the interaction starts.

This is the constructor which creates a new interactions between two BaseInteractable objects. The timeStamp is time the interactions is created and is used to check if the interations is current or has ended. It adds

Parameters
 [in] P BaseInteractable pointer which is the first object involved in the interaction normally a particle. [in] I BaseInteractable pointer which is the second object involved in the interaction often a wall or particle. [in] timeStamp Mdouble which is the time the interaction starts.

Definition at line 44 of file BaseInteraction.cc.

45  : BaseObject()
46 {
47  P_ = P;
49  I_ = I;
51  normal_.setZero();
52  overlap_ = 0;
53  timeStamp_ = timeStamp;
54  species_ = 0;
55  force_.setZero();
56  torque_.setZero();
57 #ifdef DEBUG_CONSTRUCTOR
58  std::cout<<"BaseInteraction::BaseInteraction() finished"<<std::endl;
59 #endif
60 }
BaseInteractable * I_
Adds an interaction to this BaseInteractable.
BaseSpecies * species_
void setZero()
Sets all elements to zero.
Definition: Vector.cc:52
BaseInteractable * P_
BaseObject()
Default constructor.
Definition: BaseObject.cc:51
 BaseInteraction::BaseInteraction ( const BaseInteraction & p )

Copy constructor.

This an copy constructor for a BaseInteraction.

Parameters
 [in] p BaseInteraction

Definition at line 66 of file BaseInteraction.cc.

References force_, I_, normal_, overlap_, P_, species_, timeStamp_, and torque_.

67  : BaseObject(p)
68 {
69  P_ = p.P_;
70  I_ = p.I_;
71  normal_ = p.normal_;
72  overlap_ = p.overlap_;
73  force_ = p.force_;
74  torque_ = p.torque_;
75  species_ = p.species_;
77 }
BaseInteractable * I_
BaseSpecies * species_
BaseInteractable * P_
BaseObject()
Default constructor.
Definition: BaseObject.cc:51
 BaseInteraction::~BaseInteraction ( )
virtual

The default destructor.

Destructor for BaseInteraction. Also removes the interaction from the list of interactions for both objects involved in the interaction.

Definition at line 83 of file BaseInteraction.cc.

References I_, P_, and BaseInteractable::removeInteraction().

84 {
85  P_->removeInteraction(this);
86  I_->removeInteraction(this);
87 }
BaseInteractable * I_
bool removeInteraction(BaseInteraction *I)
Removes an interaction from this BaseInteractable.
BaseInteractable * P_

## Member Function Documentation

 void BaseInteraction::addForce ( Vec3D force )
protected

add an force increment to the total force.

add an increment to total force in the interaction. This is used by tangential and non-contact forces (e.g. adhesive forces) as this are 'added' after the normal forces have been computed.

Definition at line 541 of file BaseInteraction.cc.

References force_.

542 {
543  force_+=force;
544 }
 void BaseInteraction::addTorque ( Vec3D torque )
protected

add an increment to total torque in the interaction. This is used by tangential and non-contact forces (e.g. adhesive forces) as this are 'added' after the normal forces have been computed.

Definition at line 551 of file BaseInteraction.cc.

References torque_.

Referenced by FrictionInteraction::computeFrictionForce().

552 {
553  torque_+=torque;
554 }
 void BaseInteraction::computeForce ( )
virtual

Virtual function that contains the force law between the two objects interacting.

The children of this class will implement this function; however, it is blank. This function will do the actually force calculation for this interaction. Note, it is not virtual as it is not called from within this class.

Definition at line 629 of file BaseInteraction.cc.

Referenced by DPMBase::computeForcesDueToWalls(), and DPMBase::computeInternalForces().

630 {}
 virtual BaseInteraction* BaseInteraction::copy ( ) const
pure virtual

Makes a copy of the interaction and returns a pointer to the copy.

Referenced by copySwitchPointer().

 void BaseInteraction::copySwitchPointer ( const BaseInteractable * original, BaseInteractable * ghost ) const

This copies the interactions of the original particle and replaces the original with the ghost copy.

This functions copies the interactions of a real original particle. It first works out which of P and I is not the original particle. Then it create a new interactions between the new ghost copy and which every object is not the original particle from the P and I of the interaction. Note, at the end the ghost will be I in the new interaction and original item being interacted with will be P.

Todo:
Can this be simpler if we replace the particle with the ghost.
Parameters
 [in] original BaseInteractable* to the original particles who periodic image is being created from. [in] ghost BaseInteractble* to the new ghost (periodic partcles) that has just been created.

Definition at line 224 of file BaseInteraction.cc.

225 {
226  //Copy the interaction of ghost
227  BaseInteraction* C = copy();
228  //Finds out which of P and I is that the particle from whom the ghost is begin created.
229  //The object being interacted with is set to P
230  if (C->getP() == original)
231  {
232  //Reverse some force history
233  C->reverseHistory();
234  //Set the P to the original particle
235  C->P_ =C->getI();
236  }
237  //The new ghost particle is set to I in the interaction.
238  C->I_ = ghost;
239
240  //Add the the interaction to both original and the ghost
244 }
BaseInteractable * I_
virtual BaseInteraction * copy() const =0
Makes a copy of the interaction and returns a pointer to the copy.
Adds an interaction to this BaseInteractable.
virtual void reverseHistory()
When periodic particles some interaction need certain history properties reversing. This is the function for that.
Stores information about interactions between two interactable objects; often particles but could be ...
BaseInteractable * P_
BaseInteractable * getI()
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Adds an Interaction to the InteractionHandler.
InteractionHandler * handler_
 void BaseInteraction::gatherContactStatistics ( )
Todo:
Thomas please document this; as this is the area you are currently rewriting.
Todo:
Todo:
TW centre is used just for backward compatibility; replace centre by contact law; we also have to correct it in StatisticsVector::gatherContactStatistics. There also seems to be an issue with the normal being defined differently for walls

Definition at line 732 of file BaseInteraction.cc.

733 {
734  BaseParticle* IParticle = dynamic_cast<BaseParticle*>(I_);
735  BaseParticle* PParticle = dynamic_cast<BaseParticle*>(P_);
736
737  Vec3D tangentialForce = getTangentialForce();
738  Mdouble tangentialOverlap = getTangentialOverlap();
739
740  Mdouble scalarNormalForce = Vec3D::dot(force_, getNormal());
741  Mdouble scalarTangentialForce = tangentialForce.getLength();
742  Vec3D tangential;
743  if (scalarTangentialForce!=0.0)
744  tangential = tangentialForce/scalarTangentialForce;
745  else
746  tangential = Vec3D(0.0,0.0,0.0);
747
750  Vec3D centre;
751  if (IParticle!=0)
752  centre = 0.5 * (getP()->getPosition() + getI()->getPosition());
753  else
754  centre = getP()->getPosition() - normal_ * (PParticle->getRadius() - overlap_);
755
756  if (PParticle!=0 && !PParticle->isFixed())
757  {
759  P_->getIndex(),
760  static_cast<int>((IParticle==0?(-I_->getIndex()-1):I_->getIndex())),
761  centre,
762  getOverlap(),
763  tangentialOverlap,
764  scalarNormalForce,
765  scalarTangentialForce,
766  (IParticle==0?-normal_:normal_),
767  (IParticle==0?-tangential:tangential));
768  }
769  if (IParticle!=0 && !IParticle->isFixed() && IParticle->getPeriodicFromParticle()==0)
770  {
772  I_->getIndex(),
773  static_cast<int>(P_->getIndex()),
774  centre,
775  getOverlap(),
776  tangentialOverlap,
777  scalarNormalForce,
778  scalarTangentialForce,
779  -normal_,
780  -tangential);
781
782  }
783 }
BaseInteractable * I_
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:106
virtual void gatherContactStatistics(unsigned int index1 UNUSED, int index2 UNUSED, Vec3D Contact UNUSED, Mdouble delta UNUSED, Mdouble ctheta UNUSED, Mdouble fdotn UNUSED, Mdouble fdott UNUSED, Vec3D P1_P2_normal_ UNUSED, Vec3D P1_P2_tangential UNUSED)
//Not unsigned index because of possible wall collisions.
Definition: DPMBase.cc:696
InteractionHandler * getHandler() const
Gets a point to the interaction handlers to which this interaction belongs.
double Mdouble
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:427
BaseInteractable * P_
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
virtual const Vec3D getTangentialForce() const
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
BaseInteractable * getI()
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
virtual Mdouble getTangentialOverlap() const
get the length of the current tangential overlap
bool isFixed() const
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
 Mdouble BaseInteraction::getAbsoluteNormalForce ( ) const

Returns the absolute value of the norm (length) of the Normal force vector.

Return the absolve normal force. This is the magnitude of the normal force.

Todo:
Ant: Check this comment.
Returns
Mdouble that contains the absolute norm (length) of the normal force.

Definition at line 531 of file BaseInteraction.cc.

References absoluteNormalForce_.

532 {
533  return absoluteNormalForce_;
534 }
Mdouble absoluteNormalForce_
 const BaseSpecies * BaseInteraction::getBaseSpecies ( ) const
protected

Return a constant point to BaseSpecies of the interaction.

Returns a BaseSpecies pointer to the current species. Note, this will be either a Species or a MixedSpecies done of which are derived from BaseSpecies.

Returns
A BaseSpecies pointer to the species associated with this interaction.

Definition at line 617 of file BaseInteraction.cc.

References species_.

618 {
619  return species_;
620 }
BaseSpecies * species_
 const Vec3D & BaseInteraction::getContactPoint ( ) const

Gets constant reference to contact point (vector).

Returns a reference to a Vec3D which contains the current value of the contact point for the particles in interaction. Normally, does not change about the interaction is created.

Returns
A reference to a Vec3D containing the contact point.

Definition at line 282 of file BaseInteraction.cc.

References contactPoint_.

283 {
284  return contactPoint_;
285 }
 Mdouble BaseInteraction::getDistance ( ) const

Returns an Mdouble which is the norm (length) of distance vector.

Definition at line 474 of file BaseInteraction.cc.

References distance_.

Referenced by SlidingFrictionInteraction::computeFrictionForce().

475 {
476  return distance_;
477 }
protected

Returns a Mdouble to the effective radius corrected for the overlaps of the particles.

Computes the effective corrected radius of a particle. This is used by some of the later interaction models. This correction is for the overlap. This functions assumes P is the particle and I is either a particle or a wall. See also BaseInteraction::getEffectiveCorrectedRadius()

Returns
A Mdouble which is the effective radius of the particles.

Definition at line 707 of file BaseInteraction.cc.

References getI(), getOverlap(), getP(), and BaseParticle::getRadius().

Referenced by FrictionInteraction::computeFrictionForce().

708 {
709  BaseParticle* PParticle = dynamic_cast<BaseParticle*>(getP());
710  BaseParticle* IParticle = dynamic_cast<BaseParticle*>(getI());
711  if (PParticle==nullptr)
712  {
713  std::cerr << "BaseInteraction::getEffectiveCorrectedRadius(): first interactable P is not a particle" << std::endl;
714  exit(-1);
715  }
716  //Compute the reduced diameter
717  if (IParticle==nullptr) //if particle-wall
718  {
720  }
721  else
722  {
726  }
727 }
double Mdouble
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
BaseInteractable * getI()
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
protected

Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap)

Computes the effective radius of a particle. This is used by many of the later interaction models. This functions assumes P is the particle and I is either a particle or a wall. Effective Radius = $$R_I*R_P/(R_I+R_P)$$ See also BaseInteraction::getEffectiveCorrectedRadius()

Returns
A Mdouble which is the effective radius of the particles.

Definition at line 676 of file BaseInteraction.cc.

677 {
678  const BaseParticle* PParticle = dynamic_cast<const BaseParticle*>(getP());
679  const BaseParticle* IParticle = dynamic_cast<const BaseParticle*>(getI());
680  if (PParticle==nullptr)
681  {
682  std::cerr << "BaseInteraction::getEffectiveCorrectedRadius(): first interactable P is not a particle" << std::endl;
683  exit(-1);
684  }
685  //Compute the reduced diameter
686  if (IParticle==nullptr) //if particle-wall
687  {
689  }
690  else
691  {
695  }
696 }
double Mdouble
BaseInteractable * getI()
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
 Mdouble BaseInteraction::getElasticEnergy ( ) const
virtual

Returns a Mdouble which is the current about of Elastic energy in the interaction.

The children of this class will implement this function; however, it is blank. This function will contain the calculation for th elastic energy. Note, it is not virtual as it is not called from within this class.

Definition at line 638 of file BaseInteraction.cc.

639 {
640  return 0.0;
641 }
 const Vec3D & BaseInteraction::getForce ( ) const

Gets the current force (vector) between the two interacting objects.

Return a reference to a Vec3D which contains the current value of the force associated with this interaction.

Returns
A reference to a Vec3D containing the total force.

Definition at line 251 of file BaseInteraction.cc.

References force_.

Referenced by DPMBase::computeForcesDueToWalls(), and DPMBase::computeInternalForces().

252 {
253  return force_;
254 }
 InteractionHandler * BaseInteraction::getHandler ( ) const

Gets a point to the interaction handlers to which this interaction belongs.

Returns a pointer to the InteractionHandler that this interaction belongs.

Returns
Constant pointer to the InteractionHandler.

Definition at line 196 of file BaseInteraction.cc.

References handler_.

197 {
198  return handler_;
199 }
InteractionHandler * handler_
 BaseInteractable * BaseInteraction::getI ( )

Returns a pointer to the second object in the interaction; often a particle or a wall i.e. a general interactale hence I.

Returns
Pointer to BaseInteraction often a particle or a wall.

Definition at line 312 of file BaseInteraction.cc.

References I_.

313 {
314  return I_;
315 }
BaseInteractable * I_
 const BaseInteractable * BaseInteraction::getI ( ) const

Returns a constant pointer to the second object involved in the interaction.

Returns a constant pointer to the second object in the interaction; often a particle or a wall i.e. a general interactale hence I.

Returns
Constant pointer to BaseInteraction often a particle or a wall.

Definition at line 332 of file BaseInteraction.cc.

References I_.

333 {
334  return I_;
335 }
BaseInteractable * I_
 std::string BaseInteraction::getName ( ) const
virtual

Virtual function which allows interactions to be named.

Functions which returns the name of the Interaction here is called BaseInteraction; but, it should be later overridden by the actual interaction classes.

Implements BaseObject.

Definition at line 127 of file BaseInteraction.cc.

Referenced by write().

128 {
129  return "BaseInteraction";
130 }
 const Vec3D & BaseInteraction::getNormal ( ) const

Gets the normal vector between the two interacting objects.

Returns a reference to a Vec3D which contains the current value of the normal associated with the interactions.

Returns
A reference to a Vec3D containing the current normal.

Definition at line 271 of file BaseInteraction.cc.

References normal_.

272 {
273  return normal_;
274 }
 Mdouble BaseInteraction::getNormalRelativeVelocity ( ) const

Returns a double which is the norm (length) of the relative velocity vector.

Returns the norm (length) of the relative normal velocity. Note, this can be negative or positive it is not a speed.

Todo:
Ant: Check this comment.
Returns
Mdouble that contains the norm (length) of the relative velocity.

Definition at line 519 of file BaseInteraction.cc.

References normalRelativeVelocity_.

520 {
522 }
Mdouble normalRelativeVelocity_
 Mdouble BaseInteraction::getOverlap ( ) const

Returns a Mdouble with the current overlap between the two interacting objects.

Returns a Mdouble to the current overlap for the objects involved in the interaction.

Returns
Mdouble which is the value of the overlap.

Definition at line 292 of file BaseInteraction.cc.

References overlap_.

293 {
294  return overlap_;
295 }
 BaseInteractable * BaseInteraction::getP ( )

Returns a pointer to first object involved in the interaction (normally a particle).

Returns a pointer to the first object in the interactions; normally the particle.

Returns
Pointer to BaseInteraction but normally will be a BaseParticle.

Definition at line 302 of file BaseInteraction.cc.

References P_.

303 {
304  return P_;
305 }
BaseInteractable * P_
 const BaseInteractable * BaseInteraction::getP ( ) const

Returns a constant pointer to the first object in the interactions; normally the particle.

Returns
Constant pointer to BaseInteraction but normally will be a BaseParticle.

Definition at line 322 of file BaseInteraction.cc.

References P_.

323 {
324  return P_;
325 }
BaseInteractable * P_
 const Vec3D & BaseInteraction::getRelativeVelocity ( ) const

Returns a constant reference to a vector of relative velocity.

Returns the relative velocity between the two interactable objects involved in the interaction.

Returns
A reference to Vec3D that contains the relative velocity.

Definition at line 508 of file BaseInteraction.cc.

References relativeVelocity_.

509 {
510  return relativeVelocity_;
511 }
 const Vec3D BaseInteraction::getTangentialForce ( ) const
protectedvirtual

Returns a constant vector to the Tangential Force

Returns the vector that is the tangential force Note, at this level there cannot be a tangential force therefore by default it return the zero vector. This function will be overridden by interactions that have tangential components.

Returns
Vec3D that contains the current tangential force of the interaction.

Reimplemented in EmptyFrictionInteraction, and SlidingFrictionInteraction.

Definition at line 498 of file BaseInteraction.cc.

Referenced by gatherContactStatistics(), and writeToFStat().

499 {
500  return Vec3D(0.0,0.0,0.0);
501 }
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
 Mdouble BaseInteraction::getTangentialOverlap ( ) const
virtual

get the length of the current tangential overlap

Returns tangential overlap. Note, at this level there cannot be a tangential overlap hence by default it returns 0. This function will be overridden by interactions that have tangential components.

Returns
Positive Mdouble that is the tangential overlap.

Reimplemented in EmptyFrictionInteraction, and SlidingFrictionInteraction.

Definition at line 486 of file BaseInteraction.cc.

Referenced by gatherContactStatistics(), and writeToFStat().

487 {
488  return 0;
489 }
 Mdouble BaseInteraction::getTimeStamp ( ) const

Returns an Mdouble which is the time stamp of the interaction.

Returns the current time stamp of interaction. This should be the last time the interaction was active and used to find the end of the interaction.

Returns
Mdouble which is the last time the interaction was active.

Definition at line 343 of file BaseInteraction.cc.

References timeStamp_.

344 {
345  return timeStamp_;
346 }
 const Vec3D & BaseInteraction::getTorque ( ) const

Gets the current torque (vector) between the two interacting objects.

Return a reference to a Vec3D which contains the current value of the torque associated with the interaction.

Returns
A reference to a Vec3D containing the total torque.

Definition at line 261 of file BaseInteraction.cc.

References torque_.

Referenced by DPMBase::computeForcesDueToWalls(), and DPMBase::computeInternalForces().

262 {
264 }
 void BaseInteraction::integrate ( Mdouble timeStep UNUSED )
virtual

integrates variables of the interaction which need to be integrate e.g. the tangential overlap.

Various variables in the force law need to be integrated. This is the place where this code goes. Note, it is empty and abstract at this point; but, not virtual as it as not called from within this class. It is only called by higher classes.

Parameters
 [in] timeStep This is the current time step and is passed in case the variables that are integrated depend on the absolute time of the system
Todo:
Ant: When is this case; is there an examepl?

Reimplemented in EmptyFrictionInteraction, FrictionInteraction, and SlidingFrictionInteraction.

Definition at line 359 of file BaseInteraction.cc.

360 {
361
362 }
 void BaseInteraction::read ( std::istream & is )
virtual

Interaction read function, which accepts an std::istream as input.

Parameters
 [in] is std::istream to which the information is read from.

Implements BaseObject.

Definition at line 115 of file BaseInteraction.cc.

References force_, and torque_.

116 {
117  //the rest gets read by the interaction handler
118  std::string dummy;
119  is >> dummy >> force_ >> dummy >> torque_;
120 }
 void BaseInteraction::removeFromHandler ( )

Removes this interaction from its interaction hander.

Removes the interaction from its InteractionHandler. Does no other cleaning up as it does not remove it from the particles.

Definition at line 205 of file BaseInteraction.cc.

References BaseObject::getIndex(), handler_, and BaseHandler< T >::removeObject().

206 {
208 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:106
virtual void removeObject(unsigned const int id)
Removes an Object from the BaseHandler.
Definition: BaseHandler.h:303
InteractionHandler * handler_
 void BaseInteraction::reverseHistory ( )
protectedvirtual

When periodic particles some interaction need certain history properties reversing. This is the function for that.

The children of this class will implement this function; however, it is blank. This function will contain code that changes some history information if a copy changes the P <-> I order; as can happen in creating a periodic particle. See also PeriodicBoundary::createPeriodicParticles and BaseInteraction::copySwitchPointer Note, it is not virtual as it is not called from within this class.

Reimplemented in SlidingFrictionInteraction, and FrictionInteraction.

Definition at line 653 of file BaseInteraction.cc.

Referenced by copySwitchPointer().

654 {
655 }
 void BaseInteraction::rotateHistory ( Matrix3D & rotationMatrix )
virtual

When periodic particles are used, some interactions need certain history properties rotated (e.g. tangential springs). This is the function for that.

Todo:
some of these might be unneccesary

Reimplemented in SlidingFrictionInteraction, and FrictionInteraction.

Definition at line 657 of file BaseInteraction.cc.

References contactPoint_, force_, normal_, relativeVelocity_, and torque_.

658 {
659  contactPoint_=rotationMatrix*contactPoint_;
660  relativeVelocity_=rotationMatrix*relativeVelocity_;
661  force_=rotationMatrix*force_;
662  torque_=rotationMatrix*torque_;
663  normal_=rotationMatrix*normal_;
665 }
 void BaseInteraction::setAbsoluteNormalForce ( Mdouble absoluteNormalForce )
protected

the absolute values of the norm (length) of the normal force

set absolute normal force.

Parameters
 [in] absoluteNormalForce Mdouble contain the value of the absolute normal force.

Definition at line 605 of file BaseInteraction.cc.

References absoluteNormalForce_.

606 {
607  absoluteNormalForce_ = absoluteNormalForce;
608 }
Mdouble absoluteNormalForce_
 void BaseInteraction::setContactPoint ( Vec3D contactPoint )

Set the location of the contact point between the two interacting objects.

Definition at line 165 of file BaseInteraction.cc.

References contactPoint_.

166 {
167  contactPoint_ = contactPoint;
168 }
 void BaseInteraction::setDistance ( Mdouble distance )

Sets the interaction distance between the two interacting objects.

set the distance of the interaction.

Parameters
 [in] distance Mdouble which is the distance to set.

Definition at line 146 of file BaseInteraction.cc.

References distance_.

147 {
148  distance_ = distance;
149 }
 void BaseInteraction::setForce ( Vec3D force )
protected

set total force (this is used by the normal force, tangential forces are added use addForce)

set the absolute values of the force. This is used by the normal forces as these are always called first and then the tangential and non-contact (e.g. adhesive forces) forces are added. See also BaseInteraction::addForce.

Definition at line 562 of file BaseInteraction.cc.

References force_.

563 {
564  force_=force;
565 }
 void BaseInteraction::setHandler ( InteractionHandler * handler )

Sets the pointer to the interaction hander which is storing this interaction.

set the handler which this interactions belongs to.

Parameters
 [in] handler InteractionHandler* pointer to the interaction handler, this interaction will belong.

Definition at line 186 of file BaseInteraction.cc.

References handler_.

187 {
188  handler_ = handler;
189 }
InteractionHandler * handler_
 void BaseInteraction::setI ( BaseInteractable * I )

Sets the second object involved in the interaction (often particle or wall).

Changes the second object involved in the interaction; often a general interactable not always a particle. Note, set is slightly misleading as it removed the interaction from old interactable and adds it to the new interactable.

Parameters
 [in] I BaseInteractable* An interactable object that is involved in the interaction.

Definition at line 399 of file BaseInteraction.cc.

Referenced by InteractionHandler::removeObjectKeepingPeriodics().

400 {
401  I_->removeInteraction(this);
402  I_=I;
404 }
BaseInteractable * I_
bool removeInteraction(BaseInteraction *I)
Removes an interaction from this BaseInteractable.
Adds an interaction to this BaseInteractable.
 void BaseInteraction::setNormal ( Vec3D normal )

Sets the normal vector between the two interacting objects.

sets the normal of the interaction, in direction from I to P. Must be a unit normal vector. This is not checked by the class.

Parameters
 [in] normal Vec3D which is the normal of the interaction.

Definition at line 137 of file BaseInteraction.cc.

References normal_.

138 {
139  normal_ = normal;
140 }
 void BaseInteraction::setNormalRelativeVelocity ( Mdouble normalRelativeVelocity )
protected

set the normal component of the relative velocity.

set the norm (length) of the normal relative velocity.

Parameters
 [in] normalRelativeVelocity Mdouble containing the normal (length) of the normal velocity between the interactable objects.

Definition at line 595 of file BaseInteraction.cc.

References normalRelativeVelocity_.

596 {
597  normalRelativeVelocity_=normalRelativeVelocity;
598 }
Mdouble normalRelativeVelocity_
 void BaseInteraction::setOverlap ( Mdouble overlap )

Set the overlap between the two interacting object.

set the overlap between the two interactable object involved in the interactions.

Parameters
 [in] overlap Mdouble which is the overlap to set.

Definition at line 156 of file BaseInteraction.cc.

References overlap_.

157 {
158  overlap_ = overlap;
159 }
 void BaseInteraction::setP ( BaseInteractable * P )

Sets the first object involved in the interaction (normally a particle).

Changes the first object involved in the interaction; normally a particle. Note, set is slightly misleading as it removed the interaction from old particle and adds it to the new particle.

Parameters
 [in] P BaseInteractable* An interactable object that is involved in the interaction.

Definition at line 384 of file BaseInteraction.cc.

385 {
386  P_->removeInteraction(this);
387  P_=P;
389 }
bool removeInteraction(BaseInteraction *I)
Removes an interaction from this BaseInteractable.
Adds an interaction to this BaseInteractable.
BaseInteractable * P_
 void BaseInteraction::setRelativeVelocity ( Vec3D relativeVelocity )
protected

set the relative velocity of the current of the interactions.

set the relative velocity between the two particles involved in the interaction.

Parameters
 [in] relativeVelocity This is Vec3D that contains the relative velocity between the two interactable objects.

Definition at line 584 of file BaseInteraction.cc.

References relativeVelocity_.

585 {
586  relativeVelocity_=relativeVelocity;
587 }
 void BaseInteraction::setSpecies ( BaseSpecies * species )

Set the Species of the interaction; note this can either be a Species or MixedSpecies.

Sets the species for the interactions. Note, this can be either a normal Species or a MixedSpecies; depending on if this interaction is between interactables of the same or different types.

Parameters
 [in] BaseSpecies* pointer to the actually species of the interaction.

Definition at line 371 of file BaseInteraction.cc.

References species_.

Referenced by InteractionHandler::getInteraction().

372 {
373  species_ = species;
374 }
BaseSpecies * species_
 void BaseInteraction::setTimeStamp ( Mdouble timeStamp )

Updates the time step of the interacting. Note, timesteps used to find completed interactions.

Updated the time stamp of the interaction. The time stamp being old is how ended interactions are detected.

Parameters
 [in] timeStamp The new timeStamp for the interactions should be the current time step.

Definition at line 176 of file BaseInteraction.cc.

References timeStamp_.

Referenced by InteractionHandler::getInteraction().

177 {
178  timeStamp_ = timeStamp;
179 }
 void BaseInteraction::setTorque ( Vec3D torque )
protected

set the total force (this is used by the normal force, tangential torques are added use addTorque)

set the absolute values of the torque. This is used by the normal forces as these are always called first and then the tangential and non-contact (e.g. adhesive forces) forces/torques are added. See also BaseInteraction::addTorque.

Definition at line 573 of file BaseInteraction.cc.

References torque_.

574 {
575  torque_=torque;
576 }
 void BaseInteraction::write ( std::ostream & os ) const
virtual

Interaction print function, which accepts an std::ostream as input.

BaseInteaction write function. Writes out all the information required to recreate this interaction. To write this interaction to the screen call write(std::cout). See also BaseInteraction::read

Parameters
 [in] os std::ostream to which the information is written. Note, is any ostram is can be file or screen.
Todo:
should we output id's here? os << " id " << getId() << " particleIds " << P_->getId() << " " << I_->getId();

Implements BaseObject.

Definition at line 97 of file BaseInteraction.cc.

References force_, BaseObject::getId(), getName(), I_, P_, timeStamp_, and torque_.

98 {
99  os << getName();
100  if (dynamic_cast<BaseParticle*>(I_) != nullptr)
101  os << " particleIds " << P_->getId() << " " << I_->getId();
103  else
104  os << " particleWallIds " << P_->getId() << " " << I_->getId();
105  os <<" timeStamp "<<timeStamp_<< " force " << force_ << " torque " << torque_;
106 }
BaseInteractable * I_
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.cc:113
BaseInteractable * P_
virtual std::string getName() const
Virtual function which allows interactions to be named.
 void BaseInteraction::writeToFStat ( std::ostream & os ) const

Writes forces data to the FStat file.

Writes the FStat information that is required for the coarse- graining package MercuryCG if you want stress and force information. Note, it takes a general ostream but is normally a file i.e. ofstream

Parameters
 [in] os This is the ostream that the FStat information will be written to. Normally, a file but could be a gerneral ostream.
Todo:
TW centre is used just for backward compatibility; replace centre by contact law; we also have to correct it in StatisticsVector::gatherContactStatistics. There also seems to be an issue with the normal being defined differently for walls
Todo:
the flip in normal/tangential direction for walls should not be done; this is an old bug

Definition at line 415 of file BaseInteraction.cc.

416 {
417  BaseParticle* IParticle = dynamic_cast<BaseParticle*>(I_);
418  BaseParticle* PParticle = dynamic_cast<BaseParticle*>(P_);
419
420  Vec3D tangentialForce = getTangentialForce();
421  Mdouble tangentialOverlap = getTangentialOverlap();
422
423  Mdouble scalarNormalForce = Vec3D::dot(force_, getNormal());
424  Mdouble scalarTangentialForce = tangentialForce.getLength();
425  Vec3D tangential;
426  if (scalarTangentialForce!=0.0)
427  tangential = tangentialForce/scalarTangentialForce;
428  else
429  tangential = Vec3D(0.0,0.0,0.0);
430
433  Vec3D centre;
434  if (IParticle!=0)
435  centre = 0.5 * (getP()->getPosition() + getI()->getPosition());
436  else
437  centre = getP()->getPosition() - normal_ * (PParticle->getRadius() - overlap_);
438
439  if (PParticle!=0 && !PParticle->isFixed())
440  {
441  os << timeStamp_
442  << " " << P_->getIndex()
443  << " " << static_cast<int>((IParticle==0?(-I_->getIndex()-1):I_->getIndex()))
444  << " " << centre
445  << " " << getOverlap()
446  << " " << tangentialOverlap
447  << " " << scalarNormalForce
448  << " " << scalarTangentialForce
449  << " " << (IParticle==0?-normal_:normal_)
450  << " " << (IParticle==0?-tangential:tangential) << std::endl;
452  }
453  if (IParticle!=0 && !IParticle->isFixed() && IParticle->getPeriodicFromParticle()==0)
454  {
455  os << timeStamp_
456  << " " << I_->getIndex()
457  << " " << P_->getIndex()
458  << " " << centre
459  << " " << getOverlap()
460  << " " << tangentialOverlap
461  << " " << scalarNormalForce
462  << " " << scalarTangentialForce
463  << " " << -normal_
464  << " " << -tangential << std::endl;
465  }
466
467 }
BaseInteractable * I_
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:106
double Mdouble
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:427
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
BaseInteractable * P_
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
virtual const Vec3D getTangentialForce() const
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
BaseInteractable * getI()
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual Mdouble getTangentialOverlap() const
get the length of the current tangential overlap
bool isFixed() const
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...

## Member Data Documentation

 Mdouble BaseInteraction::absoluteNormalForce_
private

Variables calculated by NormalForceInteraction, used by FrictionForceInteraction and AdhesiveForceInteraction (but not changed by them)

Definition at line 363 of file BaseInteraction.h.

Referenced by getAbsoluteNormalForce(), and setAbsoluteNormalForce().

 Vec3D BaseInteraction::contactPoint_
private

This is Vec3D which stores the contact point of the interaction.

Definition at line 346 of file BaseInteraction.h.

Referenced by getContactPoint(), rotateHistory(), and setContactPoint().

 Mdouble BaseInteraction::distance_
private

Variables calculated by NormalForceInteraction, used by FrictionForceInteraction and AdhesiveForceInteraction (but not changed by them)

Definition at line 368 of file BaseInteraction.h.

Referenced by getDistance(), and setDistance().

 Vec3D BaseInteraction::force_
private

Definition at line 373 of file BaseInteraction.h.

 InteractionHandler* BaseInteraction::handler_
private

Pointer to the InteractionHander for this interaction.

Definition at line 331 of file BaseInteraction.h.

Referenced by copySwitchPointer(), getHandler(), removeFromHandler(), and setHandler().

 BaseInteractable* BaseInteraction::I_
private

This is the second of the two interactable object involved in the interaction; often a particle or a wall, hence I because it is general interactable.

Definition at line 341 of file BaseInteraction.h.

 Vec3D BaseInteraction::normal_
private

Vec3D which stores the normal vector of the interaction.

Definition at line 388 of file BaseInteraction.h.

 Mdouble BaseInteraction::normalRelativeVelocity_
private

Variables calculated by NormalForceInteraction, used in other force routines (but not changed by them)

Definition at line 358 of file BaseInteraction.h.

Referenced by getNormalRelativeVelocity(), and setNormalRelativeVelocity().

 Mdouble BaseInteraction::overlap_
private

Mdouble which stores the current overlap.

Definition at line 393 of file BaseInteraction.h.

Referenced by BaseInteraction(), gatherContactStatistics(), getOverlap(), setOverlap(), and writeToFStat().

 BaseInteractable* BaseInteraction::P_
private

This first of two interactable objects involved in the interaction; normally a particle hence P.

Definition at line 336 of file BaseInteraction.h.

 Vec3D BaseInteraction::relativeVelocity_
private

Variables calculated by the normal force routines used in other force routines (but not changed by them).

Definition at line 353 of file BaseInteraction.h.

Referenced by getRelativeVelocity(), rotateHistory(), and setRelativeVelocity().

 BaseSpecies* BaseInteraction::species_
private

Pointer to the species of the interaction could be a mixed species or a species.

Definition at line 398 of file BaseInteraction.h.

Referenced by BaseInteraction(), getBaseSpecies(), and setSpecies().

 Mdouble BaseInteraction::timeStamp_
private

Mdouble which store the last timeStamp the interaction was active.

Definition at line 383 of file BaseInteraction.h.

Referenced by BaseInteraction(), getTimeStamp(), setTimeStamp(), write(), and writeToFStat().

 Vec3D BaseInteraction::torque_
private

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