MercuryDPM  Beta
 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 the density to be changed. More...
 
Mdouble getMassFromRadius (const Mdouble radius)
 
Mdouble getDensity () const
 Allows the density to be accessed. More...
 
virtual 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)=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 particle 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 36 of file ParticleSpecies.cc.

References density_.

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

The default copy constructor.

Parameters
[in]pthe species that is copied

Definition at line 47 of file ParticleSpecies.cc.

References density_.

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

The default destructor.

Definition at line 55 of file ParticleSpecies.cc.

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

Member Function Documentation

void ParticleSpecies::computeMass ( BaseParticle p) const
virtual

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

147 {
148  if (!p->isFixed())
149  {
150  switch (p->getParticleDimensions())
151  {
152  case 3:
153  {
154  p->mass_ = (4.0 / 3.0 * constants::pi * p->getRadius() * p->getRadius() * p->getRadius() * getDensity());
155  p->invMass_ = 1.0 / (p->mass_);
156  p->inertia_ = (.4 * p->getMass() * mathsFunc::square(p->getRadius()));
157  p->invInertia_ = 1.0 / (p->inertia_);
158  break;
159  }
160  case 2:
161  {
162  p->mass_ = (constants::pi * p->getRadius() * p->getRadius() * getDensity());
163  p->invMass_ = 1.0 / (p->mass_);
164  p->inertia_ = (.5 * p->getMass() * mathsFunc::square(p->getRadius()));
165  p->invInertia_ = 1.0 / (p->inertia_);
166  break;
167  }
168  case 1:
169  {
170  p->mass_ = (2.0 * p->getRadius() * getDensity());
171  p->invMass_ = 1.0/p->mass_;
172  p->inertia_ = 0.0;
173  p->invInertia_ = std::numeric_limits<Mdouble>::quiet_NaN();
174  break;
175  }
176  default:
177  {
178  logger(ERROR, "ParticleSpecies::computeMass()] the dimension of the particle is not set");
179  }
180  }
181  }
182 }
Mdouble invInertia_
Particle inertia_.
Definition: BaseParticle.h:397
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble mass_
Pointer to the previous Particle in the same HGrid cell.
Definition: BaseParticle.h:394
Mdouble invMass_
Particle mass_.
Definition: BaseParticle.h:395
T square(T val)
squares a number
Definition: ExtendedMath.h:91
Mdouble inertia_
Inverse Particle mass (for computation optimization)
Definition: BaseParticle.h:396
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 the 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 85 of file ParticleSpecies.cc.

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

Allows the density to be accessed.

Returns
the particle density

Definition at line 111 of file ParticleSpecies.cc.

References density_.

Referenced by computeMass(), getMassFromRadius(), and ChuteBottom::makeRoughBottom().

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

Definition at line 116 of file ParticleSpecies.cc.

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

Referenced by ChuteBottom::makeRoughBottom().

117 {
118  if (getHandler() == nullptr)
119  {
120  logger(ERROR, "[Species::MassFromRadius()] No handler has been set, therefore, I can't figure out the dimensions.");
121  return 0;
122  }
123 
124  unsigned int particleDimensions = getHandler()->getDPMBase()->getParticleDimensions();
125  if (particleDimensions == 3)
126  {
127  return 4.0 / 3.0 * constants::pi * radius * radius * radius * getDensity();
128  }
129  else if (particleDimensions == 2)
130  {
131  return constants::pi * radius * radius * getDensity();
132  }
133  else if (particleDimensions == 1)
134  {
135  return 2.0 * radius * getDensity();
136  }
137  else
138  {
139  logger(ERROR, "[Species::MassFromRadius()] the dimension of the particle is wrongly set to %",particleDimensions);
140  return 0.0;
141  }
142 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int getParticleDimensions() const
Returns the particle dimensions.
Definition: DPMBase.cc:492
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
Mdouble getDensity() const
Allows the density to be accessed.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
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 75 of file ParticleSpecies.cc.

References density_, and BaseObject::read().

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

76 {
78  std::string dummy;
79  is >> dummy >> density_;
80 }
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:120
Mdouble density_
The particle mass density.
void ParticleSpecies::setDensity ( Mdouble  density)

Allows the density to be changed.

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

Definition at line 93 of file ParticleSpecies.cc.

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

Referenced by SpeciesHandler::readOldObject().

94 {
95  if (density >= 0)
96  {
97  density_ = density;
98  if (getHandler())
100  }
101  else
102  {
103  logger(ERROR, "[ParticleSpecies::setDensity()] Error in the density to be set: % ", density);
104  exit(-1);
105  }
106 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:106
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:878
Mdouble density_
The particle mass density.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
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 65 of file ParticleSpecies.cc.

References density_, and BaseObject::write().

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

66 {
67  //note we inherit from BaseObject, not BaseParticle
69  os << " density " << density_;
70 }
Mdouble density_
The particle 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:128

Member Data Documentation

Mdouble ParticleSpecies::density_
private

The particle mass density.

Definition at line 91 of file ParticleSpecies.h.

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


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