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...
 
- Public Member Functions inherited from BaseAdhesiveForce
virtual void setInteractionDistance ()
 

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

83 {
84  normalForce_ = this;
85  frictionForce_ = this;
86  adhesiveForce_ = this;
90  logger(DEBUG, "MixedSpecies::MixedSpecies() finished");
91 }
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.
void setBaseSpecies(BaseSpecies *baseSpecies)
Definition: BaseForce.h:21
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters.
Definition: BaseSpecies.h:166
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:17
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
Defines a contact force orthogonal to the contact normal.
Defines a contact force parallel to the contact normal.

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

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

96 {
97  normalForce_ = this;
98  frictionForce_ = this;
99  adhesiveForce_ = this;
103  logger(DEBUG, "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished");
104 }
RealScalar s
Definition: level1_cplx_impl.h:130

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.

110 {
111  normalForce_ = this;
112  frictionForce_ = this;
113  adhesiveForce_ = this;
117  logger(DEBUG, "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished");
118 }

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.

122 {
123  logger(DEBUG, "MixedSpecies::~MixedSpecies() finished");
124 }

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.

131 {
132  return new MixedSpecies(*this);
133 }
MixedSpecies()
The default constructor.
Definition: MixedSpecies.h:81

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.

145 {
146  if (bs == nullptr)
147  {
148  logger(WARN, "Error in %::copyInto: cannot copy into a nullptr");
149  return;
150  }
152  if (s == nullptr)
153  {
154  logger(WARN, "Error in %::copyInto: copying of species failed", getName());
155  return;
156  }
157  *s = *this;
158 }
@ WARN
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:22
std::string getName() const final
Returns the name of the MixedSpecies as it is used in the restart file.
Definition: MixedSpecies.h:218

References getName(), logger, s, and WARN.

◆ deleteEmptyInteraction()

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

Implements BaseSpecies.

252 {
255  delete interactionDestroyer;
256 }
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:95

◆ getEmptyInteraction()

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

219 {
220  return NormalForceSpecies::getBaseName()
221  + FrictionForceSpecies::getBaseName()
222  + AdhesiveForceSpecies::getBaseName() + "MixedSpecies";
223 }

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

236 {
237  // JMFT: memory is allocated here, so it will need to be freed later
239  P, I, timeStamp);
240 }
#define I
Definition: main.h:127
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77

References I, and 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.

266 {
267  return FrictionForceSpecies::getUseAngularDOFs();
268 }

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

279 {
280  logger.assert_always(T!= nullptr && S!= nullptr,"Arguments of mixAll cannot be null pointers");
281 
282  logger.assert_always(S->getNormalForce()->getConstantRestitution() == T->getNormalForce()->getConstantRestitution(), "mixing two LinearPlasticViscoelasticNormalSpecies, but only one has constantRestitution");
283  NormalForceSpecies::setConstantRestitution(S->getNormalForce()->getConstantRestitution());
284 
285  const auto TN = dynamic_cast<NormalForceSpecies*> (T);
286  const auto TF = dynamic_cast<FrictionForceSpecies*> (T);
287  const auto TA = dynamic_cast<AdhesiveForceSpecies*> (T);
288  logger.assert_always(TN!= nullptr && TF!= nullptr && TA!= nullptr,
289  "Cannot mix two species of different type (% and %)",S->getName(),T->getName());
290 
291  const auto SN = dynamic_cast<NormalForceSpecies*> (S);
292  const auto SF = dynamic_cast<FrictionForceSpecies*> (S);
293  const auto SA = dynamic_cast<AdhesiveForceSpecies*> (S);
294  logger.assert_always(SN!= nullptr && SF!= nullptr && SA!= nullptr,
295  "Cannot mix two species of different type (% and %)",S->getName(),T->getName());
296 
297  NormalForceSpecies::mix(SN,TN);
298  FrictionForceSpecies::mix(SF,TF);
299  AdhesiveForceSpecies::mix(SA,TA);
300 }
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11
@ S
Definition: quadtree.h:62

References logger, and oomph::QuadTreeNames::S.

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.

187 {
188  //note: name is already read by SpeciesHandler::readAndAddObject
189  std::string dummy;
190  unsigned int id, index;
191  is >> dummy >> id;
192  is >> dummy >> index;
193  BaseObject::setId(id);
194  BaseObject::setIndex(index);
195  BaseSpecies::read(is);
199  // ensure that interaction distance is recomputed after restarting
200  AdhesiveForceSpecies::setInteractionDistance();
201 }
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:42
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:50
void read(std::istream &is) override
Definition: BaseSpecies.cc:119
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::enable_if_t< PacketLoad, PacketType > read(const TensorMapper &tensorMapper, const StorageIndex &NCIndex, const StorageIndex &CIndex, const StorageIndex &ld)
read, a template function used for loading the data from global memory. This function is used to guar...
Definition: TensorContractionSycl.h:162
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References Eigen::TensorSycl::internal::read(), BaseSpecies::read(), BaseObject::setId(), BaseObject::setIndex(), and oomph::Global_string_for_annotation::string().

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

170 {
171  os << getName();
172  os << " idA " << BaseObject::getId();
173  os << " idB " << BaseObject::getIndex();
174  BaseSpecies::write(os);
178 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:104
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:97
void write(std::ostream &os) const override
Sets the boolean constantRestitution_.
Definition: BaseSpecies.cc:110
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::enable_if_t< dt !=data_source::global_mem, void > write(PacketType &packet_data, DataScalar ptr)
write, a template function used for storing the data to local memory. This function is used to guaran...
Definition: TensorContractionSycl.h:221

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


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