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

The base class that provides the necessary function definitions that can be applied to an octree. More...

#include <OctreeNodeInterface.h>

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

Public Member Functions

 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.
 

Static Public Member Functions

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.
 

Protected Member Functions

bool hasParent ()
 Check if this is not the root node.
 

Protected Attributes

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.
 

Detailed Description

template<class Particle_T>
class autopas::OctreeNodeInterface< Particle_T >

The base class that provides the necessary function definitions that can be applied to an octree.

Template Parameters
Particle_T

Constructor & Destructor Documentation

◆ OctreeNodeInterface()

template<class Particle_T >
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 
)
inline

Create an octree node interface by initializing the given fields.

Parameters
boxMinThe minimum coordinate of the enclosing box
boxMaxThe maximum coordinate of the enclosing box
parentA pointer to the parent of this node, may be nullptr for the root.
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

Member Function Documentation

◆ appendAllLeafBoxes()

template<class Particle_T >
virtual void autopas::OctreeNodeInterface< Particle_T >::appendAllLeafBoxes ( std::vector< std::pair< std::array< double, 3 >, std::array< double, 3 > > > &  boxes) const
pure virtual

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

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ appendAllLeaves()

template<class Particle_T >
virtual void autopas::OctreeNodeInterface< Particle_T >::appendAllLeaves ( std::vector< OctreeLeafNode< Particle_T > * > &  leaves) const
pure virtual

Put all leaves below this subtree into a given list.

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

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ clearChildren()

template<class Particle_T >
virtual void autopas::OctreeNodeInterface< Particle_T >::clearChildren ( std::unique_ptr< OctreeNodeInterface< Particle_T > > &  ref)
pure virtual

Delete the entire tree below this node.

Parameters
refA reference that contains this node

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ collectAllParticles()

template<class Particle_T >
virtual void autopas::OctreeNodeInterface< Particle_T >::collectAllParticles ( std::vector< Particle_T * > &  ps) const
pure virtual

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

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ deleteParticle()

template<class Particle_T >
virtual bool autopas::OctreeNodeInterface< Particle_T >::deleteParticle ( Particle_T &  particle)
pure virtual

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.

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ enclosesVolumeWithOtherOnAxis()

template<class Particle_T >
bool autopas::OctreeNodeInterface< Particle_T >::enclosesVolumeWithOtherOnAxis ( const int  axis,
const OctreeNodeInterface< Particle_T > *  other 
)
inline

Check if an octree node's box encloses volume with another octree node's box on a specific axis.

Parameters
axisAn axis index (0, 1 or 2)
otherThe octree node to check against.
Returns
true iff the enclosed volume is greater than zero, false if the enclosed volume is equal to zero.

◆ EQ_EDGE_NEIGHBOR()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::OctreeNodeInterface< Particle_T >::EQ_EDGE_NEIGHBOR ( const octree::Edge  I)
inline

Find a node (via the pointer structure) that is of equal size of the current node's bounding box, according to the Samet paper.

This function searches along an edge.

Parameters
IThe edge in which direction the search should find a node
Returns
An octree node

◆ EQ_FACE_NEIGHBOR()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::OctreeNodeInterface< Particle_T >::EQ_FACE_NEIGHBOR ( const octree::Face  I)
inline

Find a node (via the pointer structure) that is of equal size of the current node's bounding box, according to the Samet paper.

This function searches along a face.

Parameters
IThe face in which direction the search should find a node
Returns
An octree node

◆ EQ_VERTEX_NEIGHBOR()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::OctreeNodeInterface< Particle_T >::EQ_VERTEX_NEIGHBOR ( const octree::Vertex  I)
inline

Find a node (via the pointer structure) that is of equal size of the current node's bounding box, according to the Samet paper.

This function searches along a vertex.

Parameters
IThe face in which direction the search should find a node
Returns
An octree node

◆ getBoxMax()

template<class Particle_T >
const std::array< double, 3 > & autopas::OctreeNodeInterface< Particle_T >::getBoxMax ( ) const
inline

Get the maximum coordinate of the enclosing box.

Returns
A point in 3D space

◆ getBoxMin()

template<class Particle_T >
const std::array< double, 3 > & autopas::OctreeNodeInterface< Particle_T >::getBoxMin ( ) const
inline

Get the minimum coordinate of the enclosing box.

Returns
A point in 3D space

◆ getChild()

template<class Particle_T >
virtual OctreeNodeInterface< Particle_T > * autopas::OctreeNodeInterface< Particle_T >::getChild ( int  index)
pure virtual

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.

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ getEnclosedVolumeWith() [1/2]

template<class Particle_T >
static double autopas::OctreeNodeInterface< Particle_T >::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 
)
inlinestatic

Get the enclosed volume between two boxes a and b.

Parameters
aMinThe minimum coordinate of box a
aMaxThe maximum coordinate of box b
bMinThe minimum coordinate of box a
bMaxThe maximum coordinate of box b
Returns
The enclosed volume or zero if the boxes do not overlap

◆ getEnclosedVolumeWith() [2/2]

template<class Particle_T >
double autopas::OctreeNodeInterface< Particle_T >::getEnclosedVolumeWith ( const std::array< double, 3 > &  otherMin,
const std::array< double, 3 > &  otherMax 
)
inline

Calculate the overlap volume between the node's axis aligned bounding box and the given box.

Parameters
otherMinThe minimum coordinate of the other box
otherMaxThe maximum coordinate of the other box
Returns
The volume enclosed by the two boxes

◆ getLeavesFromDirections()

template<class Particle_T >
virtual std::vector< OctreeLeafNode< Particle_T > * > autopas::OctreeNodeInterface< Particle_T >::getLeavesFromDirections ( const std::vector< octree::Vertex > &  directions)
pure virtual

Find all leaf nodes along a list of given directions.

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

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ getLeavesInRange()

template<class Particle_T >
virtual std::set< OctreeLeafNode< Particle_T > * > autopas::OctreeNodeInterface< Particle_T >::getLeavesInRange ( const std::array< double, 3 > &  min,
const std::array< double, 3 > &  max 
)
pure virtual

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

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ getNeighborLeaves() [1/2]

template<class Particle_T >
std::set< OctreeLeafNode< Particle_T > * > autopas::OctreeNodeInterface< Particle_T >::getNeighborLeaves ( )
inline

Get the neighbor leaves in all directions.

Returns
A set of (unique) neighboring leaves

◆ getNeighborLeaves() [2/2]

template<class Particle_T >
std::vector< OctreeLeafNode< Particle_T > * > autopas::OctreeNodeInterface< Particle_T >::getNeighborLeaves ( const octree::Any  direction)
inline

This function combines all required functions when traversing down a subtree of the octree and finding all leaves.

Parameters
directionThe "original" direction. The leaves will be found along the opposite direction.
Returns
A list of leaf nodes

◆ getNumberOfParticles()

template<class Particle_T >
virtual size_t autopas::OctreeNodeInterface< Particle_T >::getNumberOfParticles ( IteratorBehavior  behavior = IteratorBehavior::owned) const
pure virtual

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.

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ getParent()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::OctreeNodeInterface< Particle_T >::getParent ( ) const
inline

Get the parent node of this node.

Returns
A pointer to the parent, can be nullptr.

◆ GTEQ_EDGE_NEIGHBOR()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::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.

This function searches along an edge.

Parameters
IThe edge in which direction the search should find a node
Returns
An octree node

◆ GTEQ_FACE_NEIGHBOR()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::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.

This function searches along a face.

Parameters
IThe face in which direction the search should find a node
Returns
An octree node

◆ GTEQ_VERTEX_NEIGHBOR()

template<class Particle_T >
OctreeNodeInterface< Particle_T > * autopas::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.

This function searches along a vertex.

Parameters
IThe vertex in which direction the search should find a node
Returns
An octree node

◆ hasChildren()

template<class Particle_T >
virtual bool autopas::OctreeNodeInterface< Particle_T >::hasChildren ( )
pure virtual

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.

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ hasParent()

template<class Particle_T >
bool autopas::OctreeNodeInterface< Particle_T >::hasParent ( )
inlineprotected

Check if this is not the root node.

Returns
true iff there does not exist a parent for this node.

◆ insert()

template<class Particle_T >
virtual std::unique_ptr< OctreeNodeInterface< Particle_T > > autopas::OctreeNodeInterface< Particle_T >::insert ( const Particle_T &  p)
pure virtual

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

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ isInside()

template<class Particle_T >
bool autopas::OctreeNodeInterface< Particle_T >::isInside ( const std::array< double, 3 > &  point)
inline

Check if a 3d point is inside the node's axis aligned bounding box.

(Set by the boxMin and boxMax fields.)

Parameters
pointThe node to test
Returns
true if the point is inside the node's bounding box and false otherwise

◆ overlapsBox()

template<class Particle_T >
bool autopas::OctreeNodeInterface< Particle_T >::overlapsBox ( const std::array< double, 3 > &  otherMin,
const std::array< double, 3 > &  otherMax 
)
inline

Check if the node's axis aligned bounding box overlaps with the given axis aligned bounding box.

Parameters
otherMinThe minimum coordinate of the other box
otherMaxThe maximum coordinate of the other box
Returns
true iff the overlapping volume is non-negative

◆ size()

template<class Particle_T >
virtual size_t autopas::OctreeNodeInterface< Particle_T >::size ( ) const
pure virtual

Get the total number of particles saved in the container (owned + halo + dummy).

Returns
Number of particles saved in the container (owned + halo + dummy).

Implemented in autopas::OctreeInnerNode< Particle_T >, and autopas::OctreeLeafNode< Particle_T >.

◆ SON()

template<class Particle_T >
virtual OctreeNodeInterface< Particle_T > * autopas::OctreeNodeInterface< Particle_T >::SON ( octree::Octant  O)
pure virtual

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

Implemented in autopas::OctreeLeafNode< Particle_T >, and autopas::OctreeInnerNode< Particle_T >.

◆ volumeExistsOnAxis()

template<class Particle_T >
static bool autopas::OctreeNodeInterface< Particle_T >::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 
)
inlinestatic

Check if the volume enclosed by two boxes a and b is nonzero on a specific axis.

Parameters
axisAn axis index (0, 1 or 2)
aMinThe minimum coordinate of a's volume
aMaxThe maximum coordinate of a's volume
bMinThe minimum coordinate of b's volume
bMaxThe maximum coordinate of b's volume
Returns
true iff the enclosed volume is greater than zero, false if the enclosed volume is equal to zero.

Member Data Documentation

◆ _parent

template<class Particle_T >
OctreeNodeInterface<Particle_T>* autopas::OctreeNodeInterface< Particle_T >::_parent
protected

A pointer to the parent node.

Can be nullptr (iff this is the root node).


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