searchablePlate.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2018-2020 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::searchablePlate
29 
30 Description
31  Searching on finite plate. Plate has to be aligned with coordinate
32  axes.
33  Plate defined as origin and span. One of the components of span has
34  to be 0 which defines the normal direction. E.g.
35 
36  \verbatim
37  span = (Sx Sy 0) // plate in x-y plane
38  origin = (Ox Oy Oz)
39  \endverbatim
40 
41  now plane is from (Ox Oy Oz) to (Ox+Sx Oy+Sy Oz)
42 
43  \heading Dictionary parameters
44  \table
45  Property | Description | Required | Default
46  type | plate | selector |
47  origin | The minimum corner of the plate | yes |
48  span | The plate dimensions | yes |
49  \endtable
50 
51 Note
52  Longer type name : \c searchablePlate
53 
54 SourceFiles
55  searchablePlate.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef searchablePlate_H
60 #define searchablePlate_H
61 
62 #include "searchableSurface.H"
63 #include "treeBoundBox.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 /*---------------------------------------------------------------------------*\
71  Class searchablePlate Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class searchablePlate
75 :
76  public searchableSurface
77 {
78  // Private Member Data
79 
80  //- The minimum corner of the plate
81  const point origin_;
82 
83  //- The span size of the plate
84  const vector span_;
85 
86  //- Coordinate direction which is normal
87  const direction normalDir_;
88 
89  //- Names of regions
90  mutable wordList regions_;
91 
92 
93  // Private Member Functions
94 
95  //- Calculate normal direction from span
96  static direction calcNormal(const point&);
97 
98  //- Inherit findNearest from searchableSurface
100 
101  pointIndexHit findNearest
102  (
103  const point& sample,
104  const scalar nearestDistSqr
105  ) const;
106 
107  pointIndexHit findLine
108  (
109  const point& start,
110  const point& end
111  ) const;
112 
113  //- No copy construct
114  searchablePlate(const searchablePlate&) = delete;
115 
116  //- No copy assignment
117  void operator=(const searchablePlate&) = delete;
118 
119 
120 public:
121 
122  //- Runtime type information
123  TypeName("searchablePlate");
124 
125 
126  // Constructors
127 
128  //- Construct from components
130  (
131  const IOobject& io,
132  const point& origin,
133  const vector& span
134  );
135 
136  //- Construct from dictionary (used by searchableSurface)
138  (
139  const IOobject& io,
140  const dictionary& dict
141  );
142 
143 
144  //- Destructor
145  virtual ~searchablePlate() = default;
146 
147 
148  // Member Functions
149 
150  //- The centre (origin) of the plate
151  inline const point& centre() const noexcept
152  {
153  return origin_;
154  }
155 
156  //- Names of regions
157  virtual const wordList& regions() const;
158 
159  //- Whether supports volume type below
160  virtual bool hasVolumeType() const
161  {
162  return false;
163  }
164 
165  //- What is type of points outside bounds
166  virtual volumeType outsideVolumeType() const
167  {
168  return volumeType::UNKNOWN;
169  }
170 
171  //- Range of local indices that can be returned.
172  virtual label size() const
173  {
174  return 1;
175  }
176 
177  //- Get representative set of element coordinates
178  // Usually the element centres (should be of length size()).
179  virtual tmp<pointField> coordinates() const;
180 
181  //- Get bounding spheres (centre and radius squared), one per element.
182  // Any point on element is guaranteed to be inside.
183  virtual void boundingSpheres
184  (
185  pointField& centres,
186  scalarField& radiusSqr
187  ) const;
188 
189  //- Get the points that define the surface.
190  virtual tmp<pointField> points() const;
191 
192  //- Does any part of the surface overlap the supplied bound box?
193  virtual bool overlaps(const boundBox& bb) const;
194 
195 
196  // Multiple point queries.
197 
198  virtual void findNearest
199  (
200  const pointField& sample,
201  const scalarField& nearestDistSqr,
203  ) const;
204 
205  virtual void findLine
206  (
207  const pointField& start,
208  const pointField& end,
210  ) const;
211 
212  virtual void findLineAny
213  (
214  const pointField& start,
215  const pointField& end,
217  ) const;
218 
219  //- Get all intersections in order from start to end.
220  virtual void findLineAll
221  (
222  const pointField& start,
223  const pointField& end,
225  ) const;
226 
227  //- From a set of points and indices get the region
228  virtual void getRegion
229  (
230  const List<pointIndexHit>&,
231  labelList& region
232  ) const;
233 
234  //- From a set of points and indices get the normal
235  virtual void getNormal
236  (
237  const List<pointIndexHit>&,
238  vectorField& normal
239  ) const;
240 
241  //- Determine type (inside/outside/mixed) for point. unknown if
242  // cannot be determined (e.g. non-manifold surface)
243  virtual void getVolumeType
244  (
245  const pointField&,
247  ) const;
248 
249 
250  // regIOobject implementation
251 
252  bool writeData(Ostream&) const
253  {
255  return false;
256  }
257 };
258 
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 } // End namespace Foam
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
searchableSurface.H
Foam::searchablePlate::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
Definition: searchablePlate.C:364
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::searchablePlate::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchablePlate.H:271
Foam::searchablePlate::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchablePlate.C:314
Foam::searchablePlate
Searching on finite plate. Plate has to be aligned with coordinate axes. Plate defined as origin and ...
Definition: searchablePlate.H:93
Foam::searchablePlate::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchablePlate.C:287
Foam::searchablePlate::~searchablePlate
virtual ~searchablePlate()=default
Destructor.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:52
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
treeBoundBox.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
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:123
Foam::searchablePlate::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchablePlate.H:191
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
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::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::searchablePlate::centre
const point & centre() const noexcept
The centre (origin) of the plate.
Definition: searchablePlate.H:170
Foam::searchablePlate::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchablePlate.H:185
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::List< word >
Foam::searchablePlate::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchablePlate.C:264
Foam::searchablePlate::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: searchablePlate.C:353
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::searchablePlate::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchablePlate.C:253
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::searchablePlate::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchablePlate.C:401
Foam::searchablePlate::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchablePlate.C:271
Foam::searchablePlate::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchablePlate.H:179
Foam::searchablePlate::TypeName
TypeName("searchablePlate")
Runtime type information.
Foam::searchablePlate::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: searchablePlate.C:416
Foam::searchablePlate::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchablePlate.C:390
sample
Minimal example by using system/controlDict.functions: