tree.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_TREE_H 00021 #define LIBMESH_TREE_H 00022 00023 // Local includes 00024 #include "libmesh/tree_node.h" 00025 #include "libmesh/tree_base.h" 00026 00027 // C++ includes 00028 00029 namespace libMesh 00030 { 00031 00032 // Forward Declarations 00033 class MeshBase; 00034 00042 // ------------------------------------------------------------ 00043 // Tree class definition 00044 template <unsigned int N> 00045 class Tree : public TreeBase 00046 { 00047 public: 00048 00052 Tree (const MeshBase& m, const unsigned int level, Trees::BuildType bt=Trees::NODES); 00053 00057 Tree (const Tree<N>& other_tree); 00058 00062 ~Tree() {} 00063 00067 void print_nodes(std::ostream& my_out=libMesh::out) const 00068 { my_out << "Printing nodes...\n"; root.print_nodes(my_out); } 00069 00073 void print_elements(std::ostream& my_out=libMesh::out) const 00074 { my_out << "Printing elements...\n"; root.print_elements(my_out); } 00075 00079 unsigned int n_active_bins() const { return root.n_active_bins(); } 00080 00084 const Elem* find_element(const Point& p) const; 00085 00089 const Elem* operator() (const Point& p) const; 00090 00091 00092 private: 00093 00094 00098 TreeNode<N> root; 00099 00103 const Trees::BuildType build_type; 00104 00105 }; 00106 00107 00108 00113 namespace Trees 00114 { 00119 typedef Tree<2> BinaryTree; 00120 00125 typedef Tree<4> QuadTree; 00126 00131 typedef Tree<8> OctTree; 00132 } 00133 00134 00135 00136 // ------------------------------------------------------------ 00137 // Tree class inline methods 00138 00139 00140 00141 // copy-constructor 00142 template <unsigned int N> 00143 inline 00144 Tree<N>::Tree (const Tree<N>& other_tree) : 00145 TreeBase (other_tree), 00146 root (other_tree.root), 00147 build_type (other_tree.build_type) 00148 { 00149 libmesh_error(); 00150 } 00151 00152 00153 00154 template <unsigned int N> 00155 inline 00156 const Elem* Tree<N>::operator() (const Point& p) const 00157 { 00158 return this->find_element(p); 00159 } 00160 00161 00162 } // namespace libMesh 00163 00164 00165 #endif // LIBMESH_TREE_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:49 UTC
Hosted By: