searchableSphere.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-2019 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::searchableSphere
26 
27 Description
28  Searching on sphere
29 
30 SourceFiles
31  searchableSphere.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef searchableSphere_H
36 #define searchableSphere_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 searchableSphere Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class searchableSphere
53 :
54  public searchableSurface
55 {
56  // Private Member Data
57 
58  //- Centre point
59  const point centre_;
60 
61  //- Radius
62  const scalar radius_;
63 
64  //- Names of regions
65  mutable wordList regions_;
66 
67 
68  // Private Member Functions
69 
70  //- Inherit findNearest from searchableSurface
72 
73  //- Find nearest point on sphere.
74  pointIndexHit findNearest
75  (
76  const point& sample,
77  const scalar nearestDistSqr
78  ) const;
79 
80  //- Find intersection with sphere
81  void findLineAll
82  (
83  const point& start,
84  const point& end,
85  pointIndexHit& near,
86  pointIndexHit& far
87  ) const;
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("searchableSphere");
94 
95 
96  // Constructors
97 
98  //- Construct from components
99  searchableSphere(const IOobject& io, const point&, const scalar radius);
100 
101  //- Construct from dictionary (used by searchableSurface)
103  (
104  const IOobject& io,
105  const dictionary& dict
106  );
107 
108  //- Disallow default bitwise copy construction
109  searchableSphere(const searchableSphere&) = delete;
110 
111 
112  //- Destructor
113  virtual ~searchableSphere();
114 
115 
116  // Member Functions
117 
118  virtual const wordList& regions() const;
119 
120  //- Whether supports volume type below
121  virtual bool hasVolumeType() const
122  {
123  return true;
124  }
125 
126  //- Range of local indices that can be returned.
127  virtual label size() const
128  {
129  return 1;
130  }
131 
132  //- Get representative set of element coordinates
133  // Usually the element centres (should be of length size()).
134  virtual tmp<pointField> coordinates() const
135  {
136  tmp<pointField> tCtrs(new pointField(1, centre_));
137  return tCtrs;
138  }
139 
140  //- Get bounding spheres (centre and radius squared), one per element.
141  // Any point on element is guaranteed to be inside.
142  virtual void boundingSpheres
143  (
144  pointField& centres,
145  scalarField& radiusSqr
146  ) const;
147 
148  //- Get the points that define the surface.
149  virtual tmp<pointField> points() const
150  {
151  return coordinates();
152  }
153 
154  //- Does any part of the surface overlap the supplied bound box?
155  virtual bool overlaps(const boundBox& bb) const;
156 
157 
158  // Multiple point queries.
159 
160  virtual void findNearest
161  (
162  const pointField& sample,
163  const scalarField& nearestDistSqr,
165  ) const;
166 
167  virtual void findLine
168  (
169  const pointField& start,
170  const pointField& end,
172  ) const;
173 
174  virtual void findLineAny
175  (
176  const pointField& start,
177  const pointField& end,
179  ) const;
180 
181  //- Get all intersections in order from start to end.
182  virtual void findLineAll
183  (
184  const pointField& start,
185  const pointField& end,
187  ) const;
188 
189  //- From a set of points and indices get the region
190  virtual void getRegion
191  (
192  const List<pointIndexHit>&,
193  labelList& region
194  ) const;
195 
196  //- From a set of points and indices get the normal
197  virtual void getNormal
198  (
199  const List<pointIndexHit>&,
200  vectorField& normal
201  ) const;
202 
203  //- Determine type (inside/outside/mixed) for point. unknown if
204  // cannot be determined (e.g. non-manifold surface)
205  virtual void getVolumeType
206  (
207  const pointField&,
209  ) const;
210 
211 
212  // regIOobject implementation
214  bool writeData(Ostream&) const
215  {
217  return false;
218  }
219 
220 
221  // Member Operators
222 
223  //- Disallow default bitwise assignment
224  void operator=(const searchableSphere&) = delete;
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
dictionary dict
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
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:158
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.
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.
void operator=(const searchableSphere &)=delete
Disallow default bitwise assignment.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
searchableSphere(const IOobject &io, const point &, const scalar radius)
Construct from components.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
bool writeData(Ostream &) const
Pure virtual writaData function.
virtual ~searchableSphere()
Destructor.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Searching on sphere.
TypeName("searchableSphere")
Runtime type information.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual bool hasVolumeType() const
Whether supports volume type below.
virtual const wordList & regions() const
Names of regions.
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.
A class for managing temporary objects.
Definition: PtrList.H:53
#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:92
Namespace for OpenFOAM.