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-2020 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 Member Data
56 
57  //- origin
58  const point origin_;
59 
60  //- normal
61  vector normal_;
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 disk
76  pointIndexHit findNearest
77  (
78  const point& sample,
79  const scalar nearestDistSqr
80  ) const;
81 
82  //- Find intersection with disk
83  void findLine
84  (
85  const point& start,
86  const point& end,
88  ) const;
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("searchableDisk");
95 
96 
97  // Constructors
98 
99  //- Construct from components
101  (
102  const IOobject& io,
103  const point& origin,
104  const point& normal,
105  const scalar radius
106  );
107 
108  //- Construct from dictionary (used by searchableSurface)
110  (
111  const IOobject& io,
112  const dictionary& dict
113  );
114 
115  //- Disallow default bitwise copy construction
116  searchableDisk(const searchableDisk&) = delete;
117 
118 
119  //- Destructor
120  virtual ~searchableDisk();
121 
122 
123  // Member Functions
124 
125  virtual const wordList& regions() const;
126 
127  //- Whether supports volume type below
128  virtual bool hasVolumeType() const
129  {
130  return false;
131  }
132 
133  //- Range of local indices that can be returned.
134  virtual label size() const
135  {
136  return 1;
137  }
138 
139  //- Get representative set of element coordinates
140  // Usually the element centres (should be of length size()).
141  virtual tmp<pointField> coordinates() const
142  {
143  tmp<pointField> tCtrs(new pointField(1, origin_));
144  return tCtrs;
145  }
146 
147  //- Get bounding spheres (centre and radius squared), one per element.
148  // Any point on element is guaranteed to be inside.
149  virtual void boundingSpheres
150  (
151  pointField& centres,
152  scalarField& radiusSqr
153  ) const;
154 
155  //- Get the points that define the surface.
156  virtual tmp<pointField> points() const
157  {
158  return coordinates();
159  }
160 
161  //- Does any part of the surface overlap the supplied bound box?
162  virtual bool overlaps(const boundBox& bb) const
163  {
165 
166  return false;
167  }
168 
169 
170  // Multiple point queries.
171 
172  virtual void findNearest
173  (
174  const pointField& sample,
175  const scalarField& nearestDistSqr,
177  ) const;
178 
179  virtual void findLine
180  (
181  const pointField& start,
182  const pointField& end,
184  ) const;
185 
186  virtual void findLineAny
187  (
188  const pointField& start,
189  const pointField& end,
191  ) const;
192 
193  //- Get all intersections in order from start to end.
194  virtual void findLineAll
195  (
196  const pointField& start,
197  const pointField& end,
199  ) const;
200 
201  //- From a set of points and indices get the region
202  virtual void getRegion
203  (
204  const List<pointIndexHit>&,
205  labelList& region
206  ) const;
207 
208  //- From a set of points and indices get the normal
209  virtual void getNormal
210  (
211  const List<pointIndexHit>&,
212  vectorField& normal
213  ) const;
214 
215  //- Determine type (inside/outside/mixed) for point. unknown if
216  // cannot be determined (e.g. non-manifold surface)
217  virtual void getVolumeType
218  (
219  const pointField&,
221  ) const;
222 
223 
224  // regIOobject implementation
226  bool writeData(Ostream&) const
227  {
229  return false;
230  }
231 
232 
233  // Member Operators
234 
235  //- Disallow default bitwise assignment
236  void operator=(const searchableDisk&) = delete;
237 };
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 } // End namespace Foam
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
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.
void operator=(const searchableDisk &)=delete
Disallow default bitwise assignment.
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:156
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.
searchableDisk(const IOobject &io, const point &origin, const point &normal, const scalar radius)
Construct from components.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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:370
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.