treeDataCell.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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  //- Reference to the mesh
60  const polyMesh& mesh_;
61 
62  //- Subset of cells to work on
63  const labelList cellLabels_;
64 
65  //- Whether to precalculate and store cell bounding box
66  const bool cacheBb_;
67 
68  //- How to decide if point is inside cell
69  const polyMesh::cellDecomposition decompMode_;
70 
71  //- Cell bounding boxes (valid only if cacheBb_)
72  treeBoundBoxList bbs_;
73 
74 
75  // Private Member Functions
76 
77  //- Initialise all member data
78  void update();
79 
80 
81 public:
82 
83 
84  class findNearestOp
85  {
86  const indexedOctree<treeDataCell>& tree_;
87 
88  public:
89 
91 
92  void operator()
93  (
94  const labelUList& indices,
95  const point& sample,
96 
97  scalar& nearestDistSqr,
98  label& minIndex,
99  point& nearestPoint
100  ) const;
101 
102  void operator()
103  (
104  const labelUList& indices,
105  const linePointRef& ln,
106 
107  treeBoundBox& tightest,
108  label& minIndex,
109  point& linePoint,
110  point& nearestPoint
111  ) const;
112  };
113 
115  class findIntersectOp
116  {
117  const indexedOctree<treeDataCell>& tree_;
118 
119  public:
120 
122 
123  bool operator()
124  (
125  const label index,
126  const point& start,
127  const point& end,
128  point& intersectionPoint
129  ) const;
130  };
131 
132 
133  // Declare name of the class and its debug switch
134  ClassName("treeDataCell");
135 
136 
137  // Constructors
138 
139  //- Construct from mesh and subset of cells.
141  (
142  const bool cacheBb,
143  const polyMesh&,
144  const labelUList&,
146  );
147 
148  //- Move construct from mesh and subset of cells, transferring contents
150  (
151  const bool cacheBb,
152  const polyMesh&,
153  labelList&&,
154  const polyMesh::cellDecomposition decompMode
155  );
156 
157  //- Construct from mesh. Uses all cells in mesh.
159  (
160  const bool cacheBb,
161  const polyMesh&,
162  const polyMesh::cellDecomposition decompMode
163  );
164 
165 
166  // Member Functions
167 
168  // Access
170  inline const labelList& cellLabels() const
171  {
172  return cellLabels_;
173  }
175  inline const polyMesh& mesh() const
176  {
177  return mesh_;
178  }
181  {
182  return decompMode_;
183  }
185  inline label size() const
186  {
187  return cellLabels_.size();
188  }
189 
190  //- Get representative point cloud for all shapes inside
191  // (one point per shape)
192  pointField shapePoints() const;
193 
194 
195  // Search
196 
197  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
198  // Only makes sense for closed surfaces.
200  (
202  const point&
203  ) const
204  {
206  return volumeType::unknown;
207  }
208 
209  //- Does (bb of) shape at index overlap bb
210  bool overlaps
211  (
212  const label index,
213  const treeBoundBox& sampleBb
214  ) const;
215 
216  //- Does shape at index contain sample
217  bool contains
218  (
219  const label index,
220  const point& sample
221  ) const;
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 
232 #endif
233 
234 // ************************************************************************* //
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataCell.C:148
A line primitive.
Definition: line.H:56
polyMesh::cellDecomposition decompMode() const
Definition: treeDataCell.H:179
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
cellDecomposition
Enumeration defining the decomposition of the cell for.
Definition: polyMesh.H:100
const polyMesh & mesh() const
Definition: treeDataCell.H:174
volumeType getVolumeType(const indexedOctree< treeDataCell > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataCell.H:199
treeDataCell(const bool cacheBb, const polyMesh &, const labelUList &, const polyMesh::cellDecomposition decompMode)
Construct from mesh and subset of cells.
Definition: treeDataCell.C:65
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
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e...
Definition: treeDataCell.H:54
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataCell.C:134
findNearestOp(const indexedOctree< treeDataCell > &tree)
Definition: treeDataCell.C:115
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
ClassName("treeDataCell")
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
const labelList & cellLabels() const
Definition: treeDataCell.H:169
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
label size() const
Definition: treeDataCell.H:184
bool contains(const label index, const point &sample) const
Does shape at index contain sample.
Definition: treeDataCell.C:172
Namespace for OpenFOAM.