tree.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // C++ includes
21 
22 // Local includes
23 #include "libmesh/tree.h"
24 #include "libmesh/mesh_base.h"
25 #include "libmesh/mesh_tools.h"
26 
27 namespace libMesh
28 {
29 
30 
31 
32 // ------------------------------------------------------------
33 // Tree class method
34 
35 // constructor
36 template <unsigned int N>
38  const unsigned int target_bin_size,
39  const Trees::BuildType bt) :
40  TreeBase(m),
41  root(m,target_bin_size),
42  build_type(bt)
43 {
44  // Set the root node bounding box equal to the bounding
45  // box for the entire domain.
46  root.set_bounding_box (MeshTools::bounding_box(mesh));
47 
48 
49  if (build_type == Trees::NODES)
50  {
51  // Add all the nodes to the root node. It will
52  // automagically build the tree for us.
55 
56  for (; it != end; ++it)
57  root.insert (*it);
58 
59  // Now the tree contains the nodes.
60  // However, we want element pointers, so here we
61  // convert between the two.
62  std::vector<std::vector<const Elem*> > nodes_to_elem;
63 
65  root.transform_nodes_to_elements (nodes_to_elem);
66  }
67 
68  else if (build_type == Trees::ELEMENTS)
69  {
70  // Add all active elements to the root node. It will
71  // automatically build the tree for us.
74 
75 
76  for (; it != end; ++it)
77  root.insert (*it);
78  }
79 }
80 
81 
82 
83 template <unsigned int N>
84 const Elem* Tree<N>::find_element(const Point& p) const
85 {
86  return root.find_element(p);
87 }
88 
89 
90 // ------------------------------------------------------------
91 // Explicit Instantiations
92 template class Tree<2>;
93 template class Tree<4>;
94 template class Tree<8>;
95 
96 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo