searchableBox.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) 2018-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::searchableBox
29
30Description
31 Searching on bounding box
32
33 \heading Dictionary parameters
34 \table
35 Property | Description | Required | Default
36 type | box | selector |
37 min | Minimum point for bounding box | yes |
38 max | Maximum point for bounding box | yes |
39 span | Box width | cond'l |
40 \endtable
41
42Note
43 The order of precedence from the highest to the lowest is
44 \c min-max or \c min-span pair
45
46Note
47 Longer type name : \c searchableBox
48
49SourceFiles
50 searchableBox.C
51
52\*---------------------------------------------------------------------------*/
53
54#ifndef searchableBox_H
55#define searchableBox_H
56
57#include "searchableSurface.H"
58#include "treeBoundBox.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
64
65/*---------------------------------------------------------------------------*\
66 Class searchableBox Declaration
67\*---------------------------------------------------------------------------*/
68
69class searchableBox
70:
71 public searchableSurface,
72 public treeBoundBox
73{
74 // Private Member Data
75
76 mutable wordList regions_;
77
78
79 // Private Member Functions
80
81 //- Project onto component dir of planePt and update index() (=face)
82 void projectOntoCoordPlane
83 (
84 const direction dir,
85 const point& planePt,
87 ) const;
88
89 //- Inherit findNearest from searchableSurface
91
92 //- Returns miss or hit with face (0..5)
93 pointIndexHit findNearest
94 (
95 const point& bbMid,
96 const point& sample,
97 const scalar nearestDistSqr
98 ) const;
99
100
101 //- No copy construct
102 searchableBox(const searchableBox&) = delete;
103
104 //- No copy assignment
105 void operator=(const searchableBox&) = delete;
106
107
108public:
109
110 //- Runtime type information
111 TypeName("searchableBox");
112
113
114 // Constructors
115
116 //- Construct from components
117 searchableBox(const IOobject& io, const treeBoundBox& bb);
118
119 //- Construct from dictionary (used by searchableSurface)
121 (
122 const IOobject& io,
123 const dictionary& dict
124 );
125
126
127 //- Destructor
128 virtual ~searchableBox() = default;
129
130
131 // Member Functions
132
133 //- Names of regions
134 virtual const wordList& regions() const;
136 //- Whether surface supports volume type (below)
137 virtual bool hasVolumeType() const
138 {
139 return true;
140 }
141 //- What is type of points outside bounds
142 virtual volumeType outsideVolumeType() const
143 {
144 return volumeType::OUTSIDE;
145 }
146
147 //- Range of local indices that can be returned.
148 virtual label size() const
149 {
150 return 6;
151 }
153 //- Get representative set of element coordinates
154 // Usually the element centres (should be of length size()).
155 virtual tmp<pointField> coordinates() const;
156
157 //- Get bounding spheres (centre and radius squared), one per element.
158 // Any point on element is guaranteed to be inside.
159 virtual void boundingSpheres
160 (
161 pointField& centres,
162 scalarField& radiusSqr
163 ) const;
164
165 //- Get the points that define the surface.
166 virtual tmp<pointField> points() const;
167
168 // Does any part of the surface overlap the supplied bound box?
169 virtual bool overlaps(const boundBox& bb) const
170 {
171 return boundBox::overlaps(bb);
173
174 // Single point queries.
175
176 //- Calculate nearest point on surface.
177 // Returns
178 // - bool : any point found nearer than nearestDistSqr
179 // - label: relevant index in surface (=face 0..5)
180 // - point: actual nearest point found
181 pointIndexHit findNearest
182 (
183 const point& sample,
184 const scalar nearestDistSqr
185 ) const;
186
187 //- Calculate nearest point on edge.
188 // Returns
189 // - bool : any point found nearer than nearestDistSqr
190 // - label: relevant index in surface(=?)
191 // - point: actual nearest point found
194 const point& sample,
195 const scalar nearestDistSqr
196 ) const;
197
198 //- Find nearest to segment.
199 // Returns
200 // - bool : any point found?
201 // - label: relevant index in shapes (=face 0..5)
202 // - point: actual nearest point found
203 // sets:
204 // - tightest : bounding box
205 // - linePoint : corresponding nearest point on line
206 pointIndexHit findNearest
207 (
208 const linePointRef& ln,
209 treeBoundBox& tightest,
210 point& linePoint
211 ) const;
212
213 //- Find nearest intersection of line between start and end.
215 (
216 const point& start,
217 const point& end
218 ) const;
219
220 //- Find any intersection of line between start and end.
222 (
223 const point& start,
224 const point& end
225 ) const;
226
227
228 // Multiple point queries.
229
230 virtual void findNearest
231 (
232 const pointField& sample,
233 const scalarField& nearestDistSqr,
235 ) const;
236
237 virtual void findLine
238 (
239 const pointField& start,
240 const pointField& end,
242 ) const;
243
244 virtual void findLineAny
245 (
246 const pointField& start,
247 const pointField& end,
249 ) const;
250
251 //- Get all intersections in order from start to end.
252 virtual void findLineAll
253 (
254 const pointField& start,
255 const pointField& end,
257 ) const;
258
259 //- From a set of points and indices get the region
260 virtual void getRegion
261 (
262 const List<pointIndexHit>&,
263 labelList& region
264 ) const;
265
266 //- From a set of points and indices get the normal
267 virtual void getNormal
268 (
269 const List<pointIndexHit>&,
270 vectorField& normal
271 ) const;
272
273 //- Determine type (inside/outside) for points.
274 virtual void getVolumeType
275 (
276 const pointField& points,
277 List<volumeType>& volType
278 ) const;
279
280
281 // regIOobject implementation
282
283 bool writeData(Ostream&) const
284 {
286 return false;
287 }
288};
289
290
291// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293} // End namespace Foam
294
295// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296
297#endif
298
299// ************************************************************************* //
Minimal example by using system/controlDict.functions:
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
InfoProxy< IOobject > info() const
Return info proxy, for printing information to a stream.
Definition: IOobject.H:690
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
int overlaps
Flag to control which overlap calculations are performed.
Definition: PDRparams.H:97
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A line primitive.
Definition: line.H:68
Searching on bounding box.
Definition: searchableBox.H:97
virtual label size() const
Range of local indices that can be returned.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
bool writeData(Ostream &) const
Pure virtual writeData function.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside) for points.
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual ~searchableBox()=default
Destructor.
virtual bool hasVolumeType() const
Whether surface supports volume type (below)
TypeName("searchableBox")
Runtime type information.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
virtual tmp< pointField > points() const
Get the points that define the surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
A class for managing temporary objects.
Definition: tmp.H:65
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
@ OUTSIDE
A location outside the volume.
Definition: volumeType.H:69
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
Definition: pointIndexHit.H:46
vector point
Point is a vector.
Definition: point.H:43
uint8_t direction
Definition: direction.H:56
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:933
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73