AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
autopas::CellBasedParticleContainer< ParticleCell > Class Template Reference

The CellBasedParticleContainer class stores particles in some object and provides methods to iterate over its particles. More...

#include <CellBasedParticleContainer.h>

Inheritance diagram for autopas::CellBasedParticleContainer< ParticleCell >:
Inheritance graph
[legend]
Collaboration diagram for autopas::CellBasedParticleContainer< ParticleCell >:
Collaboration graph
[legend]

Public Member Functions

 CellBasedParticleContainer (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, const double cutoff, double skin, unsigned int rebuildFrequency)
 Constructor of CellBasedParticleContainer.
 
 ~CellBasedParticleContainer () override=default
 Destructor of CellBasedParticleContainer.
 
 CellBasedParticleContainer (const CellBasedParticleContainer &obj)=delete
 Delete the copy constructor to prevent unwanted copies.
 
CellBasedParticleContaineroperator= (const CellBasedParticleContainer &other)=delete
 Delete the copy assignment operator to prevent unwanted copies No particle container should ever be copied.
 
const std::array< double, 3 > & getBoxMax () const final
 Get the upper corner of the container without halo.
 
const std::array< double, 3 > & getBoxMin () const final
 Get the lower corner of the container without halo.
 
double getCutoff () const final
 Return the cutoff of the container.
 
void setCutoff (double cutoff) final
 Set the cutoff of the container.
 
double getInteractionLength () const final
 Return the interaction length (cutoff+skin) of the container.
 
double getVerletSkin () const final
 Returns the verlet Skin length.
 
void deleteAllParticles () override
 Deletes all particles from the container.
 
size_t getNumberOfParticles (IteratorBehavior behavior) const override
 Get the number of particles with respect to the specified IteratorBehavior.
 
size_t size () const override
 Get the total number of particles saved in the container (owned + halo + dummy).
 
const std::vector< ParticleCell > & getCells () const
 Get immutable vector of cells.
 
- Public Member Functions inherited from autopas::ParticleContainerInterface< ParticleCell::ParticleType >
virtual CellType getParticleCellTypeEnum () const=0
 Get the ParticleCell type as an Enum.
 
 ParticleContainerInterface (double skin)
 Constructor.
 
 ParticleContainerInterface (const ParticleContainerInterface &obj)=delete
 Delete the copy constructor to prevent unwanted copies.
 
virtual ~ParticleContainerInterface ()=default
 Destructor of ParticleContainerInterface.
 
ParticleContainerInterfaceoperator= (const ParticleContainerInterface &other)=delete
 Delete the copy assignment operator to prevent unwanted copies.
 
virtual ContainerOption getContainerType () const=0
 Get the ContainerType.
 
virtual void reserve (size_t numParticles, size_t numParticlesHaloEstimate)=0
 Reserve memory for a given number of particles in the container and logic layers.
 
void addParticle (const ParticleCell::ParticleType &p)
 Adds a particle to the container.
 
void addHaloParticle (const ParticleCell::ParticleType &haloParticle)
 Adds a particle to the container that lies in the halo region of the container.
 
virtual bool updateHaloParticle (const ParticleCell::ParticleType &haloParticle)=0
 Update a halo particle of the container with the given haloParticle.
 
virtual void rebuildNeighborLists (TraversalInterface *traversal)=0
 Rebuilds the neighbor lists for the next traversals.
 
virtual void deleteHaloParticles ()=0
 Deletes all halo particles.
 
virtual void deleteAllParticles ()=0
 Deletes all particles.
 
virtual size_t getNumberOfParticles (IteratorBehavior behavior=IteratorBehavior::owned) const=0
 Get the number of particles with respect to the specified IteratorBehavior.
 
virtual size_t size () const=0
 Get the total number of particles saved in the container (owned + halo + dummy).
 
virtual ContainerIterator< ParticleType, true, false > begin (IteratorBehavior behavior=autopas::IteratorBehavior::ownedOrHalo, typename ContainerIterator< ParticleType, true, false >::ParticleVecType *additionalVectors=nullptr)=0
 Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
 
virtual ContainerIterator< ParticleType, false, false > begin (IteratorBehavior behavior=autopas::IteratorBehavior::ownedOrHalo, typename ContainerIterator< ParticleType, false, false >::ParticleVecType *additionalVectors=nullptr) const=0
 Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
 
virtual ContainerIterator< ParticleType, false, false > cbegin (IteratorBehavior behavior=autopas::IteratorBehavior::ownedOrHalo, typename ContainerIterator< ParticleType, false, false >::ParticleVecType *additionalVectors=nullptr) const final
 Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
 
virtual ContainerIterator< ParticleType, true, true > getRegionIterator (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< ParticleType, true, true >::ParticleVecType *additionalVectors=nullptr)=0
 Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorner, highCorner);iter.isValid();++iter) .
 
virtual ContainerIterator< ParticleType, false, true > getRegionIterator (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< ParticleType, false, true >::ParticleVecType *additionalVectors=nullptr) const=0
 Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorner, highCorner);iter.isValid();++iter) .
 
constexpr bool end () const
 Dummy to make range-based for loops work.
 
virtual void computeInteractions (TraversalInterface *traversal)=0
 Iterates over all particle multiples (e.g.
 
virtual const std::array< double, 3 > & getBoxMax () const=0
 Get the upper corner of the container without halo.
 
virtual const std::array< double, 3 > & getBoxMin () const=0
 Get the lower corner of the container without halo.
 
virtual double getCutoff () const=0
 Return the cutoff of the container.
 
virtual void setCutoff (double cutoff)=0
 Set the cutoff of the container.
 
virtual double getVerletSkin () const=0
 Return the verletSkin of the container verletSkin.
 
virtual size_t getStepsSinceLastRebuild () const
 Return the number of time-steps since last neighbor list rebuild.
 
virtual void setStepsSinceLastRebuild (size_t stepsSinceLastRebuild)
 Set the number of time-steps since last neighbor list rebuild.
 
virtual double getInteractionLength () const=0
 Return the interaction length (cutoff+skin) of the container.
 
virtual std::vector< ParticleTypeupdateContainer (bool keepNeighborListsValid)=0
 Updates the container.
 
virtual TraversalSelectorInfo getTraversalSelectorInfo () const=0
 Generates a traversal selector info for this container.
 
std::set< TraversalOption > getAllTraversals (const InteractionTypeOption interactionType) const
 Generates a list of all traversals that are theoretically applicable to this container.
 
virtual std::tuple< const ParticleCell::ParticleType *, size_t, size_t > getParticle (size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior) const=0
 Fetch the pointer to a particle, identified via a cell and particle index.
 
virtual std::tuple< const ParticleCell::ParticleType *, size_t, size_t > getParticle (size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior, const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax) const=0
 Fetch the pointer to a particle, identified via a cell and particle index.
 
std::tuple< ParticleCell::ParticleType *, size_t, size_t > getParticle (size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior, const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax)
 Fetch the pointer to a particle, identified via a cell and particle index.
 
std::tuple< ParticleCell::ParticleType *, size_t, size_t > getParticle (size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior)
 Fetch the pointer to a particle, identified via a cell and particle index.
 
virtual bool deleteParticle (ParticleCell::ParticleType &particle)=0
 Deletes the given particle as long as this does not compromise the validity of the container.
 
virtual bool deleteParticle (size_t cellIndex, size_t particleIndex)=0
 Deletes the particle at the given index positions as long as this does not compromise the validity of the container.
 

Protected Attributes

std::vector< ParticleCell_cells
 Vector of particle cells.
 
- Protected Attributes inherited from autopas::ParticleContainerInterface< ParticleCell::ParticleType >
size_t _stepsSinceLastRebuild
 Stores the number of time-steps since last neighbor list rebuild.
 
double _skin
 Skin distance a particle is allowed to move in one time-step.
 

Additional Inherited Members

- Public Types inherited from autopas::ParticleContainerInterface< ParticleCell::ParticleType >
using ParticleType = ParticleCell::ParticleType
 Type of the Particle.
 
- Protected Member Functions inherited from autopas::ParticleContainerInterface< ParticleCell::ParticleType >
virtual void addParticleImpl (const ParticleCell::ParticleType &p)=0
 Adds a particle to the container.
 
virtual void addHaloParticleImpl (const ParticleCell::ParticleType &haloParticle)=0
 Adds a particle to the container that lies in the halo region of the container.
 

Detailed Description

template<class ParticleCell>
class autopas::CellBasedParticleContainer< ParticleCell >

The CellBasedParticleContainer class stores particles in some object and provides methods to iterate over its particles.

Template Parameters
ParticleCellClass for the particle cells

Constructor & Destructor Documentation

◆ CellBasedParticleContainer() [1/2]

template<class ParticleCell >
autopas::CellBasedParticleContainer< ParticleCell >::CellBasedParticleContainer ( const std::array< double, 3 > &  boxMin,
const std::array< double, 3 > &  boxMax,
const double  cutoff,
double  skin,
unsigned int  rebuildFrequency 
)
inline

Constructor of CellBasedParticleContainer.

Parameters
boxMin
boxMax
cutoff
skin
rebuildFrequency

◆ CellBasedParticleContainer() [2/2]

template<class ParticleCell >
autopas::CellBasedParticleContainer< ParticleCell >::CellBasedParticleContainer ( const CellBasedParticleContainer< ParticleCell > &  obj)
delete

Delete the copy constructor to prevent unwanted copies.

No particle container should ever be copied.

Parameters
obj

Member Function Documentation

◆ deleteAllParticles()

template<class ParticleCell >
void autopas::CellBasedParticleContainer< ParticleCell >::deleteAllParticles ( )
inlineoverridevirtual

Deletes all particles from the container.

Todo:
: find a sensible value for magic number numThreads should be at least 1 and maximal max_threads

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ getBoxMax()

template<class ParticleCell >
const std::array< double, 3 > & autopas::CellBasedParticleContainer< ParticleCell >::getBoxMax ( ) const
inlinefinalvirtual

Get the upper corner of the container without halo.

Returns
Upper corner of the container.

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ getBoxMin()

template<class ParticleCell >
const std::array< double, 3 > & autopas::CellBasedParticleContainer< ParticleCell >::getBoxMin ( ) const
inlinefinalvirtual

Get the lower corner of the container without halo.

Returns
Lower corner of the container.

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ getCells()

template<class ParticleCell >
const std::vector< ParticleCell > & autopas::CellBasedParticleContainer< ParticleCell >::getCells ( ) const
inline

Get immutable vector of cells.

Returns
immutable reference to _cells

◆ getCutoff()

template<class ParticleCell >
double autopas::CellBasedParticleContainer< ParticleCell >::getCutoff ( ) const
inlinefinalvirtual

Return the cutoff of the container.

Returns
Cutoff radius.

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ getInteractionLength()

template<class ParticleCell >
double autopas::CellBasedParticleContainer< ParticleCell >::getInteractionLength ( ) const
inlinefinalvirtual

Return the interaction length (cutoff+skin) of the container.

Returns
interaction length

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ getNumberOfParticles()

template<class ParticleCell >
size_t autopas::CellBasedParticleContainer< ParticleCell >::getNumberOfParticles ( IteratorBehavior  behavior) const
inlineoverridevirtual

Get the number of particles with respect to the specified IteratorBehavior.

Warning
: Since this function counts the number of the respective particles in the internal particle storage, this is in O(n) + lock is required. Only use it when it is absolutely necessary to have the exact number of different particle types like owned or halo. If it is enough to have the whole number of particles (owned + halo + dummy), the function size() can be used.
Parameters
behaviorBehavior of the iterator, see IteratorBehavior.
Returns
The number of particles with respect to the specified IteratorBehavior.

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ getVerletSkin()

template<class ParticleCell >
double autopas::CellBasedParticleContainer< ParticleCell >::getVerletSkin ( ) const
inlinefinalvirtual

Returns the verlet Skin length.

Returns
_skin

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ operator=()

Delete the copy assignment operator to prevent unwanted copies No particle container should ever be copied.

Parameters
other
Returns

◆ setCutoff()

template<class ParticleCell >
void autopas::CellBasedParticleContainer< ParticleCell >::setCutoff ( double  cutoff)
inlinefinalvirtual

Set the cutoff of the container.

Parameters
cutoff

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

◆ size()

template<class ParticleCell >
size_t autopas::CellBasedParticleContainer< ParticleCell >::size ( ) const
inlineoverridevirtual

Get the total number of particles saved in the container (owned + halo + dummy).

Returns
Number of particles saved in the container (owned + halo + dummy).

Implements autopas::ParticleContainerInterface< ParticleCell::ParticleType >.

Member Data Documentation

◆ _cells

template<class ParticleCell >
std::vector<ParticleCell> autopas::CellBasedParticleContainer< ParticleCell >::_cells
protected

Vector of particle cells.

All particle containers store their particles in ParticleCells. This is the common vector for this purpose.


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