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

Inner nodes of the octree data structure. More...

#include <OctreeInnerNode.h>

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

Public Member Functions

 OctreeInnerNode (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, OctreeNodeInterface< Particle_T > *parent, int unsigned treeSplitThreshold, double interactionLength, double cellSizeFactor)
 Create an octree inner node that points to eight leaves.
 
 OctreeInnerNode (const OctreeInnerNode< Particle_T > &other)
 Copy all children from the other octree into this octree.
 
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 octant) 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.
 
template<typename Lambda >
void forEach (Lambda forEachLambda)
 Apply the forEach lambda to each particle.
 
template<typename Lambda , typename A >
void reduce (Lambda reduceLambda, A &result)
 Apply the reduce lambda to each particle.
 
template<typename Lambda >
void forEach (Lambda forEachLambda, const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior)
 Apply the forEach lambda to each particle in the region.
 
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)
 Apply the reduce lambda to each particle in the region.
 
- 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.
 

Additional Inherited Members

- 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.
 
- 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.
 

Detailed Description

template<class Particle_T>
class autopas::OctreeInnerNode< Particle_T >

Inner nodes of the octree data structure.

An inner node always points to eight children, which can either be leaves or inner nodes as well.

Template Parameters
Particle_T

Constructor & Destructor Documentation

◆ OctreeInnerNode() [1/2]

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

Create an octree inner node that points to eight leaves.

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

◆ OctreeInnerNode() [2/2]

template<class Particle_T >
autopas::OctreeInnerNode< Particle_T >::OctreeInnerNode ( const OctreeInnerNode< Particle_T > &  other)
inline

Copy all children from the other octree into this octree.

(Create a new, copied subtree)

Parameters
otherThe other octree (to copy from)

Member Function Documentation

◆ appendAllLeafBoxes()

template<class Particle_T >
void autopas::OctreeInnerNode< 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<class Particle_T >
void autopas::OctreeInnerNode< 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<class Particle_T >
void autopas::OctreeInnerNode< 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<class Particle_T >
void autopas::OctreeInnerNode< 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<class Particle_T >
bool autopas::OctreeInnerNode< 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 >.

◆ forEach() [1/2]

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

Apply the forEach lambda to each particle.

Template Parameters
LambdaFunction type
Parameters
forEachLambdaFunction to apply

◆ forEach() [2/2]

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

Apply the forEach lambda to each particle in the region.

Template Parameters
LambdaFunction type
Parameters
forEachLambdaFunction to apply
lowerCornerLower corner of region
higherCornerHigher corner of region
behaviorParameter is only there to reuse functionality already implemented in FullParticleCell, should be set to ownedOrHalo

◆ getChild()

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

◆ getLeavesFromDirections()

template<class Particle_T >
std::vector< OctreeLeafNode< Particle_T > * > autopas::OctreeInnerNode< 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<class Particle_T >
std::set< OctreeLeafNode< Particle_T > * > autopas::OctreeInnerNode< 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<class Particle_T >
size_t autopas::OctreeInnerNode< 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::OctreeNodeInterface< Particle_T >.

◆ hasChildren()

template<class Particle_T >
bool autopas::OctreeInnerNode< 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<class Particle_T >
std::unique_ptr< OctreeNodeInterface< Particle_T > > autopas::OctreeInnerNode< 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 >.

◆ reduce() [1/2]

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

Apply the reduce lambda to each particle.

Template Parameters
LambdaFunction type
AInitial value type
Parameters
reduceLambdaFunction to apply
resultInitial value

◆ reduce() [2/2]

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

Apply the reduce lambda to each particle in the region.

Template Parameters
LambdaFunction type
AInitial value type
Parameters
reduceLambdaFunction to apply
resultInitial value
lowerCornerLower corner of region
higherCornerHigher corner of region
behaviorParameter is only there to reuse functionality already implemented in FullParticleCell, should be set to ownedOrHalo

◆ size()

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

◆ SON()

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