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

An octree leaf node. More...

#include <OctreeLeafNode.h>

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

Public Member Functions

 OctreeLeafNode (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, OctreeNodeInterface< Particle_T > *parent, const int unsigned treeSplitThreshold, const double interactionLength, const double cellSizeFactor)
 Create an empty octree leaf node.
 
 OctreeLeafNode (OctreeLeafNode< Particle_T > const &other)
 Copy a leaf by copying all particles from the other leaf to this leaf.
 
std::unique_ptr< OctreeNodeInterface< Particle_T > > insert (const Particle_T &p) override
 Insert a particle into the octree.
 
bool deleteParticle (Particle_T &particle) override
 Delete the given particle from the data structure.
 
void collectAllParticles (std::vector< Particle_T * > &ps) const override
 Put all particles that are below this node into the vector.
 
void appendAllLeafBoxes (std::vector< std::pair< std::array< double, 3 >, std::array< double, 3 > > > &boxes) const override
 Put the min/max corner coordinates of every leaf into the vector.
 
void clearChildren (std::unique_ptr< OctreeNodeInterface< Particle_T > > &ref) override
 Delete the entire tree below this node.
 
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.
 
bool hasChildren () override
 Check if the node is a leaf or an inner node.
 
OctreeNodeInterface< Particle_T > * getChild (int index) override
 Get a child by its index from the node.
 
std::vector< OctreeLeafNode< Particle_T > * > getLeavesFromDirections (const std::vector< octree::Vertex > &directions) override
 Find all leaf nodes along a list of given directions.
 
OctreeNodeInterface< Particle_T > * SON (octree::Octant O) override
 Get a child node of this node (if there are children) given a specific octant using the spacial structure of the stored children.
 
void appendAllLeaves (std::vector< OctreeLeafNode< Particle_T > * > &leaves) const override
 Put all leaves below this subtree into a given list.
 
std::set< OctreeLeafNode< Particle_T > * > getLeavesInRange (const std::array< double, 3 > &min, const std::array< double, 3 > &max) override
 Find all leaves below this subtree that are in the given range.
 
int getID ()
 Get the assigned id of this leaf node.
 
void setID (int id)
 Set the ID of this node.
 
- Public Member Functions inherited from autopas::OctreeNodeInterface< Particle_T >
 OctreeNodeInterface (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, OctreeNodeInterface< Particle_T > *parent, const int unsigned treeSplitThreshold, const double interactionLength, const double cellSizeFactor)
 Create an octree node interface by initializing the given fields.
 
virtual ~OctreeNodeInterface ()=default
 To make clang happy.
 
 OctreeNodeInterface (const OctreeNodeInterface< Particle_T > &)=default
 Default copy constructor.
 
virtual std::unique_ptr< OctreeNodeInterface< Particle_T > > insert (const Particle_T &p)=0
 Insert a particle into the octree.
 
virtual bool deleteParticle (Particle_T &particle)=0
 Delete the given particle from the data structure.
 
virtual void collectAllParticles (std::vector< Particle_T * > &ps) const =0
 Put all particles that are below this node into the vector.
 
virtual void appendAllLeafBoxes (std::vector< std::pair< std::array< double, 3 >, std::array< double, 3 > > > &boxes) const =0
 Put the min/max corner coordinates of every leaf into the vector.
 
virtual void appendAllLeaves (std::vector< OctreeLeafNode< Particle_T > * > &leaves) const =0
 Put all leaves below this subtree into a given list.
 
virtual void clearChildren (std::unique_ptr< OctreeNodeInterface< Particle_T > > &ref)=0
 Delete the entire tree below this node.
 
virtual size_t size () const =0
 Get the total number of particles saved in the container (owned + halo + dummy).
 
virtual size_t getNumberOfParticles (IteratorBehavior behavior=IteratorBehavior::owned) const =0
 Get the number of particles with respect to the specified IteratorBehavior.
 
virtual OctreeNodeInterface< Particle_T > * SON (octree::Octant O)=0
 Get a child node of this node (if there are children) given a specific octant using the spacial structure of the stored children.
 
virtual bool hasChildren ()=0
 Check if the node is a leaf or an inner node.
 
virtual OctreeNodeInterface< Particle_T > * getChild (int index)=0
 Get a child by its index from the node.
 
virtual std::set< OctreeLeafNode< Particle_T > * > getLeavesInRange (const std::array< double, 3 > &min, const std::array< double, 3 > &max)=0
 Find all leaves below this subtree that are in the given range.
 
bool isInside (const std::array< double, 3 > &point)
 Check if a 3d point is inside the node's axis aligned bounding box.
 
bool enclosesVolumeWithOtherOnAxis (const int axis, const OctreeNodeInterface< Particle_T > *other)
 Check if an octree node's box encloses volume with another octree node's box on a specific axis.
 
bool overlapsBox (const std::array< double, 3 > &otherMin, const std::array< double, 3 > &otherMax)
 Check if the node's axis aligned bounding box overlaps with the given axis aligned bounding box.
 
double getEnclosedVolumeWith (const std::array< double, 3 > &otherMin, const std::array< double, 3 > &otherMax)
 Calculate the overlap volume between the node's axis aligned bounding box and the given box.
 
OctreeNodeInterface< Particle_T > * EQ_FACE_NEIGHBOR (const octree::Face I)
 Find a node (via the pointer structure) that is of equal size of the current node's bounding box, according to the Samet paper.
 
OctreeNodeInterface< Particle_T > * EQ_EDGE_NEIGHBOR (const octree::Edge I)
 Find a node (via the pointer structure) that is of equal size of the current node's bounding box, according to the Samet paper.
 
OctreeNodeInterface< Particle_T > * EQ_VERTEX_NEIGHBOR (const octree::Vertex I)
 Find a node (via the pointer structure) that is of equal size of the current node's bounding box, according to the Samet paper.
 
OctreeNodeInterface< Particle_T > * GTEQ_FACE_NEIGHBOR (octree::Face I)
 Find a node (via the pointer structure) that is of greater than or equal to the size of the current node's bounding box, according to the Samet paper.
 
OctreeNodeInterface< Particle_T > * GTEQ_EDGE_NEIGHBOR (octree::Edge I)
 Find a node (via the pointer structure) that is of greater than or equal to the size of the current node's bounding box, according to the Samet paper.
 
OctreeNodeInterface< Particle_T > * GTEQ_VERTEX_NEIGHBOR (octree::Vertex I)
 Find a node (via the pointer structure) that is of greater than or equal to the size of the current node's bounding box, according to the Samet paper.
 
virtual std::vector< OctreeLeafNode< Particle_T > * > getLeavesFromDirections (const std::vector< octree::Vertex > &directions)=0
 Find all leaf nodes along a list of given directions.
 
std::vector< OctreeLeafNode< Particle_T > * > getNeighborLeaves (const octree::Any direction)
 This function combines all required functions when traversing down a subtree of the octree and finding all leaves.
 
std::set< OctreeLeafNode< Particle_T > * > getNeighborLeaves ()
 Get the neighbor leaves in all directions.
 
const std::array< double, 3 > & getBoxMin () const
 Get the minimum coordinate of the enclosing box.
 
const std::array< double, 3 > & getBoxMax () const
 Get the maximum coordinate of the enclosing box.
 
OctreeNodeInterface< Particle_T > * getParent () const
 Get the parent node of this node.
 
- 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 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.
 
- Static Public Member Functions inherited from autopas::OctreeNodeInterface< Particle_T >
static bool volumeExistsOnAxis (const int axis, const std::array< double, 3 > &aMin, const std::array< double, 3 > &aMax, const std::array< double, 3 > &bMin, const std::array< double, 3 > &bMax)
 Check if the volume enclosed by two boxes a and b is nonzero on a specific axis.
 
static double getEnclosedVolumeWith (const std::array< double, 3 > &aMin, const std::array< double, 3 > &aMax, const std::array< double, 3 > &bMin, const std::array< double, 3 > &bMax)
 Get the enclosed volume between two boxes a and b.
 
- 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 Member Functions inherited from autopas::OctreeNodeInterface< Particle_T >
bool hasParent ()
 Check if this is not the root node.
 
- Protected Attributes inherited from autopas::OctreeNodeInterface< Particle_T >
OctreeNodeInterface< Particle_T > * _parent
 A pointer to the parent node.
 
std::array< double, 3 > _boxMin
 The min coordinate of the enclosed volume.
 
std::array< double, 3 > _boxMax
 The max coordinate of the enclosed volume.
 
int unsigned _treeSplitThreshold
 Maximum number of particles inside a leaf node before the leaf tries to split itself.
 
double _interactionLength
 The minimum distance at which a force is considered nonzero, cutoff+skin.
 
double _cellSizeFactor
 The cell size factor for this node.
 
- 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<typename Particle_T>
class autopas::OctreeLeafNode< Particle_T >

An octree leaf node.

This forward declaration is required since the OctreeNodeInterface provides a method to gather all OctreeLeafNodes.

This class utilizes the FullParticleCell to store the actual particles.

Template Parameters
Particle_T
Particle_T

Constructor & Destructor Documentation

◆ OctreeLeafNode() [1/2]

template<typename Particle_T >
autopas::OctreeLeafNode< Particle_T >::OctreeLeafNode ( const std::array< double, 3 > &  boxMin,
const std::array< double, 3 > &  boxMax,
OctreeNodeInterface< Particle_T > *  parent,
const int unsigned  treeSplitThreshold,
const double  interactionLength,
const double  cellSizeFactor 
)
inline

Create an empty octree leaf node.

Parameters
boxMinThe min coordinate of the octree box
boxMaxThe max coordinate of the octree box
parentA pointer to the parent node. Should be nullptr for root nodes.
treeSplitThresholdMaximum number of particles inside a leaf before it tries to split itself
interactionLengthThe minimum distance at which a force is considered nonzero, cutoff+skin.
cellSizeFactorThe cell size factor

◆ OctreeLeafNode() [2/2]

template<typename Particle_T >
autopas::OctreeLeafNode< Particle_T >::OctreeLeafNode ( OctreeLeafNode< Particle_T > const &  other)
inline

Copy a leaf by copying all particles from the other leaf to this leaf.

Parameters
otherThe leaf to copy from

Member Function Documentation

◆ appendAllLeafBoxes()

template<typename Particle_T >
void autopas::OctreeLeafNode< Particle_T >::appendAllLeafBoxes ( std::vector< std::pair< std::array< double, 3 >, std::array< double, 3 > > > &  boxes) const
inlineoverridevirtual

Put the min/max corner coordinates of every leaf into the vector.

Parameters
boxesA reference to the vector that should contain pairs of the min/max corner coordinates

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ appendAllLeaves()

template<typename Particle_T >
void autopas::OctreeLeafNode< Particle_T >::appendAllLeaves ( std::vector< OctreeLeafNode< Particle_T > * > &  leaves) const
inlineoverridevirtual

Put all leaves below this subtree into a given list.

Parameters
leavesA reference to the vector that should contain pointers to the leaves

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ clearChildren()

template<typename Particle_T >
void autopas::OctreeLeafNode< Particle_T >::clearChildren ( std::unique_ptr< OctreeNodeInterface< Particle_T > > &  ref)
inlineoverridevirtual

Delete the entire tree below this node.

Parameters
refA reference that contains this node

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ collectAllParticles()

template<typename Particle_T >
void autopas::OctreeLeafNode< Particle_T >::collectAllParticles ( std::vector< Particle_T * > &  ps) const
inlineoverridevirtual

Put all particles that are below this node into the vector.

Parameters
psA reference to the vector that should contain the particles after the operation

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ deleteParticle()

template<typename Particle_T >
bool autopas::OctreeLeafNode< Particle_T >::deleteParticle ( Particle_T &  particle)
inlineoverridevirtual

Delete the given particle from the data structure.

This function does not change the tree layout if the node is empty after the operation.

Parameters
particle
Returns
True if the given pointer still points to a new, valid particle.

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ getChild()

template<typename Particle_T >
OctreeNodeInterface< Particle_T > * autopas::OctreeLeafNode< Particle_T >::getChild ( int  index)
inlineoverridevirtual

Get a child by its index from the node.

Parameters
indexThe index of the child. Must be between 0 and 7 inclusive.
Returns
A pointer to the child.

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ getID()

template<typename Particle_T >
int autopas::OctreeLeafNode< Particle_T >::getID ( )
inline

Get the assigned id of this leaf node.

Returns
An ID (or -1 if there was no ID assigned to this node)

◆ getLeavesFromDirections()

template<typename Particle_T >
std::vector< OctreeLeafNode< Particle_T > * > autopas::OctreeLeafNode< Particle_T >::getLeavesFromDirections ( const std::vector< octree::Vertex > &  directions)
inlineoverridevirtual

Find all leaf nodes along a list of given directions.

Parameters
directionsA list of allowed directions for traversal.
Returns
A list of leaf nodes

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ getLeavesInRange()

template<typename Particle_T >
std::set< OctreeLeafNode< Particle_T > * > autopas::OctreeLeafNode< Particle_T >::getLeavesInRange ( const std::array< double, 3 > &  min,
const std::array< double, 3 > &  max 
)
inlineoverridevirtual

Find all leaves below this subtree that are in the given range.

Parameters
minThe minimum coordinate in 3D space of the query area
maxThe maximum coordinate in 3D space of the query area
Returns
A set of all leaf nodes that are in the query region

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ getNumberOfParticles()

template<typename Particle_T >
size_t autopas::OctreeLeafNode< 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.

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ hasChildren()

template<typename Particle_T >
bool autopas::OctreeLeafNode< Particle_T >::hasChildren ( )
inlineoverridevirtual

Check if the node is a leaf or an inner node.

Use this over dynamic_cast to distinguish node types. It is 20-50 times faster! https://stackoverflow.com/a/49296405/7019073

Returns
true iff the node is a leaf, false otherwise.

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ insert()

template<typename Particle_T >
std::unique_ptr< OctreeNodeInterface< Particle_T > > autopas::OctreeLeafNode< Particle_T >::insert ( const Particle_T &  p)
inlineoverridevirtual

Insert a particle into the octree.

Parameters
pThe particle to insert
Returns
A std::unique_ptr to a newly created subtree or nullptr if the subtree did not change

Implements autopas::OctreeNodeInterface< Particle_T >.

◆ setID()

template<typename Particle_T >
void autopas::OctreeLeafNode< Particle_T >::setID ( int  id)
inline

Set the ID of this node.

Parameters
idAn integer ID

◆ size()

template<typename Particle_T >
size_t autopas::OctreeLeafNode< 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).

Reimplemented from autopas::FullParticleCell< Particle_T >.

◆ SON()

template<typename Particle_T >
OctreeNodeInterface< Particle_T > * autopas::OctreeLeafNode< Particle_T >::SON ( octree::Octant  O)
inlineoverridevirtual

Get a child node of this node (if there are children) given a specific octant using the spacial structure of the stored children.

Parameters
OThe octant
Returns
A pointer to a child node

Implements autopas::OctreeNodeInterface< Particle_T >.


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