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