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 / searchableCylinder | selector |
37  point1 | coordinate of endpoint | yes |
38  point2 | coordinate of endpoint | yes |
39  radius | cylinder radius | yes |
40  \endtable
41 
42 SourceFiles
43  searchableCylinder.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef searchableCylinder_H
48 #define searchableCylinder_H
49 
50 #include "treeBoundBox.H"
51 #include "searchableSurface.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class searchableCylinder Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class searchableCylinder
63 :
64  public searchableSurface
65 {
66 private:
67 
68  // Private Member Data
69 
70  //- The 'left' point
71  const point point1_;
72 
73  //- The 'right' point
74  const point point2_;
75 
76  //- Length of vector point2-point1
77  const scalar magDir_;
78 
79  //- Normalised vector point2-point1
80  const vector unitDir_;
81 
82  //- The radius
83  const scalar radius_;
84 
85  //- Names of regions
86  mutable wordList regions_;
87 
88 
89  // Private Member Functions
90 
91  //- Inherit findNearest from searchableSurface
93 
94  //- Find nearest point on cylinder.
95  pointIndexHit findNearest
96  (
97  const point& sample,
98  const scalar nearestDistSqr
99  ) const;
100 
101  scalar radius2(const point& pt) const;
102 
103  //- Find intersection with cylinder
104  void findLineAll
105  (
106  const point& start,
107  const point& end,
108  pointIndexHit& near,
109  pointIndexHit& far
110  ) const;
111 
112  //- Return the boundBox of the cylinder
113  boundBox calcBounds() const;
114 
115  //- No copy construct
116  searchableCylinder(const searchableCylinder&) = delete;
117 
118  //- No copy assignment
119  void operator=(const searchableCylinder&) = delete;
120 
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("searchableCylinder");
126 
127 
128  // Constructors
129 
130  //- Construct from components
132  (
133  const IOobject& io,
134  const point& point1,
135  const point& point2,
136  const scalar radius
137  );
138 
139  //- Construct from dictionary (used by searchableSurface)
141  (
142  const IOobject& io,
143  const dictionary& dict
144  );
145 
146 
147  //- Destructor
148  virtual ~searchableCylinder() = default;
149 
150 
151  // Member Functions
152 
153  //- Names of regions
154  virtual const wordList& regions() const;
155 
156  //- Whether supports volume type below
157  virtual bool hasVolumeType() const
158  {
159  return true;
160  }
161 
162  //- What is type of points outside bounds
163  virtual volumeType outsideVolumeType() const
164  {
165  return volumeType::OUTSIDE;
166  }
167 
168  //- Range of local indices that can be returned.
169  virtual label size() const
170  {
171  return 1;
172  }
173 
174  //- Get representative set of element coordinates
175  // Usually the element centres (should be of length size()).
176  virtual tmp<pointField> coordinates() const;
177 
178  //- Get bounding spheres (centre and radius squared), one per element.
179  // Any point on element is guaranteed to be inside.
180  virtual void boundingSpheres
181  (
182  pointField& centres,
183  scalarField& radiusSqr
184  ) const;
185 
186  //- Get the points that define the surface.
187  virtual tmp<pointField> points() const;
188 
189  //- Does any part of the surface overlap the supplied bound box?
190  virtual bool overlaps(const boundBox& bb) const
191  {
193  return false;
194  }
195 
196 
197  // Multiple point queries.
198 
199  virtual void findNearest
200  (
201  const pointField& sample,
202  const scalarField& nearestDistSqr,
204  ) const;
205 
206  virtual void findLine
207  (
208  const pointField& start,
209  const pointField& end,
211  ) const;
212 
213  virtual void findLineAny
214  (
215  const pointField& start,
216  const pointField& end,
218  ) const;
219 
220  //- Get all intersections in order from start to end.
221  virtual void findLineAll
222  (
223  const pointField& start,
224  const pointField& end,
226  ) const;
227 
228  //- From a set of points and indices get the region
229  virtual void getRegion
230  (
231  const List<pointIndexHit>&,
232  labelList& region
233  ) const;
234 
235  //- From a set of points and indices get the normal
236  virtual void getNormal
237  (
238  const List<pointIndexHit>&,
239  vectorField& normal
240  ) const;
241 
242  //- Determine type (inside/outside/mixed) for point.
243  // Unknown if cannot be determined (e.g. non-manifold surface)
244  virtual void getVolumeType
245  (
246  const pointField& points,
247  List<volumeType>& volType
248  ) const;
249 
250 
251  // regIOobject implementation
252 
253  bool writeData(Ostream&) const
254  {
256  return false;
257  }
258 
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
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:104
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:59
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:181
Foam::searchableCylinder
Searching on a cylinder.
Definition: searchableCylinder.H:86
Foam::searchableCylinder::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableCylinder.H:214
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:419
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:55
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:62
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:121
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:115
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:187
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::start
label ListType::const_reference const label start
Definition: ListOps.H:408
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:277
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
Foam::searchableCylinder::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableCylinder.H:193