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