MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > Class Template Reference

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
 Creates a deep copy of the MixedSpecies from which it is called. More...
 
void read (std::istream &is)
 Reads the species properties from an input stream. More...
 
void write (std::ostream &os) const
 Writes the MixedSpecies properties to an output stream. More...
 
std::string getName () const
 Returns the name of the MixedSpecies as it is used in the restart file. More...
 
BaseInteractiongetNewInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp) const
 When a contact between two particles is determined, an Interaction object is created, as the type of Interaction depends on the MixedSpecies type. More...
 
bool getUseAngularDOFs () const
 Returns true if torques have to be calculated. More...
 
void mixAll (BaseSpecies *const S, BaseSpecies *const T)
 sets the MixedSpecies properties by mixing the properties of two particle species More...
 
Mdouble getInteractionDistance () const
 Returns the particle distance below which adhesive forces can occur (needed for contact detection) 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 40 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 92 of file MixedSpecies.h.

94 {
95 #ifdef DEBUG_CONSTRUCTOR
96  std::cout << "MixedSpecies::MixedSpecies() finished" << std::endl;
97 #endif
98 }
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:44
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 >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::MixedSpecies ( const MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > &  s)

The default copy constructor.

Definition at line 101 of file MixedSpecies.h.

103 {
104 #ifdef DEBUG_CONSTRUCTOR
105  std::cout << "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished" << std::endl;
106 #endif
107 }
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:44
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 >
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 110 of file MixedSpecies.h.

112 {
113 #ifdef DEBUG_CONSTRUCTOR
114  std::cout << "MixedSpecies::MixedSpecies(const MixedSpecies &p) finished" << std::endl;
115 #endif
116 }
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:44
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 >
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::~MixedSpecies ( )
virtual

The default destructor.

Definition at line 119 of file MixedSpecies.h.

120 {
121 #ifdef DEBUG_DESTRUCTOR
122  std::cout << "MixedSpecies::~MixedSpecies() finished" << std::endl;
123 #endif
124 }

Member Function Documentation

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

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.

Definition at line 129 of file MixedSpecies.h.

130 {
131  return new MixedSpecies(*this);
132 }
MixedSpecies()
The default constructor.
Definition: MixedSpecies.h:92
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
Mdouble MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getInteractionDistance ( ) const

Returns the particle distance below which adhesive forces can occur (needed for contact detection)

Definition at line 244 of file MixedSpecies.h.

245 {
246  return AdhesiveForceSpecies::getInteractionDistance();
247 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
std::string MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getName ( ) const

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.

Definition at line 188 of file MixedSpecies.h.

189 {
190  return NormalForceSpecies::getBaseName()
191  + FrictionForceSpecies::getBaseName()
192  + AdhesiveForceSpecies::getBaseName() + "MixedSpecies";
193 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
BaseInteraction * MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getNewInteraction ( BaseInteractable P,
BaseInteractable I,
Mdouble  timeStamp 
) const

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.

Definition at line 204 of file MixedSpecies.h.

205 {
207 }
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:107
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
bool MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::getUseAngularDOFs ( ) const

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

Definition at line 216 of file MixedSpecies.h.

217 {
218  return FrictionForceSpecies::getUseAngularDOFs();
219 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::mixAll ( BaseSpecies *const  S,
BaseSpecies *const  T 
)

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

Definition at line 228 of file MixedSpecies.h.

229 {
230  if (dynamic_cast<NormalForceSpecies*> (T) ==NULL||
231  dynamic_cast<FrictionForceSpecies*> (T) ==NULL||
232  dynamic_cast<AdhesiveForceSpecies*> (T) ==NULL) {
233  std::cerr << "Warning: cannot mix two species of different type; the mixed species is an empty species of the same type as the second species instead" << std::endl;
234  return;
235  }
236  NormalForceSpecies::mix(dynamic_cast<NormalForceSpecies*> (S), dynamic_cast<NormalForceSpecies*> (T));
237  FrictionForceSpecies::mix(dynamic_cast<FrictionForceSpecies*> (S), dynamic_cast<FrictionForceSpecies*> (T));
238  AdhesiveForceSpecies::mix(dynamic_cast<AdhesiveForceSpecies*> (S), dynamic_cast<AdhesiveForceSpecies*> (T));
239 }
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read ( std::istream &  is)

Reads the species properties from an input stream.

Called by SpeciesHandler::readObject

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

Definition at line 159 of file MixedSpecies.h.

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

160 {
161  //note: name is already read by SpeciesHandler::readObject
162  std::string dummy;
163  unsigned int id, index;
164  is >> dummy >> id;
165  is >> dummy >> index;
166  BaseObject::setId(id);
167  BaseObject::setIndex(index);
168  NormalForceSpecies::read(is);
169  FrictionForceSpecies::read(is);
170  AdhesiveForceSpecies::read(is);
171 }
void setIndex(const unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:91
void setId(const unsigned int id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:99
template<class NormalForceSpecies , class FrictionForceSpecies , class AdhesiveForceSpecies >
void MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::write ( std::ostream &  os) const

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)

Definition at line 143 of file MixedSpecies.h.

References BaseObject::getId(), and BaseObject::getIndex().

144 {
145  os << getName();
146  os << " idA " << BaseObject::getId();
147  os << " idB " << BaseObject::getIndex();
148  NormalForceSpecies::write(os);
149  FrictionForceSpecies::write(os);
150  AdhesiveForceSpecies::write(os);
151 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.cc:116
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:108
std::string getName() const
Returns the name of the MixedSpecies as it is used in the restart file.
Definition: MixedSpecies.h:188

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