searchableCone.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) 2015 OpenCFD Ltd.
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::searchableCone
26 
27 Description
28  Searching on (optionally hollow) cone.
29 
30  \heading Function object usage
31  \table
32  Property | Description | Required | Default value
33  point1 | coordinate of endpoint | yes |
34  radius1 | radius at point1 | yes | yes
35  innerRadius1 | inner radius at point1 | no |
36  point2 | coordinate of endpoint | yes |
37  radius2 | radius at point2 | yes | yes
38  innerRadius2 | inner radius at point2 | no |
39  \endtable
40 
41 Note
42  Initial implementation, might suffer from robustness (e.g. radius1==radius2)
43 
44 SourceFiles
45  searchableCone.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef searchableCone_H
50 #define searchableCone_H
51 
52 #include "searchableSurface.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class searchableCone Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class searchableCone
64 :
65  public searchableSurface
66 {
67  // Private Member Data
68 
69  //- 'Left' point
70  const point point1_;
71 
72  //- Outer radius at point1
73  const scalar radius1_;
74 
75  //- Inner radius at point1
76  const scalar innerRadius1_;
77 
78 
79  //- 'Right' point
80  const point point2_;
81 
82  //- Outer radius at point2
83  const scalar radius2_;
84 
85  //- Inner radius at point2
86  const scalar innerRadius2_;
87 
88 
89  //- Length of vector point2-point1
90  const scalar magDir_;
91 
92  //- Normalised vector point2-point1
93  const vector unitDir_;
94 
95 
96  //- Names of regions
97  mutable wordList regions_;
98 
99 
100  // Private Member Functions
101 
102  //- Find nearest point on cylinder.
104  (
105  const point& sample,
106  const scalar nearestDistSqr,
108  vector& normal
109  ) const;
110 
111  //- Determine radial coordinate (squared)
112  static scalar radius2(const searchableCone& cone, const point& pt);
113 
114  //- Find both intersections with cone. innerRadii supplied externally.
115  void findLineAll
116  (
117  const searchableCone& cone,
118  const scalar innerRadius1,
119  const scalar innerRadius2,
120  const point& start,
121  const point& end,
122  pointIndexHit& near,
123  pointIndexHit& far
124  ) const;
125 
126  //- Insert a hit if it differs (by a tolerance) from the existing ones
128  (
129  const point& start,
130  const point& end,
132  const pointIndexHit& hit
133  ) const;
134 
135  //- Return the boundBox of the cylinder
136  boundBox calcBounds() const;
137 
138  //- Disallow default bitwise copy construct
140 
141  //- Disallow default bitwise assignment
142  void operator=(const searchableCone&);
143 
144 
145 public:
146 
147  //- Runtime type information
148  TypeName("searchableCone");
149 
150 
151  // Constructors
152 
153  //- Construct from components
155  (
156  const IOobject& io,
157  const point& point1,
158  const scalar radius1,
159  const scalar innerRadius1,
160  const point& point2,
161  const scalar radius2,
162  const scalar innerRadius2
163  );
164 
165  //- Construct from dictionary (used by searchableSurface)
167  (
168  const IOobject& io,
169  const dictionary& dict
170  );
171 
172 
173  //- Destructor
174 
175  virtual ~searchableCone();
176 
177 
178  // Member Functions
179 
180  virtual const wordList& regions() const;
181 
182  //- Whether supports volume type below
183  virtual bool hasVolumeType() const
184  {
185  return true;
186  }
187 
188  //- Range of local indices that can be returned.
189  virtual label size() const
190  {
191  return 1;
192  }
193 
194  //- Get representative set of element coordinates
195  // Usually the element centres (should be of length size()).
196  virtual tmp<pointField> coordinates() const;
197 
198  //- Get bounding spheres (centre and radius squared), one per element.
199  // Any point on element is guaranteed to be inside.
200  virtual void boundingSpheres
201  (
202  pointField& centres,
203  scalarField& radiusSqr
204  ) const;
205 
206  //- Get the points that define the surface.
207  virtual tmp<pointField> points() const;
208 
209  //- Does any part of the surface overlap the supplied bound box?
210  virtual bool overlaps(const boundBox& bb) const
211  {
213  return false;
214  }
215 
216 
217  // Multiple point queries.
218 
219  //- Find nearest point on cylinder
220  virtual void findNearest
221  (
222  const pointField& sample,
223  const scalarField& nearestDistSqr,
225  ) const;
226 
227  //- Find nearest intersection on line from start to end
228  virtual void findLine
229  (
230  const pointField& start,
231  const pointField& end,
233  ) const;
234 
235  //- Find all intersections in order from start to end
236  virtual void findLineAll
237  (
238  const pointField& start,
239  const pointField& end,
241  ) const;
242 
243  //- Find any intersection on line from start to end
244  virtual void findLineAny
245  (
246  const pointField& start,
247  const pointField& end,
249  ) const;
250 
251  //- From a set of points and indices get the region
252  virtual void getRegion
253  (
254  const List<pointIndexHit>&,
255  labelList& region
256  ) const;
257 
258  //- From a set of points and indices get the normal
259  virtual void getNormal
260  (
261  const List<pointIndexHit>&,
263  ) const;
264 
265  //- Determine type (inside/outside/mixed) for point. unknown if
266  // cannot be determined (e.g. non-manifold surface)
267  virtual void getVolumeType
268  (
269  const pointField&,
271  ) const;
272 
273 
274  // regIOobject implementation
275 
276  virtual bool writeData(Ostream&) const
277  {
279  return false;
280  }
281 };
282 
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Foam::searchableCone::radius2
static scalar radius2(const searchableCone &cone, const point &pt)
Determine radial coordinate (squared)
Definition: searchableCone.C:312
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::searchableCone::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableCone.H:244
Foam::searchableCone::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find any intersection on line from start to end.
Definition: searchableCone.C:871
Foam::searchableCone::insertHit
void insertHit(const point &start, const point &end, List< pointIndexHit > &info, const pointIndexHit &hit) const
Insert a hit if it differs (by a tolerance) from the existing ones.
Definition: searchableCone.C:612
searchableSurface.H
Foam::searchableCone::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableCone.C:42
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::searchableCone::TypeName
TypeName("searchableCone")
Runtime type information.
Foam::searchableCone::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
Find nearest point on cylinder.
Definition: searchableCone.C:773
Foam::searchableCone::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableCone.C:761
Foam::searchableCone
Searching on (optionally hollow) cone.
Definition: searchableCone.H:97
Foam::searchableCone::writeData
virtual bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: searchableCone.H:310
Foam::searchableCone::radius2_
const scalar radius2_
Outer radius at point2.
Definition: searchableCone.H:117
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:434
Foam::searchableCone::unitDir_
const vector unitDir_
Normalised vector point2-point1.
Definition: searchableCone.H:127
Foam::searchableCone::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: searchableCone.C:1070
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
Foam::searchableCone::magDir_
const scalar magDir_
Length of vector point2-point1.
Definition: searchableCone.H:124
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::searchableCone::innerRadius2_
const scalar innerRadius2_
Inner radius at point2.
Definition: searchableCone.H:120
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::searchableCone::findNearestAndNormal
void findNearestAndNormal(const point &sample, const scalar nearestDistSqr, pointIndexHit &nearInfo, vector &normal) const
Find nearest point on cylinder.
Definition: searchableCone.C:87
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
Foam::searchableCone::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableCone.C:74
Foam::searchableCone::regions_
wordList regions_
Names of regions.
Definition: searchableCone.H:131
Foam::searchableCone::~searchableCone
virtual ~searchableCone()
Destructor.
Definition: searchableCone.C:755
Foam::searchableCone::point1_
const point point1_
'Left' point
Definition: searchableCone.H:104
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::searchableCone::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableCone.H:217
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Foam::searchableCone::calcBounds
boundBox calcBounds() const
Return the boundBox of the cylinder.
Definition: searchableCone.C:652
Foam::searchableCone::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find nearest intersection on line from start to end.
Definition: searchableCone.C:789
Foam::searchableCone::findLineAll
void findLineAll(const searchableCone &cone, const scalar innerRadius1, const scalar innerRadius2, const point &start, const point &end, pointIndexHit &near, pointIndexHit &far) const
Find both intersections with cone. innerRadii supplied externally.
Definition: searchableCone.C:325
Foam::searchableCone::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableCone.C:1033
Foam::searchableCone::searchableCone
searchableCone(const searchableCone &)
Disallow default bitwise copy construct.
Foam::searchableCone::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableCone.H:223
Foam::searchableCone::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableCone.C:51
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::searchableCone::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableCone.C:1044
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::searchableCone::point2_
const point point2_
'Right' point
Definition: searchableCone.H:114
Foam::searchableCone::operator=
void operator=(const searchableCone &)
Disallow default bitwise assignment.
Foam::searchableCone::innerRadius1_
const scalar innerRadius1_
Inner radius at point1.
Definition: searchableCone.H:110
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Tuple2
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
Foam::point
vector point
Point is a vector.
Definition: point.H:41
Foam::searchableCone::radius1_
const scalar radius1_
Outer radius at point1.
Definition: searchableCone.H:107
normal
A normal distribution model.