![]() |
Aboria::HyperOctree — A hyper octree spatial data structure that is paired with a HyperOctreeQuery query type.
// In header: </home/travis/build/martinjrobins/Aboria/src/OctTree.h> template<typename Traits> class HyperOctree : public Aboria::neighbour_search_base< HyperOctree< Traits >, Traits, HyperOctreeQuery< Traits > > { public: // member classes/structs/unions struct child_index_to_tag_mask { // types typedef vector_int::const_pointer ptr_type; // construct/copy/destruct child_index_to_tag_mask(int, int, ptr_type); // public member functions int operator()(int) const; // public data members const int level; const int max_level; ptr_type m_nodes; static const unsigned mask; }; struct classify_node { // construct/copy/destruct classify_node(int, int); // public member functions template<typename tuple_type> int operator()(const tuple_type &) const; // public data members const int threshold; const int last_level; }; struct classify_point { // construct/copy/destruct classify_point(const bbox< dimension > &, int); // public member functions int operator()(const double_d &); // public data members bbox< dimension > box; int max_level; }; struct make_leaf { // types typedef vint2 result_type; // public member functions template<typename tuple_type> result_type operator()(const tuple_type &) const; }; struct write_nodes { // construct/copy/destruct write_nodes(int, int); // public member functions template<typename tuple_type> int operator()(const tuple_type &) const; // public data members int num_nodes; int num_leaves; }; // construct/copy/destruct HyperOctree(); // public member functions void build_tree(); void print_data_structure() const; // public static functions static constexpr bool ordered(); // private member functions void set_domain_impl(); void update_iterator_impl(); void update_positions_impl(iterator, iterator, const int, const bool = true); const HyperOctreeQuery< Traits > & get_query_impl() const; HyperOctreeQuery< Traits > & get_query_impl(); };
An hyper octree is the general n-dimensional analog of an octree (aside: a normal octree is only defined for three dimensions). This data structure is a tree, where each level of the tree splits each bucket along the middle of each dimension. Each new bucket formed by this split becomes a child bucket for that bucket. Once the number of particles within a box falls below a threshold value (default: 10) then it is a leaf of the tree with no children
For example, consider a certain level of the tree in two dimensions which has 3 buckets, one a leaf with 9 particles, the other two non-leafs with 44 and 11 particles respectivly. The threshold value is set at 10. <heading>~~~ </heading>
| | | | leaf | |
9 | 44 |
|---------------<mdash></mdash>+-----------------<mdash></mdash>|
11 | |
<hruler></hruler>
The next level of the tree might look like this:
<hruler></hruler> | | 12 | 9 | | | | leaf | | +------<mdash></mdash>+-------<mdash></mdash>| | | 11 | 12 | | | | | |-----<mdash></mdash>+------<mdash></mdash>|------<mdash></mdash>+-------<mdash></mdash>| | 1 | 8 | | | leaf | leaf | | |-----<mdash></mdash>+------<mdash></mdash>| | | 0 | 2 | | <heading>| leaf | leaf | | </heading>
~~~
HyperOctree
private member functionsvoid set_domain_impl();
void update_iterator_impl();
void update_positions_impl(iterator update_begin, iterator update_end, const int new_n, const bool call_set_domain = true);
const HyperOctreeQuery< Traits > & get_query_impl() const;
HyperOctreeQuery< Traits > & get_query_impl();