MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParticleSpecies Class Referenceabstract

#include <ParticleSpecies.h>

+ Inheritance diagram for ParticleSpecies:

Public Types

typedef BaseInteraction InteractionType
 
typedef BaseSpecies MixedSpeciesType
 

Public Member Functions

 ParticleSpecies ()
 The default constructor. More...
 
 ParticleSpecies (const ParticleSpecies &p)
 The default copy constructor. More...
 
 ParticleSpecies (BaseNormalForce *normalForce, BaseFrictionForce *frictionForce, BaseAdhesiveForce *adhesiveForce)
 
 ~ParticleSpecies ()
 The default destructor. More...
 
ParticleSpeciescopy () const override=0
 Creates a deep copy of the object from which it is called. More...
 
virtual BaseSpeciescopyMixed () const =0
 Creates a new MixedSpecies with the same force properties as the Species from which it is called. See Species::copyMixed for details. More...
 
void read (std::istream &is) override
 Reads the species properties from an input stream. More...
 
void write (std::ostream &os) const override
 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 setDensity (Mdouble density)
 Allows density_ to be changed. More...
 
Mdouble getMassFromRadius (Mdouble radius) const
 
Mdouble getMassFromRadius (const Mdouble radius, SpeciesHandler &speciesHandler)
 
Mdouble getVolumeFromRadius (Mdouble radius) const
 
Mdouble getDensity () const
 Allows density_ to be accessed. More...
 
void computeMass (BaseParticle *p) const
 Compute Particle mass function, which required a reference to the Species vector. It computes the Particles mass, Inertia and the inverses. More...
 
void setTemperatureDependentDensity (const std::function< double(double)> &temperatureDependentDensity)
 
const std::function< double(double)> & getTemperatureDependentDensity () const
 
Mdouble getSmallestParticleMass () const
 Computes mass of the lightest particle (by mass) belonging to this species. This computation calls getLightestInverseParticleMassLocal, such that the computation is done on each node. More...
 
Mdouble getMaxInteractionDistance () const
 returns the largest separation distance at which adhesive short-range forces can occur. More...
 
void setMaxInteractionDistance (Mdouble interactionDistance=0)
 Sets maxInteractionDistance_. More...
 
const BaseSpeciesgetMixedSpecies (const ParticleSpecies *s) const
 
- 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...
 
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)
 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 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
 

Private Member Functions

Mdouble getLargestInverseParticleMassLocal () const
 Computes inverse mass of the lightest particle (by mass) belonging to this species. If MPI is used, this computation is done locally on each node. More...
 

Private Attributes

Mdouble density_
 The mass density. More...
 
std::function< double(double
temperature)> 
temperatureDependentDensity_
 
Mdouble maxInteractionDistance_
 Returns the max distance between particles of this species and any other species below which adhesive forces can occur (needed for contact detection) More...
 

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

Definition at line 36 of file ParticleSpecies.h.

Member Typedef Documentation

Constructor & Destructor Documentation

ParticleSpecies::ParticleSpecies ( )

The default constructor.

Definition at line 36 of file ParticleSpecies.cc.

37  : BaseSpecies(), density_(1.0)
38 {
39 #ifdef DEBUG_CONSTRUCTOR
40  std::cout<<"ParticleSpecies::ParticleSpecies() finished"<<std::endl;
41 #endif
42 }
Mdouble density_
The mass density.
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
ParticleSpecies::ParticleSpecies ( const ParticleSpecies p)

The default copy constructor.

Parameters
[in]pthe species that is copied

Definition at line 56 of file ParticleSpecies.cc.

References density_, and temperatureDependentDensity_.

57  : BaseSpecies(p)
58 {
59  density_ = p.density_;
61 #ifdef DEBUG_CONSTRUCTOR
62  std::cout<<"ParticleSpecies::ParticleSpecies(const ParticleSpecies &p) finished"<<std::endl;
63 #endif
64 }
std::function< double(double temperature)> temperatureDependentDensity_
Mdouble density_
The mass density.
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
ParticleSpecies::ParticleSpecies ( BaseNormalForce normalForce,
BaseFrictionForce frictionForce,
BaseAdhesiveForce adhesiveForce 
)

Definition at line 44 of file ParticleSpecies.cc.

45  : BaseSpecies(normalForce,frictionForce, adhesiveForce), density_(1.0)
46 {
47 #ifdef DEBUG_CONSTRUCTOR
48  std::cout<<"ParticleSpecies::ParticleSpecies(n,f,a) finished"<<std::endl;
49 #endif
50 }
Mdouble density_
The mass density.
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
ParticleSpecies::~ParticleSpecies ( )

The default destructor.

Definition at line 66 of file ParticleSpecies.cc.

67 {
68 #ifdef DEBUG_DESTRUCTOR
69  std::cout<<"ParticleSpecies::~ParticleSpecies() finished"<<std::endl;
70 #endif
71 }

Member Function Documentation

void ParticleSpecies::computeMass ( BaseParticle p) const

Compute Particle mass function, which required a reference to the Species vector. It computes the Particles mass, Inertia and the inverses.

Compute BaseParticle mass function, which required a reference to the Species vector.

It computes the Particles mass, Inertia and the inverses. this function is called, if BaseParticleHandler::addObject, SpeciesHandler::addObject, ParticleSpecies::setDensity, BaseParticle::setRadius or DPMBase::setParticleDimensions is called

Definition at line 166 of file ParticleSpecies.cc.

References BaseParticle::computeMass().

Referenced by ParticleHandler::addExistingObject(), ParticleHandler::addGhostObject(), ParticleHandler::addObject(), SuperQuadricParticle::setAxes(), SuperQuadricParticle::setExponents(), BaseParticle::setRadius(), and BaseParticle::unfix().

167 {
168  p->computeMass(*this);
169 }
virtual void computeMass(const ParticleSpecies &s)
Computes the particle's (inverse) mass and inertia.
ParticleSpecies* ParticleSpecies::copy ( ) const
overridepure virtual

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

See BaseSpecies::copy for details

Implements BaseSpecies.

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

virtual BaseSpecies* ParticleSpecies::copyMixed ( ) const
pure virtual

Creates a new MixedSpecies with the same force properties as the Species from which it is called. See Species::copyMixed for details.

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Referenced by SpeciesHandler::addObject().

std::string ParticleSpecies::getBaseName ( ) const

Used in Species::getName to obtain a unique name for each Species.

Returns
a string containing the name of the species (minus the word "Species")

Definition at line 99 of file ParticleSpecies.cc.

100 {
101  return "Particle";
102 }
Mdouble ParticleSpecies::getDensity ( ) const
Mdouble ParticleSpecies::getLargestInverseParticleMassLocal ( ) const
private

Computes inverse mass of the lightest particle (by mass) belonging to this species. If MPI is used, this computation is done locally on each node.

Returns
A pointer to the to the lightest BaseParticle (by mass) in this ParticleHandler.

Definition at line 187 of file ParticleSpecies.cc.

References BaseSpecies::getHandler(), and logger.

Referenced by getSmallestParticleMass().

188 {
189  Mdouble maxInvMass = 0;
190  logger.assert(getHandler() != nullptr && getHandler()->getDPMBase() != nullptr,"speciesHandler must be set");
191  for (BaseParticle* const p : getHandler()->getDPMBase()->particleHandler)
192  {
193  if (p->getSpecies()==this && !(p->isFixed() || p->isMPIParticle() || p->isPeriodicGhostParticle()) && p->getInvMass() > maxInvMass)
194  {
195  maxInvMass = p->getInvMass();
196  }
197  }
198  return maxInvMass;
199 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
Mdouble ParticleSpecies::getMassFromRadius ( Mdouble  radius) const
Todo:
TW: should getMassFromRadius be removed? IFCD: it is used in at least one driver (AxisymmetricHopper).

Definition at line 122 of file ParticleSpecies.cc.

References getDensity(), and getVolumeFromRadius().

Referenced by BaseCluster::calculateTimeStep(), getMassFromRadius(), ChuteBottom::makeRoughBottom(), and BaseCluster::setupInitialConditions().

123 {
124  return getDensity() * getVolumeFromRadius(radius);
125 }
Mdouble getVolumeFromRadius(Mdouble radius) const
Mdouble getDensity() const
Allows density_ to be accessed.
Mdouble ParticleSpecies::getMassFromRadius ( const Mdouble  radius,
SpeciesHandler speciesHandler 
)

Definition at line 127 of file ParticleSpecies.cc.

References getMassFromRadius(), and BaseSpecies::setHandler().

128 {
129  setHandler(&speciesHandler);
130  return getMassFromRadius(radius);
131 }
Mdouble getMassFromRadius(Mdouble radius) const
void setHandler(SpeciesHandler *handler)
Sets the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:91
Mdouble ParticleSpecies::getMaxInteractionDistance ( ) 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).

Definition at line 113 of file ParticleSpecies.h.

References maxInteractionDistance_.

Referenced by BaseParticle::getMaxInteractionRadius().

113 {return maxInteractionDistance_;}
Mdouble maxInteractionDistance_
Returns the max distance between particles of this species and any other species below which adhesive...
const BaseSpecies * ParticleSpecies::getMixedSpecies ( const ParticleSpecies s) const

Definition at line 237 of file ParticleSpecies.cc.

References BaseSpecies::getHandler(), BaseObject::getIndex(), and SpeciesHandler::getMixedObject().

Referenced by BaseParticle::getInteractionDistance().

237  {
238  return (getIndex()==s->getIndex())?this:getHandler()->getMixedObject(getIndex(),s->getIndex());
239 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
Mdouble ParticleSpecies::getSmallestParticleMass ( ) const

Computes mass of the lightest particle (by mass) belonging to this species. This computation calls getLightestInverseParticleMassLocal, such that the computation is done on each node.

Definition at line 201 of file ParticleSpecies.cc.

References getLargestInverseParticleMassLocal(), and MPIContainer::Instance().

202 {
203 #ifdef MERCURY_USE_MPI
204  Mdouble maxInvMass = 0;
206  //Obtain the global value
207  MPIContainer::Instance().allReduce(invMassLocal, maxInvMass, MPI_MAX);
208  //return value
209  return 1.0 / maxInvMass;
210 #else
211  return 1.0 / getLargestInverseParticleMassLocal();
212 #endif
213 
214 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getLargestInverseParticleMassLocal() const
Computes inverse mass of the lightest particle (by mass) belonging to this species. If MPI is used, this computation is done locally on each node.
const std::function< double(double)> & ParticleSpecies::getTemperatureDependentDensity ( ) const

Definition at line 171 of file ParticleSpecies.cc.

References temperatureDependentDensity_.

Referenced by ThermalParticle::actionsAfterTimeStep().

172 {
174 }
std::function< double(double temperature)> temperatureDependentDensity_
Mdouble ParticleSpecies::getVolumeFromRadius ( Mdouble  radius) const
Todo:
this should depend on the particle shape; thus, it should be a static function of BaseParticle

Definition at line 134 of file ParticleSpecies.cc.

References ERROR, BaseHandler< T >::getDPMBase(), BaseSpecies::getHandler(), DPMBase::getParticleDimensions(), logger, and constants::pi.

Referenced by getMassFromRadius().

135 {
136  if (getHandler() == nullptr)
137  {
138  logger(ERROR,
139  "[Species::VolumeFromRadius()] No handler has been set, therefore, I can't figure out the dimensions.");
140  return 0;
141  }
142 
143  unsigned int particleDimensions = getHandler()->getDPMBase()->getParticleDimensions();
144  if (particleDimensions == 3)
145  {
146  return 4.0 / 3.0 * constants::pi * radius * radius * radius;
147  }
148  else if (particleDimensions == 2)
149  {
150  return constants::pi * radius * radius;
151  }
152  else if (particleDimensions == 1)
153  {
154  return 2.0 * radius;
155  }
156  else
157  {
158  logger(ERROR, "[Species::VolumeFromRadius()] the dimension of the particle is wrongly set to %",
159  particleDimensions);
160  return 0.0;
161  }
162 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int getParticleDimensions() const
Returns the particle dimensionality.
Definition: DPMBase.cc:1427
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
const Mdouble pi
Definition: ExtendedMath.h:45
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void ParticleSpecies::read ( std::istream &  is)
overridevirtual

Reads the species properties from an input stream.

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

Reimplemented from BaseSpecies.

Reimplemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Definition at line 88 of file ParticleSpecies.cc.

References density_, BaseObject::read(), and BaseSpecies::read().

Referenced by Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read().

89 {
90  BaseObject::read(is);
91  std::string dummy;
92  is >> dummy >> density_;
94 }
virtual void read(std::istream &is)=0
Definition: BaseObject.cc:81
void read(std::istream &is) override
Definition: BaseSpecies.cc:140
Mdouble density_
The mass density.
void ParticleSpecies::setDensity ( Mdouble  density)

Allows density_ to be changed.

Todo:
recalculate masses when setting dim_particle or rho
Parameters
[in]densitythe particle density

Definition at line 107 of file ParticleSpecies.cc.

References ParticleHandler::computeAllMasses(), density_, BaseHandler< T >::getDPMBase(), BaseSpecies::getHandler(), BaseObject::getIndex(), logger, and DPMBase::particleHandler.

Referenced by FileReader::read(), and SpeciesHandler::readOldObject().

108 {
109  logger.assert_always(density >= 0, "[ParticleSpecies::setDensity(%)] value cannot be negative", density);
110  density_ = density;
112 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void computeAllMasses(unsigned int indSpecies)
Computes the mass for all BaseParticle of the given species in this ParticleHandler.
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
Mdouble density_
The mass density.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void ParticleSpecies::setMaxInteractionDistance ( Mdouble  interactionDistance = 0)

Sets maxInteractionDistance_.

Parameters
interactionDistancethe interaction distance that has been changed

Sets maxInteractionDistance_

Parameters
interactionDistancethe interaction distance that has been changed

Definition at line 220 of file ParticleSpecies.cc.

References BaseSpecies::getHandler(), BaseObject::getIndex(), SpeciesHandler::getMixedObject(), BaseHandler< T >::getSize(), constants::i, and maxInteractionDistance_.

Referenced by SpeciesHandler::addObject(), and BaseSpecies::setInteractionDistance().

220  {
221  // if maxInteractionDistance_ has increased it's simple
222  if (interactionDistance>=maxInteractionDistance_) {
223  maxInteractionDistance_ = interactionDistance;
224  } else /*else we need to recompute*/ {
226  int j = getIndex();
227  for (int i=0; i<getHandler()->getSize(); ++i) {
228  const auto mixedSpecies = getHandler()->getMixedObject(i,j);
229  if (mixedSpecies) { //this check is necessary because the mixed species handler might not yet be built fully
231  mixedSpecies->getInteractionDistance());
232  }
233  }
234  }
235 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Mdouble maxInteractionDistance_
Returns the max distance between particles of this species and any other species below which adhesive...
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
void ParticleSpecies::setTemperatureDependentDensity ( const std::function< double(double)> &  temperatureDependentDensity)

Definition at line 176 of file ParticleSpecies.cc.

References temperatureDependentDensity_.

178 {
179  temperatureDependentDensity_ = temperatureDependentDensity;
180 // density_ = temperatureDependentDensity_(0);
181 // logger(INFO,"Setting initial density to %",temperature_);
182 }
std::function< double(double temperature)> temperatureDependentDensity_
void ParticleSpecies::write ( std::ostream &  os) const
overridevirtual

Writes the species properties to an output stream.

Parameters
[out]osoutput stream (typically the restart file)

Reimplemented from BaseSpecies.

Reimplemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Definition at line 76 of file ParticleSpecies.cc.

References density_, BaseObject::write(), and BaseSpecies::write().

Referenced by Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::write().

77 {
78  //note we inherit from BaseObject, not BaseParticle
80  os << " density " << density_;
82  //todo flip the two values
83 }
void write(std::ostream &os) const override
Sets the boolean constantRestitution_.
Definition: BaseSpecies.cc:131
Mdouble density_
The mass density.
virtual void write(std::ostream &os) const =0
A purely virtual function which has an implementation which writes the name and the object id_ to the...
Definition: BaseObject.cc:91

Member Data Documentation

Mdouble ParticleSpecies::density_
private

The mass density.

Definition at line 134 of file ParticleSpecies.h.

Referenced by getDensity(), ParticleSpecies(), read(), setDensity(), and write().

Mdouble ParticleSpecies::maxInteractionDistance_
private

Returns the max distance between particles of this species and any other species below which adhesive forces can occur (needed for contact detection)

Definition at line 145 of file ParticleSpecies.h.

Referenced by getMaxInteractionDistance(), and setMaxInteractionDistance().

std::function<double(double temperature)> ParticleSpecies::temperatureDependentDensity_
private

Change this function to let the particles expand due to temperature. The default value (empty) stands for constant density.

Definition at line 140 of file ParticleSpecies.h.

Referenced by getTemperatureDependentDensity(), ParticleSpecies(), and setTemperatureDependentDensity().


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