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

This class defines a sorted view on a given ParticleCell. More...

#include <SortedCellView.h>

Inheritance diagram for autopas::SortedCellView< ParticleCellType >:
Inheritance graph
[legend]
Collaboration diagram for autopas::SortedCellView< ParticleCellType >:
Collaboration graph
[legend]

Public Types

using ParticleType = typename ParticleCellType::ParticleType
 The particle type for this view is the particle type from the cell.
 
using StorageType = std::vector< ParticleType * >
 Type that holds or refers to the actual particles.
 
- Public Types inherited from autopas::ParticleCell< ParticleCellType::ParticleType >
using ParticleType = ParticleCellType::ParticleType
 The particle type for this cell.
 

Public Member Functions

 SortedCellView (ParticleCellType &cell, const std::array< double, 3 > &r)
 Constructs a FullSortedParticleCell.
 
CellType getParticleCellTypeAsEnum () override
 Get the ParticleCell type as an ParticleCellTypeEnum.
 
void addParticle (const ParticleType &p) override
 Adds a Particle to the cell.
 
CellIterator< typename ParticleCellType::StorageType, true > begin ()
 Get an iterator to the start of a ParticleCell.
 
CellIterator< typename ParticleCellType::StorageType, false > begin () const
 Get an iterator to the start of a ParticleCell.
 
CellIterator< typename ParticleCellType::StorageType, true > end ()
 Get an iterator to the end of a ParticleCell.
 
CellIterator< typename ParticleCellType::StorageType, false > end () const
 Get an iterator to the end of a ParticleCell.
 
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.
 
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.
 
ParticleTypeat (size_t index)
 Returns the particle at position index.
 
const ParticleTypeat (size_t index) const
 Returns the const particle at position index.
 
- Public Member Functions inherited from autopas::ParticleCell< ParticleCellType::ParticleType >
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 ParticleCellType::ParticleType &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

std::vector< std::pair< double, ParticleType * > > _particles
 Sorted vector of projected positions and particle pointers.
 
ParticleCellType * _cell
 Underlying cell.
 

Additional Inherited Members

- Protected Attributes inherited from autopas::ParticleCell< ParticleCellType::ParticleType >
AutoPasLock _cellLock
 Lock object for exclusive access to this cell.
 
OwnershipState _ownershipState
 The particles which can be contained in this cell are determined by the OwnershipState.
 
bool _ownershipStateDefined
 Flag that is set to true once OwnershipState has been set to avoid resetting the OwnershipState.
 

Detailed Description

template<class ParticleCellType>
class autopas::SortedCellView< ParticleCellType >

This class defines a sorted view on a given ParticleCell.

Particles are sorted along the normalized vector r.

Projection of particles in 2D

The projected position of a particle as well as a pointer to the underlying particle are stored in a vector, which is sorted by the projected positions.

Note
Insertion, deletion and change of position of particles invalidates the view.
Template Parameters
ParticleCellType

Constructor & Destructor Documentation

◆ SortedCellView()

template<class ParticleCellType >
autopas::SortedCellView< ParticleCellType >::SortedCellView ( ParticleCellType &  cell,
const std::array< double, 3 > &  r 
)
inline

Constructs a FullSortedParticleCell.

Parameters
cellCell whose particles are sorted.
rNormalized vector along particles are sorted.

Member Function Documentation

◆ addParticle()

template<class ParticleCellType >
void autopas::SortedCellView< ParticleCellType >::addParticle ( const ParticleType p)
inlineoverridevirtual

Adds a Particle to the cell.

Parameters
pthe particle to be added

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

◆ at() [1/2]

template<class ParticleCellType >
ParticleType & autopas::SortedCellView< ParticleCellType >::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 ParticleCellType >
const ParticleType & autopas::SortedCellView< ParticleCellType >::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 ParticleCellType >
CellIterator< typename ParticleCellType::StorageType, true > autopas::SortedCellView< ParticleCellType >::begin ( )
inline

Get an iterator to the start of a ParticleCell.

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

Returns
the iterator
Note
: iterating via begin / iterators does not yield the sorted order.

◆ begin() [2/2]

template<class ParticleCellType >
CellIterator< typename ParticleCellType::StorageType, false > autopas::SortedCellView< ParticleCellType >::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
: iterating via begin / iterators does not yield the sorted order.
const version

◆ clear()

template<class ParticleCellType >
void autopas::SortedCellView< ParticleCellType >::clear ( )
inlineoverridevirtual

Deletes all particles in this cell.

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

◆ deleteByIndex()

template<class ParticleCellType >
void autopas::SortedCellView< ParticleCellType >::deleteByIndex ( size_t  index)
inlineoverridevirtual

Deletes the index-th particle.

Parameters
indexthe index of the particle that shall be deleted

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

◆ deleteDummyParticles()

template<class ParticleCellType >
void autopas::SortedCellView< ParticleCellType >::deleteDummyParticles ( )
inlineoverridevirtual

Deletes all dummy particles in this cell.

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

◆ end() [1/2]

template<class ParticleCellType >
CellIterator< typename ParticleCellType::StorageType, true > autopas::SortedCellView< ParticleCellType >::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 ParticleCellType >
CellIterator< typename ParticleCellType::StorageType, false > autopas::SortedCellView< ParticleCellType >::end ( ) const
inline

Get an iterator to the end of a ParticleCell.

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

Returns
the iterator
Note
const version

◆ getCellLength()

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

Get the side lengths of this cell.

Returns
cell side length

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

◆ getNumberOfParticles()

template<class ParticleCellType >
size_t autopas::SortedCellView< ParticleCellType >::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< ParticleCellType::ParticleType >.

◆ getParticleCellTypeAsEnum()

template<class ParticleCellType >
CellType autopas::SortedCellView< ParticleCellType >::getParticleCellTypeAsEnum ( )
inlineoverridevirtual

Get the ParticleCell type as an ParticleCellTypeEnum.

Returns
The Cell type as an Enum

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

◆ isEmpty()

template<class ParticleCellType >
bool autopas::SortedCellView< ParticleCellType >::isEmpty ( ) const
inlineoverridevirtual

Check if the cell is empty.

Returns
true if no particles are stored in this cell.

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

◆ setCellLength()

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

Set the side lengths of this cell.

Parameters
cellLengthcell side length

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

◆ size()

template<class ParticleCellType >
size_t autopas::SortedCellView< ParticleCellType >::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< ParticleCellType::ParticleType >.


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