oomph::TreeForest Class Referenceabstract

#include <tree.h>

+ Inheritance diagram for oomph::TreeForest:

Public Member Functions

 TreeForest (Vector< TreeRoot * > &trees_pt)
 
 TreeForest ()
 Default constructor (empty and broken) More...
 
 TreeForest (const TreeForest &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const TreeForest &)=delete
 Broken assignment operator. More...
 
virtual ~TreeForest ()
 Kill tree forest: Delete the constituent trees. More...
 
void stick_leaves_into_vector (Vector< Tree * > &forest_nodes)
 Traverse forst and stick pointers to leaf "nodes" into Vector. More...
 
void stick_all_tree_nodes_into_vector (Vector< Tree * > &all_forest_nodes)
 Traverse forest and stick pointers to all "nodes" into Vector. More...
 
virtual void check_all_neighbours (DocInfo &doc_info)=0
 
virtual void open_hanging_node_files (DocInfo &doc_info, Vector< std::ofstream * > &output_stream)=0
 
void close_hanging_node_files (DocInfo &doc_info, Vector< std::ofstream * > &output_stream)
 
unsigned ntree ()
 Number of trees in forest. More...
 
TreeRoottree_pt (const unsigned &i) const
 Return pointer to i-th tree in forest. More...
 
void flush_trees ()
 Flush trees from forest. More...
 

Protected Attributes

Vector< TreeRoot * > Trees_pt
 Vector containing the pointers to the trees. More...
 

Detailed Description

A TreeForest consists of a collection of TreeRoots. Each member tree can have neighbours in various enumerated directions (e.g. S/W/N/E for a QuadTreeForest) and the orientation of their compasses can differ, allowing for complex, unstructured meshes.

Constructor & Destructor Documentation

◆ TreeForest() [1/3]

oomph::TreeForest::TreeForest ( Vector< TreeRoot * > &  trees_pt)

Constructor for Tree forest: Pass Vector of (pointers to) constituents trees.

Constructor for TreeForest:

Pass:

  • trees_pt[], the Vector of pointers to the constituent trees (TreeRoot objects)

Note that the pointers to the neighbour's of each tree must have been allocated before the constructor is called, otherwise the relative rotation scheme will not be constructed correctly.

359 : Trees_pt(trees_pt) {}
Vector< TreeRoot * > Trees_pt
Vector containing the pointers to the trees.
Definition: tree.h:480

◆ TreeForest() [2/3]

oomph::TreeForest::TreeForest ( )
inline

Default constructor (empty and broken)

417  {
418  // Throw an error
419  throw OomphLibError(
420  "Don't call an empty constructor for a TreeForest object",
423  }
#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.

◆ TreeForest() [3/3]

oomph::TreeForest::TreeForest ( const TreeForest dummy)
delete

Broken copy constructor.

◆ ~TreeForest()

oomph::TreeForest::~TreeForest ( )
virtual

Kill tree forest: Delete the constituent trees.

Destructor: Delete the constituent trees (and thus the objects associated with its non-leaf nodes!)

365  {
366  long int numtrees = Trees_pt.size();
367  for (long int i = 0; i < numtrees; i++)
368  {
369  // Kill the trees
370  delete Trees_pt[i];
371  Trees_pt[i] = 0;
372  }
373  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9

References i, and Trees_pt.

Member Function Documentation

◆ check_all_neighbours()

virtual void oomph::TreeForest::check_all_neighbours ( DocInfo doc_info)
pure virtual

Document/check the neighbours of all the nodes in the forest. This must be overloaded for different types of forest.

Implemented in oomph::QuadTreeForest, oomph::OcTreeForest, and oomph::BinaryTreeForest.

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

◆ close_hanging_node_files()

void oomph::TreeForest::close_hanging_node_files ( DocInfo doc_info,
Vector< std::ofstream * > &  output_stream 
)

Close output files that will store any hanging nodes in the forest and delete any associated storage. This can be performed genercially in this base class.

Close the hanging node output files and delete storage allocated at the pointers. This can be done generically at the base level

434  {
435  // Find the number of files
436  unsigned n_file = output_stream.size();
437  // If we opened the files, close them
438  if (doc_info.is_doc_enabled())
439  {
440  for (unsigned n = 0; n < n_file; n++)
441  {
442  output_stream[n]->close();
443  }
444  }
445 
446  // We should have always created ofstreams, so delete them and null out
447  for (unsigned n = n_file; n > 0; n--)
448  {
449  delete output_stream[n - 1];
450  output_stream[n - 1] = 0;
451  }
452 
453  // Finally clear out the vector
454  output_stream.clear();
455  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11

References oomph::DocInfo::is_doc_enabled(), and n.

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

◆ flush_trees()

void oomph::TreeForest::flush_trees ( )
inline

Flush trees from forest.

473  {
474  // Clear Trees_pt vector
475  Trees_pt.clear();
476  }

References Trees_pt.

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

◆ ntree()

◆ open_hanging_node_files()

virtual void oomph::TreeForest::open_hanging_node_files ( DocInfo doc_info,
Vector< std::ofstream * > &  output_stream 
)
pure virtual

Open output files that will store any hanging nodes in the forest. Return a vector of the output streams. This is included in the tree structure, so that we can use generic routines for mesh adaptation in two and three dimensions. The need for pointers to the output streams is because one cannot copy a stream!

Implemented in oomph::QuadTreeForest, oomph::OcTreeForest, and oomph::BinaryTreeForest.

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

◆ operator=()

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

Broken assignment operator.

◆ stick_all_tree_nodes_into_vector()

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

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

Traverse TreeForest: Preorder traverse and stick pointers to all nodes into Vector

407  {
408  unsigned numtrees = ntree();
409  for (unsigned itree = 0; itree < numtrees; itree++)
410  {
411  all_forest_nodes.push_back(tree_pt(itree));
412 
413  // Now do the sons (if they exist)
414  unsigned numsons = tree_pt(itree)->nsons();
415  if (numsons > 0)
416  {
417  // Now do the sons (if they exist)
418  for (unsigned i = 0; i < numsons; i++)
419  {
421  all_forest_nodes);
422  }
423  }
424  }
425  }
unsigned ntree()
Number of trees in forest.
Definition: tree.h:460
TreeRoot * tree_pt(const unsigned &i) const
Return pointer to i-th tree in forest.
Definition: tree.h:466
void stick_all_tree_nodes_into_vector(Vector< Tree * > &)
Traverse and stick pointers to all "nodes" into Vector.
Definition: tree.cc:277
unsigned nsons() const
Return number of sons (zero if it's a leaf node)
Definition: tree.h:129
Tree * son_pt(const int &son_index) const
Definition: tree.h:103

References i, oomph::Tree::nsons(), ntree(), oomph::Tree::son_pt(), oomph::Tree::stick_all_tree_nodes_into_vector(), and tree_pt().

Referenced by oomph::TreeBasedRefineableMeshBase::adapt_mesh(), oomph::BinaryTreeForest::check_all_neighbours(), oomph::OcTreeForest::check_all_neighbours(), oomph::QuadTreeForest::check_all_neighbours(), oomph::TreeBasedRefineableMeshBase::get_elements_at_refinement_level(), oomph::TreeBasedRefineableMeshBase::get_refinement_pattern(), oomph::TreeBasedRefineableMeshBase::p_adapt_mesh(), oomph::BinaryTreeForest::self_test(), oomph::OcTreeForest::self_test(), oomph::QuadTreeForest::self_test(), oomph::RefineableBrickMesh< ELEMENT >::setup_octree_forest(), and oomph::RefineableQuadMesh< ELEMENT >::setup_quadtree_forest().

◆ stick_leaves_into_vector()

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

Traverse forst and stick pointers to leaf "nodes" into Vector.

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

380  {
381  unsigned numtrees = ntree();
382  for (unsigned itree = 0; itree < numtrees; itree++)
383  {
384  // Now do the sons (if they exist)
385  unsigned numsons = tree_pt(itree)->nsons();
386  if (numsons > 0)
387  {
388  for (unsigned i = 0; i < numsons; i++)
389  {
390  tree_pt(itree)->son_pt(i)->stick_leaves_into_vector(forest_nodes);
391  }
392  }
393  else
394  {
395  forest_nodes.push_back(tree_pt(itree));
396  }
397  }
398  }
void stick_leaves_into_vector(Vector< Tree * > &)
Traverse tree and stick pointers to leaf "nodes" (only) into Vector.
Definition: tree.cc:255

References i, oomph::Tree::nsons(), ntree(), oomph::Tree::son_pt(), oomph::Tree::stick_leaves_into_vector(), and tree_pt().

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

◆ tree_pt()

Member Data Documentation

◆ Trees_pt


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