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-2022 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  Surface geometry with a circular disk shape, which can be used with
29  snappyHexMesh.
30 
31 Usage
32  \table
33  Property | Description | Required
34  origin | Centre of the disk | yes
35  centre | Normal to the disk surface | yes
36  radius | Radius of the disk | yes
37  \endtable
38 
39  Example specification in snappyHexMeshDict/geometry:
40  \verbatim
41  type searchableDisk;
42  origin (10 10 10);
43  normal (0 1 0);
44  radius 5;
45  \endverbatim
46 
47 SourceFiles
48  searchableDisk.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef searchableDisk_H
53 #define searchableDisk_H
54 
55 #include "treeBoundBox.H"
56 #include "searchableSurface.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class searchableDisk Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class searchableDisk
68 :
69  public searchableSurface
70 {
71  // Private Member Data
72 
73  //- origin
74  const point origin_;
75 
76  //- normal
77  vector normal_;
78 
79  //- radius
80  const scalar radius_;
81 
82  //- Names of regions
83  mutable wordList regions_;
84 
85 
86  // Private Member Functions
87 
88  //- Inherit findNearest from searchableSurface
90 
91  //- Find nearest point on disk
92  pointIndexHit findNearest
93  (
94  const point& sample,
95  const scalar nearestDistSqr
96  ) const;
97 
98  //- Find intersection with disk
99  void findLine
100  (
101  const point& start,
102  const point& end,
104  ) const;
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("searchableDisk");
111 
112 
113  // Constructors
114 
115  //- Construct from components
117  (
118  const IOobject& io,
119  const point& origin,
120  const point& normal,
121  const scalar radius
122  );
123 
124  //- Construct from dictionary (used by searchableSurface)
126  (
127  const IOobject& io,
128  const dictionary& dict
129  );
130 
131  //- Disallow default bitwise copy construction
132  searchableDisk(const searchableDisk&) = delete;
133 
134 
135  //- Destructor
136  virtual ~searchableDisk();
137 
138 
139  // Member Functions
140 
141  virtual const wordList& regions() const;
142 
143  //- Whether supports volume type below
144  virtual bool hasVolumeType() const
145  {
146  return false;
147  }
148 
149  //- Range of local indices that can be returned.
150  virtual label size() const
151  {
152  return 1;
153  }
154 
155  //- Get representative set of element coordinates
156  // Usually the element centres (should be of length size()).
157  virtual tmp<pointField> coordinates() const
158  {
159  tmp<pointField> tCtrs(new pointField(1, origin_));
160  return tCtrs;
161  }
162 
163  //- Get bounding spheres (centre and radius squared), one per element.
164  // Any point on element is guaranteed to be inside.
165  virtual void boundingSpheres
166  (
167  pointField& centres,
168  scalarField& radiusSqr
169  ) const;
170 
171  //- Get the points that define the surface.
172  virtual tmp<pointField> points() const
173  {
174  return coordinates();
175  }
176 
177  //- Does any part of the surface overlap the supplied bound box?
178  virtual bool overlaps(const boundBox& bb) const
179  {
181 
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  (
197  const pointField& start,
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& normal
229  ) const;
230 
231  //- Determine type (inside/outside/mixed) for point. unknown if
232  // cannot be determined (e.g. non-manifold surface)
233  virtual void getVolumeType
234  (
235  const pointField&,
237  ) const;
238 
239 
240  // regIOobject implementation
241 
242  bool writeData(Ostream&) const
243  {
245  return false;
246  }
247 
248 
249  // Member Operators
250 
251  //- Disallow default bitwise assignment
252  void operator=(const searchableDisk&) = delete;
253 };
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:54
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Surface geometry with a circular disk shape, which can be used with snappyHexMesh.
virtual label size() const
Range of local indices that can be returned.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
void operator=(const searchableDisk &)=delete
Disallow default bitwise assignment.
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.
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.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
TypeName("searchableDisk")
Runtime type information.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
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 ~searchableDisk()
Destructor.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
A class for managing temporary objects.
Definition: tmp.H:55
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
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
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
vector point
Point is a vector.
Definition: point.H:41
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dictionary dict