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

This class handles the storage of particles in their full form. More...

#include <FullParticleCell.h>

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

Public Types

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

 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.
 

Public Attributes

StorageType _particles {}
 Storage of the molecules of the cell.
 
SoA< SoAArraysType_particleSoABuffer {}
 SoA buffer of this cell.
 

Additional Inherited Members

- 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::FullParticleCell< Particle_T >

This class handles the storage of particles in their full form.

Template Parameters
Particle_T

Constructor & Destructor Documentation

◆ FullParticleCell()

template<class Particle_T >
autopas::FullParticleCell< Particle_T >::FullParticleCell ( const std::array< double, 3 > &  cellLength)
inlineexplicit

Constructs a new FullParticleCell with the given cell side length.

Parameters
cellLengthcell side length

Member Function Documentation

◆ addParticle()

template<class Particle_T >
void autopas::FullParticleCell< Particle_T >::addParticle ( const Particle_T &  p)
inlineoverridevirtual

Adds a Particle to the cell.

Parameters
pthe particle to be added

Implements autopas::ParticleCell< Particle_T >.

◆ at() [1/2]

template<class Particle_T >
Particle_T & autopas::FullParticleCell< Particle_T >::at ( size_t  index)
inline

Returns the particle at position index.

Needed by SingleCellIterator.

Parameters
indexthe position of the particle to return.
Returns
the particle at position index.

◆ at() [2/2]

template<class Particle_T >
const Particle_T & autopas::FullParticleCell< Particle_T >::at ( size_t  index) const
inline

Returns the const particle at position index.

Needed by SingleCellIterator.

Parameters
indexthe position of the particle to return.
Returns
the particle at position index.

◆ begin() [1/2]

template<class Particle_T >
CellIterator< StorageType, true > autopas::FullParticleCell< Particle_T >::begin ( )
inline

Get an iterator to the start of a ParticleCell.

normal use: for(auto iter = cell.begin(); iter.isValid; ++iter){...}

Returns
the iterator

◆ begin() [2/2]

template<class Particle_T >
CellIterator< StorageType, false > autopas::FullParticleCell< Particle_T >::begin ( ) const
inline

Get an iterator to the start of a ParticleCell.

normal use: for(auto iter = cell.begin(); iter.isValid; ++iter){...}

Returns
the iterator
Note
const version

◆ clear()

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

Deletes all particles in this cell.

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ deleteByIndex()

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

Deletes the index-th particle.

Parameters
indexthe index of the particle that shall be deleted

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ deleteDummyParticles()

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

Deletes all dummy particles in this cell.

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ end() [1/2]

template<class Particle_T >
CellIterator< StorageType, true > autopas::FullParticleCell< Particle_T >::end ( )
inline

Get an iterator to the end of a ParticleCell.

normal use: for(auto &p : cell){...}

Returns
the iterator

◆ end() [2/2]

template<class Particle_T >
CellIterator< StorageType, false > autopas::FullParticleCell< Particle_T >::end ( ) const
inline

Get an iterator to the end of a ParticleCell.

normal use: for(auto &p : cell){...}

Returns
the iterator
Note
const version

◆ forEach() [1/3]

template<class Particle_T >
template<typename Lambda >
void autopas::FullParticleCell< Particle_T >::forEach ( Lambda  forEachLambda)
inline

Executes code for every particle in this cell as defined by lambda function.

Template Parameters
Lambda(Particle_T &p) -> void
Parameters
forEachLambdacode to be executed on particles

◆ forEach() [2/3]

template<class Particle_T >
template<typename Lambda >
void autopas::FullParticleCell< Particle_T >::forEach ( Lambda  forEachLambda,
const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  higherCorner,
IteratorBehavior  behavior 
)
inline

Executes code for every particle in this cell as defined by lambda function.

Template Parameters
Lambda(Particle_T &p) -> void
Parameters
forEachLambdacode to be executed on particles
lowerCornerlower corner of bounding box
higherCornerhigher corner of bounding box
behaviorownerships of particles that should be in-/excluded

◆ forEach() [3/3]

template<class Particle_T >
template<typename Lambda >
void autopas::FullParticleCell< Particle_T >::forEach ( Lambda  forEachLambda,
IteratorBehavior  behavior 
)
inline

Executes code for every particle in this cell as defined by lambda function.

Template Parameters
Lambda(Particle_T &p) -> void
Parameters
forEachLambdacode to be executed on particles
behaviorownerships of particles that should be in-/excluded

◆ getCellLength()

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

Get the side lengths of this cell.

Returns
cell side length

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ getNumberOfParticles()

template<class Particle_T >
size_t autopas::FullParticleCell< Particle_T >::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::ParticleCell< Particle_T >.

Reimplemented in autopas::OctreeLeafNode< Particle_T >.

◆ getParticleCellTypeAsEnum()

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

Get the ParticleCell type as an ParticleCellTypeEnum.

Returns
The Cell type as an Enum

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ isEmpty()

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

Check if the cell is empty.

Returns
true if no particles are stored in this cell.

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ operator[]() [1/2]

template<class Particle_T >
Particle_T & autopas::FullParticleCell< Particle_T >::operator[] ( size_t  n)
inline

Returns a reference to the element at position n in the cell.

Parameters
nPosition of an element in the container
Returns
Reference to the element

◆ operator[]() [2/2]

template<class Particle_T >
const Particle_T & autopas::FullParticleCell< Particle_T >::operator[] ( size_t  n) const
inline

Returns a const reference to the element at position n in the cell.

Parameters
nPosition of an element in the container
Returns
Reference to the element

◆ reduce() [1/3]

template<class Particle_T >
template<typename Lambda , typename A >
void autopas::FullParticleCell< Particle_T >::reduce ( Lambda  reduceLambda,
A &  result 
)
inline

Reduce properties of particles as defined by a lambda function.

Template Parameters
Lambda(Particle_T p, A initialValue) -> void
Atype of particle attribute to be reduced
Parameters
reduceLambdacode to reduce properties of particles
resultreference to result of type A

◆ reduce() [2/3]

template<class Particle_T >
template<typename Lambda , typename A >
void autopas::FullParticleCell< Particle_T >::reduce ( Lambda  reduceLambda,
A &  result,
const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  higherCorner,
IteratorBehavior  behavior 
)
inline

Reduce properties of particles as defined by a lambda function.

Template Parameters
Lambda(Particle_T p, A initialValue) -> void
Atype of particle attribute to be reduced
Parameters
reduceLambdacode to reduce properties of particles
resultreference to result of type A
lowerCornerlower corner of bounding box
higherCornerhigher corner of bounding box
behaviorownerships of particles that should be in-/excluded

◆ reduce() [3/3]

template<class Particle_T >
template<typename Lambda , typename A >
void autopas::FullParticleCell< Particle_T >::reduce ( Lambda  reduceLambda,
A &  result,
IteratorBehavior  behavior 
)
inline

Reduce properties of particles as defined by a lambda function.

Template Parameters
Lambda(Particle_T p, A initialValue) -> void
Atype of particle attribute to be reduced
Parameters
reduceLambdacode to reduce properties of particles
resultreference to result of type A
behaviorownerships of particles that should be in-/excluded

◆ reserve()

template<class Particle_T >
void autopas::FullParticleCell< Particle_T >::reserve ( size_t  n)
inline

Requests that the vector capacity be at least enough to contain n elements.

Parameters
nMinimum capacity for the vector.

◆ resize()

template<class Particle_T >
void autopas::FullParticleCell< Particle_T >::resize ( size_t  n,
const Particle_T &  toInsert 
)
inline

Resizes the container so that it contains n elements.

Parameters
nNew container size
toInsertParticle to insert. This is needed to allow for non-default-constructible particles.

◆ setCellLength()

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

Set the side lengths of this cell.

Parameters
cellLengthcell side length

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::internal::ClusterTower< Particle_T >.

◆ size()

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

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

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

Implements autopas::ParticleCell< Particle_T >.

Reimplemented in autopas::OctreeLeafNode< Particle_T >, and autopas::internal::ClusterTower< Particle_T >.

◆ sortByDim()

template<class Particle_T >
void autopas::FullParticleCell< Particle_T >::sortByDim ( const size_t  dim)
inline

Sort the particles in the cell by a dimension.

Parameters
dimdimension to sort

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