searchableSphere.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) 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::searchableSphere
29 
30 Description
31  Searching on sphere
32 
33  \heading Dictionary parameters
34  \table
35  Property | Description | Required | Default
36  type | sphere / searchableSphere | selector |
37  origin | The origin (centre) of the sphere | yes |
38  radius | The (outside) radius of sphere | yes |
39  centre | Alternative for 'origin' | no |
40  \endtable
41 
42 SourceFiles
43  searchableSphere.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef searchableSphere_H
48 #define searchableSphere_H
49 
50 #include "treeBoundBox.H"
51 #include "searchableSurface.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class searchableSphere Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class searchableSphere
63 :
64  public searchableSurface
65 {
66 private:
67 
68  // Private Member Data
69 
70  //- Centre point of the sphere
71  const point origin_;
72 
73  //- The outer radius of the sphere
74  const scalar radius_;
75 
76  //- Names of regions
77  mutable wordList regions_;
78 
79 
80  // Private Member Functions
81 
82  //- Inherit findNearest from searchableSurface
84 
85  //- Find nearest point on sphere.
86  pointIndexHit findNearest
87  (
88  const point& sample,
89  const scalar nearestDistSqr
90  ) const;
91 
92  //- Find intersection with sphere
93  void findLineAll
94  (
95  const point& start,
96  const point& end,
97  pointIndexHit& near,
98  pointIndexHit& far
99  ) const;
100 
101 
102  //- No copy construct
103  searchableSphere(const searchableSphere&) = delete;
104 
105  //- No copy assignment
106  void operator=(const searchableSphere&) = delete;
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("searchableSphere");
113 
114 
115  // Constructors
116 
117  //- Construct from components
119  (
120  const IOobject& io,
121  const point& centre,
122  const scalar radius
123  );
124 
125  //- Construct from dictionary (used by searchableSurface)
127  (
128  const IOobject& io,
129  const dictionary& dict
130  );
131 
132 
133  //- Destructor
134  virtual ~searchableSphere() = default;
135 
136 
137  // Member Functions
138 
139  //- Names of regions
140  virtual const wordList& regions() const;
141 
142  //- Whether supports volume type (below)
143  virtual bool hasVolumeType() const
144  {
145  return true;
146  }
147 
148  //- What is type of points outside bounds
149  virtual volumeType outsideVolumeType() const
150  {
151  return volumeType::OUTSIDE;
152  }
153 
154  //- Range of local indices that can be returned.
155  virtual label size() const
156  {
157  return 1;
158  }
159 
160  //- Get representative set of element coordinates
161  // Usually the element centres (should be of length size()).
162  virtual tmp<pointField> coordinates() const
163  {
164  return tmp<pointField>::New(1, origin_);
165  }
166 
167  //- Get bounding spheres (centre and radius squared), one per element.
168  // Any point on element is guaranteed to be inside.
169  virtual void boundingSpheres
170  (
171  pointField& centres,
172  scalarField& radiusSqr
173  ) const;
174 
175  //- Get the points that define the surface.
176  virtual tmp<pointField> points() const
177  {
178  return coordinates();
179  }
180 
181  //- Does any part of the surface overlap the supplied bound box?
182  virtual bool overlaps(const boundBox& bb) const;
183 
184 
185  // Multiple point queries.
186 
187  virtual void findNearest
188  (
189  const pointField& sample,
190  const scalarField& nearestDistSqr,
192  ) const;
193 
194  virtual void findLine
195  (
196  const pointField& start,
197  const pointField& end,
199  ) const;
200 
201  virtual void findLineAny
202  (
203  const pointField& start,
204  const pointField& end,
206  ) const;
207 
208  //- Get all intersections in order from start to end.
209  virtual void findLineAll
210  (
211  const pointField& start,
212  const pointField& end,
214  ) const;
215 
216  //- From a set of points and indices get the region
217  virtual void getRegion
218  (
219  const List<pointIndexHit>&,
220  labelList& region
221  ) const;
222 
223  //- From a set of points and indices get the normal
224  virtual void getNormal
225  (
226  const List<pointIndexHit>&,
227  vectorField& normal
228  ) const;
229 
230  //- Determine type (inside/outside/mixed) for point.
231  // Unknown if cannot be determined (e.g. non-manifold surface)
232  virtual void getVolumeType
233  (
234  const pointField& points,
235  List<volumeType>& volType
236  ) const;
237 
238 
239  // regIOobject implementation
240 
241  bool writeData(Ostream&) const
242  {
244  return false;
245  }
246 
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
searchableSurface.H
Foam::searchableSphere::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Definition: searchableSphere.C:226
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::searchableSphere::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableSphere.H:173
Foam::searchableSphere::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableSphere.C:316
Foam::searchableSphere::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableSphere.C:180
Foam::searchableSphere::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableSphere.H:179
Foam::searchableSphere::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableSphere.H:265
Foam::searchableSphere::TypeName
TypeName("searchableSphere")
Runtime type information.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
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::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
Foam::searchableSphere::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableSphere.C:327
treeBoundBox.H
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::searchableSphere::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableSphere.C:193
Foam::searchableSphere::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: searchableSphere.C:249
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::searchableSphere::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableSphere.H:186
Foam::searchableSphere::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
Definition: searchableSphere.C:350
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
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< scalar >
Foam::searchableSphere::~searchableSphere
virtual ~searchableSphere()=default
Destructor.
Foam::List< word >
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::searchableSphere::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableSphere.H:200
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
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::searchableSphere::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableSphere.C:174
Foam::searchableSphere::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type (below)
Definition: searchableSphere.H:167
Foam::volumeType::OUTSIDE
A location outside the volume.
Definition: volumeType.H:69
Foam::searchableSphere
Searching on sphere.
Definition: searchableSphere.H:86