SpECTRE  v2025.08.19
domain::ElementSearchTree< Dim > Class Template Reference

Search tree for efficiently looking up elements by their bounding boxes in block-logical coordinates. More...

#include <ElementSearchTree.hpp>

Public Member Functions

 ElementSearchTree (ElementSearchTree &&)
 
ElementSearchTreeoperator= (ElementSearchTree &&)
 
 ElementSearchTree (const ElementSearchTree &)=delete
 
ElementSearchTreeoperator= (const ElementSearchTree &)=delete
 
template<typename Iter >
 ElementSearchTree (Iter begin, const Iter end)
 Construct a search tree containing the ids in [begin, end).
 
size_t size () const
 
bool empty () const
 
void clear ()
 
void insert (const ElementId< Dim > &id)
 
template<typename Iter >
void insert (Iter begin, const Iter end)
 Insert the ids in [begin, end).
 
ElementSearchTreeIterator< Dim > begin_covers (const tnsr::I< double, Dim, Frame::BlockLogical > &coords) const
 
ElementSearchTreeIterator< Dim > end_covers () const
 

Detailed Description

template<size_t Dim>
class domain::ElementSearchTree< Dim >

Search tree for efficiently looking up elements by their bounding boxes in block-logical coordinates.

The search tree is constructed from a list of ElementIds, which define bounding boxes in block-logical coordinates. All ElementIds must be in the same block. Then, the search tree can be used to efficiently search for the element that contains a given block-logical coordinate (see e.g. element_logical_coordinates).

Example usage:

const std::vector<ElementId<2>> element_ids{
// Element layout in block-logical coordinates:
// xi -->
// -1 0 1
// eta -1 -------------
// | | 0 | 2 |
// v 0 |-------------|
// | 1 | 3 | 4 |
// 1 -------------
ElementId<2>{0, {{{1, 0}, {1, 0}}}}, // 0
ElementId<2>{0, {{{1, 0}, {1, 1}}}}, // 1
ElementId<2>{0, {{{1, 1}, {1, 0}}}}, // 2
ElementId<2>{0, {{{2, 2}, {1, 1}}}}, // 3
ElementId<2>{0, {{{2, 3}, {1, 1}}}} // 4
};
const ElementSearchTree<2> search_tree(element_ids.begin(),
element_ids.end());
std::vector<ElementId<2>> search_result(
search_tree.begin_covers(
search_tree.end_covers());
CHECK(search_result.size() == 1);
CHECK(search_result[0] == element_ids[2]);
An ElementId uniquely labels an Element.
Definition: ElementId.hpp:44
Definition: ContractFirstNIndices.hpp:16

Use domain::index_element_ids() to create one search tree for each block in the domain given the full list of ElementIds.

Details

The search tree is a boost::geometry::rtree with a choice of quadratic splitting algorithm and a maximum of 16 elements per node. These choices work well, but haven't been extensively tuned.


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