Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Octree.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Octree.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: octree object header
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_MESHUTILS_OCTREE_OCTREE
37 #define NEKTAR_MESHUTILS_OCTREE_OCTREE
38 
39 #include <boost/shared_ptr.hpp>
40 
45 
48 
49 namespace Nektar
50 {
51 namespace NekMeshUtils
52 {
53 
54 /**
55  * @brief class for octree
56  *
57  * This class contains the routines to generate and query a automatically
58  * generated set of mesh spacing parameters based on the CAD
59  */
60 class Octree
61 {
62 public:
63  friend class MemoryManager<Octree>;
64 
65  /**
66  * @brief Defualt constructor
67  *
68  * @param cad CAD object
69  * @param ver bool verbose
70  */
72  const bool ver,
73  const NekDouble min,
74  const NekDouble max,
75  const NekDouble eps,
76  const std::string uds)
77  : m_minDelta(min), m_maxDelta(max), m_eps(eps), m_cad(cad),
78  m_verbose(ver), m_udsfile(uds)
79  {
80  }
81 
82  /**
83  * @brief executes octree building routines
84  */
85  void Build();
86 
87  /**
88  * @brief once constructed queryies the octree based on x,y,z location
89  * to get a mesh spacing
90  *
91  * @param loc array of x,y,z
92  * @return mesh spacing parameter
93  */
95 
96  /**
97  * @brief returns the miminum spacing in the octree (for meshing purposes)
98  *
99  * @return miminum delta in octree
100  */
102  {
103  return m_minDelta;
104  }
105 
106  /**
107  * @brief populates the mesh m with a invalid hexahedral mesh based on the
108  * octree, used for visualisation
109  */
111 
112 private:
113  /**
114  * @brief Smooths specification over all octants to a gradation criteria
115  */
116  void SmoothAllOctants();
117 
118  /**
119  * @brief gets an optimum number of curvature sampling points and
120  * calculates the curavture at these points
121  */
123 
124  /**
125  * @brief Function which initiates and controls the subdivision process
126  */
127  void SubDivide();
128 
129  /**
130  * @brief Smooths specification over the surface encompasing octants to a
131  * gradation criteria
132  */
133  void SmoothSurfaceOctants();
134 
135  /**
136  * @brief takes the mesh specification from surface octants and
137  * progates that through the domain so all octants have a
138  * specification
139  * using gradiation crieteria
140  */
141  void PropagateDomain();
142 
143  /**
144  * @brief estimates the number of elements to be created in the mesh
145  */
146  int CountElemt();
147 
148  /**
149  * @brief Calculates the difference in delta divided by the difference
150  * in location between two octants i and j
151  */
153 
154  /**
155  * @brief Looks over all leaf octants and checks that their neigbour
156  * assigments are valid
157  */
158  bool VerifyNeigbours();
159 
160  /// minimum delta in the octree
162  /// maximum delta in the octree
164  /// curavture sensivity paramter
166  /// cad object
168  /// verbose output
169  bool m_verbose;
170  /// x,y,z location of the center of the octree
172  /// physical size of the octree
174  /// list of curvature sample points
175  std::vector<CurvaturePointSharedPtr> m_cpList;
176  /// list of leaf octants
177  std::vector<OctantSharedPtr> m_octants;
178  /// master octant for searching
180  /// number of octants made, used for id index
181  int m_numoct;
182 
183  std::string m_udsfile;
184 };
185 
186 typedef boost::shared_ptr<Octree> OctreeSharedPtr;
187 }
188 }
189 
190 #endif
NekDouble ddx(OctantSharedPtr i, OctantSharedPtr j)
Calculates the difference in delta divided by the difference in location between two octants i and j...
Definition: Octree.cpp:1066
CADSystemSharedPtr m_cad
cad object
Definition: Octree.h:167
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
void SubDivide()
Function which initiates and controls the subdivision process.
Definition: Octree.cpp:235
std::vector< OctantSharedPtr > m_octants
list of leaf octants
Definition: Octree.h:177
NekDouble GetMinDelta()
returns the miminum spacing in the octree (for meshing purposes)
Definition: Octree.h:101
NekDouble m_minDelta
minimum delta in the octree
Definition: Octree.h:161
Octree(CADSystemSharedPtr cad, const bool ver, const NekDouble min, const NekDouble max, const NekDouble eps, const std::string uds)
Defualt constructor.
Definition: Octree.h:71
bool m_verbose
verbose output
Definition: Octree.h:169
bool VerifyNeigbours()
Looks over all leaf octants and checks that their neigbour assigments are valid.
Definition: Octree.cpp:345
OctantSharedPtr m_masteroct
master octant for searching
Definition: Octree.h:179
void GetOctreeMesh(MeshSharedPtr m)
populates the mesh m with a invalid hexahedral mesh based on the octree, used for visualisation ...
Definition: Octree.cpp:125
void CompileCuravturePointList()
gets an optimum number of curvature sampling points and calculates the curavture at these points ...
Definition: Octree.cpp:845
void PropagateDomain()
takes the mesh specification from surface octants and progates that through the domain so all octants...
Definition: Octree.cpp:477
class for octree
Definition: Octree.h:60
double NekDouble
int CountElemt()
estimates the number of elements to be created in the mesh
Definition: Octree.cpp:681
int m_numoct
number of octants made, used for id index
Definition: Octree.h:181
boost::shared_ptr< Octree > OctreeSharedPtr
Definition: Octree.h:186
boost::shared_ptr< Octant > OctantSharedPtr
Definition: Octant.h:74
void Build()
executes octree building routines
Definition: Octree.cpp:185
NekDouble m_eps
curavture sensivity paramter
Definition: Octree.h:165
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:137
NekDouble m_dim
physical size of the octree
Definition: Octree.h:173
boost::shared_ptr< CADSystem > CADSystemSharedPtr
Definition: CADSystem.h:185
Array< OneD, NekDouble > m_centroid
x,y,z location of the center of the octree
Definition: Octree.h:171
NekDouble Query(Array< OneD, NekDouble > loc)
once constructed queryies the octree based on x,y,z location to get a mesh spacing ...
Definition: Octree.cpp:48
std::vector< CurvaturePointSharedPtr > m_cpList
list of curvature sample points
Definition: Octree.h:175
void SmoothSurfaceOctants()
Smooths specification over the surface encompasing octants to a gradation criteria.
Definition: Octree.cpp:420
NekDouble m_maxDelta
maximum delta in the octree
Definition: Octree.h:163
void SmoothAllOctants()
Smooths specification over all octants to a gradation criteria.
Definition: Octree.cpp:632