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. More...
 
BaseFrictionForcefrictionForce_
 A pointer to the friction force parameters. More...
 
BaseAdhesiveForceadhesiveForce_
 A pointer to the adhesive force parameters. 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.

18  : BaseObject(), handler_(nullptr), interactionDistance_(0)
19 {
20  logger(DEBUG, "BaseSpecies::BaseSpecies() finished");
21 }
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:174
Mdouble interactionDistance_
Definition: BaseSpecies.h:180

References DEBUG, and logger.

◆ BaseSpecies() [2/3]

BaseSpecies::BaseSpecies ( BaseNormalForce normalForce,
BaseFrictionForce frictionForce_,
BaseAdhesiveForce adhesiveForce 
)
24  : BaseObject(), normalForce_(normalForce), frictionForce_(frictionForce), adhesiveForce_(adhesiveForce),
25  handler_(nullptr), interactionDistance_(0)
26 {
30  logger(DEBUG, "BaseSpecies::BaseSpecies() finished");
31 }
void setBaseSpecies(BaseSpecies *baseSpecies)
Definition: BaseForce.h:21
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters.
Definition: BaseSpecies.h:166
BaseFrictionForce * frictionForce_
A pointer to the friction force parameters.
Definition: BaseSpecies.h:159
BaseNormalForce * normalForce_
A pointer to the normal force parameters.
Definition: BaseSpecies.h:152

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
38  : BaseObject(p), handler_(p.handler_), interactionDistance_(p.interactionDistance_)
39 {
40  logger(DEBUG, "BaseSpecies::BaseSpecies(const BaseSpecies &p) finished");
41 }
float * p
Definition: Tutorial_Map_using.cpp:9

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
44 {
48  //for now, I added a particleHandler.clear(); wallHandler.clear() before speciesHandler.clear() in DPMBase::read()
49 
50 // //if species gets removed, all particles/ walls of this type need to be removed as well
51 // if (getHandler()) {
52 // DPMBase* dpm = getHandler()->getDPMBase();
53 // for (const auto o : dpm->wallHandler) {
54 // if (o->getSpecies()==this) {
55 // dpm->wallHandler.removeObject(o->getIndex());
56 // }
57 // }
58 // for (const auto o : dpm->particleHandler) {
59 // if (o->getSpecies()==this) {
60 // dpm->particleHandler.removeObject(o->getIndex());
61 // }
62 // }
63 // }
64  logger(DEBUG, "BaseSpecies::~BaseSpecies() finished");
65 }

References DEBUG, and logger.

Member Function Documentation

◆ average()

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

Returns the harmonic mean of two variables.

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}\)
90 {
91  //the second algorithm seems to have a better accuracy, at least for the case average(2e5,2e5)
92  //return (a + b) != 0.0 ? (2. * (a * b) / (a + b)) : 0;
93  return (a==0||b==0) ? 0.0 : (2. / (1.0 / a + 1.0 / b));
94 }
Scalar * b
Definition: benchVecAdd.cpp:17
const Scalar * a
Definition: level2_cplx_impl.h:32

References a, and b.

Referenced by averageInf(), BondedSpecies::mix(), ChargedBondedSpecies::mix(), FrictionSpecies::mix(), HertzianSinterNormalSpecies::mix(), JKRAdhesiveSpecies::mix(), LinearPlasticViscoelasticNormalSpecies::mix(), LinearViscoelasticNormalSpecies::mix(), LiquidBridgeBagheriSpecies::mix(), LiquidBridgeClassicalWilletSpecies::mix(), LiquidBridgeWilletSpecies::mix(), LiquidMigrationLSSpecies::mix(), LiquidMigrationWilletSpecies::mix(), LiquidMigrationWilletViscousSpecies::mix(), MeltableNormalSpecies::mix(), MindlinRollingTorsionSpecies::mix(), MindlinSpecies::mix(), ReversibleAdhesiveSpecies::mix(), SinterLinNormalSpecies::mix(), SinterNormalSpecies::mix(), SlidingFrictionSpecies::mix(), SolidifyingLiquidMigrationWilletSpecies::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.

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

100 {
101  if (a == constants::inf || b == constants::inf)
102  return constants::inf;
103  else
104  return average(a, b);
105 }
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:89
const Mdouble inf
Definition: GeneralDefine.h:23

References a, average(), b, 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< LinearViscoelasticNormalSpecies, FrictionSpecies >, 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).

125 {return interactionDistance_;}

References interactionDistance_.

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

120 {
121  //BaseObject::read(is);
122  bool constantRestitution;
123  if (helpers::readOptionalVariable(is, "constantRestitution", constantRestitution)) {
124  normalForce_->setConstantRestitution(constantRestitution);
125  }
126 }
void setConstantRestitution(bool constantRestitution)
Definition: BaseNormalForce.cc:8
bool readOptionalVariable(std::istream &is, const std::string &name, T &variable)
Reads optional variables in the restart file.
Definition: FileIOHelpers.h:68

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.
71 {
72  handler_ = handler;
73 }

References handler_.

Referenced by ParticleSpecies::getMassFromRadius(), main(), regimeForceUnitTest::regimeForceUnitTest(), 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
135  {
136  interactionDistance_ = interactionDistance;
137 
138  SpeciesHandler* handler = getHandler();
139  if (handler == nullptr) return;
140 
141  for (auto mixedSpecies : handler->getMixedObjects()) {
142  if (mixedSpecies == this) {
143  // get the two particlespecies id's
144  unsigned mixedId = mixedSpecies->getIndex();
145  unsigned maxId= 1;
146  unsigned maxMixedId = (maxId * (maxId + 1)) / 2;
147  while (maxMixedId<mixedId) {
148  ++maxId;
149  maxMixedId = (maxId * (maxId + 1)) / 2;
150  }
151  unsigned minId = (mixedId + maxId) - maxMixedId;
152  handler->getObject(minId)->setMaxInteractionDistance(interactionDistance);
153  handler->getObject(maxId)->setMaxInteractionDistance(interactionDistance);
154  //logger(INFO,"setInteractionDistance(%) mixed % handler %",interactionDistance, getIndex(), getHandler());
155  return;
156  }
157  }
158  // if not a mixed species, check it's a species in the speciesHandler
159  if (handler->getSize()>getId() && handler->getObject(getId()) == this) {
160  handler->getObject(getId())->setMaxInteractionDistance(interactionDistance);
161  }
162 
163  //logger(INFO,"setInteractionDistance(%) species % handler %",interactionDistance, getIndex(), getHandler());
164 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:663
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:621
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:104
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:78
void setMaxInteractionDistance(Mdouble interactionDistance=0)
Sets maxInteractionDistance_.
Definition: ParticleSpecies.cc:201
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:15
const std::vector< BaseSpecies * > & getMixedObjects() const
Returns a pointer to the vector of all mixed objects.
Definition: SpeciesHandler.cc:941

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

Referenced by ChargedBondedSpecies::setInteractionDistance(), LiquidBridgeBagheriSpecies::setInteractionDistance(), LiquidBridgeClassicalWilletSpecies::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.

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.

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.

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: