MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > Class Template Referencefinal

Contains contact force properties for contacts between particles with two different species. More...

#include <MixedSpecies.h>

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

Public Member Functions

 MixedSpecies ()
 The default constructor. More...
 
 MixedSpecies (const MixedSpecies &s)
 The default copy constructor. More...
 
 MixedSpecies (const Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > &s)
 Creates a mixed species with the same force properties as a Species. More...
 
virtual ~MixedSpecies ()
 The default destructor. More...
 
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * copy () const final
 Creates a deep copy of the MixedSpecies from which it is called. More...
 
void copyInto (BaseSpecies *bs) const final
 Copies the content of this into the species bs, if they are of the same type. More...
 
void read (std::istream &is) final
 Reads the species properties from an input stream. More...
 
void write (std::ostream &os) const final
 Writes the MixedSpecies properties to an output stream. More...
 
std::string getName () const final
 Returns the name of the MixedSpecies as it is used in the restart file. More...
 
BaseInteractiongetNewInteraction (BaseInteractable *const P, BaseInteractable *const I, unsigned timeStamp) const final
 When a contact between two particles is determined, an Interaction object is created, as the type of Interaction depends on the MixedSpecies type. More...
 
BaseInteractiongetEmptyInteraction () const final
 
void deleteEmptyInteraction (BaseInteraction *interaction) const final
 
bool getUseAngularDOFs () const final
 Returns true if torques have to be calculated. More...
 
void mixAll (BaseSpecies *const S, BaseSpecies *const T) final
 sets the MixedSpecies properties by mixing the properties of
two particle species More...
 
- Public Member Functions inherited from BaseSpecies
 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...
 
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 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 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
 
- Public Member Functions inherited from EmptyFrictionSpecies
 EmptyFrictionSpecies ()
 The default constructor. More...
 
 EmptyFrictionSpecies (const EmptyFrictionSpecies &s UNUSED)
 The default copy constructor. More...
 
 ~EmptyFrictionSpecies ()
 The default destructor. More...
 
void read (std::istream &is)
 Reads the species properties from an input stream. More...
 
void write (std::ostream &os) const
 Writes the species properties to an output stream. More...
 
std::string getBaseName () const
 Used in Species::getName to obtain a unique name for each Species. More...
 
void mix (EmptyFrictionSpecies *S, EmptyFrictionSpecies *T)
 creates default values for mixed species More...
 
- Public Member Functions inherited from BaseForce
BaseSpeciesgetBaseSpecies () const
 
void setBaseSpecies (BaseSpecies *baseSpecies)
 
- Public Member Functions inherited from EmptyAdhesiveSpecies
 EmptyAdhesiveSpecies ()
 The default constructor. More...
 
 EmptyAdhesiveSpecies (const EmptyAdhesiveSpecies &s UNUSED)
 The default copy constructor. More...
 
 ~EmptyAdhesiveSpecies ()
 The default destructor. More...
 
void read (std::istream &is)
 Reads the species properties from an input stream. More...
 
void write (std::ostream &os) const
 Writes the species properties to an output stream. More...
 
std::string getBaseName () const
 Used in Species::getName to obtain a unique name for each Species. More...
 
void mix (EmptyAdhesiveSpecies *S, EmptyAdhesiveSpecies *T)
 creates default values for mixed species More...
 

Additional Inherited Members

- Public Types inherited from EmptyFrictionSpecies
typedef EmptyFrictionInteraction InteractionType
 The correct Interaction type for this FrictionForceSpecies. More...
 
- Public Types inherited from EmptyAdhesiveSpecies
typedef EmptyAdhesiveInteraction InteractionType
 The correct Interaction type for this AdhesiveForceSpecies. More...
 
- Static Public Member Functions inherited from BaseSpecies
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 Attributes inherited from BaseSpecies
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...
 

Detailed Description

template<class NormalForceSpecies, class FrictionForceSpecies = EmptyFrictionSpecies, class AdhesiveForceSpecies = EmptyAdhesiveSpecies>
class MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >

Contains contact force properties for contacts between particles with two different species.

See Species for details.

Constructor & Destructor Documentation

◆ MixedSpecies() [1/3]

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies

The default constructor.

104 {
105  logger(DEBUG, "MixedSpecies::MixedSpecies() finished");
106 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive.
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
Defines a contact force orthogonal to the contact normal.
Defines a contact force parallel to the contact normal.

References DEBUG, and logger.

◆ MixedSpecies() [2/3]

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies ( const MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > &  s)

The default copy constructor.

111 {
112  normalForce_ = this;
113  frictionForce_ = this;
114  adhesiveForce_ = this;
118  logger(DEBUG, "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished");
119 }
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 BaseSpecies::adhesiveForce_, DEBUG, BaseSpecies::frictionForce_, logger, BaseSpecies::normalForce_, and BaseForce::setBaseSpecies().

◆ MixedSpecies() [3/3]

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies ( const Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > &  s)

Creates a mixed species with the same force properties as a Species.

125 {
126  normalForce_ = this;
127  frictionForce_ = this;
128  adhesiveForce_ = this;
132  logger(DEBUG, "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished");
133 }

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

◆ ~MixedSpecies()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::~MixedSpecies
virtual

The default destructor.

137 {
138  logger(DEBUG, "MixedSpecies::~MixedSpecies() finished");
139 }

References DEBUG, and logger.

Member Function Documentation

◆ copy()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::copy
finalvirtual

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

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

Implements BaseSpecies.

146 {
147  return new MixedSpecies(*this);
148 }
MixedSpecies()
The default constructor.
Definition: MixedSpecies.h:102

Referenced by SpeciesHandler::readAndAddObject().

◆ copyInto()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::copyInto ( BaseSpecies bs) const
finalvirtual

Copies the content of this into the species bs, if they are of the same type.

Useful for polymorphism: speciesHandler.getObject(i)->copyInto(bs); creates a deep copy (i.e. also copies properties of the derived species), whereas bs = speciesHandler.getObject(i); would only create a shallow copy.

Implements BaseSpecies.

160 {
161  if (bs == nullptr)
162  {
163  logger(WARN, "Error in %::copyInto: cannot copy into a nullptr");
164  return;
165  }
167  if (s == nullptr)
168  {
169  logger(WARN, "Error in %::copyInto: copying of species failed", getName());
170  return;
171  }
172  *s = *this;
173 }
@ WARN
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:43
std::string getName() const final
Returns the name of the MixedSpecies as it is used in the restart file.
Definition: MixedSpecies.h:231

References getName(), logger, and WARN.

◆ deleteEmptyInteraction()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::deleteEmptyInteraction ( BaseInteraction interaction) const
finalvirtual

Implements BaseSpecies.

265 {
268  delete interactionDestroyer;
269 }
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:116

◆ getEmptyInteraction()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
BaseInteraction * MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getEmptyInteraction
finalvirtual

◆ getName()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
std::string MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getName
finalvirtual

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

Returns the name of the MixedSpecies 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.

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

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

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

will output "LinearViscoelasticMixedSpecies".

Returns
The name of the MixedSpecies.

Implements BaseObject.

232 {
233  return NormalForceSpecies::getBaseName()
234  + FrictionForceSpecies::getBaseName()
235  + AdhesiveForceSpecies::getBaseName() + "MixedSpecies";
236 }

◆ getNewInteraction()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
BaseInteraction * MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getNewInteraction ( BaseInteractable *const  P,
BaseInteractable *const  I,
unsigned  timeStamp 
) const
finalvirtual

When a contact between two particles is determined, an Interaction object is created, as the type of Interaction depends on the MixedSpecies 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.

249 {
250  // JMFT: memory is allocated here, so it will need to be freed later
252  P, I, timeStamp);
253 }
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73

References Global_Physical_Variables::P.

◆ getUseAngularDOFs()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
bool MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getUseAngularDOFs
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.

279 {
280  return FrictionForceSpecies::getUseAngularDOFs();
281 }

◆ mixAll()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::mixAll ( BaseSpecies *const S  ,
BaseSpecies *const T   
)
finalvirtual

sets the MixedSpecies properties by mixing the properties of
two particle species

Uses the harmonic mean for most properties. Calls the mix function for each of the force species from which MixedSpecies is derived.

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

Implements BaseSpecies.

292 {
293  logger.assert_always(T!= nullptr && S!= nullptr,"Arguments of mixAll cannot be null pointers");
294 
295  logger.assert_always(S->getNormalForce()->getConstantRestitution() == T->getNormalForce()->getConstantRestitution(), "mixing two LinearPlasticViscoelasticNormalSpecies, but only one has constantRestitution");
296  NormalForceSpecies::setConstantRestitution(S->getNormalForce()->getConstantRestitution());
297 
298  const auto TN = dynamic_cast<NormalForceSpecies*> (T);
299  const auto TF = dynamic_cast<FrictionForceSpecies*> (T);
300  const auto TA = dynamic_cast<AdhesiveForceSpecies*> (T);
301  logger.assert_always(TN!= nullptr && TF!= nullptr && TA!= nullptr,
302  "Cannot mix two species of different type (% and %)",S->getName(),T->getName());
303 
304  const auto SN = dynamic_cast<NormalForceSpecies*> (S);
305  const auto SF = dynamic_cast<FrictionForceSpecies*> (S);
306  const auto SA = dynamic_cast<AdhesiveForceSpecies*> (S);
307  logger.assert_always(SN!= nullptr && SF!= nullptr && SA!= nullptr,
308  "Cannot mix two species of different type (% and %)",S->getName(),T->getName());
309 
310  NormalForceSpecies::mix(SN,TN);
311  FrictionForceSpecies::mix(SF,TF);
312  AdhesiveForceSpecies::mix(SA,TA);
313 }

References BaseNormalForce::getConstantRestitution(), BaseObject::getName(), BaseSpecies::getNormalForce(), and logger.

Referenced by main().

◆ read()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read ( std::istream &  is)
finalvirtual

Reads the species properties from an input stream.

Called by SpeciesHandler::readAndAddObject

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

Reimplemented from BaseSpecies.

202 {
203  //note: name is already read by SpeciesHandler::readAndAddObject
204  std::string dummy;
205  unsigned int id, index;
206  is >> dummy >> id;
207  is >> dummy >> index;
208  BaseObject::setId(id);
209  BaseObject::setIndex(index);
210  BaseSpecies::read(is);
211  NormalForceSpecies::read(is);
212  FrictionForceSpecies::read(is);
213  AdhesiveForceSpecies::read(is);
214 }
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:64
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:72
void read(std::istream &is) override
Definition: BaseSpecies.cc:140

References BaseSpecies::read(), BaseObject::setId(), and BaseObject::setIndex().

◆ write()

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::write ( std::ostream &  os) const
finalvirtual

Writes the MixedSpecies properties to an output stream.

It prints human readable MixedSpecies 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 BaseSpecies.

185 {
186  os << getName();
187  os << " idA " << BaseObject::getId();
188  os << " idB " << BaseObject::getIndex();
189  BaseSpecies::write(os);
190  NormalForceSpecies::write(os);
191  FrictionForceSpecies::write(os);
192  AdhesiveForceSpecies::write(os);
193 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
void write(std::ostream &os) const override
Sets the boolean constantRestitution_.
Definition: BaseSpecies.cc:131

References BaseObject::getId(), BaseObject::getIndex(), getName(), and BaseSpecies::write().


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