treeDataFace.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::treeDataFace
29 
30 Description
31  Encapsulation of data needed to search for faces.
32 
33 SourceFiles
34  treeDataFace.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef treeDataFace_H
39 #define treeDataFace_H
40 
41 #include "face.H"
42 #include "indexedOctree.H"
43 #include "treeBoundBoxList.H"
44 #include "bitSet.H"
45 #include "primitiveMesh.H"
46 #include "volumeType.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 class polyPatch;
55 
56 /*---------------------------------------------------------------------------*\
57  Class treeDataFace Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class treeDataFace
61 {
62  // Static Data
63 
64  //- Tolerance on linear dimensions
65  static scalar tolSqr;
66 
67 
68  // Private Data
69 
70  const primitiveMesh& mesh_;
71 
72  //- Subset of faces to work on
73  const labelList faceLabels_;
74 
75  //- Inverse of faceLabels. For every mesh whether face is in faceLabels.
76  bitSet isTreeFace_;
77 
78  //- Whether to precalculate and store face bounding box
79  const bool cacheBb_;
80 
81  //- Face bounding boxes (valid only if cacheBb_)
82  treeBoundBoxList bbs_;
83 
84 
85  // Private Member Functions
86 
87  //- Calculate face bounding box
88  treeBoundBox calcBb(const label celli) const;
89 
90  //- Initialise all member data
91  void update();
92 
93 public:
94 
95 
96  class findNearestOp
97  {
98  const indexedOctree<treeDataFace>& tree_;
99 
100  public:
101 
103 
104  void operator()
105  (
106  const labelUList& indices,
107  const point& sample,
108 
109  scalar& nearestDistSqr,
110  label& minIndex,
111  point& nearestPoint
112  ) const;
113 
114  void operator()
115  (
116  const labelUList& indices,
117  const linePointRef& ln,
118 
119  treeBoundBox& tightest,
120  label& minIndex,
121  point& linePoint,
122  point& nearestPoint
123  ) const;
124  };
125 
126 
127  class findIntersectOp
128  {
129  const indexedOctree<treeDataFace>& tree_;
130 
131  public:
132 
134 
135  //- Calculate intersection of triangle with ray.
136  // Sets result accordingly
137  bool operator()
138  (
139  const label index,
140  const point& start,
141  const point& end,
142  point& intersectionPoint
143  ) const;
144  };
145 
146 
147  // Declare name of the class and its debug switch
148  ClassName("treeDataFace");
149 
150 
151  // Constructors
152 
153  //- Construct from mesh, copying subset of faces
155  (
156  const bool cacheBb,
157  const primitiveMesh& mesh,
158  const labelUList& faceLabels
159  );
160 
161  //- Construct from mesh, moving subset of faces
163  (
164  const bool cacheBb,
165  const primitiveMesh& mesh,
167  );
168 
169  //- Construct from mesh. Uses all faces in mesh.
170  treeDataFace(const bool cacheBb, const primitiveMesh& mesh);
171 
172  //- Construct from mesh. Uses all faces in patch.
173  treeDataFace(const bool cacheBb, const polyPatch& patch);
174 
175 
176  // Member Functions
177 
178  // Access
179 
180  inline const labelList& faceLabels() const
181  {
182  return faceLabels_;
183  }
184 
185  inline const primitiveMesh& mesh() const
186  {
187  return mesh_;
188  }
189 
190  inline label size() const
191  {
192  return faceLabels_.size();
193  }
194 
195  //- Representative point cloud for all shapes inside
196  //- (one point per shape)
197  pointField shapePoints() const;
198 
199 
200  // Search
201 
202  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
203  // Only makes sense for closed surfaces.
205  (
207  const point&
208  ) const;
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 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 
226 #endif
227 
228 // ************************************************************************* //
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::treeDataFace::size
label size() const
Definition: treeDataFace.H:189
Foam::treeDataFace::getVolumeType
volumeType getVolumeType(const indexedOctree< treeDataFace > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataFace.C:165
indexedOctree.H
face.H
primitiveMesh.H
Foam::treeDataFace::faceLabels
const labelList & faceLabels() const
Definition: treeDataFace.H:179
bitSet.H
Foam::treeDataFace::mesh
const primitiveMesh & mesh() const
Definition: treeDataFace.H:184
volumeType.H
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:50
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
treeBoundBoxList.H
Foam::treeDataFace::shapePoints
pointField shapePoints() const
Definition: treeDataFace.C:151
Foam::treeDataFace::ClassName
ClassName("treeDataFace")
Foam::treeDataFace::findNearestOp
Definition: treeDataFace.H:95
Foam::treeDataFace::findIntersectOp
Definition: treeDataFace.H:126
Foam::treeDataFace::overlaps
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataFace.C:411
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::List< label >
Foam::treeDataFace
Encapsulation of data needed to search for faces.
Definition: treeDataFace.H:59
Foam::UList< label >
Foam::line
A line primitive.
Definition: line.H:53
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:925
Foam::treeDataFace::findNearestOp::findNearestOp
findNearestOp(const indexedOctree< treeDataFace > &tree)
Definition: treeDataFace.C:132
Foam::treeDataFace::treeDataFace
treeDataFace(const bool cacheBb, const primitiveMesh &mesh, const labelUList &faceLabels)
Construct from mesh, copying subset of faces.
Definition: treeDataFace.C:70
Foam::treeDataFace::findIntersectOp::findIntersectOp
findIntersectOp(const indexedOctree< treeDataFace > &tree)
Definition: treeDataFace.C:141
sample
Minimal example by using system/controlDict.functions:
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78