searchableCylinder.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-2020 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::searchableCylinder
26 
27 Description
28  Searching on cylinder
29 
30 SourceFiles
31  searchableCylinder.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef searchableCylinder_H
36 #define searchableCylinder_H
37 
38 #include "treeBoundBox.H"
39 #include "searchableSurface.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 
48 /*---------------------------------------------------------------------------*\
49  Class searchableCylinder Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public searchableSurface
55 {
56  // Private Member Data
57 
58  //- 'left' point
59  const point point1_;
60 
61  //- 'right' point
62  const point point2_;
63 
64  //- Length of vector point2-point1
65  const scalar magDir_;
66 
67  //- Normalised vector point2-point1
68  const vector unitDir_;
69 
70  //- Radius squared
71  const scalar radius_;
72 
73  //- Names of regions
74  mutable wordList regions_;
75 
76 
77  // Private Member Functions
78 
79  //- Inherit findNearest from searchableSurface
81 
82  //- Find nearest point on cylinder.
83  pointIndexHit findNearest
84  (
85  const point& sample,
86  const scalar nearestDistSqr
87  ) const;
88 
89  scalar radius2(const point& pt) const;
90 
91  //- Find intersection with cylinder
92  void findLineAll
93  (
94  const point& start,
95  const point& end,
96  pointIndexHit& near,
97  pointIndexHit& far
98  ) const;
99 
100  //- Return the boundBox of the cylinder
101  boundBox calcBounds() const;
102 
103 
104 public:
105 
106  //- Runtime type information
107  TypeName("searchableCylinder");
108 
109 
110  // Constructors
111 
112  //- Construct from components
114  (
115  const IOobject& io,
116  const point&,
117  const point&,
118  const scalar radius
119  );
120 
121  //- Construct from dictionary (used by searchableSurface)
123  (
124  const IOobject& io,
125  const dictionary& dict
126  );
127 
128  //- Disallow default bitwise copy construction
129  searchableCylinder(const searchableCylinder&) = delete;
130 
131 
132  //- Destructor
133  virtual ~searchableCylinder();
134 
135 
136  // Member Functions
137 
138  virtual const wordList& regions() const;
139 
140  //- Whether supports volume type below
141  virtual bool hasVolumeType() const
142  {
143  return true;
144  }
145 
146  //- Range of local indices that can be returned.
147  virtual label size() const
148  {
149  return 1;
150  }
151 
152  //- Get representative set of element coordinates
153  // Usually the element centres (should be of length size()).
154  virtual tmp<pointField> coordinates() const;
155 
156  //- Get bounding spheres (centre and radius squared), one per element.
157  // Any point on element is guaranteed to be inside.
158  virtual void boundingSpheres
159  (
160  pointField& centres,
161  scalarField& radiusSqr
162  ) const;
163 
164  //- Get the points that define the surface.
165  virtual tmp<pointField> points() const;
166 
167  //- Does any part of the surface overlap the supplied bound box?
168  virtual bool overlaps(const boundBox& bb) const
169  {
171 
172  return false;
173  }
174 
175 
176  // Multiple point queries.
177 
178  virtual void findNearest
179  (
180  const pointField& sample,
181  const scalarField& nearestDistSqr,
183  ) const;
184 
185  virtual void findLine
186  (
187  const pointField& start,
188  const pointField& end,
190  ) const;
191 
192  virtual void findLineAny
193  (
194  const pointField& start,
195  const pointField& end,
197  ) const;
198 
199  //- Get all intersections in order from start to end.
200  virtual void findLineAll
201  (
202  const pointField& start,
203  const pointField& end,
205  ) const;
206 
207  //- From a set of points and indices get the region
208  virtual void getRegion
209  (
210  const List<pointIndexHit>&,
211  labelList& region
212  ) const;
213 
214  //- From a set of points and indices get the normal
215  virtual void getNormal
216  (
217  const List<pointIndexHit>&,
218  vectorField& normal
219  ) const;
220 
221  //- Determine type (inside/outside/mixed) for point. unknown if
222  // cannot be determined (e.g. non-manifold surface)
223  virtual void getVolumeType
224  (
225  const pointField&,
227  ) const;
228 
229 
230  // regIOobject implementation
232  bool writeData(Ostream&) const
233  {
235  return false;
236  }
237 
238 
239  // Member Operators
240 
241  //- Disallow default bitwise assignment
242  void operator=(const searchableCylinder&) = delete;
243 };
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 } // End namespace Foam
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #endif
253 
254 // ************************************************************************* //
dictionary dict
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
bool writeData(Ostream &) const
Pure virtual writaData function.
void operator=(const searchableCylinder &)=delete
Disallow default bitwise assignment.
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
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual const wordList & regions() const
Names of regions.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
searchableCylinder(const IOobject &io, const point &, const point &, const scalar radius)
Construct from components.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual ~searchableCylinder()
Destructor.
virtual bool hasVolumeType() const
Whether supports volume type below.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual label size() const
Range of local indices that can be returned.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
TypeName("searchableCylinder")
Runtime type information.
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:370
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Searching on cylinder.
Namespace for OpenFOAM.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.