MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 Sets BaseSpecies::interactionDistance_. More...
 
- 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
 

Additional Inherited Members

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

Definition at line 42 of file MixedSpecies.h.

Constructor & Destructor Documentation

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

The default constructor.

Definition at line 102 of file MixedSpecies.h.

References DEBUG, and logger.

104 {
105  logger(DEBUG, "MixedSpecies::MixedSpecies() finished");
106 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
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...
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies ( const MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > &  s)

The default copy constructor.

Definition at line 109 of file MixedSpecies.h.

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

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
BaseNormalForce * normalForce_
A pointer to the normal force parameters This pointer is used by the Interaction's to get a pointer ...
Definition: BaseSpecies.h:173
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Defines a contact force orthogonal to the contact normal.
Defines a contact force parallel to the contact normal.
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters This pointer is used by the Interaction's to get a pointe...
Definition: BaseSpecies.h:187
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive...
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
BaseFrictionForce * frictionForce_
A pointer to the friction force parameters This pointer is used by the Interaction's to get a pointe...
Definition: BaseSpecies.h:180
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.

Definition at line 122 of file MixedSpecies.h.

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

125 {
126  normalForce_ = this;
127  frictionForce_ = this;
128  adhesiveForce_ = this;
132  logger(DEBUG, "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished");
133 }
void setBaseSpecies(BaseSpecies *baseSpecies)
Definition: BaseForce.h:40
BaseNormalForce * normalForce_
A pointer to the normal force parameters This pointer is used by the Interaction's to get a pointer ...
Definition: BaseSpecies.h:173
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Defines a contact force orthogonal to the contact normal.
Defines a contact force parallel to the contact normal.
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters This pointer is used by the Interaction's to get a pointe...
Definition: BaseSpecies.h:187
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive...
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
BaseFrictionForce * frictionForce_
A pointer to the friction force parameters This pointer is used by the Interaction's to get a pointe...
Definition: BaseSpecies.h:180
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::~MixedSpecies ( )
virtual

The default destructor.

Definition at line 136 of file MixedSpecies.h.

References DEBUG, and logger.

137 {
138  logger(DEBUG, "MixedSpecies::~MixedSpecies() finished");
139 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::copy ( ) const
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.

Definition at line 145 of file MixedSpecies.h.

Referenced by SpeciesHandler::readAndAddObject().

146 {
147  return new MixedSpecies(*this);
148 }
MixedSpecies()
The default constructor.
Definition: MixedSpecies.h:102
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.

Definition at line 159 of file MixedSpecies.h.

References getName(), logger, and WARN.

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 % failed", getName(), s->getName());
170  return;
171  }
172  *s = *this;
173 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::string getName() const final
Returns the name of the MixedSpecies as it is used in the restart file.
Definition: MixedSpecies.h:231
Contains contact force properties for contacts between particles with two different species...
Definition: MixedSpecies.h:42
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::deleteEmptyInteraction ( BaseInteraction interaction) const
finalvirtual

Implements BaseSpecies.

Definition at line 263 of file MixedSpecies.h.

265 {
268  delete interactionDestroyer;
269 }
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:115
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
BaseInteraction * MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getEmptyInteraction ( ) const
finalvirtual

Implements BaseSpecies.

Definition at line 257 of file MixedSpecies.h.

258 {
260 }
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:115
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
std::string MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getName ( ) const
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.

Definition at line 231 of file MixedSpecies.h.

232 {
233  return NormalForceSpecies::getBaseName()
234  + FrictionForceSpecies::getBaseName()
235  + AdhesiveForceSpecies::getBaseName() + "MixedSpecies";
236 }
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.

Definition at line 247 of file MixedSpecies.h.

249 {
250  // JMFT: memory is allocated here, so it will need to be freed later
252  P, I, timeStamp);
253 }
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:115
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
bool MixedSpecies< 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 278 of file MixedSpecies.h.

279 {
280  return FrictionForceSpecies::getUseAngularDOFs();
281 }
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.

Definition at line 290 of file MixedSpecies.h.

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

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 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
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...
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.

Definition at line 201 of file MixedSpecies.h.

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

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 read(std::istream &is) override
Definition: BaseSpecies.cc:140
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
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.

Definition at line 184 of file MixedSpecies.h.

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

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
std::string getName() const final
Returns the name of the MixedSpecies as it is used in the restart file.
Definition: MixedSpecies.h:231

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