disk_searchableSurface.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-2025 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::searchableSurfaces::disk
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 disk;
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 disk_searchableSurface_H
53 #define disk_searchableSurface_H
54 
55 #include "treeBoundBox.H"
56 #include "searchableSurface.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 namespace searchableSurfaces
63 {
64 
65 /*---------------------------------------------------------------------------*\
66  Class disk Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class disk
70 :
71  public searchableSurface
72 {
73  // Private Member Data
74 
75  //- origin
76  const point origin_;
77 
78  //- normal
79  vector normal_;
80 
81  //- radius
82  const scalar radius_;
83 
84  //- Names of regions
85  mutable wordList regions_;
86 
87 
88  // Private Member Functions
89 
90  //- Inherit findNearest from searchableSurface
92 
93  //- Find nearest point on disk
94  pointIndexHit findNearest
95  (
96  const point& sample,
97  const scalar nearestDistSqr
98  ) const;
99 
100  //- Find intersection with disk
101  void findLine
102  (
103  const point& start,
104  const point& end,
106  ) const;
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("disk");
113 
114 
115  // Constructors
116 
117  //- Construct from components
118  disk
119  (
120  const IOobject& io,
121  const point& origin,
122  const point& normal,
123  const scalar radius
124  );
125 
126  //- Construct from dictionary (used by searchableSurface)
128  (
129  const IOobject& io,
130  const dictionary& dict
131  );
132 
133  //- Disallow default bitwise copy construction
134  disk(const disk&) = delete;
135 
136 
137  //- Destructor
138  virtual ~disk();
139 
140 
141  // Member Functions
142 
143  virtual const wordList& regions() const;
144 
145  //- Whether supports volume type below
146  virtual bool hasVolumeType() const
147  {
148  return false;
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  tmp<pointField> tCtrs(new pointField(1, origin_));
162  return tCtrs;
163  }
164 
165  //- Get bounding spheres (centre and radius squared), one per element.
166  // Any point on element is guaranteed to be inside.
167  virtual void boundingSpheres
168  (
169  pointField& centres,
170  scalarField& radiusSqr
171  ) const;
172 
173  //- Get the points that define the surface.
174  virtual tmp<pointField> points() const
175  {
176  return coordinates();
177  }
178 
179  //- Does any part of the surface overlap the supplied bound box?
180  virtual bool overlaps(const boundBox& bb) const
181  {
183 
184  return false;
185  }
186 
187 
188  // Multiple point queries.
189 
190  virtual void findNearest
191  (
192  const pointField& sample,
193  const scalarField& nearestDistSqr,
195  ) const;
196 
197  virtual void findLine
198  (
199  const pointField& start,
200  const pointField& end,
202  ) const;
203 
204  virtual void findLineAny
205  (
206  const pointField& start,
207  const pointField& end,
209  ) const;
210 
211  //- Get all intersections in order from start to end.
212  virtual void findLineAll
213  (
214  const pointField& start,
215  const pointField& end,
217  ) const;
218 
219  //- From a set of points and indices get the region
220  virtual void getRegion
221  (
222  const List<pointIndexHit>&,
223  labelList& region
224  ) const;
225 
226  //- From a set of points and indices get the normal
227  virtual void getNormal
228  (
229  const List<pointIndexHit>&,
230  vectorField& normal
231  ) const;
232 
233  //- Determine type (inside/outside/mixed) for point. unknown if
234  // cannot be determined (e.g. non-manifold surface)
235  virtual void getVolumeType
236  (
237  const pointField&,
239  ) const;
240 
241 
242  // regIOobject implementation
243 
244  bool writeData(Ostream&) const
245  {
247  return false;
248  }
249 
250 
251  // Member Operators
252 
253  //- Disallow default bitwise assignment
254  void operator=(const disk&) = delete;
255 };
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End of namespace searchableSurfaces
261 } // End namespace Foam
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #endif
266 
267 // ************************************************************************* //
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
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?
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.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
void operator=(const disk &)=delete
Disallow default bitwise assignment.
virtual tmp< pointField > points() const
Get the points that define the surface.
disk(const IOobject &io, const point &origin, const point &normal, const scalar radius)
Construct from components.
TypeName("disk")
Runtime type information.
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.
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