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 ()
 
 Tree (const Tree &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const Tree &)=delete
 Broken assignment operator. More...
 
RefineableElementobject_pt () const
 
void flush_object ()
 Flush the object represented by the tree. More...
 
Treeson_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...
 
TreeRootroot_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...
 
virtual Treeconstruct_son (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)=0
 
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...
 
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 doublemax_neighbour_finding_tolerance ()
 

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)
 
 Tree (RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)
 

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
 

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.

Member Typedef Documentation

◆ VoidMemberFctPt

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

Function pointer to argument-free void Tree member function.

◆ VoidMeshPtArgumentMemberFctPt

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

Constructor & Destructor Documentation

◆ ~Tree()

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.

123  {
124  // Loop over all the sons and delete them
125  unsigned nsons = Son_pt.size();
126  for (unsigned i = 0; i < nsons; i++)
127  {
128  // This will call the son's destructor (a subtle recursion)
129  delete Son_pt[i];
130  Son_pt[i] = 0;
131  }
132 
133  // Delete the object only if the Tree has sons (is not a leaf node)
134  if (nsons > 0)
135  {
136  delete Object_pt;
137  Object_pt = 0;
138  }
139  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
unsigned nsons() const
Return number of sons (zero if it's a leaf node)
Definition: tree.h:129
RefineableElement * Object_pt
Pointer to the object represented by the tree.
Definition: tree.h:308
Vector< Tree * > Son_pt
Vector of pointers to the sons of the Tree.
Definition: tree.h:299

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

◆ Tree() [1/4]

oomph::Tree::Tree ( const Tree dummy)
delete

Broken copy constructor.

◆ Tree() [2/4]

oomph::Tree::Tree ( )
inlineprotected

Default constructor (empty and broken)

267  {
268  // Throw an error
269  throw OomphLibError("Don't call an empty constructor for a Tree object",
272  }
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ Tree() [3/4]

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.

64  {
65  // No father node:
66  Father_pt = 0;
67 
68  // I'm not a son, so I don't have a son type either....
69  Son_type = OMEGA;
70 
71  // I am the root
72  Level = 0;
73 
74  // Root pointer must be set in the TreeRoot constructor
75  Root_pt = 0;
76 
77  // No sons just yet:
78  Son_pt.resize(0);
79 
80  // Tell the object which tree it's represented by
81  object_pt->set_tree_pt(this);
82  };
void set_tree_pt(Tree *my_tree_pt)
Set pointer to quadtree representation of this element.
Definition: refineable_elements.h:217
Tree * Father_pt
Pointer to the Father of the Tree.
Definition: tree.h:296
RefineableElement * object_pt() const
Definition: tree.h:88
TreeRoot * Root_pt
Pointer to the root of the tree.
Definition: tree.h:292
int Son_type
Son type (e.g. SW/SE/NW/NE in a quadtree)
Definition: tree.h:305
int Level
Level of the Tree (level 0 = root)
Definition: tree.h:302
static const int OMEGA
Default value for an unassigned neighbour.
Definition: tree.h:262

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

◆ Tree() [4/4]

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.

96  {
97  // Set the father node
99 
100  // Set the son type
101  Son_type = son_type;
102 
103  // My level is one deeper than that of my father
104  Level = father_pt->Level + 1;
105 
106  // I have no sons of my own just yet:
107  Son_pt.resize(0);
108 
109  // Inherit root pointer from father
111 
112  // Tell the object which tree it's represented by
113  object_pt->set_tree_pt(this);
114  }
Tree * father_pt() const
Return pointer to father: NULL if it's a root node.
Definition: tree.h:235
int son_type() const
Return son type.
Definition: tree.h:214

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

Member Function Documentation

◆ construct_son()

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::QuadTree, oomph::OcTree, and oomph::BinaryTree.

Referenced by split_if_required().

◆ deactivate_object()

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.

342  {
343  // Call the function
345  }
virtual void deactivate_element()
Definition: refineable_elements.cc:293

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

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

◆ father_pt()

◆ flush_object()

void oomph::Tree::flush_object ( )
inline

Flush the object represented by the tree.

95  {
96  Object_pt = 0;
97  }

References Object_pt.

◆ flush_sons()

void oomph::Tree::flush_sons ( )
inline

◆ is_leaf()

bool oomph::Tree::is_leaf ( )
inline

Return true if the tree is a leaf node.

221  {
222  // If there are no sons, it's a leaf, return true
223  if (Son_pt.size() == 0)
224  {
225  return true;
226  }
227  // Otherwise return false
228  else
229  {
230  return false;
231  }
232  }

References Son_pt.

Referenced by oomph::TreeBasedRefineableMeshBase::adapt(), oomph::OcTree::doc_true_edge_neighbours(), and oomph::TreeBasedRefineableMeshBase::refine_as_in_reference_mesh().

◆ level()

unsigned oomph::Tree::level ( ) const
inline

Return the level of the Tree (root=0)

248  {
249  return Level;
250  }

References Level.

Referenced by OscRingNStProblem< ELEMENT >::doc_solution(), and OscRingNStProblem< ELEMENT >::doc_solution_historic().

◆ max_neighbour_finding_tolerance()

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)

256  {
258  }
static double Max_neighbour_finding_tolerance
Definition: tree.h:313

References Max_neighbour_finding_tolerance.

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

◆ merge_sons_if_required()

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.

303  {
304  // Check if unrefinement is required
306  {
307  // Rebuild the father from sons
308  object_pt()->rebuild_from_sons(mesh_pt);
309 
310  // Find the number of sons
311  unsigned n_sons = nsons();
312  // Kill all the sons
313  for (unsigned ison = 0; ison < n_sons; ison++)
314  {
315  // Unbuild the element by marking the nodes as obsolete
316  son_pt(ison)->object_pt()->unbuild();
317 
318  // Delete the object. This must be done here, because the
319  // destructor of a tree does not delete the leaf nodes
320  // (the actual elements that are used in the mesh).
321  // In general, the destruction of the leaf nodes is handled by the
322  // mesh destructors.
323  delete son_pt(ison)->object_pt();
324 
325  // Now delete the tree representation
326  delete son_pt(ison);
327  }
328 
329  Son_pt.resize(0);
330 
331  // Have merged my sons -- can't do it again...
333  }
334  }
virtual void rebuild_from_sons(Mesh *&mesh_pt)=0
virtual void unbuild()
Definition: refineable_elements.h:362
bool sons_to_be_unrefined()
Has the element been selected for unrefinement?
Definition: refineable_elements.h:351
void deselect_sons_for_unrefinement()
Definition: refineable_elements.h:339
Tree * son_pt(const int &son_index) const
Definition: tree.h:103

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().

◆ nsons()

◆ object_pt()

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

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

89  {
90  return Object_pt;
91  }

References Object_pt.

Referenced by oomph::TreeBasedRefineableMeshBase::adapt(), oomph::RefineableQElement< 3 >::build(), oomph::RefineableQElement< 1 >::build(), oomph::RefineableQElement< 2 >::build(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::check_integrity(), oomph::RefineableQElement< 3 >::check_integrity(), oomph::RefineableQElement< 1 >::check_integrity(), oomph::RefineableQElement< 2 >::check_integrity(), oomph::BinaryTree::construct_son(), oomph::OcTree::construct_son(), oomph::QuadTree::construct_son(), oomph::OcTreeForest::construct_up_right_equivalents(), deactivate_object(), oomph::OcTree::doc_face_neighbours(), oomph::BinaryTree::doc_neighbours(), oomph::QuadTree::doc_neighbours(), OscRingNStProblem< ELEMENT >::doc_solution(), OscRingNStProblem< ELEMENT >::doc_solution_historic(), oomph::OcTree::doc_true_edge_neighbours(), UnsteadyHeatProblem< ELEMENT >::enforce_time_periodic_boundary_conditions(), oomph::RefineableElement::father_element_pt(), oomph::RefineableLinearisedAxisymmetricQCrouzeixRaviartElement::further_build(), oomph::RefineableAxisymmetricQCrouzeixRaviartElement::further_build(), oomph::RefineableGeneralisedNewtonianAxisymmetricQCrouzeixRaviartElement::further_build(), oomph::RefineableLinearisedQCrouzeixRaviartElement::further_build(), oomph::RefineablePolarCrouzeixRaviartElement::further_build(), oomph::RefineableQSphericalCrouzeixRaviartElement::further_build(), oomph::RefineableElement::get_father_at_refinement_level(), oomph::RefineablePolarTaylorHoodElement::get_interpolated_values(), oomph::RefineablePolarCrouzeixRaviartElement::get_interpolated_values(), ModalPRefineableQElement< DIM >::initial_setup(), 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::PRefineableQElement< 2, INITIAL_NNODE_1D >::node_created_by_neighbour(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::node_created_by_neighbour(), oomph::RefineableQElement< 3 >::node_created_by_neighbour(), oomph::RefineableQElement< 1 >::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< 3, INITIAL_NNODE_1D >::node_created_by_son_of_neighbour(), oomph::RefineableQElement< 3 >::oc_hang_helper(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::oc_hang_helper(), p_refine_if_required(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::pre_build(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::pre_build(), oomph::PRefineableQElement< 2, INITIAL_NNODE_1D >::quad_hang_helper(), oomph::RefineableQElement< 2 >::quad_hang_helper(), oomph::RefineableLinearisedAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableGeneralisedNewtonianAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableLinearisedQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineablePolarCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableQSphericalCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableElement::root_element_pt(), oomph::RefineableBrickMesh< ELEMENT >::setup_octree_forest(), oomph::RefineableQuadMesh< ELEMENT >::setup_quadtree_forest(), split_if_required(), and Tree().

◆ operator=()

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

Broken assignment operator.

◆ p_refine_if_required()

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.

150  {
151 #ifdef PARANOID
152  if (Son_pt.size() != 0)
153  {
154  std::string error_message =
155  "Can't p-refine non-leaf elements (or at least I can't see\n";
156  error_message +=
157  "why you would want me to... If you're sure, then hack me... \n";
158 
159  throw OomphLibError(
161  }
162 
163  if (Object_pt == 0)
164  {
165  std::stringstream error_message;
166  error_message
167  << "No object defined in p_refine_if_required. Father nodes:\n";
168 
169  RefineableElement* el_pt = Father_pt->object_pt();
170  unsigned nnod = el_pt->nnode();
171  for (unsigned j = 0; j < nnod; j++)
172  {
173  Node* nod_pt = el_pt->node_pt(j);
174  unsigned n = nod_pt->ndim();
175  for (unsigned i = 0; i < n; i++)
176  {
177  error_message << nod_pt->x(i) << " ";
178  }
179  error_message << "\n";
180  }
181  throw OomphLibError(
182  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
183  }
184 
185 #endif
186 
187  // Cast to p-refineable element
188  PRefineableElement* p_ref_obj_pt =
189  dynamic_cast<PRefineableElement*>(Object_pt);
190 
191  // Check if we can p-refine the element
192  if (p_ref_obj_pt == 0)
193  {
194  throw OomphLibError("Element cannot be p-refined",
197  }
198 
199 
200  // Create a temporary clone of the element to be refined.
201  // This is required so that the element can read data from "itself"
202  // while it rebuilds itself with a new p-order. Only the information
203  // required for the p-refinement is copied across.
204 
205  // Make new element (using ELEMENT's standard constructor)
206  ELEMENT* clone_pt = new ELEMENT();
207 
208  // Do initial setup with myself as the clone's adopted father
209  clone_pt->initial_setup(this);
210 
211  // All that is left to do is to "build" the clone. It has the same
212  // nodes as me, so we can just copy across their pointers
213  for (unsigned j = 0; j < clone_pt->nnode(); j++)
214  {
215  clone_pt->node_pt(j) = p_ref_obj_pt->node_pt(j);
216  }
217 
218 
219  // Check if refinement is required
220  if (p_ref_obj_pt->to_be_p_refined())
221  {
222  // Perform the split for the element in question and return Vector
223  // of pointers to the newly created elements
224  p_ref_obj_pt->p_refine(1, mesh_pt, clone_pt);
225  }
226  // Check if unrefinement is required
227  else if (p_ref_obj_pt->to_be_p_unrefined())
228  {
229  // Perform the split for the element in question and return Vector
230  // of pointers to the newly created elements
231  p_ref_obj_pt->p_refine(-1, mesh_pt, clone_pt);
232  }
233 
234 
235  // Delete the temporary copy of the element
236  delete clone_pt;
237  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Father_pt, i, j, n, oomph::Node::ndim(), oomph::FiniteElement::nnode(), oomph::FiniteElement::node_pt(), object_pt(), Object_pt, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, 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().

◆ root_pt() [1/2]

◆ root_pt() [2/2]

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

Return pointer to root of the tree (const version)

148  {
149  return Root_pt;
150  }

References Root_pt.

◆ set_father_pt()

void oomph::Tree::set_father_pt ( Tree *const &  father_pt)
inline

◆ set_son_pt()

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).

124  {
125  Son_pt = son_pt;
126  }

References son_pt(), and Son_pt.

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

◆ son_pt()

Tree* oomph::Tree::son_pt ( const int son_index) const
inline

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.

104  {
105  // If there are no sons, return NULL (0)
106  if (Son_pt.size() == 0)
107  {
108  return 0;
109  }
110  // Otherwise, return the pointer to the appropriate son
111  else
112  {
113  return Son_pt[son_index];
114  }
115  }

References Son_pt.

Referenced by oomph::TreeBasedRefineableMeshBase::adapt(), merge_sons_if_required(), 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::RefineableLinearisedAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableGeneralisedNewtonianAxisymmetricQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableLinearisedQCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineablePolarCrouzeixRaviartElement::rebuild_from_sons(), oomph::RefineableQSphericalCrouzeixRaviartElement::rebuild_from_sons(), oomph::TreeBasedRefineableMeshBase::refine_as_in_reference_mesh(), set_son_pt(), oomph::RefineableBrickMesh< ELEMENT >::setup_octree_forest(), oomph::RefineableQuadMesh< ELEMENT >::setup_quadtree_forest(), oomph::TreeForest::stick_all_tree_nodes_into_vector(), and oomph::TreeForest::stick_leaves_into_vector().

◆ son_type()

◆ split_if_required()

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.

62  {
63 #ifdef PARANOID
64  if (Son_pt.size() != 0)
65  {
66  std::string error_message =
67  "Can't split non-leaf elements (or at least I can't see\n";
68  error_message +=
69  "why you would want me to... If you're sure, then hack me... \n";
70 
71  throw OomphLibError(
73  }
74 
75  if (Object_pt == 0)
76  {
77  std::stringstream error_message;
78  error_message
79  << "No object defined in split_if_required. Father nodes:\n";
80 
81  RefineableElement* el_pt = Father_pt->object_pt();
82  unsigned nnod = el_pt->nnode();
83  for (unsigned j = 0; j < nnod; j++)
84  {
85  Node* nod_pt = el_pt->node_pt(j);
86  unsigned n = nod_pt->ndim();
87  for (unsigned i = 0; i < n; i++)
88  {
89  error_message << nod_pt->x(i) << " ";
90  }
91  error_message << "\n";
92  }
93  throw OomphLibError(
94  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
95  }
96 
97 #endif
98 
99  // Check if refinement is required
100  if (Object_pt->to_be_refined())
101  {
102  // Perform the split for the element in question and return Vector
103  // of pointers to the newly created elements
104  Vector<ELEMENT*> new_elements_pt;
105  Object_pt->split(new_elements_pt);
106 
107  // Find the number of sons constructed by the element
108  unsigned n_sons = new_elements_pt.size();
109 
110  // Turn the new elements into QuadTrees and assign
111  // the pointers to the present element's sons
112  Son_pt.resize(n_sons);
113  Tree* father_pt = this;
114  for (unsigned i_son = 0; i_son < n_sons; i_son++)
115  {
116  Son_pt[i_son] = construct_son(new_elements_pt[i_son], father_pt, i_son);
117  // Now that the son knows its position in the tree, we can set it
118  // up as a proper element (e.g. p-refineable stuff)
119  Son_pt[i_son]->object_pt()->initial_setup();
120  }
121  }
122  }
void split(Vector< ELEMENT * > &son_pt) const
Definition: refineable_elements.h:254
bool to_be_refined()
Has the element been selected for refinement?
Definition: refineable_elements.h:345
virtual Tree * construct_son(RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)=0
Tree()
Default constructor (empty and broken)
Definition: tree.h:266

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

◆ stick_all_tree_nodes_into_vector()

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

278  {
279  all_tree_nodes.push_back(this);
280 
281  // If the Tree has sons
282  unsigned numsons = Son_pt.size();
283  if (numsons > 0)
284  {
285  // Now do the sons (if they exist)
286  for (unsigned i = 0; i < numsons; i++)
287  {
288  Son_pt[i]->stick_all_tree_nodes_into_vector(all_tree_nodes);
289  }
290  }
291  }

References i, and Son_pt.

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

◆ stick_leaves_into_vector()

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

256  {
257  // If the Tree has sons
258  unsigned numsons = Son_pt.size();
259  if (numsons > 0)
260  {
261  // Now do the sons (if they exist)
262  for (unsigned i = 0; i < numsons; i++)
263  {
264  Son_pt[i]->stick_leaves_into_vector(tree_nodes);
265  }
266  }
267  else
268  {
269  tree_nodes.push_back(this);
270  }
271  }

References i, and Son_pt.

Referenced by oomph::TreeForest::stick_leaves_into_vector().

◆ traverse_all() [1/2]

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

146  {
147  // Process the object contained in (well, pointed to) by current
148  // Tree
149  (this->*member_function)();
150 
151  // Now do the sons (if they exist)
152  unsigned numsons = Son_pt.size();
153  for (unsigned i = 0; i < numsons; i++)
154  {
155  Son_pt[i]->traverse_all(member_function);
156  }
157  }

References i, and Son_pt.

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

◆ traverse_all() [2/2]

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.

166  {
167  // Process the object contained in (well, pointed to) by current
168  // Tree
169  (this->*member_function)(mesh_pt);
170 
171  // Now do the sons (if they exist)
172  unsigned numsons = Son_pt.size();
173  for (unsigned i = 0; i < numsons; i++)
174  {
175  Son_pt[i]->traverse_all(member_function, mesh_pt);
176  }
177  }

References i, and Son_pt.

◆ traverse_all_but_leaves()

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.

185  {
186  // Find the number of sons
187  unsigned n_sons = Son_pt.size();
188  // If the Tree has sons,
189  if (n_sons > 0)
190  {
191  // Execute the function
192  (this->*member_function)();
193  // Proceed to the sons
194  for (unsigned i = 0; i < n_sons; i++)
195  {
196  Son_pt[i]->traverse_all_but_leaves(member_function);
197  }
198  }
199  // If the tree has no sons, the function will not be executed
200  }

References i, and Son_pt.

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

◆ traverse_leaves() [1/2]

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)

208  {
209  // If the Tree has sons
210  unsigned numsons = Son_pt.size();
211  if (numsons > 0)
212  {
213  // Proceed to the sons (if they exist)
214  for (unsigned i = 0; i < numsons; i++)
215  {
216  Son_pt[i]->traverse_leaves(member_function);
217  }
218  }
219  else
220  {
221  // Call the member function
222  (this->*member_function)();
223  }
224  }

References i, and Son_pt.

Referenced by oomph::TreeBasedRefineableMesh< ELEMENT >::p_refine_elements_if_required(), and oomph::TreeBasedRefineableMesh< ELEMENT >::split_elements_if_required().

◆ traverse_leaves() [2/2]

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)

233  {
234  // If the Tree has sons
235  unsigned numsons = Son_pt.size();
236  if (numsons > 0)
237  {
238  // Proceed to the sons (if they exist)
239  for (unsigned i = 0; i < numsons; i++)
240  {
241  Son_pt[i]->traverse_leaves(member_function, mesh_pt);
242  }
243  }
244  else
245  {
246  // Call the member function
247  (this->*member_function)(mesh_pt);
248  }
249  }

References i, and Son_pt.

Member Data Documentation

◆ Father_pt

◆ Level

◆ Max_neighbour_finding_tolerance

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)

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

◆ Object_pt

RefineableElement* oomph::Tree::Object_pt
protected

Pointer to the object represented by the tree.

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

◆ OMEGA

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!

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::PRefineableQElement< 2, INITIAL_NNODE_1D >::rebuild_from_sons(), oomph::PRefineableQElement< 3, INITIAL_NNODE_1D >::rebuild_from_sons(), oomph::RefineableQSpectralElement< 3 >::rebuild_from_sons(), oomph::RefineableQSpectralElement< 2 >::rebuild_from_sons(), oomph::OcTreeRoot::right_equivalent(), oomph::RefineableQElement< 3 >::setup_father_bounds(), oomph::RefineableQElement< 1 >::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::OcTree::setup_static_data(), oomph::QuadTree::setup_static_data(), Tree(), and oomph::OcTreeRoot::up_equivalent().

◆ Root_pt

◆ Son_pt

◆ Son_type


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