Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
oomph::Tree Class Referenceabstract

#include <tree.h>

+ Inheritance diagram for oomph::Tree:

Public Types

typedef void(Tree::* VoidMemberFctPt )()
 Function pointer to argument-free void Tree member function. More...
 
typedef void(Tree::* VoidMeshPtArgumentMemberFctPt )(Mesh *&mesh_pt)
 

Public Member Functions

virtual ~Tree ()
 Destructor. Note: Deleting a tree also deletes the objects associated with its non-leave nodes. More...
 
 Tree (const Tree &dummy)
 Broken copy constructor. More...
 
void operator= (const Tree &)
 Broken assignment operator. More...
 
RefineableElementobject_pt () const
 Return the pointer to the object (RefineableElement) represented by the tree. More...
 
void flush_object ()
 Flush the object represented by the tree. More...
 
Treeson_pt (const int &son_index) const
 Return pointer to the son for a given index. Note that to aid code readability specific enums have been defined for specific trees. However, these are simply aliases for ints and the general interface can be implemented once, here. More...
 
void set_son_pt (const Vector< Tree * > &son_pt)
 Set vector of pointers to sons, indexed by the appropriate enum that identies son types. (To aid code readability specific enums have been defined for specific trees. However, these are simply aliases for ints and the general interface can be implemented once, here). More...
 
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...
 
TreeRootroot_pt () const
 Return pointer to root of the tree (const version) More...
 
template<class ELEMENT >
void split_if_required ()
 If required, split the leaf and create its sons – criterion: bool object_pt()-> to_be_refined() = true. More...
 
template<class ELEMENT >
void p_refine_if_required (Mesh *&mesh_pt)
 If required, p-refine the leaf – criterion: bool object_pt()-> to_be_p_refined() = true or bool object_pt()-> to_be_p_unrefined() = true. More...
 
void merge_sons_if_required (Mesh *&mesh_pt)
 If required, merge the four sons for unrefinement – criterion: bool object_pt()-> sons_to_be_unrefined() = true. More...
 
void deactivate_object ()
 Call the RefineableElement's deactivate_element() function. More...
 
virtual Treeconstruct_son (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)=0
 A function that constructs a specific type of tree. This MUST be overloaded for each specific tree type. The use of such a function allows the generic implementation of split_if_required(). More...
 
void traverse_all (Tree::VoidMemberFctPt member_function)
 Traverse the tree and execute void Tree member function member_function() at all its "nodes". More...
 
void traverse_all (Tree::VoidMeshPtArgumentMemberFctPt member_function, Mesh *&mesh_pt)
 Traverse the tree and excute void Tree member function that takes a pointer to a mesh as an argument. More...
 
void traverse_all_but_leaves (Tree::VoidMemberFctPt member_function)
 Traverse the tree and execute void Tree member function. More...
 
void traverse_leaves (Tree::VoidMemberFctPt member_function)
 Traverse the tree and execute void Tree member function member_function() only at its leaves. More...
 
void traverse_leaves (Tree::VoidMeshPtArgumentMemberFctPt member_function, Mesh *&mesh_pt)
 Traverse the tree and execute void Tree member function that takes a pointer to a mesh as an argument only at its leaves. More...
 
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...
 
Treefather_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 double & max_neighbour_finding_tolerance ()
 Max. allowed discrepancy in neighbour finding routine (distance between points when identified from two neighbouring elements) More...
 

Static Public Attributes

static const int OMEGA =26
 Default value for an unassigned neighbour. More...
 

Protected Member Functions

 Tree ()
 Default constructor (empty and broken) More...
 
 Tree (RefineableElement *const &object_pt)
 Default constructor for empty (root) tree: no father, no sons; just pass a pointer to its object Protected because Trees can only be created internally, during the split operation. Only TreeRoots can be created externally. More...
 
 Tree (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)
 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 it is. Protected because Trees can only be created internally, during the split operation. Only TreeRoots can be created externally. More...
 

Protected Attributes

TreeRootRoot_pt
 Pointer to the root of the tree. More...
 
TreeFather_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...
 
RefineableElementObject_pt
 Pointer to the object represented by the tree. More...
 

Static Protected Attributes

static double Max_neighbour_finding_tolerance =1.0e-14
 Max. allowed discrepancy in neighbour finding routine (distance between points when identified from two neighbouring elements) More...
 

Detailed Description

A generalised tree base class that abstracts the common functionality between the quad- and octrees used in mesh adaptation in two and three dimensions, respectively.

The tree can also be part of a forest. If that is the case, the root of the tree will have pointers to the roots of neighbouring trees.

The objects contained in the tree must be RefineableElements.

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 Trees are only generated by splitting existing Trees. Therefore, the constructors are protected. The only Tree that "Joe User" can create is the (derived) class TreeRoot.

Definition at line 79 of file tree.h.

Member Typedef Documentation

typedef void(Tree::* oomph::Tree::VoidMemberFctPt)()

Function pointer to argument-free void Tree member function.

Definition at line 173 of file tree.h.

typedef void(Tree::* oomph::Tree::VoidMeshPtArgumentMemberFctPt)(Mesh *&mesh_pt)

Function pointer to a void Tree member function that takes a pointer to a mesh as its argument

Definition at line 177 of file tree.h.

Constructor & Destructor Documentation

oomph::Tree::~Tree ( )
virtual

Destructor. Note: Deleting a tree also deletes the objects associated with its non-leave nodes.

Destructor for Tree: Recursively kill all sons and the associated objects of the non-leaf nodes. However, the objects of the leaf nodes are not destroyed. Their destruction is handled by the Mesh destructor.

Definition at line 128 of file tree.cc.

References i, nsons(), Object_pt, and Son_pt.

oomph::Tree::Tree ( const Tree dummy)
inline

Broken copy constructor.

Definition at line 89 of file tree.h.

References oomph::BrokenCopy::broken_copy().

oomph::Tree::Tree ( )
inlineprotected

Default constructor (empty and broken)

Definition at line 246 of file tree.h.

oomph::Tree::Tree ( RefineableElement *const &  object_pt)
protected

Default constructor for empty (root) tree: no father, no sons; just pass a pointer to its object Protected because Trees can only be created internally, during the split operation. Only TreeRoots can be created externally.

Constructor for empty (root) Tree: No father, no sons. Pass pointer to the object that this tree (root) contains. Protected because Trees can only be created internally, during the split operation.

Definition at line 69 of file tree.cc.

References Father_pt, Level, OMEGA, Root_pt, oomph::RefineableElement::set_tree_pt(), Son_pt, and Son_type.

oomph::Tree::Tree ( RefineableElement *const &  object_pt,
Tree *const &  father_pt,
const int &  son_type 
)
protected

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 it is. Protected because Trees can only be created internally, during the split operation. Only TreeRoots can be created externally.

Constructor for Tree: This one has a father and is a son of a certain type, but has no sons of its own (just yet), so it's a leaf node. Protected because Trees can only be created internally, during the split operation.

Definition at line 99 of file tree.cc.

References father_pt(), Father_pt, Level, Root_pt, oomph::RefineableElement::set_tree_pt(), Son_pt, son_type(), and Son_type.

Member Function Documentation

virtual Tree* oomph::Tree::construct_son ( RefineableElement *const &  object_pt,
Tree *const &  father_pt,
const int &  son_type 
)
pure virtual

A function that constructs a specific type of tree. This MUST be overloaded for each specific tree type. The use of such a function allows the generic implementation of split_if_required().

Implemented in oomph::OcTree, oomph::QuadTree, and oomph::BinaryTree.

Referenced by split_if_required().

void oomph::Tree::deactivate_object ( )

Call the RefineableElement's deactivate_element() function.

Call the RefineableElement's deactivate_element() function that is used to perform any final changes to internal data storage of deactivated objects.

Definition at line 338 of file tree.cc.

References oomph::RefineableElement::deactivate_element(), and object_pt().

Referenced by oomph::TreeBasedRefineableMeshBase::adapt_mesh(), and oomph::TreeBasedRefineableMeshBase::p_adapt_mesh().

Tree* oomph::Tree::father_pt ( ) const
inline
void oomph::Tree::flush_object ( )
inline

Flush the object represented by the tree.

Definition at line 105 of file tree.h.

References Object_pt.

Referenced by oomph::Mesh::distribute(), and oomph::Mesh::prune_halo_elements_and_nodes().

void oomph::Tree::flush_sons ( )
inline
bool oomph::Tree::is_leaf ( )
inline
unsigned oomph::Tree::level ( ) const
inline

Return the level of the Tree (root=0)

Definition at line 230 of file tree.h.

References Level.

static double& oomph::Tree::max_neighbour_finding_tolerance ( )
inlinestatic

Max. allowed discrepancy in neighbour finding routine (distance between points when identified from two neighbouring elements)

Definition at line 235 of file tree.h.

References Max_neighbour_finding_tolerance.

Referenced by oomph::BinaryTreeForest::check_all_neighbours(), oomph::QuadTreeForest::check_all_neighbours(), oomph::OcTreeForest::check_all_neighbours(), oomph::BinaryTreeForest::self_test(), oomph::QuadTreeForest::self_test(), and oomph::OcTreeForest::self_test().

void oomph::Tree::merge_sons_if_required ( Mesh *&  mesh_pt)

If required, merge the four sons for unrefinement – criterion: bool object_pt()-> sons_to_be_unrefined() = true.

If required, kill the sons to perform unrefinement.

Unrefinement is performed if

 object_pt()->sons_to_be_unrefined()

returns true.

Definition at line 299 of file tree.cc.

References oomph::RefineableElement::deselect_sons_for_unrefinement(), nsons(), object_pt(), Object_pt, oomph::RefineableElement::rebuild_from_sons(), son_pt(), Son_pt, oomph::RefineableElement::sons_to_be_unrefined(), and oomph::RefineableElement::unbuild().

Referenced by oomph::TreeBasedRefineableMeshBase::adapt_mesh().

unsigned oomph::Tree::nsons ( ) const
inline
RefineableElement* oomph::Tree::object_pt ( ) const
inline

Return the pointer to the object (RefineableElement) represented by the tree.

Definition at line 102 of file tree.h.

References Object_pt.

Referenced by oomph::TreeBasedRefineableMeshBase::adapt(), oomph::RefineableQElement< 3 >::check_integrity(), oomph::RefineableQElement< 1 >::check_integrity(), oomph::RefineableQElement< 2 >::check_integrity(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::check_integrity(), deactivate_object(), oomph::OcTree::doc_face_neighbours(), oomph::BinaryTree::doc_neighbours(), oomph::QuadTree::doc_neighbours(), oomph::OcTree::doc_true_edge_neighbours(), oomph::RefineableElement::father_element_pt(), oomph::RefineableLinearisedAxisymmetricQCrouzeixRaviartElement::further_build(), oomph::RefineableQSphericalCrouzeixRaviartElement::further_build(), oomph::RefineablePolarCrouzeixRaviartElement::further_build(), oomph::RefineableAxisymmetricQCrouzeixRaviartElement::further_build(), oomph::RefineableGeneralisedNewtonianAxisymmetricQCrouzeixRaviartElement::further_build(), oomph::RefineableElement::get_father_at_refinement_level(), oomph::RefineablePolarTaylorHoodElement::get_interpolated_values(), oomph::RefineablePolarCrouzeixRaviartElement::get_interpolated_values(), oomph::PRefineableQElement< 1, INITIAL_NNODE_1D >::initial_setup(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::initial_setup(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::initial_setup(), merge_sons_if_required(), oomph::RefineableQElement< 3 >::node_created_by_neighbour(), oomph::RefineableQElement< 2 >::node_created_by_neighbour(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::node_created_by_neighbour(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::node_created_by_neighbour(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::node_created_by_son_of_neighbour(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::node_created_by_son_of_neighbour(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::oc_hang_helper(), p_refine_if_required(), oomph::Mesh::prune_halo_elements_and_nodes(), oomph::Problem::prune_halo_elements_and_nodes(), oomph::RefineableQElement< 2 >::quad_hang_helper(), oomph::RefineableLinearisedAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableQSphericalCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineablePolarCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableGeneralisedNewtonianAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableElement::root_element_pt(), oomph::RefineableBrickMesh< ELEMENT >::setup_octree_forest(), oomph::RefineableQuadMesh< ELEMENT >::setup_quadtree_forest(), and split_if_required().

void oomph::Tree::operator= ( const Tree )
inline

Broken assignment operator.

Definition at line 95 of file tree.h.

References oomph::BrokenCopy::broken_assign().

template<class ELEMENT >
void oomph::Tree::p_refine_if_required ( Mesh *&  mesh_pt)

If required, p-refine the leaf – criterion: bool object_pt()-> to_be_p_refined() = true or bool object_pt()-> to_be_p_unrefined() = true.

If required, p-refine/unrefine the leaf element

p-refinement is performed if

 object_pt()->to_be_p_refined()

returns true. p-unrefinement is performed if

 object_pt()->to_be_p_unrefined()

returns true.

If this is the case, then we execute

 object_pt()->p_refine(+/-1,mesh_pt,clone_pt) 

to p-refine the element, where mesh_pt is a pointer to the mesh that the element lives in, and clone_pt is a pointer to a GeneralisedElement that has all the information that would be needed from the father element during h-refinement.

Definition at line 159 of file tree.template.cc.

References Father_pt, i, oomph::Node::ndim(), oomph::FiniteElement::nnode(), oomph::FiniteElement::node_pt(), object_pt(), Object_pt, oomph::PRefineableElement::p_refine(), Son_pt, oomph::Global_string_for_annotation::string(), oomph::PRefineableElement::to_be_p_refined(), oomph::PRefineableElement::to_be_p_unrefined(), and oomph::Node::x().

TreeRoot*& oomph::Tree::root_pt ( )
inline
TreeRoot* oomph::Tree::root_pt ( ) const
inline

Return pointer to root of the tree (const version)

Definition at line 146 of file tree.h.

References Root_pt.

void oomph::Tree::set_father_pt ( Tree *const &  father_pt)
inline
void oomph::Tree::set_son_pt ( const Vector< Tree * > &  son_pt)
inline

Set vector of pointers to sons, indexed by the appropriate enum that identies son types. (To aid code readability specific enums have been defined for specific trees. However, these are simply aliases for ints and the general interface can be implemented once, here).

Definition at line 128 of file tree.h.

References son_pt(), and Son_pt.

Referenced by oomph::RefineableBrickMesh< ELEMENT >::setup_octree_forest(), and oomph::RefineableQuadMesh< ELEMENT >::setup_quadtree_forest().

Tree* oomph::Tree::son_pt ( const int &  son_index) const
inline
int oomph::Tree::son_type ( ) const
inline
template<class ELEMENT >
void oomph::Tree::split_if_required ( )

If required, split the leaf and create its sons – criterion: bool object_pt()-> to_be_refined() = true.

If required, split the leaf element and create its sons

Split is performed if

 object_pt()->to_be_refined()

returns true.

If this is the case, then we execute

 object_pt()->split(new_elements_pt) 

to create the sons. Pointers to the son objects are then inserted into the son pointers of the present element. This turns the present element into a "grey" (=non-leaf) node.

Definition at line 67 of file tree.template.cc.

References construct_son(), father_pt(), Father_pt, i, oomph::Node::ndim(), oomph::FiniteElement::nnode(), oomph::FiniteElement::node_pt(), object_pt(), Object_pt, Son_pt, oomph::RefineableElement::split(), oomph::Global_string_for_annotation::string(), oomph::RefineableElement::to_be_refined(), and oomph::Node::x().

void oomph::Tree::stick_all_tree_nodes_into_vector ( Vector< Tree * > &  all_tree_nodes)

Traverse and stick pointers to all "nodes" into Vector.

Traverse Tree: Preorder traverse and stick pointer to all nodes (incl. "grey"=non-leaf ones) into Vector

Definition at line 276 of file tree.cc.

References i, and Son_pt.

Referenced by oomph::Mesh::prune_halo_elements_and_nodes(), oomph::Problem::prune_halo_elements_and_nodes(), oomph::BinaryTree::self_test(), oomph::QuadTree::self_test(), oomph::OcTree::self_test(), oomph::RefineableBrickMesh< ELEMENT >::setup_octree_forest(), and oomph::RefineableQuadMesh< ELEMENT >::setup_quadtree_forest().

void oomph::Tree::stick_leaves_into_vector ( Vector< Tree * > &  tree_nodes)

Traverse tree and stick pointers to leaf "nodes" (only) into Vector.

Traverse Tree: Preorder traverse and stick pointers to leaf nodes (only) into Vector

Definition at line 255 of file tree.cc.

References i, and Son_pt.

Referenced by oomph::Mesh::get_all_halo_data(), oomph::Mesh::halo_element_pt(), oomph::Mesh::haloed_element_pt(), and oomph::TreeForest::stick_leaves_into_vector().

void oomph::Tree::traverse_all ( Tree::VoidMemberFctPt  member_function)

Traverse the tree and execute void Tree member function member_function() at all its "nodes".

Preorder traverse the tree and execute void Tree member function at all nodes

Definition at line 151 of file tree.cc.

References i, and Son_pt.

Referenced by oomph::TreeBasedRefineableMeshBase::adapt_mesh().

void oomph::Tree::traverse_all ( Tree::VoidMeshPtArgumentMemberFctPt  member_function,
Mesh *&  mesh_pt 
)

Traverse the tree and excute void Tree member function that takes a pointer to a mesh as an argument.

Preorder traverse the tree and execute a void Tree member function that takes one argument at all nodes.

Definition at line 170 of file tree.cc.

References i, and Son_pt.

void oomph::Tree::traverse_all_but_leaves ( Tree::VoidMemberFctPt  member_function)

Traverse the tree and execute void Tree member function.

member_function() at all its "nodes" aparat from the leaves

Preorder traverse the tree and execute a void Tree member function for all elements that are not leaf elements.

Definition at line 188 of file tree.cc.

References i, and Son_pt.

void oomph::Tree::traverse_leaves ( Tree::VoidMemberFctPt  member_function)

Traverse the tree and execute void Tree member function member_function() only at its leaves.

Preorder traverse the tree and execute void Tree member function at the leaves only (ignore "grey" = non-leaf nodes)

Definition at line 211 of file tree.cc.

References i, and Son_pt.

void oomph::Tree::traverse_leaves ( Tree::VoidMeshPtArgumentMemberFctPt  member_function,
Mesh *&  mesh_pt 
)

Traverse the tree and execute void Tree member function that takes a pointer to a mesh as an argument only at its leaves.

Preorder traverse the tree and execute void Tree member function that takes one argument at the leaves only (ignore "grey" = non-leaf nodes)

Definition at line 233 of file tree.cc.

References i, and Son_pt.

Member Data Documentation

Tree* oomph::Tree::Father_pt
protected
int oomph::Tree::Level
protected
double oomph::Tree::Max_neighbour_finding_tolerance =1.0e-14
staticprotected

Max. allowed discrepancy in neighbour finding routine (distance between points when identified from two neighbouring elements)

Maximum tolerance for neighbour finding (distance between points when identified from the two neighbours)

Definition at line 292 of file tree.h.

Referenced by oomph::OcTree::doc_face_neighbours(), oomph::OcTree::doc_true_edge_neighbours(), max_neighbour_finding_tolerance(), oomph::BinaryTree::self_test(), oomph::QuadTree::self_test(), and oomph::OcTree::self_test().

RefineableElement* oomph::Tree::Object_pt
protected

Pointer to the object represented by the tree.

Definition at line 287 of file tree.h.

Referenced by flush_object(), merge_sons_if_required(), object_pt(), p_refine_if_required(), split_if_required(), and ~Tree().

const int oomph::Tree::OMEGA =26
static

Default value for an unassigned neighbour.

Static value used to represent unassigned quantities. This has to remain consistent with the enumerations in the Octree and Quadtree namespaces!

Definition at line 241 of file tree.h.

Referenced by oomph::RefineableQElement< 3 >::build(), oomph::RefineableQElement< 2 >::build(), oomph::OcTreeForest::construct_up_right_equivalents(), oomph::BinaryTreeRoot::direction_of_neighbour(), oomph::QuadTreeRoot::direction_of_neighbour(), oomph::OcTreeRoot::direction_of_neighbour(), oomph::OcTree::doc_face_neighbours(), oomph::OcTree::doc_true_edge_neighbours(), oomph::OcTree::gteq_edge_neighbour(), oomph::MGSolver< DIM >::level_up_local_coord_of_node(), oomph::HelmholtzMGPreconditioner< DIM >::level_up_local_coord_of_node(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::p_refine(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::p_refine(), oomph::RefineableQSpectralElement< 2 >::rebuild_from_sons(), oomph::RefineableQSpectralElement< 3 >::rebuild_from_sons(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::rebuild_from_sons(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::rebuild_from_sons(), oomph::OcTreeRoot::right_equivalent(), oomph::RefineableQElement< 1 >::setup_father_bounds(), oomph::RefineableQElement< 3 >::setup_father_bounds(), oomph::RefineableQElement< 2 >::setup_father_bounds(), oomph::MGSolver< DIM >::setup_interpolation_matrices(), oomph::HelmholtzMGPreconditioner< DIM >::setup_interpolation_matrices(), oomph::BinaryTree::setup_static_data(), oomph::QuadTree::setup_static_data(), oomph::OcTree::setup_static_data(), Tree(), and oomph::OcTreeRoot::up_equivalent().

TreeRoot* oomph::Tree::Root_pt
protected
Vector<Tree*> oomph::Tree::Son_pt
protected
int oomph::Tree::Son_type
protected

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