MercuryDPM
Trunk
|
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 () override | |
Destructor, it destructs the SpeciesHandler and all ParticleSpecies it contains. More... | |
void | addObject (ParticleSpecies *S) override |
Adds a new ParticleSpecies to the SpeciesHandler. More... | |
void | clear () override |
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0. More... | |
void | removeObject (unsigned int index) override |
Remove the ParticleSpecies with given id. More... | |
void | readAndAddObject (std::istream &is) override |
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 (unsigned int id1, unsigned int id2) const |
Gets the Id of the behaviour between two given species. More... | |
template<typename U > | |
std::enable_if <!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * > ::type | getMixedObject (const U *S, const U *T) |
BaseSpecies * | getMixedObject (unsigned int id1, 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 override |
Returns the name of the handler, namely the string "SpeciesHandler". More... | |
bool | useAngularDOFs () |
Check if angular DOF have to be used. More... | |
![]() | |
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... | |
std::enable_if <!std::is_pointer< U >::value, U * >::type | copyAndAddObject (const U &object) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
std::enable_if < std::is_pointer< U >::value, U >::type | copyAndAddObject (const U object) |
Creates a copy of a Object and adds it to the BaseHandler. More... | |
std::enable_if <!std::is_pointer< U >::value, U * >::type | copyAndAddGhostObject (const U &object) |
Creates a copy of a Object and adds it to the BaseHandler. This is one locally for inserting mpi particles, they avoid the global check if the particle can actually be inserted, because the mpi domain already knows that is the case. More... | |
std::enable_if < std::is_pointer< U >::value, U >::type | copyAndAddGhostObject (const U object) |
Creates a copy of a Object and adds it to the BaseHandler. This is one locally for inserting mpi particles, they avoid the global check if the particle can actually be inserted, because the mpi domain already knows that is the case. More... | |
virtual void | addExistingObject (ParticleSpecies *O) |
Adds an existing object to the BaseHandler without changing the id of the object. More... | |
virtual void | addGhostObject (ParticleSpecies *O) |
Adds a new Object to the BaseHandler. called by the to avoid increasing the id. More... | |
void | removeIf (const std::function< bool(ParticleSpecies *)> cond) |
virtual void | removeObject (unsigned const int index) |
Removes an Object from the BaseHandler. More... | |
void | removeLastObject () |
Removes the last Object from the BaseHandler. 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... | |
std::vector< ParticleSpecies * > | getObjectsById (const unsigned int id) |
Gets a vector of pointers to the objects with the specific id. 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... | |
virtual unsigned int | getNumberOfObjects () const |
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) More... | |
unsigned int | getSize () const |
Gets the size of the particleHandler (including mpi and periodic particles) 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... | |
void | resize (const unsigned int N, const ParticleSpecies &obj) |
Resizes the container to contain N elements. 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... | |
void | setId (ParticleSpecies *object, unsigned int id) |
This function sets the id and ensures that nextId is a bigger value than id. More... | |
void | increaseId () |
unsigned int | getNextId () |
void | setNextId (unsigned int id) |
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... | |
virtual void | writeVTK () const |
now empty function for writing VTK files. More... | |
unsigned | getNextGroupId () |
Should be called each time you assign a groupId. Returns the value of nextGroupId_ and increases nextGroupId_ by one. More... | |
Private Attributes | |
std::vector< BaseSpecies * > | mixedObjects_ |
The list of pointers to the mixed species. More... | |
Additional Inherited Members | |
![]() | |
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 36 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 78 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 89 of file SpeciesHandler.cc.
References clear(), BaseSpecies::copy(), BaseHandler< ParticleSpecies >::copyContentsFromOtherHandler(), DEBUG, BaseHandler< T >::getDPMBase(), logger, mixedObjects_, and BaseHandler< ParticleSpecies >::setDPMBase().
|
override |
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 135 of file SpeciesHandler.cc.
References clear(), DEBUG, logger, and mixedObjects_.
|
overridevirtual |
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 797 of file SpeciesHandler.cc.
References BaseHandler< T >::addObject(), ParticleHandler::computeAllMasses(), ParticleSpecies::copyMixed(), BaseHandler< ParticleSpecies >::getDPMBase(), BaseObject::getIndex(), BaseSpecies::getInteractionDistance(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), BaseHandler< ParticleSpecies >::getObject(), mixedObjects_, DPMBase::particleHandler, BaseSpecies::setHandler(), ParticleSpecies::setMaxInteractionDistance(), DPMBase::setRotation(), and useAngularDOFs().
Referenced by readAndAddObject(), and DPMBase::readParAndIniFiles().
|
inlineoverridevirtual |
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Delete all objects stored in objects_ and set the maximum number of objects that have been in this container to 0, and set the Id of the next object that will be added to 0.
Reimplemented from BaseHandler< ParticleSpecies >.
Definition at line 54 of file SpeciesHandler.h.
References BaseHandler< T >::clear(), and mixedObjects_.
Referenced by operator=(), DPMBase::readParAndIniFiles(), BaseCluster::setupInitialConditions(), SpeciesHandler(), and ~SpeciesHandler().
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 742 of file SpeciesHandler.cc.
Referenced by getMixedObject(), and removeObject().
|
inline |
Definition at line 74 of file SpeciesHandler.h.
Referenced by InteractionHandler::addInteraction(), NurbsWall::getDistanceAndNormal(), Screw::getDistanceAndNormal(), IntersectionOfWalls::getDistanceAndNormal(), InteractionHandler::getInteraction(), SuperQuadricParticle::getInteractionRadius(), SuperQuadricParticle::getInteractionWith(), ParticleSpecies::getMixedSpecies(), ParticleSpecies::setMaxInteractionDistance(), and useAngularDOFs().
BaseSpecies * SpeciesHandler::getMixedObject | ( | unsigned int | id1, |
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 763 of file SpeciesHandler.cc.
References getMixedId(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), BaseHandler< ParticleSpecies >::getObject(), logger, mixedObjects_, and WARN.
const std::vector< BaseSpecies * > & SpeciesHandler::getMixedObjects | ( | ) | const |
Returns a pointer to the vector of all mixed objects.
Definition at line 751 of file SpeciesHandler.cc.
References mixedObjects_.
Referenced by BaseSpecies::setInteractionDistance().
|
overridevirtual |
Returns the name of the handler, namely the string "SpeciesHandler".
Implements BaseHandler< ParticleSpecies >.
Definition at line 854 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 109 of file SpeciesHandler.cc.
References clear(), BaseSpecies::copy(), BaseHandler< ParticleSpecies >::copyContentsFromOtherHandler(), DEBUG, logger, and mixedObjects_.
|
overridevirtual |
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 155 of file SpeciesHandler.cc.
References addObject(), MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::copy(), BaseHandler< ParticleSpecies >::copyAndAddObject(), DEBUG, helpers::getLineFromStringStream(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), constants::i, logger, mixedObjects_, readOldObject(), and WARN.
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 664 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::getDPMBase(), helpers::getLineFromStringStream(), logger, ParticleSpecies::setDensity(), DPMBase::setParticleDimensions(), and WARN.
Referenced by readAndAddObject().
|
override |
Remove the ParticleSpecies with given id.
[in] | index | The index of which ParticleSpecies has to be removed from this ParticleHandler. |
The ParticleSpecies with index is removed and the last ParticleSpecies in the vector is moved to its position. It also removes all mixed species for this ParticleSpecies.
Definition at line 822 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::getDPMBase(), getMixedId(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), mixedObjects_, BaseHandler< T >::removeObject(), DPMBase::setRotation(), and useAngularDOFs().
Referenced by CurvyChute::recreateBottom().
bool SpeciesHandler::useAngularDOFs | ( | ) |
Check if angular DOF have to be used.
Definition at line 862 of file SpeciesHandler.cc.
References getMixedObject(), BaseHandler< ParticleSpecies >::getObject(), BaseHandler< ParticleSpecies >::getSize(), BaseSpecies::getUseAngularDOFs(), and constants::i.
Referenced by addObject(), and removeObject().
|
virtual |
Write all the species and mixed species to an output stream.
First write "Species" and the amount of species in this handler, then write all ParticleSpecies and MixedSpecies.
Definition at line 836 of file SpeciesHandler.cc.
References BaseHandler< ParticleSpecies >::getNumberOfObjects(), mixedObjects_, and BaseHandler< ParticleSpecies >::objects_.
Referenced by DPMBase::write().
|
private |
The list of pointers to the mixed species.
Definition at line 96 of file SpeciesHandler.h.
Referenced by addObject(), clear(), getMixedObject(), getMixedObjects(), operator=(), readAndAddObject(), removeObject(), SpeciesHandler(), write(), and ~SpeciesHandler().