QuadTree class: Recursively defined, generalised quadtree. More...
#include <quadtree.h>
Public Member Functions | |
virtual | ~QuadTree () |
Destructor. Note: Deleting a quadtree also deletes the objects associated with all non-leaf nodes! More... | |
QuadTree (const QuadTree &dummy)=delete | |
Broken copy constructor. More... | |
void | operator= (const QuadTree &)=delete |
Broken assignment operator. More... | |
Tree * | construct_son (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type) |
Overload the function construct_son to ensure that the son is a specific QuadTree and not a general Tree. More... | |
QuadTree * | gteq_edge_neighbour (const int &direction, Vector< unsigned > &translate_s, Vector< double > &s_lo, Vector< double > &s_hi, 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 and orientation of neighbour: More... | |
void | stick_neighbouring_leaves_into_vector (Vector< const QuadTree * > &tree_neighbouring_nodes, Vector< Vector< double >> &tree_neighbouring_s_lo, Vector< Vector< double >> &tree_neighbouring_s_hi, Vector< int > &tree_neighbouring_diff_level, const QuadTree *my_neigh_pt, const int &direction) const |
Traverse Tree: Preorder traverse and stick pointers to neighbouring leaf nodes (only) into Vector. More... | |
unsigned | self_test () |
Self-test: Check all neighbours. Return success (0) if the max. distance between corresponding points in the neighbours is less than the tolerance specified in the static value QuadTree::Max_neighbour_finding_tolerance. More... | |
Public Member Functions inherited from oomph::Tree | |
virtual | ~Tree () |
Destructor. Note: Deleting a tree also deletes the objects associated with its non-leave nodes. More... | |
Tree (const Tree &dummy)=delete | |
Broken copy constructor. More... | |
void | operator= (const Tree &)=delete |
Broken assignment operator. More... | |
RefineableElement * | object_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... | |
Tree * | son_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... | |
TreeRoot * | root_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... | |
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 member_function() at all its "nodes" aparat from the leaves. 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... | |
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 () |
Setup the static data, rotation and 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) |
Doc/check all neighbours of quadtree (nodes) contained in the Vector forest_node_pt. Output into neighbours_file which can be viewed from tecplot with QuadTreeNeighbours.mcr Neighbour info and errors are displayed on neighbours_txt_file. Finally, compute the max. error between vertices when viewed from neighhbouring element. If the two filestreams are closed, output is suppressed. More... | |
Static Public Member Functions inherited from oomph::Tree | |
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 Vector< std::string > | Direct_string |
Translate (enumerated) directions into strings. More... | |
Static Public Attributes inherited from oomph::Tree | |
static const int | OMEGA = 26 |
Default value for an unassigned neighbour. More... | |
Protected Member Functions | |
QuadTree () | |
Default constructor (empty and broken) More... | |
QuadTree (RefineableElement *const &object_pt) | |
Default constructor for empty (root) tree: no father, no sons; just pass a pointer to its object Protected because QuadTrees can only be created internally, during the split operation. Only QuadTreeRoots can be created externally. More... | |
QuadTree (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 (SE/SW/NE/NW) it is. Protected because QuadTrees can only be created internally, during the split operation. Only QuadTreeRoots can be created externally. More... | |
Protected Member Functions inherited from oomph::Tree | |
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... | |
Static Protected Attributes | |
static bool | Static_data_has_been_setup = false |
Bool indicating that static member data has been setup. More... | |
Static Protected Attributes inherited from oomph::Tree | |
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... | |
Private Member Functions | |
QuadTree * | gteq_edge_neighbour (const int &direction, double &s_diff, int &diff_level, bool &in_neighbouring_tree, int max_level, QuadTreeRoot *const &orig_root_pt) const |
Find greater or equal-sized edge neighbour in direction. Auxiliary internal routine which passes additional information around. More... | |
Static Private Attributes | |
static Vector< std::string > | Colour |
Colours for neighbours in various directions. More... | |
static DenseMatrix< double > | S_base |
S_base(i,direction): Initial value for coordinate s[i] on the edge indicated by direction (S/E/N/W) More... | |
static DenseMatrix< double > | S_step |
S_step(i,direction) Increments for coordinate s[i] when progressing along the edge indicated by direction (S/E/N/W); Left/lower vertex: S_base; Right/upper vertex: S_base + S_step. More... | |
static Vector< int > | Reflect_edge |
Get opposite edge, e.g. Reflect_edge[N]=S. More... | |
static DenseMatrix< bool > | Is_adjacent |
Array of direction/quadrant adjacency scheme: Is_adjacent(i_vertex_or_edge,j_quadrant): Is edge/vertex adjacent to quadrant? More... | |
static DenseMatrix< int > | Reflect |
Reflection scheme: Reflect(direction,quadrant): Get mirror of quadrant in specified direction. E.g. Reflect(S,NE)=SE. More... | |
static DenseMatrix< int > | Rotate |
Rotate coordinates: If North becomes NorthIs then direction becomes Rotate(NorthIs,direction). E.g. Rotate(E,NW)=NE;. More... | |
static DenseMatrix< int > | Rotate_angle |
Angle betwen rotated coordinates: If old_direction becomes new_direction then the angle between the axes (in anti-clockwise direction is Rotate_angle(old_direction,new_direction); E.g. Rotate_angle(E,N)=90;. More... | |
static DenseMatrix< int > | S_direct |
S_direct(direction,son_quadrant): The lower left corner of son_quadrant has an offset of h/2 S_direct(direction,son_quadrant) in the specified direction. E.g. S_direct(S,NE)=1 and S_direct(S,NW)=0. More... | |
Additional Inherited Members | |
Public Types inherited from oomph::Tree | |
typedef void(Tree::* | VoidMemberFctPt) () |
Function pointer to argument-free void Tree member function. More... | |
typedef void(Tree::* | VoidMeshPtArgumentMemberFctPt) (Mesh *&mesh_pt) |
Function pointer to a void Tree member function that takes a pointer to a mesh as its argument. More... | |
Protected Attributes inherited from oomph::Tree | |
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... | |
QuadTree class: Recursively defined, generalised quadtree.
A QuadTree 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 quadtrees.
The objects contained in the quadtree are assumed to be (topologically) rectangular elements whose geometry is parametrised by local coordinates .
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 QuadTrees are only generated by splitting existing QuadTrees. Therefore, the constructors are protected. The only QuadTree that "Joe User" can create is the (derived) class QuadTreeRoot.
Definition at line 103 of file quadtree.h.
|
inlinevirtual |
Destructor. Note: Deleting a quadtree also deletes the objects associated with all non-leaf nodes!
Definition at line 108 of file quadtree.h.
|
delete |
Broken copy constructor.
|
inlineprotected |
Default constructor (empty and broken)
Definition at line 203 of file quadtree.h.
Referenced by construct_son().
|
inlineprotected |
Default constructor for empty (root) tree: no father, no sons; just pass a pointer to its object Protected because QuadTrees can only be created internally, during the split operation. Only QuadTreeRoots can be created externally.
Definition at line 216 of file quadtree.h.
|
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 (SE/SW/NE/NW) it is. Protected because QuadTrees can only be created internally, during the split operation. Only QuadTreeRoots can be created externally.
Definition at line 224 of file quadtree.h.
|
inlinevirtual |
Overload the function construct_son to ensure that the son is a specific QuadTree and not a general Tree.
Implements oomph::Tree.
Definition at line 118 of file quadtree.h.
References oomph::Tree::father_pt(), oomph::Tree::object_pt(), QuadTree(), and oomph::Tree::son_type().
|
static |
Doc/check all neighbours of quadtree (nodes) contained in the Vector forest_node_pt. Output into neighbours_file which can be viewed from tecplot with QuadTreeNeighbours.mcr Neighbour info and errors are displayed on neighbours_txt_file. Finally, compute the max. error between vertices when viewed from neighhbouring element. If the two filestreams are closed, output is suppressed.
Doc/check all neighbours of quadtree ("nodes") contained in the Vector forest_node_pt. Output into neighbours_file which can be viewed from tecplot with QuadTreeNeighbours.mcr Neighbour info and errors are displayed on neighbours_txt_file. Finally, compute the max. error between vertices when viewed from neighhbouring element. Output is suppressed if the output streams are closed.
Definition at line 1402 of file quadtree.cc.
References oomph::FiniteElement::get_x(), gteq_edge_neighbour(), i, oomph::TreeRoot::is_neighbour_periodic(), oomph::QuadTreeNames::N, oomph::RefineableElement::nodes_built(), oomph::RefineableElement::number(), oomph::Tree::object_pt(), oomph::BinaryTreeNames::OMEGA, oomph::Tree::root_pt(), s, and oomph::QuadTreeNames::W.
Referenced by oomph::QuadTreeForest::check_all_neighbours(), self_test(), and oomph::QuadTreeForest::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 (N/E/S/W).
This is an auxiliary routine which allows neighbour finding in adjacent quadtrees. Needs to keep track of previous son types and the maximum level to which search is performed.
Parameters:
Definition at line 601 of file quadtree.cc.
References oomph::QuadTreeNames::E, oomph::Tree::Father_pt, gteq_edge_neighbour(), Is_adjacent, oomph::Tree::Level, oomph::QuadTreeNames::N, oomph::TreeRoot::neighbour_pt(), Reflect, oomph::Tree::Root_pt, Rotate, oomph::QuadTreeNames::S, S_direct, oomph::Tree::Son_pt, oomph::Tree::Son_type, and oomph::QuadTreeNames::W.
QuadTree * oomph::QuadTree::gteq_edge_neighbour | ( | const int & | direction, |
Vector< unsigned > & | translate_s, | ||
Vector< double > & | s_lo, | ||
Vector< double > & | s_hi, | ||
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 and orientation of neighbour:
s_lo
[0], s_lo
[1]) in the neighbouring quadtree.s_hi
[0], s_hi
[1]) in the neighbouring quadtree.direction
. When viewed from the neighbouring quadtree, the edge that separates the present quadtree from its neighbour is the neighbour's edge
edge. If there's no rotation between the two quadtrees, this is a simple reflection: For instance, if we're looking for a neighhbour in the N
[orthern] direction
, edge
will be S
[outh]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 quadtree.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.s_lo
[0], s_lo
[1]) in the neighbouring quadtree.s_hi
[0], s_hi
[1]) in the neighbouring quadtree.direction
. When viewed from the neighbouring quadtree, the edge that separates the present quadtree from its neighbour is the neighbour's edge
edge. If there's no rotation between the two quadtrees, this is a simple reflection: For instance, if we're looking for a neighhbour in the N
[orthern] direction
, edge
will be S
[outh]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 quadtree.in_neighbouring_tree
returns true is we have had to flip to a different root, even if that root is actually the same as it can be in periodic problems. Definition at line 413 of file quadtree.cc.
References oomph::QuadTreeNames::E, oomph::Tree::Level, oomph::QuadTreeNames::N, oomph::QuadTreeRoot::north_equivalent(), Reflect_edge, oomph::Tree::root_pt(), oomph::Tree::Root_pt, Rotate, Rotate_angle, oomph::QuadTreeNames::S, S_base, S_step, and oomph::QuadTreeNames::W.
Referenced by oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::check_integrity(), oomph::RefineableQElement< 2 >::check_integrity(), doc_neighbours(), gteq_edge_neighbour(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::node_created_by_neighbour(), oomph::RefineableQElement< 2 >::node_created_by_neighbour(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::node_created_by_son_of_neighbour(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::quad_hang_helper(), oomph::RefineableQElement< 2 >::quad_hang_helper(), and stick_neighbouring_leaves_into_vector().
|
delete |
Broken assignment operator.
unsigned oomph::QuadTree::self_test | ( | ) |
Self-test: Check all neighbours. Return success (0) if the max. distance between corresponding points in the neighbours is less than the tolerance specified in the static value QuadTree::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 neigbour. If the difference is less than Tree::Max_neighbour_finding_tolerance. return success (0), otherwise failure (1)
Definition at line 814 of file quadtree.cc.
References doc_neighbours(), i, oomph::Tree::Max_neighbour_finding_tolerance, oomph::oomph_info, and oomph::Tree::stick_all_tree_nodes_into_vector().
|
static |
Setup the static data, rotation and reflection schemes, etc.
Setup the static data stored in the QuadTree – this needs to be called before QuadTrees can be used. Automatically called by RefineableQuadMesh constructor.
Definition at line 120 of file quadtree.cc.
References Colour, Direct_string, oomph::QuadTreeNames::E, Is_adjacent, oomph::QuadTreeNames::N, oomph::QuadTreeNames::NE, oomph::QuadTreeNames::NW, oomph::Tree::OMEGA, Reflect, Reflect_edge, oomph::DenseMatrix< T >::resize(), Rotate, Rotate_angle, oomph::QuadTreeNames::S, S_base, S_direct, S_step, oomph::QuadTreeNames::SE, Static_data_has_been_setup, oomph::QuadTreeNames::SW, and oomph::QuadTreeNames::W.
Referenced by oomph::RefineableQuadMesh< ELEMENT >::RefineableQuadMesh().
void oomph::QuadTree::stick_neighbouring_leaves_into_vector | ( | Vector< const QuadTree * > & | tree_neighbouring_nodes, |
Vector< Vector< double >> & | tree_neighbouring_s_lo, | ||
Vector< Vector< double >> & | tree_neighbouring_s_hi, | ||
Vector< int > & | tree_neighbouring_diff_level, | ||
const QuadTree * | my_neigh_pt, | ||
const int & | direction | ||
) | const |
Traverse Tree: Preorder traverse and stick pointers to neighbouring leaf nodes (only) into Vector.
Definition at line 751 of file quadtree.cc.
References gteq_edge_neighbour(), i, and oomph::Tree::Son_pt.
|
staticprivate |
Colours for neighbours in various directions.
Colours for neighbours in various directions (static data)
Definition at line 246 of file quadtree.h.
Referenced by setup_static_data().
|
static |
Translate (enumerated) directions into strings.
Translate (enumerated) directions into strings (static data)
Definition at line 199 of file quadtree.h.
Referenced by oomph::QuadTreeRoot::north_equivalent(), and setup_static_data().
|
staticprivate |
Array of direction/quadrant adjacency scheme: Is_adjacent(i_vertex_or_edge,j_quadrant): Is edge/vertex adjacent to quadrant?
Array of direction/quadrant adjacency scheme: Is_adjacent(i_vertex_or_edge,j_quadrant): Is edge/vertex adjacent to quadrant? (static data)
Definition at line 263 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
Reflection scheme: Reflect(direction,quadrant): Get mirror of quadrant in specified direction. E.g. Reflect(S,NE)=SE.
Reflection scheme: Reflect(direction,quadrant): Get mirror of quadrant in specified direction. E.g. Reflect(S,NE)=SE (static data)
Definition at line 267 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
Get opposite edge, e.g. Reflect_edge[N]=S.
Get opposite edge, e.g. Reflect_edge[N]=S (static data)
Definition at line 258 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
Rotate coordinates: If North becomes NorthIs then direction becomes Rotate(NorthIs,direction). E.g. Rotate(E,NW)=NE;.
Rotate coordinates: If north becomes NorthIs then direction becomes Rotate(NorthIs,direction). E.g. Rotate(E,NW)=NE; (static data)
Definition at line 271 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
Angle betwen rotated coordinates: If old_direction becomes new_direction then the angle between the axes (in anti-clockwise direction is Rotate_angle(old_direction,new_direction); E.g. Rotate_angle(E,N)=90;.
Angle betwen rotated coordinates: If old_direction becomes new_direction then the angle between the axes (in anti-clockwise direction is Rotate_angle(old_direction,new_direction); E.g. Rotate_angle(E,N)=90; (static data)
Definition at line 277 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
S_base(i,direction): Initial value for coordinate s[i] on the edge indicated by direction (S/E/N/W)
S_base(i,direction): Initial value for coordinate s[i] on the edge indicated by direction (S/E/N/W) (static data)
Definition at line 250 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
S_direct(direction,son_quadrant): The lower left corner of son_quadrant has an offset of h/2 S_direct(direction,son_quadrant) in the specified direction. E.g. S_direct(S,NE)=1 and S_direct(S,NW)=0.
S_direct(direction,son_quadrant): The lower left corner of son_quadrant has an offset of h/2 S_direct(direction,son_quadrant) in the specified direction. E.g. S_direct(S,NE)=1 and S_direct(S,NW)=0 (static data)
Definition at line 282 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprivate |
S_step(i,direction) Increments for coordinate s[i] when progressing along the edge indicated by direction (S/E/N/W); Left/lower vertex: S_base; Right/upper vertex: S_base + S_step.
S_step(i,direction) Increments for coordinate s[i] when progressing along the edge indicated by direction (S/E/N/W); Left/lower vertex: S_base; Right/upper vertex: S_base + S_step (static data)
Definition at line 255 of file quadtree.h.
Referenced by gteq_edge_neighbour(), and setup_static_data().
|
staticprotected |
Bool indicating that static member data has been setup.
Definition at line 232 of file quadtree.h.
Referenced by oomph::QuadTreeRoot::QuadTreeRoot(), and setup_static_data().