MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > Class Template Reference

Contains material and contact force properties. More...

#include <Interaction.h>

+ Inheritance diagram for Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >:

Public Types

typedef MixedSpecies
< NormalForceSpecies,
FrictionForceSpecies,
AdhesiveForceSpecies
MixedSpeciesType
 The correct MixedSpecies type for this Species. More...
 
typedef Interaction< typename
NormalForceSpecies::InteractionType,
typename
FrictionForceSpecies::InteractionType,
typename
AdhesiveForceSpecies::InteractionType > 
InteractionType
 
- Public Types inherited from ParticleSpecies
typedef BaseInteraction InteractionType
 

Public Member Functions

 Species ()
 The default constructor. More...
 
 Species (const Species &s)
 The default copy constructor. More...
 
virtual ~Species ()
 The default destructor. More...
 
Species< NormalForceSpecies,
FrictionForceSpecies,
AdhesiveForceSpecies > * 
copy () const final
 Creates a deep copy of the Species from which it is called. More...
 
BaseSpeciescopyMixed () const final
 Creates a new MixedSpecies with the same force properties as the Species from which it is called. More...
 
void read (std::istream &is) final
 Called by SpeciesHandler::readObject. More...
 
void write (std::ostream &os) const final
 Writes the Species properties to an output stream. More...
 
std::string getName () const final
 Returns the name of the Species as it is used in the restart file. More...
 
BaseInteractiongetNewInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp) const final
 When a contact between two particles is determined, an Interaction object is created, as the type of Interaction depends on the Species type. More...
 
bool getUseAngularDOFs () const final
 Returns true if torques have to be calculated. More...
 
void mixAll (BaseSpecies *const S, BaseSpecies *const T)
 This function should not be called. More...
 
Mdouble getInteractionDistance () const final
 Returns the particle distance below which adhesive forces can occur (needed for contact detection) More...
 
- Public Member Functions inherited from ParticleSpecies
 ParticleSpecies ()
 The default constructor. More...
 
 ParticleSpecies (const ParticleSpecies &p)
 The default copy constructor. More...
 
virtual ~ParticleSpecies ()
 The default destructor. More...
 
std::string getBaseName () const
 Used in Species::getName to obtain a unique name for each Species. More...
 
void setDensity (Mdouble density)
 Allows density_ to be changed. More...
 
Mdouble getMassFromRadius (const Mdouble radius) const
 
Mdouble getVolumeFromRadius (const Mdouble radius) const
 
Mdouble getDensity () const
 Allows density_ to be accessed. More...
 
void computeMass (BaseParticle *p) const
 Compute Particle mass function, which required a reference to the Species vector. It computes the Particles mass, Inertia and the inverses. More...
 
- Public Member Functions inherited from BaseSpecies
 BaseSpecies ()
 The default constructor. More...
 
 BaseSpecies (const BaseSpecies &p)
 The copy constructor. More...
 
virtual ~BaseSpecies ()
 The default destructor. 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...
 
- 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...
 

Detailed Description

template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
class Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >

Contains material and contact force properties.

The species class contains both material and contact force properties. 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, four kinds of Species are created:

  • ParticleSpecies: Contains material properties like density.
  • NormalForceSpecies: Describes the normal contact force, therefore contains properties such as stiffness and dissipation.
  • FrictionForceSpecies: Describes the tangential contact force, therefore contains properties such as SlidingFrictionCoefficient and SlidingDissipation.
  • AdhesiveForceSpecies: Describes the short-range normal contact force, which are typically adhesive. Therefore, it contains properties such as interactionDistance and adhesiveStiffness. A full Species object is then derived by inheriting from all of the above.
    dot_inline_dotgraph_2.png

There is only one ParticleSpecies; the three force species can be added using templates. E.g. to create a species with linear elastic-dissipative normal forces, sliding friction forces, and linear reversible short-range adhesion forces, use

Species<LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, LinearReversibleAdhesiveSpecies> species;

EmptyFrictionSpecies and EmptyAdhesiveSpecies are the default template parameters, therefore they don't have to be explicitly named. A species with only linear elastic-dissipative normal forces and sliding friction tangential forces is created using

Species<LinearViscoelasticNormalSpecies, SlidingFrictionSpecies> species;

Also, to avoid that the user has to use templates, many combination of forces are predefined as a typedef, with the names of the force laws concatenated, e.g.

typedef Species<LinearViscoelasticNormalSpecies, SlidingFrictionSpecies> LinearViscoelasticSlidingFrictionSpecies;

Therefore to create such a Species, one has to type

LinearViscoelasticSlidingFrictionSpecies species;

If your code contains multiple Species, then MixedSpecies have to be defined, which contain the description of the forces acting between two species (it does not need a ParticleSpecies, since it is never used to assign mass to an object). Note, we assume that all Species have to be of the same type when multiple Species are used.

dot_inline_dotgraph_3.png

Since these MixedSpecies don't require a set of particle properties (such as density), they are created without a ParticleSpecies. The MixedSpecies is predefined as a typedef inside the Species definition, and can be accessed using

LinearViscoelasticSlidingFrictionSpecies::MixedSpeciesType mixedSpecies;

When a contact between two particles is determined, an Interaction object is created by Species::getNewInteraction, as the type of Interaction depends on the Species type. See Interaction for details.

Definition at line 35 of file Interaction.h.

Member Typedef Documentation

template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
typedef Interaction<typename NormalForceSpecies::InteractionType, typename FrictionForceSpecies::InteractionType, typename AdhesiveForceSpecies::InteractionType > Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::InteractionType

Definition at line 139 of file Species.h.

template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
typedef MixedSpecies<NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies> Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpeciesType

The correct MixedSpecies type for this Species.

The mixed species between two objects of type

Species<NormalForceSpecies,FrictionForceSpecies,AdhesiveForceSpecies>

is

MixedSpecies<NormalForceSpecies,FrictionForceSpecies,AdhesiveForceSpecies>

To access this MixedSpecies type, you can use this typedef.

Definition at line 138 of file Species.h.

Constructor & Destructor Documentation

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::Species ( )

The default constructor.

Definition at line 191 of file Species.h.

193 {
194 #ifdef DEBUG_CONSTRUCTOR
195  std::cout << "Species::Species() finished" << std::endl;
196 #endif
197 }
Defines a contact force orthogonal to the contact normal.
Defines a contact force parallel to the contact normal.
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive...
ParticleSpecies()
The default constructor.
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::Species ( const Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > &  s)

The default copy constructor.

Parameters
[in]sthe species that is copied

Definition at line 203 of file Species.h.

205 {
206 #ifdef DEBUG_CONSTRUCTOR
207  std::cout << "Species::Species(const Species &p) finished" << std::endl;
208 #endif
209 }
Defines a contact force orthogonal to the contact normal.
Defines a contact force parallel to the contact normal.
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive...
ParticleSpecies()
The default constructor.
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::~Species ( )
virtual

The default destructor.

Definition at line 212 of file Species.h.

213 {
214 #ifdef DEBUG_DESTRUCTOR
215  std::cout << "Species::~Species() finished" << std::endl;
216 #endif
217 }

Member Function Documentation

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::copy ( ) const
finalvirtual

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

Creates a deep copy of the Species. As this depends on the template parameters of Species, the definition of this function is in the Species class.

To create a copy of a Species, use

species->copy();

Implements ParticleSpecies.

Definition at line 228 of file Species.h.

229 {
230  return new Species(*this);
231 }
Species()
The default constructor.
Definition: Species.h:191
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
BaseSpecies * Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::copyMixed ( ) const
finalvirtual

Creates a new MixedSpecies with the same force properties as the Species from which it is called.

Species copy method. It calls to copy constructor of this Species, useful for polymorphism.

Implements ParticleSpecies.

Definition at line 236 of file Species.h.

237 {
239 }
Contains contact force properties for contacts between particles with two different species...
Definition: MixedSpecies.h:40
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
Mdouble Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getInteractionDistance ( ) const
finalvirtual

Returns the particle distance below which adhesive forces can occur (needed for contact detection)

Returns
the maximum separation distance below which adhesive forces can occur (needed for contact detection)

Implements BaseSpecies.

Definition at line 333 of file Species.h.

334 {
335  return AdhesiveForceSpecies::getInteractionDistance();
336 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
std::string Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getName ( ) const
finalvirtual

Returns the name of the Species as it is used in the restart file.

Returns the name of the Species as it is used in the restart file. The name of the species is a concatenation of the names of the three force components, e.g.

Species<LinearViscoelasticNormalSpecies,SlidingFrictionSpecies,ReversibleAdhesiveSpecies> species; std::cout << species.getName();

will output "LinearViscoelasticSlidingFrictionReversibleAdhesiveSpecies". The EmptyFrictionSpecies and the EmptyAdhesiveSpecies return empty strings, such that

Species<LinearViscoelasticNormalSpecies> species; std::cout << species.getName();

will output "LinearViscoelasticSpecies".

Returns
The name of the Species.

Implements BaseObject.

Definition at line 284 of file Species.h.

285 {
286  return NormalForceSpecies::getBaseName()
287  + FrictionForceSpecies::getBaseName()
288  + AdhesiveForceSpecies::getBaseName() + "Species";
289 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
BaseInteraction * Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getNewInteraction ( BaseInteractable P,
BaseInteractable I,
Mdouble  timeStamp 
) const
finalvirtual

When a contact between two particles is determined, an Interaction object is created, as the type of Interaction depends on the Species type.

The input parameters of this function are directly passed into the constructor for the new interaction. See Interaction for details.

Parameters
[in]Pfirst of the two objects that interact
[in]Isecond of the two objects that interact
[in]timeStampcurrent value of DPMBase::time_
Returns
pointer to the newly created Interaction.

Implements BaseSpecies.

Definition at line 300 of file Species.h.

301 {
302  return new InteractionType(P, I, timeStamp);
303 }
Interaction< typename NormalForceSpecies::InteractionType, typename FrictionForceSpecies::InteractionType, typename AdhesiveForceSpecies::InteractionType > InteractionType
Definition: Species.h:139
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
bool Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getUseAngularDOFs ( ) const
finalvirtual

Returns true if torques have to be calculated.

Returns true for any FrictionForceSpecies except EmptyFrictionSpecies, because for spherical particles, torques are only caused by tangential forces. See SpeciesHandler::useAngularDOFs for more details

Returns
true iff torques have to be calculated

Implements BaseSpecies.

Definition at line 312 of file Species.h.

313 {
314  return FrictionForceSpecies::getUseAngularDOFs();
315 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::mixAll ( BaseSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > *const S  UNUSED,
BaseSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > *const T  UNUSED 
)
virtual

This function should not be called.

This function should not be called as the mix of two Species results in a MixedSpecies, not a Species. However, I don't know how to avoid creating this function, as BaseSpecies pointers are used for the MixedSpecies, so BaseSpecies must have this function defined.

Parameters
[in]Sthe first of the two species whose properties are mixed to create the new species
[in]Tthe second of the two species whose properties are mixed to create the new species

Implements BaseSpecies.

Definition at line 326 of file Species.h.

References ERROR, and logger.

327 {
328  logger(ERROR, "%::mix() This function should not be called", getName());
329 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::string getName() const final
Returns the name of the Species as it is used in the restart file.
Definition: Species.h:284
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read ( std::istream &  is)
finalvirtual

Called by SpeciesHandler::readObject.

Parameters
[in]isinput stream (typically the restart file)

Reimplemented from ParticleSpecies.

Definition at line 261 of file Species.h.

References ParticleSpecies::read().

262 {
264  NormalForceSpecies::read(is);
265  FrictionForceSpecies::read(is);
266  AdhesiveForceSpecies::read(is);
267 }
void read(std::istream &is)
Reads the species properties from an input stream.
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::write ( std::ostream &  os) const
finalvirtual

Writes the Species properties to an output stream.

It prints human readable Species information to the output stream, typically to Files::restartFile::fstream_ The basic species information is written in ParticleSpecies::write; then the three force types write additional information to the stream.

Parameters
[out]osoutput stream (typically the restart file)

Reimplemented from ParticleSpecies.

Definition at line 249 of file Species.h.

References ParticleSpecies::write().

250 {
252  NormalForceSpecies::write(os);
253  FrictionForceSpecies::write(os);
254  AdhesiveForceSpecies::write(os);
255 }
void write(std::ostream &os) const
Writes the species properties to an output stream.

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