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
69 
70  //- Cell bounding boxes (valid only if cacheBb_)
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  {
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 
115 
116  class findIntersectOp
117  {
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>&,
156  );
157 
158  //- Construct from mesh. Uses all cells in mesh.
160  (
161  const bool cacheBb,
162  const polyMesh&,
164  );
165 
166 
167  // Member Functions
168 
169  // Access
170 
171  inline const labelList& cellLabels() const
172  {
173  return cellLabels_;
174  }
175 
176  inline const polyMesh& mesh() const
177  {
178  return mesh_;
179  }
180 
182  {
183  return decompMode_;
184  }
185 
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  return volumeType::UNKNOWN;
208  }
209 
210  //- Does (bb of) shape at index overlap bb
211  bool overlaps
212  (
213  const label index,
214  const treeBoundBox& sampleBb
215  ) const;
216 
217  //- Does shape at index contain sample
218  bool contains
219  (
220  const label index,
221  const point& sample
222  ) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 
233 #endif
234 
235 // ************************************************************************* //
Foam::polyMesh::cellDecomposition
cellDecomposition
Enumeration defining the decomposition of the cell for.
Definition: polyMesh.H:98
Foam::treeDataCell::shapePoints
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataCell.C:156
Foam::treeDataCell::mesh_
const polyMesh & mesh_
Definition: treeDataCell.H:58
Foam::treeDataCell::update
void update()
Initialise all member data.
Definition: treeDataCell.C:70
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::treeDataCell::findNearestOp::findNearestOp
findNearestOp(const indexedOctree< treeDataCell > &tree)
Definition: treeDataCell.C:137
Foam::treeDataCell::mesh
const polyMesh & mesh() const
Definition: treeDataCell.H:175
Foam::treeDataCell::treeDataCell
treeDataCell(const bool cacheBb, const polyMesh &, const labelUList &, const polyMesh::cellDecomposition decompMode)
Construct from mesh and subset of cells.
Definition: treeDataCell.C:87
polyMesh.H
Foam::treeDataCell::findNearestOp::tree_
const indexedOctree< treeDataCell > & tree_
Definition: treeDataCell.H:86
Foam::Xfer
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::treeDataCell::bbs_
treeBoundBoxList bbs_
Cell bounding boxes (valid only if cacheBb_)
Definition: treeDataCell.H:70
Foam::treeDataCell::getVolumeType
volumeType getVolumeType(const indexedOctree< treeDataCell > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataCell.H:200
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
volumeType.H
Foam::treeDataCell
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
Definition: treeDataCell.H:54
Foam::label
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
Foam::treeDataCell::calcCellBb
treeBoundBox calcCellBb(const label cellI) const
Calculate cell bounding box.
Definition: treeDataCell.C:40
Foam::volumeType
Definition: volumeType.H:54
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::treeDataCell::findIntersectOp::tree_
const indexedOctree< treeDataCell > & tree_
Definition: treeDataCell.H:117
Foam::treeDataCell::cellLabels
const labelList & cellLabels() const
Definition: treeDataCell.H:170
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
Foam::treeDataCell::size
label size() const
Definition: treeDataCell.H:185
Foam::treeDataCell::decompMode
polyMesh::cellDecomposition decompMode() const
Definition: treeDataCell.H:180
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::treeDataCell::overlaps
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataCell.C:170
Foam::treeDataCell::ClassName
ClassName("treeDataCell")
treeBoundBoxList.H
Foam::treeDataCell::findNearestOp
Definition: treeDataCell.H:84
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::UList
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
Foam::treeDataCell::contains
bool contains(const label index, const point &sample) const
Does shape at index contain sample.
Definition: treeDataCell.C:187
Foam::treeDataCell::cacheBb_
const bool cacheBb_
Whether to precalculate and store cell bounding box.
Definition: treeDataCell.H:64
Foam::line
A line primitive.
Definition: line.H:56
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:854
Foam::treeDataCell::findIntersectOp::findIntersectOp
findIntersectOp(const indexedOctree< treeDataCell > &tree)
Definition: treeDataCell.C:146
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::treeDataCell::decompMode_
const polyMesh::cellDecomposition decompMode_
How to decide if point is inside cell.
Definition: treeDataCell.H:67
Foam::treeDataCell::cellLabels_
const labelList cellLabels_
Subset of cells to work on.
Definition: treeDataCell.H:61
Foam::treeDataCell::findIntersectOp
Definition: treeDataCell.H:115
Foam::volumeType::UNKNOWN
@ UNKNOWN
Definition: volumeType.H:61