32 : mesh_(mesh), leaf_size_limit(soft_leaf_size_limit), r_gen(123)
72 double left_bound=node_box.
min(axis);
73 double right_bound=node_box.
max(axis);
77 left_bound = std::max( left_bound,
elements_[ *
left ].max(axis) );
83 right_bound = std::min( right_bound,
elements_[ *
right ].min(axis) );
92 left_bound = std::max( left_bound,
elements_[ *
left ].max(axis) );
96 right_bound = std::min( right_bound,
elements_[ *
right ].min(axis) );
101 unsigned int right_end = node.
leaf_end();
102 unsigned int depth = node.
depth()+1;
106 nodes_.back().set_leaf(left_begin, left_end, left_bound, depth);
108 nodes_.back().set_leaf(left_end, right_end, right_bound, depth);
153 unsigned int median_idx;
154 unsigned int n_elements = node.
leaf_size();
158 std::uniform_int_distribution<unsigned int> distribution(node.
leaf_begin(), node.
leaf_end()-1);
160 for (
unsigned int i=0; i<
coors_.size(); i++) {
161 median_idx = distribution(this->
r_gen);
168 coors_.resize(n_elements);
169 for (
unsigned int i=0; i<
coors_.size(); i++) {
176 unsigned int median_position = (
unsigned int)(
coors_.size() / 2);
179 return coors_[median_position];
195 std::stack<unsigned int, std::vector<unsigned int> > node_stack;
199 while (! node_stack.empty()) {
219 node_stack.push( node.
child(0) );
223 node_stack.push( node.
child(1) );
230 #ifdef FLOW123D_DEBUG_ASSERTS 233 sort(cpy.begin(), cpy.end());
void set_max(unsigned int axis, double max)
static const double size_reduce_factor
required reduction in size of box to allow further splitting
unsigned int leaf_end() const
Bounding box in 3d ambient space.
unsigned int child(unsigned int i_child) const
Return index of child node.
const BoundingBox & tree_box()
unsigned char longest_axis() const
#define FOR_ELEMENTS(_mesh_, __i)
unsigned int max_n_levels
Maximal count of BIH tree levels.
void split_node(const BoundingBox &node_box, unsigned int node_idx)
split tree node given by node_idx, distribute elements to child nodes
std::vector< BoundingBox > elements_
vector of mesh elements bounding boxes
double estimate_median(unsigned char axis, const BIHNode &node)
void expand(const Point &point)
void element_boxes()
create bounding boxes of element
BoundingBox main_box_
Main bounding box.
void make_node(const BoundingBox &box, unsigned int node_idx)
create child nodes of node given by node_idx
unsigned int size() const
Returns size of the container. This is independent of the allocated space.
Global macros to enhance readability and debugging, general constants.
unsigned int n_elements() const
unsigned int leaf_size_limit
Maximal number of elements stored in a leaf node of BIH tree.
arma::vec::fixed< spacedim > Point
bool projection_lt(unsigned int axis, double value) const
const Point & max() const
unsigned char depth() const
return depth of leaf node
bool projection_gt(unsigned int axis, double value) const
BIHTree(Mesh *mesh, unsigned int soft_leaf_size_limit=20)
std::vector< double > coors_
temporary vector stored values of coordinations for calculating median
void find_point(const Space< 3 >::Point &point, std::vector< unsigned int > &result_list) const
#define FOR_NODES(_mesh_, i)
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
double size(unsigned int axis) const
void find_bounding_box(const BoundingBox &boundingBox, std::vector< unsigned int > &result_list) const
std::vector< unsigned int > in_leaves_
vector stored element indexes in leaf nodes
unsigned int leaf_size() const
unsigned int get_element_count()
unsigned int axis() const
return axes (coordination of splitting) of inner node
void set_min(unsigned int axis, double min)
#define OLD_ASSERT_EQUAL(a, b)
bool is_leaf() const
return true if node is leaf
const Point & min() const
static const unsigned int max_median_sample_size
max count of elements to estimate median - value must be even
NodeVector node_vector
Vector of nodes of the mesh.
unsigned int leaf_begin() const
ElementVector element
Vector of elements of the mesh.
std::vector< BIHNode > nodes_
vector of tree nodes