treeDataCell.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::treeDataCell
26 
27 Description
28  Encapsulation of data needed to search in/for cells. Used to find the
29  cell containing a point (e.g. cell-cell mapping).
30 
31 SourceFiles
32  treeDataCell.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef treeDataCell_H
37 #define treeDataCell_H
38 
39 #include "polyMesh.H"
40 #include "treeBoundBoxList.H"
41 #include "volumeType.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 template<class Type> class indexedOctree;
50 
51 /*---------------------------------------------------------------------------*\
52  Class treeDataCell Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class treeDataCell
56 {
57  // Private data
58 
59  const polyMesh& mesh_;
60 
61  //- Subset of cells to work on
62  const labelList cellLabels_;
63 
64  //- Whether to precalculate and store cell bounding box
65  const bool cacheBb_;
66 
67  //- How to decide if point is inside cell
68  const polyMesh::cellDecomposition decompMode_;
69 
70  //- Cell bounding boxes (valid only if cacheBb_)
71  treeBoundBoxList bbs_;
72 
73 
74  // Private Member Functions
75 
76  //- Calculate cell bounding box
77  treeBoundBox calcCellBb(const label cellI) const;
78 
79  //- Initialise all member data
80  void update();
81 
82 public:
83 
84 
85  class findNearestOp
86  {
87  const indexedOctree<treeDataCell>& tree_;
88 
89  public:
90 
92 
93  void operator()
94  (
95  const labelUList& indices,
96  const point& sample,
97 
98  scalar& nearestDistSqr,
99  label& minIndex,
100  point& nearestPoint
101  ) const;
102 
103  void operator()
104  (
105  const labelUList& indices,
106  const linePointRef& ln,
107 
108  treeBoundBox& tightest,
109  label& minIndex,
110  point& linePoint,
111  point& nearestPoint
112  ) const;
113  };
114 
116  class findIntersectOp
117  {
118  const indexedOctree<treeDataCell>& tree_;
119 
120  public:
121 
123 
124  bool operator()
125  (
126  const label index,
127  const point& start,
128  const point& end,
129  point& intersectionPoint
130  ) const;
131  };
132 
133 
134  // Declare name of the class and its debug switch
135  ClassName("treeDataCell");
136 
137 
138  // Constructors
139 
140  //- Construct from mesh and subset of cells.
142  (
143  const bool cacheBb,
144  const polyMesh&,
145  const labelUList&,
147  );
148 
149  //- Construct from mesh and subset of cells, transferring contents
151  (
152  const bool cacheBb,
153  const polyMesh&,
154  const Xfer<labelList>&,
155  const polyMesh::cellDecomposition decompMode
156  );
157 
158  //- Construct from mesh. Uses all cells in mesh.
160  (
161  const bool cacheBb,
162  const polyMesh&,
163  const polyMesh::cellDecomposition decompMode
164  );
165 
166 
167  // Member Functions
168 
169  // Access
171  inline const labelList& cellLabels() const
172  {
173  return cellLabels_;
174  }
176  inline const polyMesh& mesh() const
177  {
178  return mesh_;
179  }
182  {
183  return decompMode_;
184  }
186  inline label size() const
187  {
188  return cellLabels_.size();
189  }
190 
191  //- Get representative point cloud for all shapes inside
192  // (one point per shape)
193  pointField shapePoints() const;
194 
195 
196  // Search
197 
198  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
199  // Only makes sense for closed surfaces.
201  (
203  const point&
204  ) const
205  {
207  (
208  "treeDataCell::getVolumeType"
209  "(const indexedOctree<treeDataCell>&, const point&)"
210  );
211  return volumeType::UNKNOWN;
212  }
213 
214  //- Does (bb of) shape at index overlap bb
215  bool overlaps
216  (
217  const label index,
218  const treeBoundBox& sampleBb
219  ) const;
220 
221  //- Does shape at index contain sample
222  bool contains
223  (
224  const label index,
225  const point& sample
226  ) const;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 
237 #endif
238 
239 // ************************************************************************* //
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataCell.C:170
polyMesh::cellDecomposition decompMode() const
Definition: treeDataCell.H:180
const polyMesh & mesh() const
Definition: treeDataCell.H:175
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataCell.C:156
Namespace for OpenFOAM.
A line primitive.
Definition: line.H:56
findNearestOp(const indexedOctree< treeDataCell > &tree)
Definition: treeDataCell.C:137
bool contains(const label index, const point &sample) const
Does shape at index contain sample.
Definition: treeDataCell.C:187
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:855
volumeType getVolumeType(const indexedOctree< treeDataCell > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataCell.H:200
const labelList & cellLabels() const
Definition: treeDataCell.H:170
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
treeDataCell(const bool cacheBb, const polyMesh &, const labelUList &, const polyMesh::cellDecomposition decompMode)
Construct from mesh and subset of cells.
Definition: treeDataCell.C:87
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
ClassName("treeDataCell")
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
Definition: treeDataCell.H:54
cellDecomposition
Enumeration defining the decomposition of the cell for.
Definition: polyMesh.H:98
label size() const
Definition: treeDataCell.H:185