MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseSpecies Class Referenceabstract

BaseSpecies is the class from which all other species are derived. More...

#include <BaseSpecies.h>

+ Inheritance diagram for BaseSpecies:

Public Member Functions

 BaseSpecies ()
 The default constructor. More...
 
 BaseSpecies (const BaseSpecies &p)
 The copy constructor. More...
 
virtual ~BaseSpecies ()
 The default destructor. More...
 
virtual BaseSpeciescopy () const =0
 Creates a deep copy of the object from which it is called. More...
 
void setHandler (SpeciesHandler *handler)
 Sets the pointer to the handler to which this species belongs. More...
 
SpeciesHandlergetHandler () const
 Returns the pointer to the handler to which this species belongs. More...
 
Mdouble average (Mdouble a, Mdouble b)
 defines the average of two variables by the harmonic mean. More...
 
virtual void mixAll (BaseSpecies *const S, BaseSpecies *const T)=0
 creates default values for mixed species More...
 
virtual Mdouble getInteractionDistance () const =0
 returns the largest separation distance at which adhesive short-range forces can occur. More...
 
virtual bool getUseAngularDOFs () const =0
 Returns true if torques (i.e. angular degrees of freedom) have to be calculated. More...
 
virtual BaseInteractiongetNewInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)=0
 returns new Interaction object. 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 read (std::istream &is)=0
 A purely virtual method with an implementation which reads the index from the stream and assigns it to id_. More...
 
virtual void write (std::ostream &os) const =0
 A purely virtual function which has an implementation which writes the name and the object id_ to the output stream. More...
 
virtual std::string getName () const =0
 A purely virtual function. 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...
 

Private Attributes

SpeciesHandlerhandler_
 A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set when SpeciesHandler::addObject() is called. More...
 

Detailed Description

BaseSpecies is the class from which all other species are derived.

A base species is almost empty, with the exception of a pointer to the particleHandler. All other properties get added in the inherited classes. See Species for more details.

Definition at line 44 of file BaseSpecies.h.

Constructor & Destructor Documentation

BaseSpecies::BaseSpecies ( )

The default constructor.

Definition at line 35 of file BaseSpecies.cc.

References handler_.

36 : BaseObject()
37 {
38  handler_ = 0;
39 #ifdef DEBUG_CONSTRUCTOR
40  std::cout << "BaseSpecies::BaseSpecies() finished" << std::endl;
41 #endif
42 }
SpeciesHandler * handler_
A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set whe...
Definition: BaseSpecies.h:134
BaseObject()
Default constructor.
Definition: BaseObject.cc:51
BaseSpecies::BaseSpecies ( const BaseSpecies p)

The copy constructor.

Parameters
[in]pthe species that is copied

Definition at line 47 of file BaseSpecies.cc.

References handler_.

48 : BaseObject(p)
49 {
50  handler_ = p.handler_;
51 #ifdef DEBUG_CONSTRUCTOR
52  std::cout << "BaseSpecies::BaseSpecies(const BaseSpecies &p) finished" << std::endl;
53 #endif
54 }
SpeciesHandler * handler_
A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set whe...
Definition: BaseSpecies.h:134
BaseObject()
Default constructor.
Definition: BaseObject.cc:51
BaseSpecies::~BaseSpecies ( )
virtual

The default destructor.

Definition at line 56 of file BaseSpecies.cc.

57 {
58 #ifdef DEBUG_DESTRUCTOR
59  std::cout << "BaseSpecies::~BaseSpecies() finished" << std::endl;
60 #endif
61 }

Member Function Documentation

Mdouble BaseSpecies::average ( Mdouble  a,
Mdouble  b 
)

defines the average of two variables by the harmonic mean.

Defines the average of two variables by the harmonic mean. This function is used to define default mixed species.

Parameters
[in]a,bThe two variables you want to average
Returns
The harmonic mean of a and b, \(\frac{2}{1/a+1/b}\)

Definition at line 85 of file BaseSpecies.cc.

Referenced by LiquidBridgeWilletSpecies::mix(), ReversibleAdhesiveSpecies::mix(), LinearPlasticViscoelasticNormalSpecies::mix(), FrictionSpecies::mix(), LinearViscoelasticNormalSpecies::mix(), HertzianViscoelasticNormalSpecies::mix(), and SlidingFrictionSpecies::mix().

86 {
87  //the second algorithm seems to have a better accuracy, at least for the case average(2e5,2e5)
88  //return (a + b) != 0.0 ? (2. * (a * b) / (a + b)) : 0;
89  return (a + b) != 0.0 ? (2./(1.0/a+1.0/b)) : 0.0;
90 }
virtual BaseSpecies* BaseSpecies::copy ( ) const
pure virtual

Creates a deep copy of the object from which it is called.

Creates a deep copy of the Species, or MixedSpecies from which it is called. As this depends on the template parameters of Species, the definition of this function is in the Species class. It is defined as a virtual function here to allow the function to be called from a BaseSpecies pointer (which is the kind of pointer used for MixedSpecies).

To create a copy of a MixedSpecies, use

BaseSpecies* mixedSpecies->copy();

To create a copy of a Species, use

ParticleSpecies* species->copy();

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, and ParticleSpecies.

Referenced by SpeciesHandler::operator=(), and SpeciesHandler::SpeciesHandler().

SpeciesHandler * BaseSpecies::getHandler ( ) const

Returns the pointer to the handler to which this species belongs.

Returns
the pointer to the handler to which this species belongs.

Definition at line 74 of file BaseSpecies.cc.

References handler_.

Referenced by ParticleSpecies::getMassFromRadius(), ParticleSpecies::setDensity(), BaseWall::setSpecies(), and BaseParticle::setSpecies().

75 {
76  return handler_;
77 }
SpeciesHandler * handler_
A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set whe...
Definition: BaseSpecies.h:134
virtual Mdouble BaseSpecies::getInteractionDistance ( ) const
pure virtual

returns the largest separation distance at which adhesive short-range forces can occur.

returns the largest separation distance (negative overlap) at which (adhesive) short-range forces can occur (needed for contact detection). Defined in each of the AdhesiveForceSpecies It is defined as a virtual function here to allow the function to be called from a BaseSpecies pointer (which is the kind of pointer used for MixedSpecies).

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, LiquidBridgeWilletSpecies, ReversibleAdhesiveSpecies, and EmptyAdhesiveSpecies.

Referenced by BaseParticle::getInteractionRadius(), and BaseParticle::getWallInteractionRadius().

virtual BaseInteraction* BaseSpecies::getNewInteraction ( BaseInteractable P,
BaseInteractable I,
Mdouble  timeStamp 
)
pure virtual

returns new Interaction object.

As each Species has its own Interaction type, getNewInteraction can be used to access the right type of Interaction It is defined as a virtual function here to allow the function to be called from a BaseSpecies pointer (which is the kind of pointer used for MixedSpecies).

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Referenced by InteractionHandler::getInteraction().

virtual bool BaseSpecies::getUseAngularDOFs ( ) const
pure virtual

Returns true if torques (i.e. angular degrees of freedom) have to be calculated.

returns true if torques have to be calculated. This is currently only true if a tangential force is applied, but can be true for non-spherical objects even if no tangential force is applied . Defined in FrictionForceSpecies. It is defined as a virtual function here to allow the function to be called from a BaseSpecies pointer (which is the kind of pointer used for MixedSpecies).

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, SlidingFrictionSpecies, EmptyFrictionSpecies, and FrictionSpecies.

Referenced by SpeciesHandler::useAngularDOFs().

virtual void BaseSpecies::mixAll ( BaseSpecies *const  S,
BaseSpecies *const  T 
)
pure virtual

creates default values for mixed species

returns the largest separation distance (negative overlap) at which (adhesive) short-range forces can occur (needed for contact detection). Defined in each of the AdhesiveForceSpecies It is defined as a virtual function here to allow the function to be called from a BaseSpecies pointer (which is the kind of pointer used for MixedSpecies).

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

void BaseSpecies::setHandler ( SpeciesHandler handler)

Sets the pointer to the handler to which this species belongs.

Parameters
[in]thepointer to the handler to which this species belongs.

Definition at line 66 of file BaseSpecies.cc.

References handler_.

Referenced by SpeciesHandler::addObject().

67 {
68  handler_ = handler;
69 }
SpeciesHandler * handler_
A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set whe...
Definition: BaseSpecies.h:134

Member Data Documentation

SpeciesHandler* BaseSpecies::handler_
private

A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set when SpeciesHandler::addObject() is called.

Definition at line 134 of file BaseSpecies.h.

Referenced by BaseSpecies(), getHandler(), and setHandler().


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