35 template <
unsigned int N>
42 if (!this->bounds_node(nd))
51 if (nodes.size() == tgt_bin_size)
59 libmesh_assert_equal_to (children.size(), N);
61 bool was_inserted =
false;
62 for (
unsigned int c=0; c<N; c++)
63 if (children[c]->insert (nd))
70 template <
unsigned int N>
88 elements.push_back (elem);
90 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 95 this->contains_ifems =
true;
99 unsigned int element_count = cast_int<unsigned int>(elements.size());
103 if (elem_dimensions.size() > 1)
106 unsigned char highest_dim_elem = *elem_dimensions.rbegin();
107 for (std::size_t i=0; i<elements.size(); i++)
109 if (elements[i]->dim() == highest_dim_elem)
118 if (element_count == tgt_bin_size)
126 libmesh_assert_equal_to (children.size(), N);
128 bool was_inserted =
false;
129 for (
unsigned int c=0; c<N; c++)
130 if (children[c]->insert (elem))
137 template <
unsigned int N>
141 libmesh_assert (this->active());
142 libmesh_assert (children.empty());
149 unsigned int new_target_bin_size = tgt_bin_size;
150 if (level() >= target_bin_size_increase_level)
152 new_target_bin_size *= 2;
155 for (
unsigned int c=0; c<N; c++)
162 for (std::size_t n=0; n<nodes.size(); n++)
163 children[c]->insert(nodes[n]);
166 for (std::size_t e=0; e<elements.size(); e++)
167 children[c]->insert(elements[e]);
173 std::vector<const Node *>().
swap(nodes);
174 std::vector<const Elem *>().
swap(elements);
176 libmesh_assert_equal_to (nodes.capacity(), 0);
177 libmesh_assert_equal_to (elements.capacity(), 0);
182 template <
unsigned int N>
190 template <
unsigned int N>
192 Real relative_tol)
const 195 return bounds_point(*nd, relative_tol);
200 template <
unsigned int N>
202 Real relative_tol)
const 207 const Real tol = (
max -
min).norm() * relative_tol;
209 if ((p(0) >=
min(0) - tol)
210 && (p(0) <=
max(0) + tol)
212 && (p(1) >=
min(1) - tol)
213 && (p(1) <=
max(1) + tol)
216 && (p(2) >=
min(2) - tol)
217 && (p(2) <=
max(2) + tol)
227 template <
unsigned int N>
244 const Real xc = .5*(xmin + xmax);
245 const Real yc = .5*(ymin + ymax);
246 const Real zc = .5*(zmin + zmax);
255 Point(xmax, yc, zc));
258 Point(xc, ymax, zc));
261 Point(xmax, ymax, zc));
264 Point(xc, yc, zmax));
267 Point(xmax, yc, zmax));
270 Point(xc, ymax, zmax));
273 Point(xmax, ymax, zmax));
275 libmesh_error_msg(
"c >= N! : " << c);
290 const Real xc = .5*(xmin + xmax);
291 const Real yc = .5*(ymin + ymax);
308 libmesh_error_msg(
"c >= N!");
321 const Real xc = .5*(xmin + xmax);
332 libmesh_error_msg(
"c >= N!");
339 libmesh_error_msg(
"Only implemented for Octrees, QuadTrees, and Binary Trees!");
345 template <
unsigned int N>
350 out_stream <<
"TreeNode Level: " << this->level() << std::endl;
352 for (std::size_t n=0; n<nodes.size(); n++)
353 out_stream <<
" " << nodes[n]->
id();
355 out_stream << std::endl << std::endl;
359 for (std::size_t child=0; child<children.size(); child++)
360 children[child]->print_nodes();
366 template <
unsigned int N>
371 out_stream <<
"TreeNode Level: " << this->level() << std::endl;
373 for (
const auto & elem : elements)
374 out_stream <<
" " << elem;
376 out_stream << std::endl << std::endl;
380 for (std::size_t child=0; child<children.size(); child++)
381 children[child]->print_elements();
387 template <
unsigned int N>
397 std::set<const Elem *> elements_set;
399 for (std::size_t n=0; n<nodes.size(); n++)
406 libmesh_assert_less (node_number, nodes_to_elem.size());
408 for (std::size_t e=0; e<nodes_to_elem[node_number].size(); e++)
409 elements_set.insert(nodes_to_elem[node_number][e]);
413 std::vector<const Node *>().
swap(nodes);
419 elements.reserve(elements_set.size());
421 for (
const auto & elem : elements_set)
423 elements.push_back(elem);
425 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 429 if (elem->infinite())
430 this->contains_ifems =
true;
437 for (std::size_t child=0; child<children.size(); child++)
438 children[child]->transform_nodes_to_elements (nodes_to_elem);
445 template <
unsigned int N>
455 std::set<const Elem *> elements_set;
457 for (std::size_t n=0; n<nodes.size(); n++)
465 auto & my_elems = nodes_to_elem[node_number];
466 elements_set.insert(my_elems.begin(), my_elems.end());
470 std::vector<const Node *>().
swap(nodes);
476 elements.reserve(elements_set.size());
478 for (
const auto & elem : elements_set)
480 elements.push_back(elem);
482 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 486 if (elem->infinite())
487 this->contains_ifems =
true;
494 for (std::size_t child=0; child<children.size(); child++)
495 children[child]->transform_nodes_to_elements (nodes_to_elem);
502 template <
unsigned int N>
512 for (std::size_t c=0; c<children.size(); c++)
513 sum += children[c]->n_active_bins();
521 template <
unsigned int N>
524 const std::set<subdomain_id_type> * allowed_subdomains,
525 Real relative_tol)
const 531 if (this->bounds_point(p, relative_tol) || this->contains_ifems)
533 for (
const auto & elem : elements)
534 if (!allowed_subdomains || allowed_subdomains->count(elem->subdomain_id()))
535 if (elem->active() && elem->contains_point(p, relative_tol))
542 return this->find_element_in_children(p,allowed_subdomains,
549 template <
unsigned int N>
551 const std::set<subdomain_id_type> * allowed_subdomains,
552 Real relative_tol)
const 554 libmesh_assert (!this->active());
557 auto searched_child = std::array<bool, N>();
561 for (std::size_t c=0; c<children.size(); c++)
562 if (children[c]->bounds_point(p, relative_tol))
565 children[c]->find_element(p,allowed_subdomains,
576 searched_child[c] =
true;
584 for (std::size_t c=0; c<children.size(); c++)
585 if (!searched_child[c])
588 children[c]->find_element(p,allowed_subdomains,
BoundingBox create_bounding_box(unsigned int c) const
A geometric point in (x,y,z) space associated with a DOF.
bool intersects(const BoundingBox &) const
bool bounds_point(const Point &p, Real relative_tol=0) const
unsigned int n_active_bins() const
bool get_count_lower_dim_elems_in_point_locator() const
The base class for all geometric element types.
virtual BoundingBox loose_bounding_box() const
void transform_nodes_to_elements(std::vector< std::vector< const Elem *>> &nodes_to_elem)
bool bounds_node(const Node *nd, Real relative_tol=0) const
long double max(long double a, double b)
bool insert(const Node *nd)
const Elem * find_element_in_children(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains, Real relative_tol) const
const std::set< unsigned char > & elem_dimensions() const
Base class for different Tree types.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void print_nodes(std::ostream &out=libMesh::out) const
void swap(Iterator &lhs, Iterator &rhs)
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *allowed_subdomains=nullptr, Real relative_tol=TOLERANCE) const
virtual bool infinite() const =0
void set_bounding_box(const std::pair< Point, Point > &bbox)
long double min(long double a, double b)
void print_elements(std::ostream &out=libMesh::out) const
A geometric point in (x,y,z) space.
virtual dof_id_type n_nodes() const =0