![]() |
|
#include <binary_tree.h>
Public Member Functions | |
virtual | ~BinaryTree () |
BinaryTree (const BinaryTree &dummy)=delete | |
Broken copy constructor. More... | |
void | operator= (const BinaryTree &)=delete |
Broken assignment operator. More... | |
Tree * | construct_son (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type) |
BinaryTree * | gteq_edge_neighbour (const int &direction, Vector< double > &s_in_neighbour, int &edge, int &diff_level, bool &in_neighbouring_tree) const |
unsigned | self_test () |
![]() | |
virtual | ~Tree () |
Tree (const Tree &dummy)=delete | |
Broken copy constructor. More... | |
void | operator= (const Tree &)=delete |
Broken assignment operator. More... | |
RefineableElement * | object_pt () const |
void | flush_object () |
Flush the object represented by the tree. More... | |
Tree * | son_pt (const int &son_index) const |
void | set_son_pt (const Vector< Tree * > &son_pt) |
unsigned | nsons () const |
Return number of sons (zero if it's a leaf node) More... | |
void | flush_sons () |
Flush the sons. More... | |
TreeRoot *& | root_pt () |
Return pointer to root of the tree. More... | |
TreeRoot * | root_pt () const |
Return pointer to root of the tree (const version) More... | |
template<class ELEMENT > | |
void | split_if_required () |
template<class ELEMENT > | |
void | p_refine_if_required (Mesh *&mesh_pt) |
void | merge_sons_if_required (Mesh *&mesh_pt) |
void | deactivate_object () |
Call the RefineableElement's deactivate_element() function. More... | |
void | traverse_all (Tree::VoidMemberFctPt member_function) |
void | traverse_all (Tree::VoidMeshPtArgumentMemberFctPt member_function, Mesh *&mesh_pt) |
void | traverse_all_but_leaves (Tree::VoidMemberFctPt member_function) |
void | traverse_leaves (Tree::VoidMemberFctPt member_function) |
void | traverse_leaves (Tree::VoidMeshPtArgumentMemberFctPt member_function, Mesh *&mesh_pt) |
void | stick_leaves_into_vector (Vector< Tree * > &) |
Traverse tree and stick pointers to leaf "nodes" (only) into Vector. More... | |
void | stick_all_tree_nodes_into_vector (Vector< Tree * > &) |
Traverse and stick pointers to all "nodes" into Vector. More... | |
int | son_type () const |
Return son type. More... | |
bool | is_leaf () |
Return true if the tree is a leaf node. More... | |
Tree * | father_pt () const |
Return pointer to father: NULL if it's a root node. More... | |
void | set_father_pt (Tree *const &father_pt) |
Set the father. More... | |
unsigned | level () const |
Return the level of the Tree (root=0) More... | |
Static Public Member Functions | |
static void | setup_static_data () |
Set up the static data, reflection schemes, etc. More... | |
static void | doc_neighbours (Vector< Tree * > forest_nodes_pt, std::ofstream &neighbours_file, std::ofstream &neighbours_txt_file, double &max_error) |
![]() | |
static double & | max_neighbour_finding_tolerance () |
Static Public Attributes | |
static Vector< std::string > | Direct_string |
Translate (enumerated) directions into strings. More... | |
![]() | |
static const int | OMEGA = 26 |
Default value for an unassigned neighbour. More... | |
Protected Member Functions | |
BinaryTree () | |
Default constructor (empty and broken) More... | |
BinaryTree (RefineableElement *const &object_pt) | |
BinaryTree (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type) | |
![]() | |
Tree () | |
Default constructor (empty and broken) More... | |
Tree (RefineableElement *const &object_pt) | |
Tree (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type) | |
Static Protected Attributes | |
static bool | Static_data_has_been_setup = false |
Boolean indicating that static member data has been setup. More... | |
![]() | |
static double | Max_neighbour_finding_tolerance = 1.0e-14 |
Private Member Functions | |
BinaryTree * | gteq_edge_neighbour (const int &direction, double &s_diff, int &diff_level, bool &in_neighbouring_tree, int max_level, BinaryTreeRoot *const &orig_root_pt) const |
Static Private Attributes | |
static Vector< std::string > | Colour |
Colours for neighbours in various directions. More... | |
static Vector< double > | S_base |
static Vector< int > | Reflect_edge |
Get opposite edge, e.g. Reflect_edge[L]=R. More... | |
static DenseMatrix< bool > | Is_adjacent |
static DenseMatrix< int > | Reflect |
Additional Inherited Members | |
![]() | |
typedef void(Tree::* | VoidMemberFctPt) () |
Function pointer to argument-free void Tree member function. More... | |
typedef void(Tree::* | VoidMeshPtArgumentMemberFctPt) (Mesh *&mesh_pt) |
![]() | |
TreeRoot * | Root_pt |
Pointer to the root of the tree. More... | |
Tree * | Father_pt |
Pointer to the Father of the Tree. More... | |
Vector< Tree * > | Son_pt |
Vector of pointers to the sons of the Tree. More... | |
int | Level |
Level of the Tree (level 0 = root) More... | |
int | Son_type |
Son type (e.g. SW/SE/NW/NE in a quadtree) More... | |
RefineableElement * | Object_pt |
Pointer to the object represented by the tree. More... | |
BinaryTree class: Recursively defined, generalised binary tree.
A BinaryTree has:
The tree can also be part of a forest. If that is the case, the root will have pointers to the roots of neighbouring binary trees.
The objects contained in the binary tree are assumed to be line elements whose geometry is parametrised by local coordinates \( {\bf s} \in [-1,1] \).
The tree can be traversed and actions performed at all its "nodes" or only at the leaf "nodes" ("nodes" without sons).
Finally, the leaf "nodes" can be split depending on a criteria defined by the object.
Note that BinaryTrees are only generated by splitting existing BinaryTrees. Therefore, the constructors are protected. The only BinaryTree that "Joe User" can create is the (derived) class BinaryTreeRoot.
|
inlinevirtual |
|
delete |
Broken copy constructor.
|
inlineprotected |
Default constructor (empty and broken)
References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.
Referenced by construct_son().
|
inlineprotected |
Default constructor for empty (root) tree: no father, no sons; just pass a pointer to its object. Protected because BinaryTrees can only be created internally, during the split operation. Only BinaryTreeRoots can be created externally.
|
inlineprotected |
Constructor for tree that has a father: Pass it the pointer to its object, the pointer to its father and tell it what type of son (L/R) it is. Protected because BinaryTrees can only be created internally, during the split operation. Only BinaryTreeRoots can be created externally.
|
inlinevirtual |
Overload the function construct_son to ensure that the son is a specific BinaryTree and not a general Tree.
Implements oomph::Tree.
References BinaryTree(), oomph::Tree::father_pt(), oomph::Tree::object_pt(), and oomph::Tree::son_type().
|
static |
Doc/check all neighbours of binary tree (nodes) contained in the Vector forest_node_pt. Output into neighbours_file which can be viewed from tecplot with BinaryTreeNeighbours.mcr. Neighbour info and errors are displayed on neighbours_txt_file. Finally, compute the maximum error between vertices when viewed from the neighbouring element. If the two filestreams are closed, output is suppressed.
Doc/check all neighbours of binary tree ("nodes") contained in the Vector forest_node_pt. Output into neighbours_file which can be viewed from tecplot with BinaryTreeNeighbours.mcr. Neighbour info and errors are displayed on neighbours_txt_file. Finally, compute the maximum error between vertices when viewed from neighbouring element. Output is suppressed if the output streams are closed.
References calibrate::error, boost::multiprecision::fabs(), oomph::FiniteElement::get_x(), gteq_edge_neighbour(), i, oomph::TreeRoot::is_neighbour_periodic(), L, MeshRefinement::max_error, oomph::RefineableElement::nodes_built(), oomph::RefineableElement::number(), oomph::Tree::object_pt(), oomph::BinaryTreeNames::OMEGA, Eigen::bfloat16_impl::pow(), R, oomph::Tree::root_pt(), s, sqrt(), and plotDoE::x.
Referenced by oomph::BinaryTreeForest::check_all_neighbours(), self_test(), and oomph::BinaryTreeForest::self_test().
|
private |
Find greater or equal-sized edge neighbour in direction. Auxiliary internal routine which passes additional information around.
Find ‘greater-or-equal-sized edge neighbour’ in given direction (L/R).
This is an auxiliary routine which allows neighbour finding in adjacent binary trees. Needs to keep track of previous son types and the maximum level to which search is performed.
Parameters:
References oomph::Tree::Father_pt, gteq_edge_neighbour(), Is_adjacent, L, oomph::Tree::Level, oomph::TreeRoot::neighbour_pt(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, Eigen::bfloat16_impl::pow(), R, Reflect, oomph::Tree::Root_pt, oomph::Tree::Son_pt, and oomph::Tree::Son_type.
BinaryTree * oomph::BinaryTree::gteq_edge_neighbour | ( | const int & | direction, |
Vector< double > & | s_in_neighbour, | ||
int & | edge, | ||
int & | diff_level, | ||
bool & | in_neighbouring_tree | ||
) | const |
Return pointer to greater or equal-sized edge neighbour in specified direction
; also provide info regarding the relative size of the neighbour:
s_in_neighbour
[0] in the neighbouring binary tree.direction
. When viewed from the neighbouring binary tree, the edge that separates the present binary tree from its neighbour is the neighbour's edge
edge. Since in 1D there can be no rotation between the two binary trees, this is a simple reflection. For instance, if we're looking for a neighhbour in the L
[eft] direction
, edge
will be R
[ight].diff_level
<= 0 indicates the difference in refinement levels between the two neighbours. If diff_level==0
, the neighbour has the same size as the current binary tree.in_neighbouring_tree
indicates whether the neighbour is actually in another tree in the forest. The introduction of this flag was necessitated by periodic problems where a TreeRoot can be its own neighbour.Return pointer to greater or equal-sized edge neighbour in specified direction
; also provide info regarding the relative size of the neighbour:
s_in_neighbour
[0] in the neighbouring binary tree.direction
. When viewed from the neighbouring binary tree, the edge that separates the present binary tree from its neighbour is the neighbour's edge
edge. Since in 1D there can be no rotation between the two binary trees, this is a simple reflection. For instance, if we're looking for a neighhbour in the L
[eft] direction
, edge
will be R
[ight].diff_level
<= 0 indicates the difference in refinement levels between the two neighbours. If diff_level==0
, the neighbour has the same size as the current binary tree.in_neighbouring_tree
returns true if we have had to flip to a different root, even if that root is actually the same (as it can be in periodic problems). References L, oomph::Tree::Level, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, R, Reflect_edge, oomph::Tree::Root_pt, and S_base.
Referenced by oomph::RefineableQElement< 1 >::check_integrity(), doc_neighbours(), gteq_edge_neighbour(), and oomph::RefineableQElement< 1 >::node_created_by_neighbour().
|
delete |
Broken assignment operator.
unsigned oomph::BinaryTree::self_test | ( | ) |
Self-test: Check all neighbours. Return success (0) if the maximum distance between corresponding points in the neighbours is less than the tolerance specified in the static value BinaryTree::Max_neighbour_finding_tolerance.
Self-test: Check neighbour finding routine. For each element in the tree and for each vertex, determine the distance between the vertex and its position in the neighbour. If the difference is less than Tree::Max_neighbour_finding_tolerance return success (0), otherwise failure (1).
References doc_neighbours(), i, MeshRefinement::max_error, oomph::Tree::Max_neighbour_finding_tolerance, oomph::oomph_info, and oomph::Tree::stick_all_tree_nodes_into_vector().
|
static |
Set up the static data, reflection schemes, etc.
Set up the static data stored in the BinaryTree – this needs to be called before BinaryTrees can be used. Automatically called by RefineableLineMesh constructor.
References Colour, Direct_string, Is_adjacent, L, oomph::Tree::OMEGA, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, R, Reflect, Reflect_edge, oomph::DenseMatrix< T >::resize(), S_base, and Static_data_has_been_setup.
Referenced by oomph::RefineableLineMesh< ELEMENT >::RefineableLineMesh().
|
staticprivate |
Colours for neighbours in various directions.
Colours for neighbours in various directions (static data).
Referenced by setup_static_data().
|
static |
Translate (enumerated) directions into strings.
Translate (enumerated) directions into strings (static data).
Referenced by setup_static_data().
|
staticprivate |
Array of direction/segment adjacency scheme: Is_adjacent(i_vertex,j_segment): Is vertex adjacent to segment?
Array of direction/segment adjacency scheme: Is_adjacent(i_vertex,j_segment): Is vertex adjacent to segment? (static data)
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
Reflection scheme: Reflect(direction,segment): Get mirror of segment in specified direction. E.g. Reflect(L,L)=R.
Reflection scheme: Reflect(direction,segment): Get mirror of segment in specified direction. E.g. Reflect(L,L)=R (static data)
Referenced by gteq_edge_neighbour(), and setup_static_data().
Get opposite edge, e.g. Reflect_edge[L]=R.
Get opposite edge, e.g. Reflect_edge[N]=S (static data)
Referenced by gteq_edge_neighbour(), and setup_static_data().
S_base(direction): Initial value for coordinate s on the edge indicated by direction (L/R)
S_base(direction): Initial value for coordinate s on the edge indicated by direction (L/R) (static data).
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprotected |
Boolean indicating that static member data has been setup.
Referenced by oomph::BinaryTreeRoot::BinaryTreeRoot(), and setup_static_data().