tree.C
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 // C++ includes 00021 00022 // Local includes 00023 #include "libmesh/tree.h" 00024 #include "libmesh/mesh_base.h" 00025 #include "libmesh/mesh_tools.h" 00026 00027 namespace libMesh 00028 { 00029 00030 00031 00032 // ------------------------------------------------------------ 00033 // Tree class method 00034 00035 // constructor 00036 template <unsigned int N> 00037 Tree<N>::Tree (const MeshBase& m, 00038 const unsigned int level, 00039 const Trees::BuildType bt) : 00040 TreeBase(m), 00041 root(m,level), 00042 build_type(bt) 00043 { 00044 // Set the root node bounding box equal to the bounding 00045 // box for the entire domain. 00046 root.set_bounding_box (MeshTools::bounding_box(mesh)); 00047 00048 00049 if (build_type == Trees::NODES) 00050 { 00051 // Add all the nodes to the root node. It will 00052 // automagically build the tree for us. 00053 MeshBase::const_node_iterator it = mesh.nodes_begin(); 00054 const MeshBase::const_node_iterator end = mesh.nodes_end(); 00055 00056 for (; it != end; ++it) 00057 root.insert (*it); 00058 00059 // Now the tree contains the nodes. 00060 // However, we want element pointers, so here we 00061 // convert between the two. 00062 std::vector<std::vector<const Elem*> > nodes_to_elem; 00063 00064 MeshTools::build_nodes_to_elem_map (mesh, nodes_to_elem); 00065 root.transform_nodes_to_elements (nodes_to_elem); 00066 } 00067 00068 else if (build_type == Trees::ELEMENTS) 00069 { 00070 // Add all active elements to the root node. It will 00071 // automatically build the tree for us. 00072 MeshBase::const_element_iterator it = mesh.active_elements_begin(); 00073 const MeshBase::const_element_iterator end = mesh.active_elements_end(); 00074 00075 00076 for (; it != end; ++it) 00077 root.insert (*it); 00078 } 00079 } 00080 00081 00082 00083 template <unsigned int N> 00084 const Elem* Tree<N>::find_element(const Point& p) const 00085 { 00086 return root.find_element(p); 00087 } 00088 00089 00090 // ------------------------------------------------------------ 00091 // Explicit Instantiations 00092 template class Tree<2>; 00093 template class Tree<4>; 00094 template class Tree<8>; 00095 00096 } // namespace libMesh 00097 00098 00099 00100 00101 00102 00103 00104 00105
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:49 UTC
Hosted By: