MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > Class Template Reference

Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInteraction::I_;. More...

#include <Interaction.h>

+ Inheritance diagram for Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >:

Public Member Functions

 Interaction (BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
 The default constructor. More...
 
 Interaction ()
 Empty constructor. More...
 
 Interaction (const Interaction &p)
 The default copy constructor. More...
 
virtual ~Interaction ()
 The default destructor. More...
 
Interaction
< NormalForceInteraction,
FrictionForceInteraction,
AdhesiveForceInteraction > * 
copy () const final
 Creates a copy of this Interaction. More...
 
void computeForce () final
 Computes the normal, tangential, and adhesive forces. More...
 
void computeInteraction ()
 Computes the interaction parameters based on the forces and torques. More...
 
void read (std::istream &is) final
 Read Interaction properties from a file. More...
 
void write (std::ostream &os) const final
 Writes Interaction properties to a file. More...
 
std::string getName () const final
 Returns the name of the Interaction. More...
 
Mdouble getElasticEnergy () const final
 Returns the elastic energy stored in the Interaction. More...
 
void integrate (Mdouble timeStep) final
 Integrates the time-dependent parameters of the contact force. More...
 
void reverseHistory () final
 Reverses the parameters of the contact force. More...
 
void rotateHistory (Matrix3D &rotationMatrix) final
 
void actionsAfterTimeStep ()
 
Mdouble getElasticEnergyAtEquilibrium (Mdouble adhesiveForce) const
 returns the overlap at which the repulsive elastic force equals a given adhesive force; to be implemented in the normal force More...
 
void getMPIInteraction (void *historyDataArray, unsigned int index) const final
 
void setMPIInteraction (void *historyDataArray, unsigned int index, const bool resetPointers) final
 
void getInteractionDetails (void *interactionDataArray, unsigned int index, unsigned int &identificationP, unsigned int &identificationI, bool &isWallInteraction, unsigned &timeStamp)
 
void createMPIType () final
 
void * createMPIInteractionDataArray (unsigned int numberOfInteractions) const final
 
void deleteMPIInteractionDataArray (void *dataArray) final
 

Detailed Description

template<class NormalForceInteraction, class FrictionForceInteraction = EmptyFrictionInteraction, class AdhesiveForceInteraction = EmptyAdhesiveInteraction>
class Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >

Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInteraction::I_;.

An instance is created every time two BaseInteractables (particles or walls) get into contact with another, and gets deleted when the contact ends.

Next, the call process is described for this function for the case of two particles (it is very similar for a particle-wall contact.

Then, in each time step, every time that a contact is detected, DPMBase::computeInternalForces is called, which calls BaseParticle::getInteractionWith to create a new Interaction (setting the links to the interactables P_ and I_ and adds it to the InteractionHandler) or find an existing one. When a new Interaction is created, the Species determines what kind of Interaction it will be. DPMBase::computeInternalForces also sets the timeStamp_, normal_, overlap_, distance_, and contactPoint_ of the Interaction.

Then, computeForce is called, which sets the force_, which sets BaseInteraction::force_ and BaseInteraction::torque_ of the Interaction, and a few temporary values to communicate between the three different computeForce routines (see diamond inheritance below).

The force_ and torque_ is then used in DPMBase::integrateBeforeForceComputation and DPMBase::integrateAfterForceComputation to calcutate the new positions and velocities.

Todo:
MX: I do not think the above is correct. integrateBeforeForceComputation() updates the positions

As there are many types of contact forces, the class is templated to allow for different force models. This is done in a diamond inheritance structure: First, three kinds of Interactions are created:

A full Interaction object is then derived by inheriting from all of the above:

dot_inline_dotgraph_5.png

Definition at line 115 of file Interaction.h.

Constructor & Destructor Documentation

template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::Interaction ( BaseInteractable P,
BaseInteractable I,
unsigned  timeStamp 
)

The default constructor.

Definition at line 184 of file Interaction.h.

186  : BaseInteraction(P, I, timeStamp), NormalForceInteraction(P, I, timeStamp),
187  FrictionForceInteraction(P, I, timeStamp), AdhesiveForceInteraction(P, I, timeStamp)
188 {
189 #ifdef DEBUG_CONSTRUCTOR
190  std::cout<<"Interaction::Interaction() finished"<<std::endl;
191 #endif
192 }
Stores information about interactions between two interactable objects; often particles but could be ...
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::Interaction ( )

Empty constructor.

Definition at line 196 of file Interaction.h.

198 {
199 #ifdef DEBUG_CONSTRUCTOR
200  std::cout<<"Interaction::Interaction() finished"<<std::endl;
201 #endif
202 }
Stores information about interactions between two interactable objects; often particles but could be ...
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::Interaction ( const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > &  p)

The default copy constructor.

Definition at line 205 of file Interaction.h.

208 {
209 #ifdef DEBUG_CONSTRUCTOR
210  std::cout<<"Interaction::Interaction(const Interaction &p finished"<<std::endl;
211 #endif
212 }
Stores information about interactions between two interactable objects; often particles but could be ...
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::~Interaction ( )
virtual

The default destructor.

Definition at line 215 of file Interaction.h.

216 {
217 #ifdef DEBUG_DESTRUCTOR
218  std::cout<<"Interaction::~Interaction() finished"<<std::endl;
219 #endif
220 }

Member Function Documentation

template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::actionsAfterTimeStep ( )

Definition at line 334 of file Interaction.h.

335 {
336  AdhesiveForceInteraction::actionsAfterTimeStep();
337 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::computeForce ( )
final

Computes the normal, tangential, and adhesive forces.

Computes the normal, tangential, and adhesive forces (in that order). The order is important, as the normal force computation also calculates some additional parameters required by the other force laws: relativeVelocity_, normalRelativeVelocity_, absoluteNormalForce_.

Definition at line 312 of file Interaction.h.

313 {
314  NormalForceInteraction::computeNormalForce();
315  FrictionForceInteraction::computeFrictionForce();
316  AdhesiveForceInteraction::computeAdhesionForce();
317 }
template<class NormalForceInteraction, class FrictionForceInteraction = EmptyFrictionInteraction, class AdhesiveForceInteraction = EmptyAdhesiveInteraction>
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::computeInteraction ( )

Computes the interaction parameters based on the forces and torques.

template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > * Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::copy ( ) const
final

Creates a copy of this Interaction.

Useful for polymorphism as it can be called from a BaseInteraction* pointer.

Definition at line 227 of file Interaction.h.

228 {
229  return new Interaction(*this);
230 }
Interaction()
Empty constructor.
Definition: Interaction.h:196
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void * Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::createMPIInteractionDataArray ( unsigned int  numberOfInteractions) const
final

Definition at line 391 of file Interaction.h.

393 {
395  void* interactionArray = static_cast<void*>(array);
396  return interactionArray;
397 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::createMPIType ( )
final

Definition at line 409 of file Interaction.h.

References MPIContainer::createMercuryMPIType(), MPIContainer::Instance(), and INTERACTION.

410 {
411 #ifdef MERCURY_USE_MPI
412  MPIContainer& communicator = MPIContainer::Instance();
414 
415  communicator.createMercuryMPIType(dummyHistoryInteraction, MercuryMPIType::INTERACTION);
416 #endif
417 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:125
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
void createMercuryMPIType(T t, MercuryMPIType type)
Get the communicator used for MPI commands.
Definition: MpiContainer.h:551
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::deleteMPIInteractionDataArray ( void *  dataArray)
final
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Mdouble Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::getElasticEnergy ( ) const
final

Returns the elastic energy stored in the Interaction.

Returns the elastic energy stored in the Interaction, adding up contributions from the normal, frictional and adhesive interaction The elastic (=potential) energy is defined as the energy gained by separating P_ and I_.

Returns
the computed elastic energy.

Definition at line 327 of file Interaction.h.

328 {
329  return NormalForceInteraction::getElasticEnergy() + FrictionForceInteraction::getElasticEnergy() +
330  AdhesiveForceInteraction::getElasticEnergy();
331 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
Mdouble Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::getElasticEnergyAtEquilibrium ( Mdouble  adhesiveForce) const

returns the overlap at which the repulsive elastic force equals a given adhesive force; to be implemented in the normal force

Definition at line 344 of file Interaction.h.

346 {
347  return NormalForceInteraction::getElasticEnergyAtEquilibrium(adhesiveForce);
348 };
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::getInteractionDetails ( void *  interactionDataArray,
unsigned int  index,
unsigned int &  identificationP,
unsigned int &  identificationI,
bool &  isWallInteraction,
unsigned timeStamp 
)
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::getMPIInteraction ( void *  historyDataArray,
unsigned int  index 
) const
final

Definition at line 352 of file Interaction.h.

References MPIInteraction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::copyFromInteraction().

354 {
356 
357  interactionData.copyFromInteraction(this);
358 
360  array[index] = interactionData;
361 }
void copyFromInteraction(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
std::string Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::getName ( ) const
final

Returns the name of the Interaction.

Returns the name of the Interaction, which depends on the template parameters.

Returns
the string to which the name is written.

Definition at line 285 of file Interaction.h.

286 {
287  return NormalForceInteraction::getBaseName() + FrictionForceInteraction::getBaseName() +
288  AdhesiveForceInteraction::getBaseName() + "Interaction";
289 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::integrate ( Mdouble  timeStep)
final

Integrates the time-dependent parameters of the contact force.

Called by ??? to integrate time-dependent parameters of the contact force, such as the SlidingFrictionInteraction::slidingSpring_

Parameters
[in]thetime step.

Definition at line 298 of file Interaction.h.

299 {
300  FrictionForceInteraction::integrate(timeStep);
301 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::read ( std::istream &  is)
final

Read Interaction properties from a file.

Reads Interaction properties in human-readable form from a file, typically Files::restartFile.

Parameters
[in]isthe istream from which the data is read.

Definition at line 251 of file Interaction.h.

252 {
253  NormalForceInteraction::read(is);
254  FrictionForceInteraction::read(is);
255  AdhesiveForceInteraction::read(is);
256 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::reverseHistory ( )
final

Reverses the parameters of the contact force.

Called by BaseInteraction::copySwitchPointer to reverse the parameters of the contact force in the case that the interactables P_ and I_ are switched. This is needed to deal with periodic particles.

Definition at line 264 of file Interaction.h.

265 {
266  NormalForceInteraction::reverseHistory();
267  FrictionForceInteraction::reverseHistory();
268  AdhesiveForceInteraction::reverseHistory();
269 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::rotateHistory ( Matrix3D rotationMatrix)
final

Definition at line 272 of file Interaction.h.

274 {
275  NormalForceInteraction::rotateHistory(rotationMatrix);
276  FrictionForceInteraction::rotateHistory(rotationMatrix);
277  AdhesiveForceInteraction::rotateHistory(rotationMatrix);
278 }
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::setMPIInteraction ( void *  historyDataArray,
unsigned int  index,
const bool  resetPointers 
)
final

Definition at line 364 of file Interaction.h.

References MPIInteraction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::copyToInteraction().

366 {
369 
370  //Copy the interaction data into the interaction
371  interactionData.copyToInteraction(this, resetPointers);
372 }
void copyToInteraction(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction, const bool resetPointers)
template<class NormalForceInteraction , class FrictionForceInteraction , class AdhesiveForceInteraction >
void Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction >::write ( std::ostream &  os) const
final

Writes Interaction properties to a file.

Writes Interaction properties in human-readable form to a file, typically Files::restartFile.

Parameters
[out]osthe ostream to which the data is written.

Definition at line 238 of file Interaction.h.

239 {
240  NormalForceInteraction::write(os);
241  FrictionForceInteraction::write(os);
242  AdhesiveForceInteraction::write(os);
243 
244 }

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