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 | Copyright (C) 2011-2016 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:
57 
58  // Private Member Data
59 
60  //- 'left' point
61  const point point1_;
62 
63  //- 'right' point
64  const point point2_;
65 
66  //- Length of vector point2-point1
67  const scalar magDir_;
68 
69  //- Normalised vector point2-point1
70  const vector unitDir_;
71 
72  //- Radius squared
73  const scalar radius_;
74 
75  //- Names of regions
76  mutable wordList regions_;
77 
78 
79  // Private Member Functions
80 
81  //- Inherit findNearest from searchableSurface
83 
84  //- Find nearest point on cylinder.
85  pointIndexHit findNearest
86  (
87  const point& sample,
88  const scalar nearestDistSqr
89  ) const;
90 
91  scalar radius2(const point& pt) const;
92 
93  //- Find intersection with cylinder
94  void findLineAll
95  (
96  const point& start,
97  const point& end,
98  pointIndexHit& near,
99  pointIndexHit& far
100  ) const;
101 
102  //- Return the boundBox of the cylinder
103  boundBox calcBounds() const;
104 
105  //- Disallow default bitwise copy construct
107 
108  //- Disallow default bitwise assignment
109  void operator=(const searchableCylinder&);
110 
111 
112 public:
113 
114  //- Runtime type information
115  TypeName("searchableCylinder");
116 
117 
118  // Constructors
119 
120  //- Construct from components
122  (
123  const IOobject& io,
124  const point&,
125  const point&,
126  const scalar radius
127  );
128 
129  //- Construct from dictionary (used by searchableSurface)
131  (
132  const IOobject& io,
133  const dictionary& dict
134  );
135 
136  //- Destructor
137  virtual ~searchableCylinder();
138 
139 
140  // Member Functions
141 
142  virtual const wordList& regions() const;
143 
144  //- Whether supports volume type below
145  virtual bool hasVolumeType() const
146  {
147  return true;
148  }
149 
150  //- Range of local indices that can be returned.
151  virtual label size() const
152  {
153  return 1;
154  }
155 
156  //- Get representative set of element coordinates
157  // Usually the element centres (should be of length size()).
158  virtual tmp<pointField> coordinates() const;
159 
160  //- Get bounding spheres (centre and radius squared), one per element.
161  // Any point on element is guaranteed to be inside.
162  virtual void boundingSpheres
163  (
164  pointField& centres,
165  scalarField& radiusSqr
166  ) const;
167 
168  //- Get the points that define the surface.
169  virtual tmp<pointField> points() const;
170 
171  //- Does any part of the surface overlap the supplied bound box?
172  virtual bool overlaps(const boundBox& bb) const
173  {
175 
176  return false;
177  }
178 
179 
180  // Multiple point queries.
181 
182  virtual void findNearest
183  (
184  const pointField& sample,
185  const scalarField& nearestDistSqr,
187  ) const;
188 
189  virtual void findLine
190  (
191  const pointField& start,
192  const pointField& end,
194  ) const;
195 
196  virtual void findLineAny
197  (
198  const pointField& start,
199  const pointField& end,
201  ) const;
202 
203  //- Get all intersections in order from start to end.
204  virtual void findLineAll
205  (
206  const pointField& start,
207  const pointField& end,
209  ) const;
210 
211  //- From a set of points and indices get the region
212  virtual void getRegion
213  (
214  const List<pointIndexHit>&,
215  labelList& region
216  ) const;
217 
218  //- From a set of points and indices get the normal
219  virtual void getNormal
220  (
221  const List<pointIndexHit>&,
223  ) const;
224 
225  //- Determine type (inside/outside/mixed) for point. unknown if
226  // cannot be determined (e.g. non-manifold surface)
227  virtual void getVolumeType
228  (
229  const pointField&,
231  ) const;
232 
233 
234  // regIOobject implementation
236  bool writeData(Ostream&) const
237  {
239  return false;
240  }
241 
242 };
243 
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 } // End namespace Foam
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
dictionary dict
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual label size() const
Range of local indices that can be returned.
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:137
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 void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual bool hasVolumeType() const
Whether supports volume type below.
virtual const wordList & regions() const
Names of regions.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
bool writeData(Ostream &) const
Pure virtual writaData function.
virtual ~searchableCylinder()
Destructor.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
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:53
A normal distribution model.
TypeName("searchableCylinder")
Runtime type information.
A class for managing temporary objects.
Definition: PtrList.H:54
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Searching on cylinder.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Namespace for OpenFOAM.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.