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 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 / searchablePlate | selector |
47  origin | centre of the plate | yes |
48  span | The plate dimensions | yes |
49  \endtable
50 
51 SourceFiles
52  searchablePlate.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef searchablePlate_H
57 #define searchablePlate_H
58 
59 #include "searchableSurface.H"
60 #include "treeBoundBox.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class searchablePlate Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 class searchablePlate
72 :
73  public searchableSurface
74 {
75 private:
76 
77  // Private Member Data
78 
79  const point origin_;
80 
81  const vector span_;
82 
83  //- Coordinate direction which is normal
84  const direction normalDir_;
85 
86  //- Names of regions
87  mutable wordList regions_;
88 
89 
90  // Private Member Functions
91 
92  //- Calculate normal direction from span
93  static direction calcNormal(const point&);
94 
95  //- Inherit findNearest from searchableSurface
97 
98  pointIndexHit findNearest
99  (
100  const point& sample,
101  const scalar nearestDistSqr
102  ) const;
103 
104  pointIndexHit findLine
105  (
106  const point& start,
107  const point& end
108  ) const;
109 
110  //- No copy construct
111  searchablePlate(const searchablePlate&) = delete;
112 
113  //- No copy assignment
114  void operator=(const searchablePlate&) = delete;
115 
116 
117 public:
118 
119  //- Runtime type information
120  TypeName("searchablePlate");
121 
122 
123  // Constructors
124 
125  //- Construct from components
127  (
128  const IOobject& io,
129  const point& origin,
130  const vector& span
131  );
132 
133  //- Construct from dictionary (used by searchableSurface)
135  (
136  const IOobject& io,
137  const dictionary& dict
138  );
139 
140 
141  //- Destructor
142  virtual ~searchablePlate() = default;
143 
144 
145  // Member Functions
146 
147  //- Names of regions
148  virtual const wordList& regions() const;
149 
150  //- Whether supports volume type below
151  virtual bool hasVolumeType() const
152  {
153  return false;
154  }
155 
156  //- What is type of points outside bounds
157  virtual volumeType outsideVolumeType() const
158  {
159  return volumeType::UNKNOWN;
160  }
161 
162  //- Range of local indices that can be returned.
163  virtual label size() const
164  {
165  return 1;
166  }
167 
168  //- Get representative set of element coordinates
169  // Usually the element centres (should be of length size()).
170  virtual tmp<pointField> coordinates() const;
171 
172  //- Get bounding spheres (centre and radius squared), one per element.
173  // Any point on element is guaranteed to be inside.
174  virtual void boundingSpheres
175  (
176  pointField& centres,
177  scalarField& radiusSqr
178  ) const;
179 
180  //- Get the points that define the surface.
181  virtual tmp<pointField> points() const;
182 
183  //- Does any part of the surface overlap the supplied bound box?
184  virtual bool overlaps(const boundBox& bb) const;
185 
186 
187  // Multiple point queries.
188 
189  virtual void findNearest
190  (
191  const pointField& sample,
192  const scalarField& nearestDistSqr,
194  ) const;
195 
196  virtual void findLine
197  (
198  const pointField& start,
199  const pointField& end,
201  ) const;
202 
203  virtual void findLineAny
204  (
205  const pointField& start,
206  const pointField& end,
208  ) const;
209 
210  //- Get all intersections in order from start to end.
211  virtual void findLineAll
212  (
213  const pointField& start,
214  const pointField& end,
216  ) const;
217 
218  //- From a set of points and indices get the region
219  virtual void getRegion
220  (
221  const List<pointIndexHit>&,
222  labelList& region
223  ) const;
224 
225  //- From a set of points and indices get the normal
226  virtual void getNormal
227  (
228  const List<pointIndexHit>&,
229  vectorField& normal
230  ) const;
231 
232  //- Determine type (inside/outside/mixed) for point. unknown if
233  // cannot be determined (e.g. non-manifold surface)
234  virtual void getVolumeType
235  (
236  const pointField&,
238  ) const;
239 
240 
241  // regIOobject implementation
242 
243  bool writeData(Ostream&) const
244  {
246  return false;
247  }
248 };
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #endif
258 
259 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
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:385
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::searchablePlate::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchablePlate.H:262
Foam::searchablePlate::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchablePlate.C:327
Foam::searchablePlate
Searching on finite plate. Plate has to be aligned with coordinate axes. Plate defined as origin and ...
Definition: searchablePlate.H:90
Foam::searchablePlate::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchablePlate.C:299
Foam::searchablePlate::~searchablePlate
virtual ~searchablePlate()=default
Destructor.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
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::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:121
Foam::searchablePlate::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchablePlate.H:182
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::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchablePlate.H:176
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:276
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:374
Foam::direction
uint8_t direction
Definition: direction.H:47
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:265
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:422
Foam::searchablePlate::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchablePlate.C:283
Foam::searchablePlate::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchablePlate.H:170
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:437
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:411