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-2018 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:
57 
58  // Private Member Data
59 
60  //- Centre point
61  const point centre_;
62 
63  //- Radius
64  const scalar radius_;
65 
66  //- Names of regions
67  mutable wordList regions_;
68 
69 
70  // Private Member Functions
71 
72  //- Inherit findNearest from searchableSurface
74 
75  //- Find nearest point on sphere.
76  pointIndexHit findNearest
77  (
78  const point& sample,
79  const scalar nearestDistSqr
80  ) const;
81 
82  //- Find intersection with sphere
83  void findLineAll
84  (
85  const point& start,
86  const point& end,
87  pointIndexHit& near,
88  pointIndexHit& far
89  ) const;
90 
91 
92  //- Disallow default bitwise copy construct
94 
95  //- Disallow default bitwise assignment
96  void operator=(const searchableSphere&);
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("searchableSphere");
103 
104 
105  // Constructors
106 
107  //- Construct from components
108  searchableSphere(const IOobject& io, const point&, const scalar radius);
109 
110  //- Construct from dictionary (used by searchableSurface)
112  (
113  const IOobject& io,
114  const dictionary& dict
115  );
116 
117  //- Destructor
118  virtual ~searchableSphere();
119 
120 
121  // Member Functions
122 
123  virtual const wordList& regions() const;
124 
125  //- Whether supports volume type below
126  virtual bool hasVolumeType() const
127  {
128  return true;
129  }
130 
131  //- Range of local indices that can be returned.
132  virtual label size() const
133  {
134  return 1;
135  }
136 
137  //- Get representative set of element coordinates
138  // Usually the element centres (should be of length size()).
139  virtual tmp<pointField> coordinates() const
140  {
141  tmp<pointField> tCtrs(new pointField(1, centre_));
142  return tCtrs;
143  }
144 
145  //- Get bounding spheres (centre and radius squared), one per element.
146  // Any point on element is guaranteed to be inside.
147  virtual void boundingSpheres
148  (
149  pointField& centres,
150  scalarField& radiusSqr
151  ) const;
152 
153  //- Get the points that define the surface.
154  virtual tmp<pointField> points() const
155  {
156  return coordinates();
157  }
158 
159  //- Does any part of the surface overlap the supplied bound box?
160  virtual bool overlaps(const boundBox& bb) const;
161 
162 
163  // Multiple point queries.
164 
165  virtual void findNearest
166  (
167  const pointField& sample,
168  const scalarField& nearestDistSqr,
170  ) const;
171 
172  virtual void findLine
173  (
174  const pointField& start,
175  const pointField& end,
177  ) const;
178 
179  virtual void findLineAny
180  (
181  const pointField& start,
182  const pointField& end,
184  ) const;
185 
186  //- Get all intersections in order from start to end.
187  virtual void findLineAll
188  (
189  const pointField& start,
190  const pointField& end,
192  ) const;
193 
194  //- From a set of points and indices get the region
195  virtual void getRegion
196  (
197  const List<pointIndexHit>&,
198  labelList& region
199  ) const;
200 
201  //- From a set of points and indices get the normal
202  virtual void getNormal
203  (
204  const List<pointIndexHit>&,
205  vectorField& normal
206  ) const;
207 
208  //- Determine type (inside/outside/mixed) for point. unknown if
209  // cannot be determined (e.g. non-manifold surface)
210  virtual void getVolumeType
211  (
212  const pointField&,
214  ) const;
215 
216 
217  // regIOobject implementation
219  bool writeData(Ostream&) const
220  {
222  return false;
223  }
224 
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:137
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.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
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.