searchableBox.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::searchableBox
26 
27 Description
28  Surface geometry with a rectangular box shape, aligned with the coordinate
29  axes, which can be used with snappyHexMesh.
30 
31 Usage
32  \table
33  Property | Description | Required
34  min | Minimum point of bounding box | yes
35  max | Maximum point of bounding box | yes
36  \endtable
37 
38  Example specification in snappyHexMeshDict/geometry:
39  \verbatim
40  type searchableBox;
41  min (0 0 0);
42  max (10 10 10);
43  \endverbatim
44 
45 SourceFiles
46  searchableBox.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef searchableBox_H
51 #define searchableBox_H
52 
53 #include "searchableSurface.H"
54 #include "treeBoundBox.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward declaration of classes
62 
63 /*---------------------------------------------------------------------------*\
64  Class searchableBox Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class searchableBox
68 :
69  public searchableSurface,
70  public treeBoundBox
71 {
72  // Private Member Data
73 
74  mutable wordList regions_;
75 
76 
77  // Private Member Functions
78 
79  //- Project onto component dir of planePt and update index() (=face)
80  void projectOntoCoordPlane
81  (
82  const direction dir,
83  const point& planePt,
85  ) const;
86 
87  //- Inherit findNearest from searchableSurface
89 
90  //- Returns miss or hit with face (0..5)
91  pointIndexHit findNearest
92  (
93  const point& bbMid,
94  const point& sample,
95  const scalar nearestDistSqr
96  ) const;
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("searchableBox");
103 
104 
105  // Constructors
106 
107  //- Construct from components
108  searchableBox(const IOobject& io, const treeBoundBox& bb);
109 
110  //- Construct from dictionary (used by searchableSurface)
112  (
113  const IOobject& io,
114  const dictionary& dict
115  );
116 
117  //- Disallow default bitwise copy construction
118  searchableBox(const searchableBox&) = delete;
119 
120 
121  //- Destructor
122  virtual ~searchableBox();
123 
124 
125  // Member Functions
126 
127  virtual const wordList& regions() const;
128 
129  //- Whether supports volume type below
130  virtual bool hasVolumeType() const
131  {
132  return true;
133  }
134 
135  //- Range of local indices that can be returned.
136  virtual label size() const
137  {
138  return 6;
139  }
140 
141  //- Get representative set of element coordinates
142  // Usually the element centres (should be of length size()).
143  virtual tmp<pointField> coordinates() const;
144 
145  //- Get bounding spheres (centre and radius squared), one per element.
146  // Any point on element is guaranteed to be inside.
147  virtual void boundingSpheres
148  (
149  pointField& centres,
150  scalarField& radiusSqr
151  ) const;
152 
153  //- Get the points that define the surface.
154  virtual tmp<pointField> points() const;
155 
156  // Does any part of the surface overlap the supplied bound box?
157  virtual bool overlaps(const boundBox& bb) const
158  {
159  return boundBox::overlaps(bb);
160  }
161 
162  // Single point queries.
163 
164  //- Calculate nearest point on surface.
165  // Returns
166  // - bool : any point found nearer than nearestDistSqr
167  // - label: relevant index in surface (=face 0..5)
168  // - point: actual nearest point found
169  pointIndexHit findNearest
170  (
171  const point& sample,
172  const scalar nearestDistSqr
173  ) const;
174 
175  //- Calculate nearest point on edge.
176  // Returns
177  // - bool : any point found nearer than nearestDistSqr
178  // - label: relevant index in surface(=?)
179  // - point: actual nearest point found
181  (
182  const point& sample,
183  const scalar nearestDistSqr
184  ) const;
185 
186  //- Find nearest to segment.
187  // Returns
188  // - bool : any point found?
189  // - label: relevant index in shapes (=face 0..5)
190  // - point: actual nearest point found
191  // sets:
192  // - tightest : bounding box
193  // - linePoint : corresponding nearest point on line
194  pointIndexHit findNearest
195  (
196  const linePointRef& ln,
197  treeBoundBox& tightest,
198  point& linePoint
199  ) const;
200 
201  //- Find nearest intersection of line between start and end.
203  (
204  const point& start,
205  const point& end
206  ) const;
207 
208  //- Find any intersection of line between start and end.
210  (
211  const point& start,
212  const point& end
213  ) const;
214 
215 
216  // Multiple point queries.
217 
218  virtual void findNearest
219  (
220  const pointField& sample,
221  const scalarField& nearestDistSqr,
223  ) const;
224 
225  virtual void findLine
226  (
227  const pointField& start,
228  const pointField& end,
230  ) const;
231 
232  virtual void findLineAny
233  (
234  const pointField& start,
235  const pointField& end,
237  ) const;
238 
239  //- Get all intersections in order from start to end.
240  virtual void findLineAll
241  (
242  const pointField& start,
243  const pointField& end,
245  ) const;
246 
247  //- From a set of points and indices get the region
248  virtual void getRegion
249  (
250  const List<pointIndexHit>&,
251  labelList& region
252  ) const;
253 
254  //- From a set of points and indices get the normal
255  virtual void getNormal
256  (
257  const List<pointIndexHit>&,
258  vectorField& normal
259  ) const;
260 
261  //- Determine type (inside/outside/mixed) for point. unknown if
262  // cannot be determined (e.g. non-manifold surface)
263  virtual void getVolumeType
264  (
265  const pointField&,
267  ) const;
268 
269 
270  // regIOobject implementation
271 
272  bool writeData(Ostream&) const
273  {
275  return false;
276  }
277 
278 
279  // Member Operators
280 
281  //- Disallow default bitwise assignment
282  void operator=(const searchableBox&) = delete;
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #endif
293 
294 // ************************************************************************* //
bool overlaps(const boundBox &) const
Overlaps/touches boundingBox?
Definition: boundBoxI.H:120
virtual const wordList & regions() const
Names of regions.
dictionary dict
A line primitive.
Definition: line.H:56
Surface geometry with a rectangular box shape, aligned with the coordinate axes, which can be used wi...
Definition: searchableBox.H:78
virtual ~searchableBox()
Destructor.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool hasVolumeType() const
Whether supports volume type below.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
uint8_t direction
Definition: direction.H:45
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual label size() const
Range of local indices that can be returned.
virtual tmp< pointField > points() const
Get the points that define the surface.
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:58
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
TypeName("searchableBox")
Runtime type information.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
searchableBox(const IOobject &io, const treeBoundBox &bb)
Construct from components.
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
bool writeData(Ostream &) const
Pure virtual writaData function.
List< word > wordList
A List of words.
Definition: fileName.H:54
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
void operator=(const searchableBox &)=delete
Disallow default bitwise assignment.
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:495
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Namespace for OpenFOAM.