revision: v0.14
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)
 
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)
 
- 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_
 

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

Member Typedef Documentation

◆ InteractionType

◆ MixedSpeciesType

Constructor & Destructor Documentation

◆ ParticleSpecies() [1/3]

ParticleSpecies::ParticleSpecies ( )

The default constructor.

37  : BaseSpecies(), density_(1.0)
38 {
39 #ifdef DEBUG_CONSTRUCTOR
40  std::cout<<"ParticleSpecies::ParticleSpecies() finished"<<std::endl;
41 #endif
42 }

◆ ParticleSpecies() [2/3]

ParticleSpecies::ParticleSpecies ( const ParticleSpecies p)

The default copy constructor.

Parameters
[in]pthe species that is copied
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 }

References density_, and temperatureDependentDensity_.

◆ ParticleSpecies() [3/3]

ParticleSpecies::ParticleSpecies ( BaseNormalForce normalForce,
BaseFrictionForce frictionForce,
BaseAdhesiveForce adhesiveForce 
)
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 }

◆ ~ParticleSpecies()

ParticleSpecies::~ParticleSpecies ( )

The default destructor.

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

Member Function Documentation

◆ computeMass()

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

167 {
168  p->computeMass(*this);
169 }

References BaseParticle::computeMass().

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

◆ copy()

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.

Referenced by CurvyChute::createBottom().

◆ copyMixed()

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.

Referenced by SpeciesHandler::addObject().

◆ getBaseName()

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")
100 {
101  return "Particle";
102 }

◆ getDensity()

◆ getLargestInverseParticleMassLocal()

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.
188 {
189  Mdouble maxInvMass = 0;
190  logger.assert_debug(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 }

References BaseSpecies::getHandler(), and logger.

Referenced by getSmallestParticleMass().

◆ getMassFromRadius() [1/2]

Mdouble ParticleSpecies::getMassFromRadius ( const Mdouble  radius,
SpeciesHandler speciesHandler 
)
128 {
129  setHandler(&speciesHandler);
130  return getMassFromRadius(radius);
131 }

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

◆ getMassFromRadius() [2/2]

Mdouble ParticleSpecies::getMassFromRadius ( Mdouble  radius) const
Todo:
TW: should getMassFromRadius be removed? IFCD: it is used in at least one driver (AxisymmetricHopper).
123 {
124  return getDensity() * getVolumeFromRadius(radius);
125 }

References getDensity(), and getVolumeFromRadius().

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

◆ getMaxInteractionDistance()

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

113 {return maxInteractionDistance_;}

References maxInteractionDistance_.

Referenced by BaseParticle::getMaxInteractionRadius().

◆ getMixedSpecies()

const BaseSpecies * ParticleSpecies::getMixedSpecies ( const ParticleSpecies s) const

◆ getSmallestParticleMass()

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.

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 }

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

◆ getTemperatureDependentDensity()

const std::function< double(double)> & ParticleSpecies::getTemperatureDependentDensity ( ) const

◆ getVolumeFromRadius()

Mdouble ParticleSpecies::getVolumeFromRadius ( Mdouble  radius) const
Todo:
this should depend on the particle shape; thus, it should be a static function of BaseParticle
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 }

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

Referenced by getMassFromRadius().

◆ read()

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.

89 {
90  BaseObject::read(is);
91  std::string dummy;
92  is >> dummy >> density_;
94 }

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

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

◆ setDensity()

void ParticleSpecies::setDensity ( Mdouble  density)

Allows density_ to be changed

Todo:
recalculate masses when setting dim_particle or rho
Parameters
[in]densitythe particle density
108 {
109  logger.assert_always(density >= 0, "[ParticleSpecies::setDensity(%)] value cannot be negative", density);
110  density_ = density;
112 }

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

Referenced by Membrane::buildMesh(), main(), and FlowRule::setDensityVariation().

◆ setMaxInteractionDistance()

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

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

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

◆ setTemperatureDependentDensity()

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

References temperatureDependentDensity_.

◆ write()

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.

77 {
78  //note we inherit from BaseObject, not BaseParticle
80  os << " density " << density_;
82  //todo flip the two values
83 }

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

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

Member Data Documentation

◆ density_

Mdouble ParticleSpecies::density_
private

The mass density.

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

◆ maxInteractionDistance_

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)

Referenced by getMaxInteractionDistance(), and setMaxInteractionDistance().

◆ temperatureDependentDensity_

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.

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


The documentation for this class was generated from the following files:
BaseObject::read
virtual void read(std::istream &is)=0
Definition: BaseObject.cc:81
DPMBase::getParticleDimensions
unsigned int getParticleDimensions() const
Returns the particle dimensionality.
Definition: DPMBase.cc:1458
constants::pi
const Mdouble pi
Definition: ExtendedMath.h:45
BaseSpecies::getHandler
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
ParticleSpecies::getVolumeFromRadius
Mdouble getVolumeFromRadius(Mdouble radius) const
Definition: ParticleSpecies.cc:134
SpeciesHandler::getMixedObject
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
BaseHandler::getSize
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
ParticleSpecies::getDensity
Mdouble getDensity() const
Allows density_ to be accessed.
Definition: ParticleSpecies.cc:117
BaseSpecies::write
void write(std::ostream &os) const override
Sets the boolean constantRestitution_.
Definition: BaseSpecies.cc:131
ParticleSpecies::getMassFromRadius
Mdouble getMassFromRadius(Mdouble radius) const
Definition: ParticleSpecies.cc:122
Mdouble
double Mdouble
Definition: GeneralDefine.h:34
BaseObject::write
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
BaseParticle::computeMass
virtual void computeMass(const ParticleSpecies &s)
Computes the particle's (inverse) mass and inertia.
Definition: BaseParticle.cc:862
ERROR
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
ParticleSpecies::maxInteractionDistance_
Mdouble maxInteractionDistance_
Definition: ParticleSpecies.h:145
BaseSpecies::setHandler
void setHandler(SpeciesHandler *handler)
Sets the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:91
BaseObject::getIndex
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
constants::i
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
BaseSpecies::read
void read(std::istream &is) override
Definition: BaseSpecies.cc:140
BaseSpecies::BaseSpecies
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:38
BaseHandler::getDPMBase
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
BaseParticle
Definition: BaseParticle.h:54
ParticleSpecies::temperatureDependentDensity_
std::function< double(double temperature)> temperatureDependentDensity_
Definition: ParticleSpecies.h:140
DPMBase::particleHandler
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1395
ParticleSpecies::getLargestInverseParticleMassLocal
Mdouble getLargestInverseParticleMassLocal() const
Computes inverse mass of the lightest particle (by mass) belonging to this species....
Definition: ParticleSpecies.cc:187
ParticleHandler::computeAllMasses
void computeAllMasses(unsigned int indSpecies)
Computes the mass for all BaseParticle of the given species in this ParticleHandler.
Definition: ParticleHandler.cc:1205
MPIContainer::Instance
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
ParticleSpecies::density_
Mdouble density_
The mass density.
Definition: ParticleSpecies.h:134