|
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... | |
void | updateMixedObjects () |
Updates the mixed species. 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... | |
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... | |
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 | addObject (ParticleSpecies *object) |
Adds a new Object to the BaseHandler. 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) |
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) |
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 | |
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.
SpeciesHandler::SpeciesHandler | ( | ) |
Default constructor, it creates an empty SpeciesHandler.
Constructor of the SpeciesHandler class. It creates an empty SpeciesHandler.
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.
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
References clear(), DEBUG, logger, and mixedObjects_.
|
override |
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.
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 GranularCollapse::GranularCollapse(), main(), MD_demo::MD_demo(), ParticleParticleInteraction::ParticleParticleInteraction(), ParticleParticleInteractionWithPlasticForces::ParticleParticleInteractionWithPlasticForces(), ParticleWallInteraction::ParticleWallInteraction(), readAndAddObject(), DPMBase::readParAndIniFiles(), BoundingRadiusTester::test(), InertiaTensorTester::test(), VolumeTest::test(), ShapeGradientHessianTester::testCushion(), ShapeGradientHessianTester::testEllipsoid(), ShapeGradientHessianTester::testRoundedBeam(), and ShapeGradientHessianTester::testSphere().
|
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 >.
References BaseHandler< T >::clear(), and mixedObjects_.
Referenced by operator=(), DPMBase::readParAndIniFiles(), DrumRot::setupInitialConditions(), RotatingDrum::setupInitialConditions(), BaseCluster::setupInitialConditions(), SpeciesHandler(), and ~SpeciesHandler().
unsigned int SpeciesHandler::getMixedId | ( | unsigned int | id1, |
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.
Referenced by getMixedObject(), removeObject(), and updateMixedObjects().
|
inline |
Referenced by InteractionHandler::addInteraction(), ConstantMassFlowMaserBoundary::addParticleToMaser(), SubcriticalMaserBoundary::addParticleToMaser(), ChuteWithPeriodicInflow::computeInternalForces(), AngleOfRepose::createBaseSpecies(), SilbertPeriodic::createBaseSpecies(), NurbsWall::getDistanceAndNormal(), Screw::getDistanceAndNormal(), IntersectionOfWalls::getDistanceAndNormal(), InteractionHandler::getInteraction(), SuperQuadricParticle::getInteractionRadius(), ParticleSpecies::getMixedSpecies(), MembraneDemo::initializeSpecies(), MembraneSelfTest::initializeSpecies(), main(), protectiveWall::protectiveWall(), MercuryOS::setMaterialProperties(), ParticleSpecies::setMaxInteractionDistance(), Calibration::setSpecies(), Material::setSpecies(), MercuryLogo::setupInitialConditions(), RotatingDrumWet::setupInitialConditions(), Binary::setupInitialConditions(), my_problem::setupInitialConditions(), Chutebelt::setupInitialConditions(), ConstantMassFlowMaserBoundaryMixedSpeciesSelfTest::setupInitialConditions(), DPM::setupInitialConditions(), ContactDetectionIntersectionOfWallsTest::setupInitialConditions(), DrumRot::setupInitialConditions(), RotatingDrum::setupInitialConditions(), SpeciesTest::setupInitialConditions(), WallSpecies::setupInitialConditions(), T_protectiveWall::T_protectiveWall(), 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. |
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.
References mixedObjects_.
Referenced by BaseSpecies::setInteractionDistance().
|
overridevirtual |
Returns the name of the handler, namely the string "SpeciesHandler".
Implements BaseHandler< ParticleSpecies >.
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.
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 >.
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.
References BaseHandler< ParticleSpecies >::getDPMBase(), helpers::getLineFromStringStream(), logger, ParticleSpecies::setDensity(), LinearViscoelasticNormalSpecies::setDissipation(), DPMBase::setParticleDimensions(), LinearViscoelasticNormalSpecies::setStiffness(), and WARN.
Referenced by readAndAddObject().
|
overridevirtual |
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.
Reimplemented from BaseHandler< ParticleSpecies >.
References BaseHandler< ParticleSpecies >::getDPMBase(), getMixedId(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), mixedObjects_, BaseHandler< T >::removeObject(), DPMBase::setRotation(), and useAngularDOFs().
Referenced by CurvyChute::recreateBottom().
void SpeciesHandler::updateMixedObjects | ( | ) |
Updates the mixed species.
Updates mixed species by calling the function mixAll() with the corresponding original species.
This may (should) be called, if a value is changed in the original species and the mixed species need to be aware of this change and update by the default rule. Note this only make sense if you are using the default mixed species and not a custom implementation.
References getMixedId(), BaseHandler< ParticleSpecies >::getNumberOfObjects(), BaseHandler< ParticleSpecies >::getObject(), and mixedObjects_.
bool SpeciesHandler::useAngularDOFs | ( | ) |
Check if angular DOF have to be used.
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.
References BaseHandler< ParticleSpecies >::getNumberOfObjects(), mixedObjects_, and BaseHandler< ParticleSpecies >::objects_.
Referenced by DPMBase::write().
|
private |
The list of pointers to the mixed species.
Referenced by addObject(), clear(), getMixedObject(), getMixedObjects(), operator=(), readAndAddObject(), removeObject(), SpeciesHandler(), updateMixedObjects(), write(), and ~SpeciesHandler().