MercuryDPM
Beta
|
Container to store all ParticleSpecies. More...
#include <SpeciesHandler.h>
Public Member Functions | |
SpeciesHandler () | |
Default constructor, it creates an empty SpeciesHandler. More... | |
SpeciesHandler (const SpeciesHandler &other) | |
Constructor that copies all species and the pointer to the DPMBase from the given SpeciesHandler. More... | |
SpeciesHandler | operator= (const SpeciesHandler &rhs) |
Assignment operator that copies all species and the pointer to the DPMBase from the given SpeciesHandler. More... | |
~SpeciesHandler () | |
Destructor, it destructs the SpeciesHandler and all ParticleSpecies it contains. More... | |
virtual void | addObject (ParticleSpecies *const S) |
Adds a new ParticleSpecies to the SpeciesHandler. More... | |
void | removeObject (unsigned const int id) |
Remove the ParticleSpecies with given id. More... | |
void | readObject (std::istream &is) |
Reads Species data into the SpeciesHandler from restart file. More... | |
ParticleSpecies * | readOldObject (std::istream &is) |
Reads ParticleSpecies into the SpeciesHandler from old-style restart data. More... | |
unsigned int | getMixedId (const unsigned int id1, const unsigned int id2) const |
Gets the Id of the behaviour between two given species. More... | |
template<typename U > | |
U::MixedSpeciesType * | getMixedObject (const U *S, const U *T) |
BaseSpecies * | getMixedObject (const unsigned int id1, const unsigned int id2) |
Gets the mixed object that is constructed from two given species. More... | |
const std::vector< BaseSpecies * > & | getMixedObjects () const |
Returns a pointer to the vector of all mixed objects. More... | |
virtual void | write (std::ostream &os) const |
Write all the species and mixed species to an output stream. More... | |
std::string | getName () const |
Returns the name of the handler, namely the string "SpeciesHandler". More... | |
bool | useAngularDOFs () |
Check if angular DOF have to be used. More... | |
Public Member Functions inherited from BaseHandler< ParticleSpecies > | |
BaseHandler () | |
Default BaseHandler constructor, it creates an empty BaseHandler and assigns DPMBase_ to a null pointer. More... | |
BaseHandler (const BaseHandler< ParticleSpecies > &BH) | |
Constructor that copies the objects of the given handler into itself and sets other variables to 0/nullptr. More... | |
virtual | ~BaseHandler () |
Destructor, it destructs the BaseHandler and all Object it contains. More... | |
void | copyContentsFromOtherHandler (const BaseHandler< ParticleSpecies > &BH) |
Function that copies the contents (vector of pointers, maxObject_, nextId_, DPMBase_) from one handler (container) to the other. More... | |
U * | copyAndAddObject (const U &O) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
U * | copyAndAddObject (U *O) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
void | removeLastObject () |
Removes the last Object from the BaseHandler. More... | |
void | clear () |
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0. More... | |
void | read (std::istream &is) |
Reads all objects from restart data. More... | |
ParticleSpecies * | getObjectById (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
ParticleSpecies * | getObject (const unsigned int id) |
Gets a pointer to the Object at the specified index in the BaseHandler. More... | |
const ParticleSpecies * | getObject (const unsigned int id) const |
Gets a constant pointer to the Object at the specified index in the BaseHandler. More... | |
ParticleSpecies * | getLastObject () |
Gets a pointer to the last Object in this BaseHandler. More... | |
const ParticleSpecies * | getLastObject () const |
Gets a constant pointer to the last Object in this BaseHandler. More... | |
unsigned int | getNumberOfObjects () const |
Gets the number of Object in this BaseHandler. More... | |
unsigned int | getStorageCapacity () const |
Gets the storage capacity of this BaseHandler. More... | |
void | setStorageCapacity (const unsigned int N) |
Sets the storage capacity of this BaseHandler. More... | |
const std::vector < ParticleSpecies * > ::const_iterator | begin () const |
Gets the begin of the const_iterator over all Object in this BaseHandler. More... | |
const std::vector < ParticleSpecies * > ::iterator | begin () |
Gets the begin of the iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector < ParticleSpecies * > ::const_iterator | end () const |
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler. More... | |
const std::vector < ParticleSpecies * > ::iterator | end () |
Gets the end of the iterator over all BaseBoundary in this BaseHandler. More... | |
void | setDPMBase (DPMBase *DPMBase) |
Sets the problem that is solved using this handler. More... | |
DPMBase * | getDPMBase () |
Gets the problem that is solved using this handler. More... | |
DPMBase * | getDPMBase () const |
Gets the problem that is solved using this handler and does not change the class. More... | |
Private Attributes | |
std::vector< BaseSpecies * > | mixedObjects_ |
The list of pointers to the mixed species. More... | |
Additional Inherited Members | |
Protected Attributes inherited from BaseHandler< ParticleSpecies > | |
std::vector< ParticleSpecies * > | objects_ |
The actual list of Object pointers. More... | |
Container to store all ParticleSpecies.
The SpeciesHandler is a container to store all ParticleSpecies. It is implemented by a vector of pointers to ParticleSpecies.
Definition at line 37 of file SpeciesHandler.h.
SpeciesHandler::SpeciesHandler | ( | ) |
Default constructor, it creates an empty SpeciesHandler.
Constructor of the SpeciesHandler class. It creates an empty SpeciesHandler.
Definition at line 56 of file SpeciesHandler.cc.
SpeciesHandler::SpeciesHandler | ( | const SpeciesHandler & | other | ) |
Constructor that copies all species and the pointer to the DPMBase from the given SpeciesHandler.
[in] | other | The SpeciesHandler that has to be copied. |
This is not a copy constructor! This constructor copies only all BaseSpecies and MixedSpecies and copies the pointer to the DPMBase. It sets all other data members to 0 or nullptr.
Definition at line 67 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::clear(), BaseSpecies::copy(), BaseHandler< ParticleSpecies >::copyContentsFromOtherHandler(), DEBUG, BaseHandler< T >::getDPMBase(), logger, mixedObjects_, and BaseHandler< ParticleSpecies >::setDPMBase().
SpeciesHandler::~SpeciesHandler | ( | ) |
Destructor, it destructs the SpeciesHandler and all ParticleSpecies it contains.
Destructor: first destroys the objects of the BaseHandler, then destroys the mixedObjects
Definition at line 111 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::clear(), DEBUG, logger, and mixedObjects_.
|
virtual |
Adds a new ParticleSpecies to the SpeciesHandler.
[in] | S | A pointer to the ParticleSpecies that has to be added. |
First, add the ParticleSpecies to the vector of ParticleSpecies (object_), then construct all MixedSpecies. Tell the ParticleSpecies that this is its handler and compute all masses and whether it should use angular degrees of freedom.
Note: The MixedSpecies objects are initialized with averaged values from both species: e.g., the mixedSpecies between Species A and B will have a stiffness $fk=(1/k_a+1/k_b)^{-1}$f, you have to change the MixedSpecies properties if you don't like these defaults.
Reimplemented from BaseHandler< ParticleSpecies >.
Definition at line 546 of file SpeciesHandler.cc.
References BaseHandler< T >::addObject(), ParticleHandler::computeAllMasses(), ParticleSpecies::copyMixed(), BaseHandler< ParticleSpecies >::getDPMBase(), BaseObject::getIndex(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), BaseHandler< ParticleSpecies >::getObject(), mixedObjects_, DPMBase::particleHandler, BaseSpecies::setHandler(), DPMBase::setRotation(), and useAngularDOFs().
Referenced by readObject(), and DPMBase::readParAndIniFiles().
unsigned int SpeciesHandler::getMixedId | ( | const unsigned int | id1, |
const unsigned int | id2 | ||
) | const |
Gets the Id of the behaviour between two given species.
[in] | id1 | Id of the first species. |
[in] | id2 | Id of the second species. |
The numbering of the mixed species is 0-1, 0-2, 1-2, 0-3, 1-3, 2-3, 0-4, 1-4, 2-4, 3-4, ..., where each pair of numbers a and b denotes the mixed species between ParticleSpecies a and b. Thus, first compute which id has a higher value, the id of the mixed species is then given by (maxId*(maxId-1))/2 + minId.
Definition at line 485 of file SpeciesHandler.cc.
Referenced by getMixedObject(), and removeObject().
U::MixedSpeciesType * SpeciesHandler::getMixedObject | ( | const U * | S, |
const U * | T | ||
) |
[in] | S | A pointer to the first ParticleSpecies. |
[in] | T | A pointer to the second ParticleSpecies. |
Definition at line 496 of file SpeciesHandler.cc.
Referenced by InteractionHandler::getInteraction(), and useAngularDOFs().
BaseSpecies * SpeciesHandler::getMixedObject | ( | const unsigned int | id1, |
const unsigned int | id2 | ||
) |
Gets the mixed object that is constructed from two given species.
[in] | id1 | Id of the first BaseSpecies. |
[in] | id2 | Id of the second BaseSpecies. |
Definition at line 516 of file SpeciesHandler.cc.
References ERROR, getMixedId(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), BaseHandler< ParticleSpecies >::getObject(), logger, and mixedObjects_.
const std::vector< BaseSpecies * > & SpeciesHandler::getMixedObjects | ( | ) | const |
Returns a pointer to the vector of all mixed objects.
Definition at line 504 of file SpeciesHandler.cc.
References mixedObjects_.
|
virtual |
Returns the name of the handler, namely the string "SpeciesHandler".
Implements BaseHandler< ParticleSpecies >.
Definition at line 619 of file SpeciesHandler.cc.
SpeciesHandler SpeciesHandler::operator= | ( | const SpeciesHandler & | rhs | ) |
Assignment operator that copies all species and the pointer to the DPMBase from the given SpeciesHandler.
[in] | rhs | The BoundaryHandler on the right hand side of the assignment. |
This is not a copy assignment operator! It copies only all BaseSpecies and MixedSpecies and copies the pointer to the DPMBase. It sets all other data members to 0 or nullptr.
Definition at line 87 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::clear(), BaseSpecies::copy(), BaseHandler< ParticleSpecies >::copyContentsFromOtherHandler(), DEBUG, logger, and mixedObjects_.
|
virtual |
Reads Species data into the SpeciesHandler from restart file.
[in] | is | The input stream from which the information is read. |
First determine the type of the object we want to read, then read the actual object. After that, clear the mixed objects and read the mixed objects.
Implements BaseHandler< ParticleSpecies >.
Definition at line 130 of file SpeciesHandler.cc.
References addObject(), BaseHandler< ParticleSpecies >::copyAndAddObject(), ERROR, helpers::getLineFromStringStream(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), logger, mixedObjects_, and readOldObject().
ParticleSpecies * SpeciesHandler::readOldObject | ( | std::istream & | is | ) |
Reads ParticleSpecies into the SpeciesHandler from old-style restart data.
[in] | is | The input stream from which the information is read. |
To read the old object, we first make a stringstream of the line that describes this ParticleSpecies. After that, we read the properties one by one, first the stiffness and after that the other properties. We stop when we either reach the end of the file(eof) or if a string is not recognized as a property.
Definition at line 407 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::getDPMBase(), helpers::getLineFromStringStream(), logger, ParticleSpecies::setDensity(), DPMBase::setParticleDimensions(), and WARN.
Referenced by readObject().
|
virtual |
Remove the ParticleSpecies with given id.
[in] | id | The identity of the ParticleSpecies that must be removed. |
First remove the object itself, then remove all mixed species for this ParticleSpecies.
Reimplemented from BaseHandler< ParticleSpecies >.
Definition at line 569 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::getDPMBase(), getMixedId(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), mixedObjects_, BaseHandler< T >::removeObject(), DPMBase::setRotation(), and useAngularDOFs().
bool SpeciesHandler::useAngularDOFs | ( | ) |
Check if angular DOF have to be used.
Definition at line 627 of file SpeciesHandler.cc.
References getMixedObject(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), BaseHandler< ParticleSpecies >::getObject(), and BaseSpecies::getUseAngularDOFs().
Referenced by addObject(), and removeObject().
|
virtual |
Write all the species and mixed species to an output stream.
[in] | os | The output stream where the object needs to be written to. |
First write "Species" and the amount of species in this handler, then write all ParticleSpecies and MixedSpecies.
Definition at line 583 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::begin(), BaseHandler< ParticleSpecies >::end(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), and mixedObjects_.
Referenced by DPMBase::write().
|
private |
The list of pointers to the mixed species.
Definition at line 93 of file SpeciesHandler.h.
Referenced by addObject(), getMixedObject(), getMixedObjects(), operator=(), readObject(), removeObject(), SpeciesHandler(), write(), and ~SpeciesHandler().