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

The octree is a CellBasedParticleContainer that consists internally of two octrees. More...

#include <Octree.h>

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

Public Types

enum  CellTypes : int { OWNED = 0 , HALO = 1 }
 This particle container contains two cells. More...
 
using ParticleCell = OctreeNodeWrapper< Particle_T >
 The particle cell used in this CellBasedParticleContainer.
 
using ParticleType = typename ParticleCell::ParticleType
 The particle type used in this container.
 
- Public Types inherited from autopas::ParticleContainerInterface< ParticleCell::ParticleType >
using ParticleType = ParticleCell::ParticleType
 Type of the Particle.
 
- Public Types inherited from autopas::internal::CellBorderAndFlagManager
using index_t = std::size_t
 The index type to access the particle cells.
 

Public Member Functions

 Octree (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, const double cutoff, const double skin, const unsigned int rebuildFrequency, const double cellSizeFactor)
 Construct a new octree with two sub-octrees: One for the owned particles and one for the halo particles.
 
std::vector< ParticleTypeupdateContainer (bool keepNeighborListValid) override
 Updates the container.
 
void computeInteractions (TraversalInterface *traversal) override
 Iterates over all particle multiples (e.g.
 
ContainerOption getContainerType () const override
 Get the ContainerType.
 
CellType getParticleCellTypeEnum () const override
 Get the ParticleCell type as an Enum.
 
void reserve (size_t numParticles, size_t numParticlesHaloEstimate) override
 Reserve memory for a given number of particles in the container and logic layers.
 
void addParticleImpl (const ParticleType &p) override
 Adds a particle to the container.
 
void addHaloParticleImpl (const ParticleType &haloParticle) override
 Adds a particle to the container that lies in the halo region of the container.
 
bool updateHaloParticle (const ParticleType &haloParticle) override
 Update a halo particle of the container with the given haloParticle.
 
void rebuildNeighborLists (TraversalInterface *traversal) override
 Rebuilds the neighbor lists for the next traversals.
 
std::tuple< const Particle_T *, 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 override
 Fetch the pointer to a particle, identified via a cell and particle index.
 
std::tuple< const Particle_T *, size_t, size_t > getParticle (size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior) const override
 Fetch the pointer to a particle, identified via a cell and particle index.
 
template<bool regionIter>
std::tuple< const ParticleType *, size_t, size_t > getParticleImpl (size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior, const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax) const
 Container specific implementation for getParticle.
 
std::tuple< std::vector< size_t >, OctreeLeafNode< Particle_T > * > getLeafCellByIndex (size_t cellIndex) const
 Helper function to retrieve the pointer to a leaf cell as well as properly parse the cell index.
 
bool deleteParticle (Particle_T &particle) override
 Deletes the given particle as long as this does not compromise the validity of the container.
 
bool deleteParticle (size_t cellIndex, size_t particleIndex) override
 Deletes the particle at the given index positions as long as this does not compromise the validity of the container.
 
ContainerIterator< Particle_T, true, false > begin (IteratorBehavior behavior, typename ContainerIterator< Particle_T, true, false >::ParticleVecType *additionalVectors=nullptr) override
 Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
 
ContainerIterator< Particle_T, false, false > begin (IteratorBehavior behavior, typename ContainerIterator< Particle_T, false, false >::ParticleVecType *additionalVectors=nullptr) const override
 Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
 
ContainerIterator< Particle_T, true, true > getRegionIterator (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< Particle_T, true, true >::ParticleVecType *additionalVectors=nullptr) override
 Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorner, highCorner);iter.isValid();++iter) .
 
ContainerIterator< Particle_T, false, true > getRegionIterator (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< Particle_T, false, true >::ParticleVecType *additionalVectors=nullptr) const override
 Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorner, highCorner);iter.isValid();++iter) .
 
TraversalSelectorInfo getTraversalSelectorInfo () const override
 Generates a traversal selector info for this container.
 
size_t size () const override
 Get the total number of particles saved in the container (owned + halo + dummy).
 
size_t getNumberOfParticles (IteratorBehavior behavior) const override
 Get the number of particles with respect to the specified IteratorBehavior.
 
void deleteHaloParticles () override
 Deletes all halo particles.
 
bool cellCanContainHaloParticles (std::size_t i) const override
 Checks if the cell with the one-dimensional index index1d can contain halo particles.
 
bool cellCanContainOwnedParticles (std::size_t i) const override
 Checks if the cell with the one-dimensional index index1d can contain owned particles.
 
template<typename Lambda >
void forEach (Lambda forEachLambda, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
 Execute code on all particles in this container as defined by a lambda function.
 
template<typename Lambda , typename A >
void reduce (Lambda reduceLambda, A &result, IteratorBehavior behavior=IteratorBehavior::ownedOrHalo)
 Reduce properties of particles as defined by a lambda function.
 
template<typename Lambda >
void forEachInRegion (Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior)
 Execute code on all particles in this container in a certain region as defined by a lambda function.
 
template<typename Lambda , typename A >
void reduceInRegion (Lambda reduceLambda, A &result, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior)
 Execute code on all particles in this container in a certain region as defined by a lambda function.
 
- Public Member Functions inherited from autopas::CellBasedParticleContainer< OctreeNodeWrapper< Particle_T > >
 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 (const CellBasedParticleContainer &obj)=delete
 Delete the copy constructor to prevent unwanted copies.
 
 ~CellBasedParticleContainer () override=default
 Destructor of CellBasedParticleContainer.
 
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< OctreeNodeWrapper< Particle_T > > & 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.
 
- Public Member Functions inherited from autopas::internal::CellBorderAndFlagManager
virtual ~CellBorderAndFlagManager ()=default
 Cestructor.
 
virtual bool cellCanContainHaloParticles (index_t index1d) const =0
 Checks if the cell with the one-dimensional index index1d can contain halo particles.
 
virtual bool cellCanContainOwnedParticles (index_t index1d) const =0
 Checks if the cell with the one-dimensional index index1d can contain owned particles.
 
bool ignoreCellForIteration (index_t index1d, IteratorBehavior behavior) const
 Checks if cell with index1d can be ignored for iteration with currently selected behavior.
 

Static Public Attributes

static constexpr size_t invalidCellIndex = 9
 A cell index that is definitely always invalid.
 

Additional Inherited Members

- 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.
 
- Protected Attributes inherited from autopas::CellBasedParticleContainer< OctreeNodeWrapper< Particle_T > >
std::vector< OctreeNodeWrapper< Particle_T > > _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.
 

Detailed Description

template<class Particle_T>
class autopas::Octree< Particle_T >

The octree is a CellBasedParticleContainer that consists internally of two octrees.

One for owned and one for halo particles. It abuses the CellBasedParticleContainer::_cell vector to hold the root nodes for each.

The tree consists of OctreeNodeWrapper objects, which

Note
Octree has a particular to interpret the index of the ContainerIterator. For details see getParticleImpl().
Template Parameters
Particle_T

Member Enumeration Documentation

◆ CellTypes

template<class Particle_T >
enum autopas::Octree::CellTypes : int

This particle container contains two cells.

Both cells are octrees.

  • this->_cells[CellTypes::OWNED] yields the octree that contains all owned particles
  • this->_cells[CellTypes::HALO] yields the octree that contains all halo particles

Constructor & Destructor Documentation

◆ Octree()

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

Construct a new octree with two sub-octrees: One for the owned particles and one for the halo particles.

Parameters
boxMinThe minimum coordinate of the enclosing box
boxMaxThe maximum coordinate of the enclosing box
cutoffThe cutoff radius
skinThe skin radius
rebuildFrequencyThe Rebuild Frequency
cellSizeFactorThe cell size factor

Member Function Documentation

◆ addHaloParticleImpl()

template<class Particle_T >
void autopas::Octree< Particle_T >::addHaloParticleImpl ( const ParticleType haloParticle)
inlineoverride

Adds a particle to the container that lies in the halo region of the container.

This is an unsafe version of addParticle() and does not perform a boundary check.

Parameters
haloParticleParticle to be added. This particle is already checked to be outside of the bounding box.
Note
Only call this function if the position of the particle is guaranteed to be outside of the bounding box!

◆ addParticleImpl()

template<class Particle_T >
void autopas::Octree< Particle_T >::addParticleImpl ( const ParticleType p)
inlineoverride

Adds a particle to the container.

This is an unsafe version of addParticle() and does not perform a boundary check.

Parameters
pThe particle to be added. This particle is already checked to be inside of the bounding box.
Note
Only call this function if the position of the particle is guaranteed to be inside of the bounding box!

◆ begin() [1/2]

template<class Particle_T >
ContainerIterator< Particle_T, false, false > autopas::Octree< Particle_T >::begin ( IteratorBehavior  behavior,
typename ContainerIterator< Particle_T, false, false >::ParticleVecType *  additionalVectors = nullptr 
) const
inlineoverridevirtual

Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .

Note
The default argument for behavior is necessary to enable range based for loops.
Parameters
behaviorBehavior of the iterator, see IteratorBehavior.
additionalVectorsVectors that should be included besides the container.
Returns
Iterator to the first particle.

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

◆ begin() [2/2]

template<class Particle_T >
ContainerIterator< Particle_T, true, false > autopas::Octree< Particle_T >::begin ( IteratorBehavior  behavior,
typename ContainerIterator< Particle_T, true, false >::ParticleVecType *  additionalVectors = nullptr 
)
inlineoverridevirtual

Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .

Note
The default argument for behavior is necessary to enable range based for loops.
Parameters
behaviorBehavior of the iterator, see IteratorBehavior.
additionalVectorsVectors that should be included besides the container.
Returns
Iterator to the first particle.

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

◆ cellCanContainHaloParticles()

template<class Particle_T >
bool autopas::Octree< Particle_T >::cellCanContainHaloParticles ( std::size_t  index1d) const
inlineoverridevirtual

Checks if the cell with the one-dimensional index index1d can contain halo particles.

Parameters
index1dthe one-dimensional index of the cell that should be checked
Returns
true if the cell can contain halo particles

Implements autopas::internal::CellBorderAndFlagManager.

◆ cellCanContainOwnedParticles()

template<class Particle_T >
bool autopas::Octree< Particle_T >::cellCanContainOwnedParticles ( std::size_t  index1d) const
inlineoverridevirtual

Checks if the cell with the one-dimensional index index1d can contain owned particles.

Parameters
index1dthe one-dimensional index of the cell that should be checked
Returns
true if the cell can contain owned particles

Implements autopas::internal::CellBorderAndFlagManager.

◆ computeInteractions()

template<class Particle_T >
void autopas::Octree< Particle_T >::computeInteractions ( TraversalInterface traversal)
inlineoverridevirtual

Iterates over all particle multiples (e.g.

pairs, triplets) in the container using the given traversal.

Parameters
traversalThe traversal to use for the iteration.

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

◆ deleteHaloParticles()

template<class Particle_T >
void autopas::Octree< Particle_T >::deleteHaloParticles ( )
inlineoverridevirtual

◆ deleteParticle() [1/2]

template<class Particle_T >
bool autopas::Octree< Particle_T >::deleteParticle ( Particle_T &  particle)
inlineoverridevirtual

Deletes the given particle as long as this does not compromise the validity of the container.

If this is not possible the particle is just marked as deleted.

Note
This function might be implemented via swap-delete and is thus not completely thread safe.
Parameters
particleReference to the particle that is to be deleted.
Returns
True if the given pointer still points to a new particle.

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

◆ deleteParticle() [2/2]

template<class Particle_T >
bool autopas::Octree< Particle_T >::deleteParticle ( size_t  cellIndex,
size_t  particleIndex 
)
inlineoverridevirtual

Deletes the particle at the given index positions as long as this does not compromise the validity of the container.

If this is not possible the particle is just marked as deleted. If the positions do not exist the behavior is undefined.

Parameters
cellIndex
particleIndex
Returns
True if the given indices still point to a new particle.

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

◆ forEach()

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

Execute code on all particles in this container as defined by a lambda function.

Template Parameters
Lambda(Particle_T &p) -> void
Parameters
forEachLambdacode to be executed on all particles
behavior
See also
IteratorBehavior

◆ forEachInRegion()

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

Execute code on all particles in this container in a certain region as defined by a lambda function.

Template Parameters
Lambda(Particle_T &p) -> void
Parameters
forEachLambdacode to be executed on all particles
lowerCornerlower corner of bounding box
higherCornerhigher corner of bounding box
behavior
See also
IteratorBehavior

◆ getContainerType()

template<class Particle_T >
ContainerOption autopas::Octree< Particle_T >::getContainerType ( ) const
inlineoverridevirtual

Get the ContainerType.

Returns
ContainerOption of the type of this container.

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

◆ getLeafCellByIndex()

template<class Particle_T >
std::tuple< std::vector< size_t >, OctreeLeafNode< Particle_T > * > autopas::Octree< Particle_T >::getLeafCellByIndex ( size_t  cellIndex) const
inline

Helper function to retrieve the pointer to a leaf cell as well as properly parse the cell index.

Note
This function assumes the given index is valid. If it is not some exceptions might be thrown or operator[] might access invalid memory
Parameters
cellIndexIndex in the tree as integer
Returns
tuple<index as vector, pointer to cell>

◆ getNumberOfParticles()

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

◆ getParticle() [1/2]

template<class Particle_T >
std::tuple< const Particle_T *, size_t, size_t > autopas::Octree< Particle_T >::getParticle ( size_t  cellIndex,
size_t  particleIndex,
IteratorBehavior  iteratorBehavior 
) const
inlineoverridevirtual

Fetch the pointer to a particle, identified via a cell and particle index.

These indices are only meaningful in the context of the current container at its current state. The same indices might (and probably will) yield different particles for different container types or might not even exist. The only guarantee is that the indices {0,0} yield the first particle in the container that satisfies the iterator requirements.

Note
This function should handle any offsets if used in a parallel iterator.
Parameters
cellIndexIndex of the cell the particle is located in.
particleIndexParticle index within the cell.
iteratorBehaviorWhich ownership states should be considered for the next particle.
Returns
Pointer to the particle and its indices. tuple<Particle_T*, cellIndex, particleIndex> If a index pair is given that does not exist but is also not beyond the last cell, the next fitting particle shall be returned. Example: If [4,2] does not exist, [5,1] shall be returned (or whatever is the next particle that fulfills the iterator requirements). If there is no next fitting particle {nullptr, 0, 0} is returned.

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

◆ getParticle() [2/2]

template<class Particle_T >
std::tuple< const Particle_T *, size_t, size_t > autopas::Octree< Particle_T >::getParticle ( size_t  cellIndex,
size_t  particleIndex,
IteratorBehavior  iteratorBehavior,
const std::array< double, 3 > &  boxMin,
const std::array< double, 3 > &  boxMax 
) const
inlineoverridevirtual

Fetch the pointer to a particle, identified via a cell and particle index.

These indices are only meaningful in the context of the current container at its current state. The same indices might (and probably will) yield different particles for different container types or might not even exist. The only guarantee is that the indices {0,0} yield the first particle in the container that satisfies the iterator requirements.

Note
This function should handle any offsets if used in a parallel iterator.
Parameters
cellIndexIndex of the cell the particle is located in.
particleIndexParticle index within the cell.
iteratorBehaviorWhich ownership states should be considered for the next particle.
Returns
Pointer to the particle and its indices. tuple<Particle_T*, cellIndex, particleIndex> If a index pair is given that does not exist but is also not beyond the last cell, the next fitting particle shall be returned. Example: If [4,2] does not exist, [5,1] shall be returned (or whatever is the next particle that fulfills the iterator requirements). If there is no next fitting particle {nullptr, 0, 0} is returned.
Parameters
boxMinstart of region in which the next particle should be. The coordinates are expected to be within the domain.
boxMaxend of region in which the next particle should be. The coordinates are expected to be within the domain.

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

◆ getParticleCellTypeEnum()

template<class Particle_T >
CellType autopas::Octree< Particle_T >::getParticleCellTypeEnum ( ) const
inlineoverridevirtual

Get the ParticleCell type as an Enum.

Returns
The Cell type as an Enum
Note
The octree stores the particles in its leaves. Even though the leaves inherit from FullParticleCell, they are an extension of FullParticleCell. However, the interface stays the same and the leaves can be treated just like regular FullParticleCells.

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

◆ getParticleImpl()

template<class Particle_T >
template<bool regionIter>
std::tuple< const ParticleType *, size_t, size_t > autopas::Octree< Particle_T >::getParticleImpl ( size_t  cellIndex,
size_t  particleIndex,
IteratorBehavior  iteratorBehavior,
const std::array< double, 3 > &  boxMin,
const std::array< double, 3 > &  boxMax 
) const
inline

Container specific implementation for getParticle.

See ParticleContainerInterface::getParticle().

Note
In this context cell == leaf cell
The index encodes the location in the octree. Each digit signifies which child of the node to enter. The right most digit selects the tree, the next the child of the root, and so on. So for example 31 would be the fourth child (3) in the halo tree (1). If this is not a leaf node, we recursively follow the first children (= prepend zeros) until the deepest level is found.
Template Parameters
regionIter
Parameters
cellIndex
particleIndex
iteratorBehavior
boxMin
boxMax
Returns
tuple<ParticlePointer, CellIndex, ParticleIndex>

◆ getRegionIterator() [1/2]

template<class Particle_T >
ContainerIterator< Particle_T, false, true > autopas::Octree< Particle_T >::getRegionIterator ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  higherCorner,
IteratorBehavior  behavior,
typename ContainerIterator< Particle_T, false, true >::ParticleVecType *  additionalVectors = nullptr 
) const
inlineoverridevirtual

Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorner, highCorner);iter.isValid();++iter) .

Parameters
lowerCornerLower corner of the region
higherCornerHigher corner of the region
behaviorThe behavior of the iterator (shall it iterate over halo particles as well?).
additionalVectorsVectors that should be included besides the container.
Returns
Iterator to iterate over all particles in a specific region.

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

◆ getRegionIterator() [2/2]

template<class Particle_T >
ContainerIterator< Particle_T, true, true > autopas::Octree< Particle_T >::getRegionIterator ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  higherCorner,
IteratorBehavior  behavior,
typename ContainerIterator< Particle_T, true, true >::ParticleVecType *  additionalVectors = nullptr 
)
inlineoverridevirtual

Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorner, highCorner);iter.isValid();++iter) .

Parameters
lowerCornerLower corner of the region
higherCornerHigher corner of the region
behaviorThe behavior of the iterator (shall it iterate over halo particles as well?).
additionalVectorsVectors that should be included besides the container.
Returns
Iterator to iterate over all particles in a specific region.

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

◆ getTraversalSelectorInfo()

template<class Particle_T >
TraversalSelectorInfo autopas::Octree< Particle_T >::getTraversalSelectorInfo ( ) const
inlineoverridevirtual

Generates a traversal selector info for this container.

Returns
Traversal selector info for this container.

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

◆ rebuildNeighborLists()

template<class Particle_T >
void autopas::Octree< Particle_T >::rebuildNeighborLists ( TraversalInterface traversal)
inlineoverridevirtual

Rebuilds the neighbor lists for the next traversals.

Parameters
traversalThe used traversal.

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

◆ reduce()

template<class Particle_T >
template<typename Lambda , typename A >
void autopas::Octree< Particle_T >::reduce ( Lambda  reduceLambda,
A &  result,
IteratorBehavior  behavior = IteratorBehavior::ownedOrHalo 
)
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
behavior
See also
IteratorBehavior default:
IteratorBehavior::ownedOrHalo

◆ reduceInRegion()

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

Execute code on all particles in this container in a certain region as defined by a lambda function.

Template Parameters
Lambda(Particle_T &p, A &result) -> void
Atype of reduction Value
Parameters
reduceLambdacode to be executed on all particles
resultreference to starting and final value for reduction
lowerCornerlower corner of bounding box
higherCornerhigher corner of bounding box
behavior
See also
IteratorBehavior

◆ reserve()

template<class Particle_T >
void autopas::Octree< Particle_T >::reserve ( size_t  numParticles,
size_t  numParticlesHaloEstimate 
)
inlineoverridevirtual

Reserve memory for a given number of particles in the container and logic layers.

This function assumes a uniform distribution of particles throughout the domain. For example, this means that in a LinkedCells Container in each cell vector.reserve(numParticles/numCells) is called.

Note
This functions will create an estimate for the number of halo particles.
Parameters
numParticlesNo buffer factor is applied. It is probably wise to slightly over-reserve to account for imbalance or particle movement.
numParticlesHaloEstimateEstimate for the number of halo particles. Reserves space in the container data structure.

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

◆ size()

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

◆ updateContainer()

template<class Particle_T >
std::vector< ParticleType > autopas::Octree< Particle_T >::updateContainer ( bool  keepNeighborListsValid)
inlineoverridevirtual

Updates the container.

This deletes halo particles, resorts particles into appropriate cells and might remove particles from the container, if necessary.

Parameters
keepNeighborListsValidDefines whether the neighbor lists have to be kept valid.
Returns
A vector of invalid particles that do not belong into the container.

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

◆ updateHaloParticle()

template<class Particle_T >
bool autopas::Octree< Particle_T >::updateHaloParticle ( const ParticleType haloParticle)
inlineoverride

Update a halo particle of the container with the given haloParticle.

Parameters
haloParticleParticle to be updated.
Returns
Returns true if the particle was updated, false if no particle could be found.

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