searchablePlate.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) 2011-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::searchablePlate
26 
27 Description
28  Surface geometry of a finite plane, aligned with the coordinate
29  axes, which can be used with snappyHexMesh.
30 
31 Usage
32  \table
33  Property | Description | Required
34  origin | Position of one corner of the plate | yes
35  span | The vector span of the plate | yes
36  \endtable
37 
38  Note: the span of the plate requires one zero component corresponding to the
39  normal direction of the plate.
40 
41  Example specification in snappyHexMeshDict/geometry:
42  \verbatim
43  type searchablePlate;
44  origin (10 10 10);
45  span (20 0 10);
46  \endverbatim
47 
48 SourceFiles
49  searchablePlate.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef searchablePlate_H
54 #define searchablePlate_H
55 
56 #include "searchableSurface.H"
57 #include "treeBoundBox.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 
64 // Forward declaration of classes
65 
66 /*---------------------------------------------------------------------------*\
67  Class searchablePlate Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class searchablePlate
71 :
72  public searchableSurface
73 {
74  // Private Member Data
75 
76  const point origin_;
77 
78  const vector span_;
79 
80  //- Coordinate direction which is normal
81  const direction normalDir_;
82 
83  mutable wordList regions_;
84 
85 
86  // Private Member Functions
87 
88  //- Calculate normal direction from span
89  static direction calcNormal(const point&);
90 
91  //- Inherit findNearest from searchableSurface
93 
94  pointIndexHit findNearest
95  (
96  const point& sample,
97  const scalar nearestDistSqr
98  ) const;
99 
100  pointIndexHit findLine
101  (
102  const point& start,
103  const point& end
104  ) const;
105 
106  //- Disallow default bitwise copy construction
107  searchablePlate(const searchablePlate&) = delete;
108 
109  //- Disallow default bitwise assignment
110  void operator=(const searchablePlate&) = delete;
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("searchablePlate");
117 
118 
119  // Constructors
120 
121  //- Construct from components
123  (
124  const IOobject& io,
125  const point& origin,
126  const vector& span
127  );
128 
129  //- Construct from dictionary (used by searchableSurface)
131  (
132  const IOobject& io,
133  const dictionary& dict
134  );
135 
136 
137  //- Destructor
138  virtual ~searchablePlate();
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  //- Get bounding spheres (centre and radius squared), one per element.
162  // Any point on element is guaranteed to be inside.
163  virtual void boundingSpheres
164  (
165  pointField& centres,
166  scalarField& radiusSqr
167  ) const;
168 
169  //- Get the points that define the surface.
170  virtual tmp<pointField> points() const;
171 
172  //- Does any part of the surface overlap the supplied bound box?
173  virtual bool overlaps(const boundBox& bb) const;
174 
175 
176  // Multiple point queries.
177 
178  virtual void findNearest
179  (
180  const pointField& sample,
181  const scalarField& nearestDistSqr,
183  ) const;
184 
185  virtual void findLine
186  (
187  const pointField& start,
188  const pointField& end,
190  ) const;
191 
192  virtual void findLineAny
193  (
194  const pointField& start,
195  const pointField& end,
197  ) const;
198 
199  //- Get all intersections in order from start to end.
200  virtual void findLineAll
201  (
202  const pointField& start,
203  const pointField& end,
205  ) const;
206 
207  //- From a set of points and indices get the region
208  virtual void getRegion
209  (
210  const List<pointIndexHit>&,
211  labelList& region
212  ) const;
213 
214  //- From a set of points and indices get the normal
215  virtual void getNormal
216  (
217  const List<pointIndexHit>&,
218  vectorField& normal
219  ) const;
220 
221  //- Determine type (inside/outside/mixed) for point. unknown if
222  // cannot be determined (e.g. non-manifold surface)
223  virtual void getVolumeType
224  (
225  const pointField&,
227  ) const;
228 
229 
230  // regIOobject implementation
231 
232  bool writeData(Ostream&) const
233  {
235  return false;
236  }
237 };
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 } // End namespace Foam
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
dictionary dict
TypeName("searchablePlate")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
uint8_t direction
Definition: direction.H:45
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
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
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
bool writeData(Ostream &) const
Pure virtual writaData function.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual ~searchablePlate()
Destructor.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual const wordList & regions() const
Names of regions.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
vector point
Point is a vector.
Definition: point.H:41
virtual bool hasVolumeType() const
Whether supports volume type below.
Surface geometry of a finite plane, aligned with the coordinate axes, which can be used with snappyHe...
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual label size() const
Range of local indices that can be returned.
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Namespace for OpenFOAM.