AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
autopas::internal::ClusterTower< Particle_T > Class Template Reference

This class represents one tower for clusters in the VerletClusterLists container. More...

#include <ClusterTower.h>

Inheritance diagram for autopas::internal::ClusterTower< Particle_T >:
Inheritance graph
[legend]
Collaboration diagram for autopas::internal::ClusterTower< Particle_T >:
Collaboration graph
[legend]

Public Types

using StorageType = typename FullParticleCell< Particle_T >::StorageType
 Type that holds or refers to the actual particles.
 
- Public Types inherited from autopas::FullParticleCell< Particle_T >
using SoAArraysType = typename Particle_T::SoAArraysType
 The structure of the SoAs is defined by the particle.
 
using StorageType = std::vector< Particle_T >
 Type that holds or refers to the actual particles.
 
- Public Types inherited from autopas::ParticleCell< Particle_T >
using ParticleType = Particle_T
 The particle type for this cell.
 

Public Member Functions

 ClusterTower ()
 Dummy constructor.
 
 ClusterTower (size_t clusterSize)
 Constructor.
 
CellType getParticleCellTypeAsEnum () override
 Get the ParticleCell type as an ParticleCellTypeEnum.
 
void clear () override
 Clears all particles from the tower and resets it to be ready for new particles.
 
size_t generateClusters ()
 Generates the clusters for the particles in this cluster tower.
 
void setDummyValues (double dummyStartX, double dummyDistZ)
 Replaces the copies of the last particle made in generateClusters() with dummies.
 
void setDummyParticlesToLastActualParticle ()
 More or less inverse operation of setDummyValues().
 
template<class Functor >
void loadSoA (Functor *functor)
 Loads the particles into the SoA stored in this tower and generates the SoAView for each cluster.
 
template<class Functor >
void extractSoA (Functor *functor)
 Extracts the SoA into the particles/clusters.
 
std::vector< Particle_T > && collectAllActualParticles ()
 Returns a rvalue reference to a std::vector containing all particles of this tower that are not dummies.
 
std::vector< Particle_T > collectOutOfBoundsParticles (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax)
 Collect all particles that should not be in this tower based on their current position.
 
size_t getNumTailDummyParticles () const
 Returns the number of dummy particles in the tower that were inserted in the tower to fill the last cluster.
 
size_t size () const override
 Get the number of all particles stored in this tower (owned, halo and dummy).
 
unsigned long getNumActualParticles () const
 Get the number of all particles saved in the tower without tailing dummies that are used to fill up clusters (owned + halo + dummies excluding tailing dummies).
 
size_t getNumClusters () const
 Returns the number of clusters in the tower.
 
auto & getClusters ()
 Returns a reference to the std::vector holding the clusters of this container.
 
const std::vector< autopas::internal::Cluster< Particle_T > >::iterator & getFirstOwnedCluster () const
 Returns an iterator to the first cluster that contains at least one owned particle.
 
size_t getFirstOwnedClusterIndex () const
 Returns the index of the first cluster that contains at least one owned particle.
 
const std::vector< autopas::internal::Cluster< Particle_T > >::iterator & getFirstTailHaloCluster () const
 Returns an iterator to the first particle after the owned clusters, that contains no owned particles anymore.
 
size_t getFirstTailHaloClusterIndex () const
 Returns the index of the first particle after the owned clusters, that contains no owned particles anymore.
 
auto & getCluster (size_t index)
 Returns the cluster at position index.
 
auto & getCluster (size_t index) const
 Returns the cluster at position index.
 
bool isEmpty () const override
 Check if the cell is empty.
 
void deleteDummyParticles () override
 Deletes all dummy particles in this cell.
 
void deleteByIndex (size_t index) override
 Deletes the index-th particle.
 
void setCellLength (std::array< double, 3 > &) override
 Set the side lengths of this cell.
 
std::array< double, 3 > getCellLength () const override
 Get the side lengths of this cell.
 
void setClusterSize (size_t clusterSize)
 Set cluster size.
 
size_t getClusterSize () const
 Get cluster size.
 
void setParticleDeletionObserver (internal::ParticleDeletedObserver *observer)
 Set the ParticleDeletionObserver, which is called, when a particle is deleted.
 
StorageTypeparticleVector ()
 Get reference to internal particle vector.
 
- Public Member Functions inherited from autopas::FullParticleCell< Particle_T >
 FullParticleCell ()
 Constructs a new FullParticleCell.
 
 FullParticleCell (const std::array< double, 3 > &cellLength)
 Constructs a new FullParticleCell with the given cell side length.
 
void addParticle (const Particle_T &p) override
 Adds a Particle to the cell.
 
CellIterator< StorageType, true > begin ()
 Get an iterator to the start of a ParticleCell.
 
CellIterator< StorageType, false > begin () const
 Get an iterator to the start of a ParticleCell.
 
CellIterator< StorageType, true > end ()
 Get an iterator to the end of a ParticleCell.
 
CellIterator< StorageType, false > end () const
 Get an iterator to the end of a ParticleCell.
 
template<typename Lambda >
void forEach (Lambda forEachLambda)
 Executes code for every particle in this cell as defined by lambda function.
 
template<typename Lambda >
void forEach (Lambda forEachLambda, IteratorBehavior behavior)
 Executes code for every particle in this cell as defined by lambda function.
 
template<typename Lambda >
void forEach (Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior)
 Executes code for every particle in this cell as defined by lambda function.
 
template<typename Lambda , typename A >
void reduce (Lambda reduceLambda, A &result)
 Reduce properties of particles as defined by a lambda function.
 
template<typename Lambda , typename A >
void reduce (Lambda reduceLambda, A &result, IteratorBehavior behavior)
 Reduce properties of particles as defined by a lambda function.
 
template<typename Lambda , typename A >
void reduce (Lambda reduceLambda, A &result, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior)
 Reduce properties of particles as defined by a lambda function.
 
size_t size () const override
 Get the number of all particles stored in this cell (owned, halo and dummy).
 
size_t getNumberOfParticles (IteratorBehavior behavior) const override
 Get the number of particles with respect to the specified IteratorBehavior.
 
Particle_T & operator[] (size_t n)
 Returns a reference to the element at position n in the cell.
 
const Particle_T & operator[] (size_t n) const
 Returns a const reference to the element at position n in the cell.
 
Particle_T & at (size_t index)
 Returns the particle at position index.
 
CellType getParticleCellTypeAsEnum () override
 Get the ParticleCell type as an ParticleCellTypeEnum.
 
const Particle_T & at (size_t index) const
 Returns the const particle at position index.
 
bool isEmpty () const override
 Check if the cell is empty.
 
void clear () override
 Deletes all particles in this cell.
 
void deleteDummyParticles () override
 Deletes all dummy particles in this cell.
 
void deleteByIndex (size_t index) override
 Deletes the index-th particle.
 
void setCellLength (std::array< double, 3 > &cellLength) override
 Set the side lengths of this cell.
 
std::array< double, 3 > getCellLength () const override
 Get the side lengths of this cell.
 
void resize (size_t n, const Particle_T &toInsert)
 Resizes the container so that it contains n elements.
 
void sortByDim (const size_t dim)
 Sort the particles in the cell by a dimension.
 
void reserve (size_t n)
 Requests that the vector capacity be at least enough to contain n elements.
 
- Public Member Functions inherited from autopas::ParticleCell< Particle_T >
virtual ~ParticleCell ()=default
 Default destructor.
 
 ParticleCell ()=default
 Default default constructor.
 
 ParticleCell (ParticleCell &&other) noexcept=default
 Default move constructor.
 
 ParticleCell (const ParticleCell &other)
 Copy constructor that creates a new default constructed lock for the new cell.
 
virtual void addParticle (const Particle_T &p)=0
 Adds a Particle to the cell.
 
virtual size_t size () const =0
 Get the number of all particles stored in this cell (owned, halo and dummy).
 
virtual size_t getNumberOfParticles (IteratorBehavior behavior=IteratorBehavior::owned) const =0
 Get the number of particles with respect to the specified IteratorBehavior.
 
virtual bool isEmpty () const =0
 Check if the cell is empty.
 
virtual void clear ()=0
 Deletes all particles in this cell.
 
virtual void deleteDummyParticles ()=0
 Deletes all dummy particles in this cell.
 
virtual CellType getParticleCellTypeAsEnum ()=0
 Get the ParticleCell type as an ParticleCellTypeEnum.
 
virtual void deleteByIndex (size_t index)=0
 Deletes the index-th particle.
 
virtual void setCellLength (std::array< double, 3 > &cellLength)=0
 Set the side lengths of this cell.
 
virtual std::array< double, 3 > getCellLength () const =0
 Get the side lengths of this cell.
 
OwnershipState getPossibleParticleOwnerships () const
 Get the type of particles contained in this cell.
 
void setPossibleParticleOwnerships (OwnershipState state)
 Set the type of particles contained in this cell.
 
AutoPasLockgetCellLock () const
 Get a reference to the lock object for exclusive access to this cell.
 

Additional Inherited Members

- Public Attributes inherited from autopas::FullParticleCell< Particle_T >
StorageType _particles {}
 Storage of the molecules of the cell.
 
SoA< SoAArraysType_particleSoABuffer {}
 SoA buffer of this cell.
 
- Protected Attributes inherited from autopas::ParticleCell< Particle_T >
AutoPasLock _cellLock {}
 Lock object for exclusive access to this cell.
 
OwnershipState _ownershipState {autopas::OwnershipState::owned | autopas::OwnershipState::halo}
 The particles which can be contained in this cell are determined by the OwnershipState.
 
bool _ownershipStateDefined {false}
 Flag that is set to true once OwnershipState has been set to avoid resetting the OwnershipState.
 

Detailed Description

template<class Particle_T>
class autopas::internal::ClusterTower< Particle_T >

This class represents one tower for clusters in the VerletClusterLists container.

A ClusterTower contains multiple clusters that are stacked on top (z-direction) of each other. It saves all particles in a FullParticleCell, provides methods to generate and work on the clusters contained, and handles the generation of dummy particles to make sure that each cluster is full.

Only the last cluster of the ClusterTower is filled up with dummy particles, since all others are guaranteed to already be full.

To use this container:

  1. Use addParticle() to add all particles you want.
  2. Then call generateClusters(). This copies the last particle as often as it is necessary to fill up the last cluster. (maximum clusterSize-1 times).
  3. Generate your neighbor lists somehow.
  4. Call setDummyValues() to replace the copies of the last particle made in generateClusters() with dummies.

If you want to add more particles after calling generateClusters(), definitely make sure to call clear() before calling addParticle() again, since doing otherwise will mess up the dummy particles and actual particles will likely get lost.

Template Parameters
Particle_T
clusterSize

Constructor & Destructor Documentation

◆ ClusterTower()

template<class Particle_T >
autopas::internal::ClusterTower< Particle_T >::ClusterTower ( size_t  clusterSize)
inlineexplicit

Constructor.

Parameters
clusterSizeof all clusters in this tower.

Member Function Documentation

◆ clear()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::clear ( )
inlineoverridevirtual

Clears all particles from the tower and resets it to be ready for new particles.

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ collectAllActualParticles()

template<class Particle_T >
std::vector< Particle_T > && autopas::internal::ClusterTower< Particle_T >::collectAllActualParticles ( )
inline

Returns a rvalue reference to a std::vector containing all particles of this tower that are not dummies.

clear() has to called afterwards!

Returns

◆ collectOutOfBoundsParticles()

template<class Particle_T >
std::vector< Particle_T > autopas::internal::ClusterTower< Particle_T >::collectOutOfBoundsParticles ( const std::array< double, 3 > &  boxMin,
const std::array< double, 3 > &  boxMax 
)
inline

Collect all particles that should not be in this tower based on their current position.

The particles are deleted from the tower.

Note
also deletes dummies.
Parameters
boxMin
boxMax
Returns
Vector of particles that should be stored somewhere else.

◆ deleteByIndex()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::deleteByIndex ( size_t  index)
inlineoverridevirtual

Deletes the index-th particle.

Parameters
indexthe index of the particle that shall be deleted
Note
The implementation of this function prevents a regionIterator to make sorted assumptions of particles inside a cell! supporting this would mean that the deleted particle should be swapped to the end of the valid particles. See also https://github.com/AutoPas/AutoPas/issues/435

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ deleteDummyParticles()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::deleteDummyParticles ( )
inlineoverridevirtual

Deletes all dummy particles in this cell.

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ extractSoA()

template<class Particle_T >
template<class Functor >
void autopas::internal::ClusterTower< Particle_T >::extractSoA ( Functor functor)
inline

Extracts the SoA into the particles/clusters.

Template Parameters
FunctorThe type of the functor to use.
Parameters
functorThe functor to use for extracting the SoA into the particles/clusters.

◆ generateClusters()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::generateClusters ( )
inline

Generates the clusters for the particles in this cluster tower.

Copies the last particle as often as necessary to fill up the last cluster. This makes sure that iteration over clusters already works after this, while the bounding box of the last cluster is also not messed up by dummy particles. This is necessary for rebuilding the neighbor lists.

Returns
Returns the number of clusters in the tower.

◆ getCellLength()

template<class Particle_T >
std::array< double, 3 > autopas::internal::ClusterTower< Particle_T >::getCellLength ( ) const
inlineoverridevirtual

Get the side lengths of this cell.

Returns
cell side length

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ getCluster() [1/2]

template<class Particle_T >
auto & autopas::internal::ClusterTower< Particle_T >::getCluster ( size_t  index)
inline

Returns the cluster at position index.

Parameters
indexThe index of the cluster to return.
Returns
the cluster at position index.

◆ getCluster() [2/2]

template<class Particle_T >
auto & autopas::internal::ClusterTower< Particle_T >::getCluster ( size_t  index) const
inline

Returns the cluster at position index.

Parameters
indexThe index of the cluster to return.
Returns
the cluster at position index.

◆ getClusters()

template<class Particle_T >
auto & autopas::internal::ClusterTower< Particle_T >::getClusters ( )
inline

Returns a reference to the std::vector holding the clusters of this container.

Returns
a reference to the std::vector holding the clusters of this container.

◆ getClusterSize()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::getClusterSize ( ) const
inline

Get cluster size.

Returns

◆ getFirstOwnedCluster()

template<class Particle_T >
const std::vector< autopas::internal::Cluster< Particle_T > >::iterator & autopas::internal::ClusterTower< Particle_T >::getFirstOwnedCluster ( ) const
inline

Returns an iterator to the first cluster that contains at least one owned particle.

Returns

◆ getFirstOwnedClusterIndex()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::getFirstOwnedClusterIndex ( ) const
inline

Returns the index of the first cluster that contains at least one owned particle.

Returns

◆ getFirstTailHaloCluster()

template<class Particle_T >
const std::vector< autopas::internal::Cluster< Particle_T > >::iterator & autopas::internal::ClusterTower< Particle_T >::getFirstTailHaloCluster ( ) const
inline

Returns an iterator to the first particle after the owned clusters, that contains no owned particles anymore.

Returns

◆ getFirstTailHaloClusterIndex()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::getFirstTailHaloClusterIndex ( ) const
inline

Returns the index of the first particle after the owned clusters, that contains no owned particles anymore.

Returns

◆ getNumActualParticles()

template<class Particle_T >
unsigned long autopas::internal::ClusterTower< Particle_T >::getNumActualParticles ( ) const
inline

Get the number of all particles saved in the tower without tailing dummies that are used to fill up clusters (owned + halo + dummies excluding tailing dummies).

Returns

◆ getNumClusters()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::getNumClusters ( ) const
inline

Returns the number of clusters in the tower.

Returns
the number of clusters in the tower.

◆ getNumTailDummyParticles()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::getNumTailDummyParticles ( ) const
inline

Returns the number of dummy particles in the tower that were inserted in the tower to fill the last cluster.

Returns
.

◆ getParticleCellTypeAsEnum()

template<class Particle_T >
CellType autopas::internal::ClusterTower< Particle_T >::getParticleCellTypeAsEnum ( )
inlineoverridevirtual

Get the ParticleCell type as an ParticleCellTypeEnum.

Returns
The Cell type as an Enum

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ isEmpty()

template<class Particle_T >
bool autopas::internal::ClusterTower< Particle_T >::isEmpty ( ) const
inlineoverridevirtual

Check if the cell is empty.

Returns
true if no particles are stored in this cell.

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ loadSoA()

template<class Particle_T >
template<class Functor >
void autopas::internal::ClusterTower< Particle_T >::loadSoA ( Functor functor)
inline

Loads the particles into the SoA stored in this tower and generates the SoAView for each cluster.

Template Parameters
FunctorThe type of the functor to use.
Parameters
functorThe functor to use for loading the particles into the SoA.

◆ particleVector()

template<class Particle_T >
StorageType & autopas::internal::ClusterTower< Particle_T >::particleVector ( )
inline

Get reference to internal particle vector.

Returns

◆ setCellLength()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::setCellLength ( std::array< double, 3 > &  cellLength)
inlineoverridevirtual

Set the side lengths of this cell.

Parameters
cellLengthcell side length

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ setClusterSize()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::setClusterSize ( size_t  clusterSize)
inline

Set cluster size.

Parameters
clusterSize

◆ setDummyParticlesToLastActualParticle()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::setDummyParticlesToLastActualParticle ( )
inline

More or less inverse operation of setDummyValues().

It sets the positions of the dummy particles to the position of the last actual particle in the tower.

◆ setDummyValues()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::setDummyValues ( double  dummyStartX,
double  dummyDistZ 
)
inline

Replaces the copies of the last particle made in generateClusters() with dummies.

Dummy particles have ID std::numeric_limits<size_t>::max().

Parameters
dummyStartXThe x-coordinate for all dummies.
dummyDistZThe distance in z-direction that all generated dummies will have from each other.

◆ setParticleDeletionObserver()

template<class Particle_T >
void autopas::internal::ClusterTower< Particle_T >::setParticleDeletionObserver ( internal::ParticleDeletedObserver observer)
inline

Set the ParticleDeletionObserver, which is called, when a particle is deleted.

Parameters
observer

◆ size()

template<class Particle_T >
size_t autopas::internal::ClusterTower< Particle_T >::size ( ) const
inlineoverridevirtual

Get the number of all particles stored in this tower (owned, halo and dummy).

Returns
number of particles stored in this tower (owned, halo and dummy).

Reimplemented from autopas::FullParticleCell< Particle_T >.


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