searchableCylinder.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-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2018 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::searchableCylinder
29 
30 Description
31  Searching on a cylinder.
32 
33  \heading Dictionary parameters
34  \table
35  Property | Description | Required | Default
36  type | cylinder | selector |
37  point1 | coordinate of endpoint | yes |
38  point2 | coordinate of endpoint | yes |
39  radius | cylinder radius | yes |
40  \endtable
41 
42 Note
43  Longer type name : \c searchableCylinder
44 
45 SourceFiles
46  searchableCylinder.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef searchableCylinder_H
51 #define searchableCylinder_H
52 
53 #include "treeBoundBox.H"
54 #include "searchableSurface.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class searchableCylinder Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class searchableCylinder
66 :
67  public searchableSurface
68 {
69 private:
70 
71  // Private Member Data
72 
73  //- The 'left' point
74  const point point1_;
75 
76  //- The 'right' point
77  const point point2_;
78 
79  //- Length of vector point2-point1
80  const scalar magDir_;
81 
82  //- Normalised vector point2-point1
83  const vector unitDir_;
84 
85  //- The radius
86  const scalar radius_;
87 
88  //- Names of regions
89  mutable wordList regions_;
90 
91 
92  // Private Member Functions
93 
94  //- Inherit findNearest from searchableSurface
96 
97  //- Find nearest point on cylinder.
98  pointIndexHit findNearest
99  (
100  const point& sample,
101  const scalar nearestDistSqr
102  ) const;
103 
104  scalar radius2(const point& pt) const;
105 
106  //- Find intersection with cylinder
107  void findLineAll
108  (
109  const point& start,
110  const point& end,
111  pointIndexHit& near,
112  pointIndexHit& far
113  ) const;
114 
115  //- Return the boundBox of the cylinder
116  boundBox calcBounds() const;
117 
118  //- No copy construct
119  searchableCylinder(const searchableCylinder&) = delete;
120 
121  //- No copy assignment
122  void operator=(const searchableCylinder&) = delete;
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("searchableCylinder");
129 
130 
131  // Constructors
132 
133  //- Construct from components
135  (
136  const IOobject& io,
137  const point& point1,
138  const point& point2,
139  const scalar radius
140  );
141 
142  //- Construct from dictionary (used by searchableSurface)
144  (
145  const IOobject& io,
146  const dictionary& dict
147  );
148 
149 
150  //- Destructor
151  virtual ~searchableCylinder() = default;
152 
153 
154  // Member Functions
155 
156  //- Names of regions
157  virtual const wordList& regions() const;
158 
159  //- Whether supports volume type below
160  virtual bool hasVolumeType() const
161  {
162  return true;
163  }
164 
165  //- What is type of points outside bounds
166  virtual volumeType outsideVolumeType() const
167  {
168  return volumeType::OUTSIDE;
169  }
170 
171  //- Range of local indices that can be returned.
172  virtual label size() const
173  {
174  return 1;
175  }
176 
177  //- Get representative set of element coordinates
178  // Usually the element centres (should be of length size()).
179  virtual tmp<pointField> coordinates() const;
180 
181  //- Get bounding spheres (centre and radius squared), one per element.
182  // Any point on element is guaranteed to be inside.
183  virtual void boundingSpheres
184  (
185  pointField& centres,
186  scalarField& radiusSqr
187  ) const;
188 
189  //- Get the points that define the surface.
190  virtual tmp<pointField> points() const;
191 
192  //- Does any part of the surface overlap the supplied bound box?
193  virtual bool overlaps(const boundBox& bb) const
194  {
196  return false;
197  }
198 
199 
200  // Multiple point queries.
201 
202  virtual void findNearest
203  (
204  const pointField& sample,
205  const scalarField& nearestDistSqr,
207  ) const;
208 
209  virtual void findLine
210  (
211  const pointField& start,
212  const pointField& end,
214  ) const;
215 
216  virtual void findLineAny
217  (
218  const pointField& start,
219  const pointField& end,
221  ) const;
222 
223  //- Get all intersections in order from start to end.
224  virtual void findLineAll
225  (
226  const pointField& start,
227  const pointField& end,
229  ) const;
230 
231  //- From a set of points and indices get the region
232  virtual void getRegion
233  (
234  const List<pointIndexHit>&,
235  labelList& region
236  ) const;
237 
238  //- From a set of points and indices get the normal
239  virtual void getNormal
240  (
241  const List<pointIndexHit>&,
242  vectorField& normal
243  ) const;
244 
245  //- Determine type (inside/outside/mixed) for point.
246  // Unknown if cannot be determined (e.g. non-manifold surface)
247  virtual void getVolumeType
248  (
249  const pointField& points,
250  List<volumeType>& volType
251  ) const;
252 
253 
254  // regIOobject implementation
255 
256  bool writeData(Ostream&) const
257  {
259  return false;
260  }
261 
262 };
263 
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 } // End namespace Foam
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 #endif
272 
273 // ************************************************************************* //
Foam::searchableCylinder::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableCylinder.C:62
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::searchableCylinder::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableCylinder.C:528
searchableSurface.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::searchableCylinder::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Definition: searchableCylinder.C:556
Foam::searchableCylinder::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableCylinder.H:184
Foam::searchableCylinder
Searching on a cylinder.
Definition: searchableCylinder.H:89
Foam::searchableCylinder::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableCylinder.H:217
Foam::searchableCylinder::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableCylinder.C:55
Foam::searchableCylinder::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableCylinder.C:644
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:52
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
treeBoundBox.H
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::searchableCylinder::~searchableCylinder
virtual ~searchableCylinder()=default
Destructor.
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam::searchableCylinder::TypeName
TypeName("searchableCylinder")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::searchableCylinder::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableCylinder.H:190
Foam::searchableCylinder::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableCylinder.C:78
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::List< word >
Foam::searchableCylinder::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: searchableCylinder.C:578
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::searchableCylinder::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableCylinder.H:280
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::searchableCylinder::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableCylinder.C:655
Foam::volumeType::OUTSIDE
A location outside the volume.
Definition: volumeType.H:69
Foam::searchableCylinder::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
Definition: searchableCylinder.C:732
sample
Minimal example by using system/controlDict.functions:
Foam::searchableCylinder::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableCylinder.H:196