searchableDisk.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) 2014-2017 OpenFOAM Foundation
9  Copyright (C) 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::searchableDisk
29 
30 Description
31  Searching on circular disk given as origin, normal (gets normalised)
32  and radius. Optionally it can be an annular ring.
33 
34  \heading Dictionary parameters
35  \table
36  Property | Description | Required | Default
37  type | disk | selector |
38  origin | centre of disk | yes |
39  normal | normal vector | yes |
40  radius | disk radius | yes |
41  innerRadius | inner disk radius | no | 0
42  \endtable
43 
44 Note
45  Longer type name : \c searchableDisk
46 
47 SourceFiles
48  searchableDisk.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef searchableDisk_H
53 #define searchableDisk_H
54 
55 #include "plane.H"
56 #include "MinMax.H"
57 #include "searchableSurface.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 
64 /*---------------------------------------------------------------------------*\
65  Class searchableDisk Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class searchableDisk
69 :
70  public searchableSurface,
71  public plane
72 {
73 private:
74 
75  // Private Data
76 
77  //- Inner/outer radial limits
78  const scalarMinMax radialLimits_;
79 
80  //- Names of regions
81  mutable wordList regions_;
82 
83 
84  // Private Member Functions
85 
86  //- Inherit findNearest from searchableSurface
88 
89  //- Find nearest point on disk
90  pointIndexHit findNearest
91  (
92  const point& sample,
93  const scalar nearestDistSqr
94  ) const;
95 
96  //- Find intersection with disk
97  void findLine
98  (
99  const point& start,
100  const point& end,
102  ) const;
103 
104  //- No copy construct
105  searchableDisk(const searchableDisk&) = delete;
106 
107  //- No copy assignment
108  void operator=(const searchableDisk&) = delete;
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("searchableDisk");
114 
115 
116  // Constructors
117 
118  //- Construct from components
120  (
121  const IOobject& io,
122  const point& originPoint,
123  const vector& normalVector,
124  const scalar outerRadius,
125  const scalar innerRadius = 0
126  );
127 
128  //- Construct from dictionary (used by searchableSurface)
130  (
131  const IOobject& io,
132  const dictionary& dict
133  );
134 
135 
136  //- Destructor
137  virtual ~searchableDisk() = default;
138 
139 
140  // Member Functions
141 
142  //- Names of regions
143  virtual const wordList& regions() const;
144 
145  //- Whether supports volume type (below)
146  virtual bool hasVolumeType() const
147  {
148  return false;
149  }
150 
151  //- What is type of points outside bounds
152  virtual volumeType outsideVolumeType() const
153  {
154  return volumeType::UNKNOWN;
155  }
156 
157  //- Range of local indices that can be returned.
158  virtual label size() const
159  {
160  return 1;
161  }
162 
163  //- Get representative set of element coordinates
164  // Usually the element centres (should be of length size()).
165  virtual tmp<pointField> coordinates() const
166  {
167  return tmp<pointField>::New(one{}, origin());
168  }
169 
170  //- Get bounding spheres (centre and radius squared), one per element.
171  // Any point on element is guaranteed to be inside.
172  virtual void boundingSpheres
173  (
174  pointField& centres,
175  scalarField& radiusSqr
176  ) const;
177 
178  //- Get the points that define the surface.
179  virtual tmp<pointField> points() const
180  {
181  return coordinates();
182  }
183 
184  //- Does any part of the surface overlap the supplied bound box?
185  virtual bool overlaps(const boundBox& bb) const
186  {
188  return false;
189  }
190 
191 
192  // Multiple point queries.
193 
194  virtual void findNearest
195  (
196  const pointField& sample,
197  const scalarField& nearestDistSqr,
199  ) const;
200 
201  virtual void findLine
202  (
203  const pointField& start,
204  const pointField& end,
206  ) const;
207 
208  virtual void findLineAny
209  (
210  const pointField& start,
211  const pointField& end,
213  ) const;
214 
215  //- Get all intersections in order from start to end.
216  virtual void findLineAll
217  (
218  const pointField& start,
219  const pointField& end,
221  ) const;
222 
223  //- From a set of points and indices get the region
224  virtual void getRegion
225  (
226  const List<pointIndexHit>&,
227  labelList& region
228  ) const;
229 
230  //- From a set of points and indices get the normal
231  virtual void getNormal
232  (
233  const List<pointIndexHit>&,
234  vectorField& normals
235  ) const;
236 
237  //- Determine type (inside/outside/mixed) for point.
238  // Unknown if cannot be determined (e.g. non-manifold surface)
239  virtual void getVolumeType
240  (
241  const pointField& points,
242  List<volumeType>& volType
243  ) const;
244 
245 
246  // regIOobject implementation
247 
248  bool writeData(Ostream&) const
249  {
251  return false;
252  }
253 };
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
Foam::searchableDisk::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Definition: searchableDisk.C:289
Foam::searchableDisk::writeData
bool writeData(Ostream &) const
Definition: searchableDisk.H:273
searchableSurface.H
Foam::searchableDisk::TypeName
TypeName("searchableDisk")
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:57
Foam::searchableDisk::coordinates
virtual tmp< pointField > coordinates() const
Definition: searchableDisk.H:190
MinMax.H
Foam::one
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:57
Foam::plane::origin
const point & origin() const
Definition: planeI.H:38
Foam::searchableDisk::regions
virtual const wordList & regions() const
Definition: searchableDisk.C:168
Foam::searchableDisk::outsideVolumeType
virtual volumeType outsideVolumeType() const
Definition: searchableDisk.H:177
Foam::plane
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Definition: plane.H:85
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:58
Foam::searchableDisk
Searching on circular disk given as origin, normal (gets normalised) and radius. Optionally it can be...
Definition: searchableDisk.H:93
NotImplemented
#define NotImplemented
Definition: error.H:553
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:48
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:56
Foam::Field
Generic templated field type.
Definition: Field.H:59
plane.H
Foam::volumeType::UNKNOWN
@ UNKNOWN
Unknown state.
Definition: volumeType.H:63
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:65
Foam::scalarMinMax
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:111
Foam::searchableDisk::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Definition: searchableDisk.C:180
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:119
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Definition: stdFoam.H:129
Foam
Definition: atmBoundaryLayer.C:26
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Foam::searchableDisk::size
virtual label size() const
Definition: searchableDisk.H:183
Foam::searchableDisk::points
virtual tmp< pointField > points() const
Definition: searchableDisk.H:204
Foam::searchableDisk::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
Definition: searchableDisk.C:267
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
Definition: pointIndexHit.H:40
Foam::Vector< scalar >
Foam::searchableDisk::~searchableDisk
virtual ~searchableDisk()=default
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::searchableDisk::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normals) const
Definition: searchableDisk.C:278
Foam::tmp::New
static tmp< T > New(Args &&... args)
Foam::searchableDisk::hasVolumeType
virtual bool hasVolumeType() const
Definition: searchableDisk.H:171
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:57
Foam::searchableDisk::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Definition: searchableDisk.C:229
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::searchableDisk::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Definition: searchableDisk.C:240
Foam::point
vector point
Point is a vector.
Definition: point.H:37
Foam::searchableDisk::overlaps
virtual bool overlaps(const boundBox &bb) const
Definition: searchableDisk.H:210
Foam::MinMax
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition: HashSet.H:72
sample
Minimal example by using system/controlDict.functions: