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 (BaseNormalForce *normalForce, BaseFrictionForce *frictionForce_, BaseAdhesiveForce *adhesiveForce)
 
 BaseSpecies (const BaseSpecies &p)
 The copy constructor. More...
 
 ~BaseSpecies ()
 The default destructor. More...
 
virtual BaseSpeciescopy () const =0
 Creates a deep copy of the object from which it is called. More...
 
virtual void copyInto (BaseSpecies *s) const =0
 
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...
 
virtual void mixAll (BaseSpecies *S, BaseSpecies *T)=0
 creates default values for mixed species 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, unsigned timeStamp) const =0
 returns new Interaction object. More...
 
virtual BaseInteractiongetEmptyInteraction () const =0
 
virtual void deleteEmptyInteraction (BaseInteraction *interaction) const =0
 
Mdouble getInteractionDistance () const
 returns the largest separation distance at which adhesive short-range forces can occur. More...
 
BaseNormalForcegetNormalForce () const
 
BaseFrictionForcegetFrictionForce () const
 
BaseAdhesiveForcegetAdhesiveForce () const
 
void setInteractionDistance (Mdouble interactionDistance)
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual std::string getName () const =0
 A purely virtual function. More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Static Public Member Functions

static Mdouble average (Mdouble a, Mdouble b)
 Returns the harmonic mean of two variables. More...
 
static Mdouble averageInf (Mdouble a, Mdouble b)
 Returns the harmonic mean of two variables, returning inf if either is inf. More...
 

Protected Member Functions

void write (std::ostream &os) const override
 Sets the boolean constantRestitution_. More...
 
void read (std::istream &is) override
 

Protected Attributes

BaseNormalForcenormalForce_
 A pointer to the normal force parameters \detail This pointer is used by the Interaction's to get a pointer to the species The pointer is set in the constructors of SPecies and MixedSpecies. More...
 
BaseFrictionForcefrictionForce_
 A pointer to the friction force parameters \detail This pointer is used by the Interaction's to get a pointer to the species The pointer is set in the constructors of SPecies and MixedSpecies. More...
 
BaseAdhesiveForceadhesiveForce_
 A pointer to the adhesive force parameters \detail This pointer is used by the Interaction's to get a pointer to the species The pointer is set in the constructors of SPecies and MixedSpecies. 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...
 
Mdouble interactionDistance_
 

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.

Constructor & Destructor Documentation

◆ BaseSpecies() [1/3]

BaseSpecies::BaseSpecies ( )

The default constructor.

39  : BaseObject(), handler_(nullptr), interactionDistance_(0)
40 {
41  logger(DEBUG, "BaseSpecies::BaseSpecies() finished");
42 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG
BaseObject()=default
Default constructor.
SpeciesHandler * handler_
A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set whe...
Definition: BaseSpecies.h:195
Mdouble interactionDistance_
Definition: BaseSpecies.h:201

References DEBUG, and logger.

◆ BaseSpecies() [2/3]

BaseSpecies::BaseSpecies ( BaseNormalForce normalForce,
BaseFrictionForce frictionForce_,
BaseAdhesiveForce adhesiveForce 
)
45  : BaseObject(), normalForce_(normalForce), frictionForce_(frictionForce), adhesiveForce_(adhesiveForce),
46  handler_(nullptr), interactionDistance_(0)
47 {
51  logger(DEBUG, "BaseSpecies::BaseSpecies() finished");
52 }
void setBaseSpecies(BaseSpecies *baseSpecies)
Definition: BaseForce.h:40
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters \detail This pointer is used by the Interaction's to get a...
Definition: BaseSpecies.h:187
BaseFrictionForce * frictionForce_
A pointer to the friction force parameters \detail This pointer is used by the Interaction's to get a...
Definition: BaseSpecies.h:180
BaseNormalForce * normalForce_
A pointer to the normal force parameters \detail This pointer is used by the Interaction's to get a p...
Definition: BaseSpecies.h:173

References adhesiveForce_, DEBUG, frictionForce_, logger, normalForce_, and BaseForce::setBaseSpecies().

◆ BaseSpecies() [3/3]

BaseSpecies::BaseSpecies ( const BaseSpecies p)

The copy constructor.

Parameters
[in]pthe species that is copied
60 {
61  logger(DEBUG, "BaseSpecies::BaseSpecies(const BaseSpecies &p) finished");
62 }

References DEBUG, and logger.

◆ ~BaseSpecies()

BaseSpecies::~BaseSpecies ( )

The default destructor.

Todo:
the BaseSpecies destructor should delete all particles and wall belonging to that species; however, that will break all codes replacing a species (e.g. Sudeshna and Hao) so we need a proper way to replace a species
65 {
69  //for now, I added a particleHandler.clear(); wallHandler.clear() before speciesHandler.clear() in DPMBase::read()
70 
71 // //if species gets removed, all particles/ walls of this type need to be removed as well
72 // if (getHandler()) {
73 // DPMBase* dpm = getHandler()->getDPMBase();
74 // for (const auto o : dpm->wallHandler) {
75 // if (o->getSpecies()==this) {
76 // dpm->wallHandler.removeObject(o->getIndex());
77 // }
78 // }
79 // for (const auto o : dpm->particleHandler) {
80 // if (o->getSpecies()==this) {
81 // dpm->particleHandler.removeObject(o->getIndex());
82 // }
83 // }
84 // }
85  logger(DEBUG, "BaseSpecies::~BaseSpecies() finished");
86 }

References DEBUG, and logger.

Member Function Documentation

◆ average()

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

Returns the harmonic mean of two variables.

\detail Returns the harmonic mean of two variables. 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}\)
111 {
112  //the second algorithm seems to have a better accuracy, at least for the case average(2e5,2e5)
113  //return (a + b) != 0.0 ? (2. * (a * b) / (a + b)) : 0;
114  return (a==0||b==0) ? 0.0 : (2. / (1.0 / a + 1.0 / b));
115 }

Referenced by averageInf(), BondedSpecies::mix(), ChargedBondedSpecies::mix(), FrictionSpecies::mix(), HertzianSinterNormalSpecies::mix(), LinearPlasticViscoelasticNormalSpecies::mix(), LinearViscoelasticNormalSpecies::mix(), LiquidBridgeWilletSpecies::mix(), LiquidMigrationLSSpecies::mix(), LiquidMigrationWilletSpecies::mix(), MindlinRollingTorsionSpecies::mix(), MindlinSpecies::mix(), ReversibleAdhesiveSpecies::mix(), SinterLinNormalSpecies::mix(), SinterNormalSpecies::mix(), SlidingFrictionSpecies::mix(), and SPHNormalSpecies::mix().

◆ averageInf()

Mdouble BaseSpecies::averageInf ( Mdouble  a,
Mdouble  b 
)
static

Returns the harmonic mean of two variables, returning inf if either is inf.

\detail Returns the harmonic mean of two variables, returning inf if either is inf.

121 {
122  if (a == constants::inf || b == constants::inf)
123  return constants::inf;
124  else
125  return average(a, b);
126 }
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:110
const Mdouble inf
Definition: GeneralDefine.h:44

References average(), and constants::inf.

Referenced by FrictionSpecies::mix().

◆ copy()

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 ParticleSpecies, Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, Species< LinearViscoelasticNormalSpecies >, Species< LinearPlasticViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, and MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

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

◆ copyInto()

◆ deleteEmptyInteraction()

◆ getAdhesiveForce()

◆ getEmptyInteraction()

◆ getFrictionForce()

◆ getHandler()

◆ getInteractionDistance()

Mdouble BaseSpecies::getInteractionDistance ( ) const
inline

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).

146 {return interactionDistance_;}

References interactionDistance_.

Referenced by SpeciesHandler::addObject(), NurbsWall::getDistanceAndNormal(), Screw::getDistanceAndNormal(), IntersectionOfWalls::getDistanceAndNormal(), ChargedBondedInteraction::getElasticEnergy(), BaseParticle::getInteractionDistance(), ParticleParticleInteraction::setupInitialConditions(), ParticleParticleInteractionWithPlasticForces::setupInitialConditions(), and ParticleWallInteraction::setupInitialConditions().

◆ getNewInteraction()

virtual BaseInteraction* BaseSpecies::getNewInteraction ( BaseInteractable P,
BaseInteractable I,
unsigned  timeStamp 
) const
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 >, Species< LinearViscoelasticNormalSpecies >, Species< LinearPlasticViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, and MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Referenced by InteractionHandler::addInteraction(), and InteractionHandler::getInteraction().

◆ getNormalForce()

◆ getUseAngularDOFs()

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 >, Species< LinearViscoelasticNormalSpecies >, Species< LinearPlasticViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, and MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Referenced by SpeciesHandler::useAngularDOFs().

◆ mixAll()

virtual void BaseSpecies::mixAll ( BaseSpecies S,
BaseSpecies 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 >, Species< LinearViscoelasticNormalSpecies >, Species< LinearPlasticViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, and MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

◆ read()

void BaseSpecies::read ( std::istream &  is)
overrideprotectedvirtual
Parameters
[in]isinput stream (typically the restart file)

Implements BaseObject.

Reimplemented in ParticleSpecies, Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, Species< LinearViscoelasticNormalSpecies >, Species< LinearPlasticViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies >, and MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

141 {
142  //BaseObject::read(is);
143  bool constantRestitution;
144  if (helpers::readOptionalVariable(is, "constantRestitution", constantRestitution)) {
145  normalForce_->setConstantRestitution(constantRestitution);
146  }
147 }
void setConstantRestitution(bool constantRestitution)
Definition: BaseNormalForce.cc:29
bool readOptionalVariable(std::istream &is, const std::string &name, T &variable)
Reads optional variables in the restart file.
Definition: FileIOHelpers.h:82

References normalForce_, helpers::readOptionalVariable(), and BaseNormalForce::setConstantRestitution().

Referenced by MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read(), and ParticleSpecies::read().

◆ setHandler()

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.
92 {
93  handler_ = handler;
94 }

References handler_.

Referenced by SpeciesHandler::addObject(), NautaMixer::addSpeciesAndSetTimeStepAndSaveCount(), ParticleSpecies::getMassFromRadius(), main(), regimeForceUnitTest::regimeForceUnitTest(), SinterPair::SinterPair(), and viscoElasticUnitTest::viscoElasticUnitTest().

◆ setInteractionDistance()

void BaseSpecies::setInteractionDistance ( Mdouble  interactionDistance)

Sets BaseSpecies::interactionDistance_. This function should not be called by the user, only by functions in classes derived from BaseSpecies (in particular, the adhesive-force species). This function gets called every time a variable is set on which the interaction distance depends. See for example LiquidBridgeWilletSpecies::setLiquidBridgeVolume.

Parameters
interactionDistance
156  {
157  interactionDistance_ = interactionDistance;
158 
159  SpeciesHandler* handler = getHandler();
160  if (handler == nullptr) return;
161 
162  for (auto mixedSpecies : handler->getMixedObjects()) {
163  if (mixedSpecies == this) {
164  // get the two particlespecies id's
165  unsigned mixedId = mixedSpecies->getIndex();
166  unsigned maxId= 1;
167  unsigned maxMixedId = (maxId * (maxId + 1)) / 2;
168  while (maxMixedId<mixedId) {
169  ++maxId;
170  maxMixedId = (maxId * (maxId + 1)) / 2;
171  }
172  unsigned minId = (mixedId + maxId) - maxMixedId;
173  handler->getObject(minId)->setMaxInteractionDistance(interactionDistance);
174  handler->getObject(maxId)->setMaxInteractionDistance(interactionDistance);
175  //logger(INFO,"setInteractionDistance(%) mixed % handler %",interactionDistance, getIndex(), getHandler());
176  return;
177  }
178  }
179  handler->getObject(getId())->setMaxInteractionDistance(interactionDistance);
180 
181  //logger(INFO,"setInteractionDistance(%) species % handler %",interactionDistance, getIndex(), getHandler());
182 }
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
void setMaxInteractionDistance(Mdouble interactionDistance=0)
Sets maxInteractionDistance_.
Definition: ParticleSpecies.cc:221
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:37
const std::vector< BaseSpecies * > & getMixedObjects() const
Returns a pointer to the vector of all mixed objects.
Definition: SpeciesHandler.cc:823

References getHandler(), BaseObject::getId(), SpeciesHandler::getMixedObjects(), BaseHandler< T >::getObject(), interactionDistance_, and ParticleSpecies::setMaxInteractionDistance().

Referenced by ChargedBondedSpecies::setInteractionDistance(), LiquidBridgeWilletSpecies::setInteractionDistance(), LiquidMigrationLSSpecies::setInteractionDistance(), LiquidMigrationWilletSpecies::setInteractionDistance(), and ReversibleAdhesiveSpecies::setInteractionDistance().

◆ write()

Member Data Documentation

◆ adhesiveForce_

BaseAdhesiveForce* BaseSpecies::adhesiveForce_
protected

A pointer to the adhesive force parameters \detail This pointer is used by the Interaction's to get a pointer to the species The pointer is set in the constructors of SPecies and MixedSpecies.

Referenced by BaseSpecies(), getAdhesiveForce(), MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies(), and Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::Species().

◆ frictionForce_

BaseFrictionForce* BaseSpecies::frictionForce_
protected

A pointer to the friction force parameters \detail This pointer is used by the Interaction's to get a pointer to the species The pointer is set in the constructors of SPecies and MixedSpecies.

Referenced by BaseSpecies(), getFrictionForce(), MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies(), and Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::Species().

◆ handler_

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.

Referenced by getHandler(), and setHandler().

◆ interactionDistance_

Mdouble BaseSpecies::interactionDistance_
private

Returns the distance between particles of this species below which adhesive forces can occur (needed for contact detection) set by the adhesive species

Referenced by getInteractionDistance(), and setInteractionDistance().

◆ normalForce_

BaseNormalForce* BaseSpecies::normalForce_
protected

A pointer to the normal force parameters \detail This pointer is used by the Interaction's to get a pointer to the species The pointer is set in the constructors of SPecies and MixedSpecies.

Referenced by BaseSpecies(), getNormalForce(), MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies(), read(), Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::Species(), and write().


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