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