MercuryDPM  Alpha
 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
 

Public Member Functions

 ParticleSpecies ()
 The default constructor. More...
 
 ParticleSpecies (const ParticleSpecies &p)
 The default copy constructor. More...
 
virtual ~ParticleSpecies ()
 The default destructor. More...
 
virtual ParticleSpeciescopy () const =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)
 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 setDensity (Mdouble density)
 Allows density_ to be changed. More...
 
Mdouble getMassFromRadius (const Mdouble radius) const
 
Mdouble getVolumeFromRadius (const 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...
 
- Public Member Functions inherited from BaseSpecies
 BaseSpecies ()
 The default constructor. More...
 
 BaseSpecies (const BaseSpecies &p)
 The copy constructor. More...
 
virtual ~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 average (Mdouble a, Mdouble b)
 defines the average of two variables by the harmonic mean. More...
 
virtual void mixAll (BaseSpecies *const S, BaseSpecies *const T)=0
 creates default values for mixed species More...
 
virtual Mdouble getInteractionDistance () const =0
 returns the largest separation distance at which adhesive short-range forces can occur. 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, Mdouble timeStamp) const =0
 returns new Interaction object. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()
 Default constructor. More...
 
 BaseObject (const BaseObject &p)
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()
 virtual destructor More...
 
virtual std::string getName () const =0
 A purely virtual function. More...
 
virtual void moveInHandler (const unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (const unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (const unsigned int 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...
 

Private Attributes

Mdouble density_
 The mass density. 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 37 of file ParticleSpecies.cc.

References density_.

38 {
39  density_ = 0.0;
40 #ifdef DEBUG_CONSTRUCTOR
41  std::cout<<"ParticleSpecies::ParticleSpecies() finished"<<std::endl;
42 #endif
43 }
Mdouble density_
The mass density.
ParticleSpecies::ParticleSpecies ( const ParticleSpecies p)

The default copy constructor.

Parameters
[in]pthe species that is copied

Definition at line 48 of file ParticleSpecies.cc.

References density_.

49 {
51 #ifdef DEBUG_CONSTRUCTOR
52  std::cout<<"ParticleSpecies::ParticleSpecies(const ParticleSpecies &p) finished"<<std::endl;
53 #endif
54 }
Mdouble density_
The mass density.
ParticleSpecies::~ParticleSpecies ( )
virtual

The default destructor.

Definition at line 56 of file ParticleSpecies.cc.

57 {
58 #ifdef DEBUG_DESTRUCTOR
59  std::cout<<"ParticleSpecies::~ParticleSpecies() finished"<<std::endl;
60 #endif
61 }

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 145 of file ParticleSpecies.cc.

References ERROR, getDensity(), BaseParticle::getMass(), BaseParticle::getParticleDimensions(), BaseParticle::getRadius(), BaseParticle::inertia_, BaseParticle::invInertia_, BaseParticle::invMass_, BaseParticle::isFixed(), logger, BaseParticle::mass_, constants::pi, and mathsFunc::square().

Referenced by ParticleHandler::addObject(), BaseParticle::setRadius(), and BaseParticle::unfix().

146 {
147  if (!p->isFixed())
148  {
149  switch (p->getParticleDimensions())
150  {
151  case 3:
152  {
153  p->mass_ = (4.0 / 3.0 * constants::pi * p->getRadius() * p->getRadius() * p->getRadius() * getDensity());
154  p->invMass_ = 1.0 / (p->mass_);
155  p->inertia_ = (.4 * p->getMass() * mathsFunc::square(p->getRadius()));
156  p->invInertia_ = 1.0 / (p->inertia_);
157  break;
158  }
159  case 2:
160  {
161  p->mass_ = (constants::pi * p->getRadius() * p->getRadius() * getDensity());
162  p->invMass_ = 1.0 / (p->mass_);
163  p->inertia_ = (.5 * p->getMass() * mathsFunc::square(p->getRadius()));
164  p->invInertia_ = 1.0 / (p->inertia_);
165  break;
166  }
167  case 1:
168  {
169  p->mass_ = (2.0 * p->getRadius() * getDensity());
170  p->invMass_ = 1.0/p->mass_;
171  p->inertia_ = 0.0;
172  p->invInertia_ = std::numeric_limits<Mdouble>::quiet_NaN();
173  break;
174  }
175  default:
176  {
177  logger(ERROR, "ParticleSpecies::computeMass()] the dimension of the particle is not set");
178  }
179  }
180  }
181 }
Mdouble invInertia_
Particle inertia_.
Definition: BaseParticle.h:409
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble mass_
Pointer to the previous Particle in the same HGrid cell.
Definition: BaseParticle.h:406
Mdouble invMass_
Particle mass_.
Definition: BaseParticle.h:407
T square(T val)
squares a number
Definition: ExtendedMath.h:91
Mdouble inertia_
Inverse Particle mass (for computation optimization)
Definition: BaseParticle.h:408
Mdouble getMass() const
Returns the particle's mass_.
const Mdouble pi
Definition: ExtendedMath.h:42
Mdouble getRadius() const
Returns the particle's radius_.
Mdouble getDensity() const
Allows density_ to be accessed.
unsigned int getParticleDimensions() const
Returns the particle's dimensions (either 2 or 3).
bool isFixed() const
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
virtual ParticleSpecies* ParticleSpecies::copy ( ) const
pure 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 >.

Referenced by MaserBoundary::addParticleToMaser().

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 86 of file ParticleSpecies.cc.

87 {
88  return "Particle";
89 }
Mdouble ParticleSpecies::getDensity ( ) const

Allows density_ to be accessed.

Returns
the particle density

Definition at line 104 of file ParticleSpecies.cc.

References density_.

Referenced by computeMass(), HertzianSinterNormalSpecies::computeTimeStep(), getMassFromRadius(), and FileReader::read().

105 {
106  return density_;
107 }
Mdouble density_
The mass density.
Mdouble ParticleSpecies::getMassFromRadius ( const Mdouble  radius) const
Todo:
TW: should getMassFromRadius be removed? IFCD: it is used in at least one driver (AxisymmetricHopper).

Definition at line 109 of file ParticleSpecies.cc.

References getDensity(), and getVolumeFromRadius().

Referenced by ChuteBottom::makeRoughBottom().

110 {
111  return getDensity()*getVolumeFromRadius(radius);
112 }
Mdouble getVolumeFromRadius(const Mdouble radius) const
Mdouble getDensity() const
Allows density_ to be accessed.
Mdouble ParticleSpecies::getVolumeFromRadius ( const Mdouble  radius) const
Todo:
this should depend on the particle shape; thus, it should be a static function of BaseParticle

Definition at line 115 of file ParticleSpecies.cc.

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

Referenced by getMassFromRadius().

116 {
117  if (getHandler() == nullptr)
118  {
119  logger(ERROR, "[Species::VolumeFromRadius()] No handler has been set, therefore, I can't figure out the dimensions.");
120  return 0;
121  }
122 
123  unsigned int particleDimensions = getHandler()->getDPMBase()->getParticleDimensions();
124  if (particleDimensions == 3)
125  {
126  return 4.0 / 3.0 * constants::pi * radius * radius * radius;
127  }
128  else if (particleDimensions == 2)
129  {
130  return constants::pi * radius * radius;
131  }
132  else if (particleDimensions == 1)
133  {
134  return 2.0 * radius;
135  }
136  else
137  {
138  logger(ERROR, "[Species::VolumeFromRadius()] the dimension of the particle is wrongly set to %",particleDimensions);
139  return 0.0;
140  }
141 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int getParticleDimensions() const
Returns the particle dimensions.
Definition: DPMBase.cc:599
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:74
const Mdouble pi
Definition: ExtendedMath.h:42
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:543
void ParticleSpecies::read ( std::istream &  is)
virtual

Reads the species properties from an input stream.

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

Implements BaseObject.

Reimplemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Definition at line 76 of file ParticleSpecies.cc.

References density_, and BaseObject::read().

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

77 {
79  std::string dummy;
80  is >> dummy >> density_;
81 }
virtual void read(std::istream &is)=0
A purely virtual method with an implementation which reads the index from the stream and assigns it t...
Definition: BaseObject.cc:124
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 94 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().

95 {
96  logger.assert_always(density>=0,"[ParticleSpecies::setDensity(%)] value cannot be negative",density);
97  density_ = density;
99 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:108
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:74
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1001
Mdouble density_
The mass density.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:543
void ParticleSpecies::write ( std::ostream &  os) const
virtual

Writes the species properties to an output stream.

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

Implements BaseObject.

Reimplemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >.

Definition at line 66 of file ParticleSpecies.cc.

References density_, and BaseObject::write().

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

67 {
68  //note we inherit from BaseObject, not BaseParticle
70  os << " density " << density_;
71 }
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:133

Member Data Documentation

Mdouble ParticleSpecies::density_
private

The mass density.

Definition at line 93 of file ParticleSpecies.h.

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


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