searchablePlane.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) 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::searchablePlane
29 
30 Description
31  Searching on (infinite) plane.
32  The dictionary specifications are identical to the Foam::plane
33  requirements.
34 
35  \heading Dictionary parameters
36  \table
37  Property | Description | Required | Default
38  type | plane | selector |
39  \endtable
40 
41 Note
42  Longer type name : \c searchablePlane
43 
44 SourceFiles
45  searchablePlane.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef searchablePlane_H
50 #define searchablePlane_H
51 
52 #include "searchableSurface.H"
53 #include "plane.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class searchablePlane Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class searchablePlane
65 :
66  public searchableSurface,
67  public plane
68 {
69 private:
70 
71  // Private Member Data
72 
73  //- Names of regions
74  mutable wordList regions_;
75 
76 
77  // Private Member Functions
78 
79  pointIndexHit findLine
80  (
81  const point& start,
82  const point& end
83  ) const;
84 
85  //- Return the boundBox of the plane
86  boundBox calcBounds() const;
87 
88  //- No copy construct
89  searchablePlane(const searchablePlane&) = delete;
90 
91  //- No copy assignment
92  void operator=(const searchablePlane&) = delete;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("searchablePlane");
99 
100 
101  // Constructors
102 
103  //- Construct from components
105  (
106  const IOobject& io,
107  const point& basePoint,
108  const vector& normal
109  );
110 
111  //- Construct from dictionary (used by searchableSurface)
113  (
114  const IOobject& io,
115  const dictionary& dict
116  );
117 
118 
119  //- Destructor
120  virtual ~searchablePlane() = default;
121 
122 
123  // Member Functions
124 
125  //- Names of regions
126  virtual const wordList& regions() const;
127 
128  //- Whether supports volume type below
129  virtual bool hasVolumeType() const
130  {
131  return false;
132  }
133 
134  //- What is type of points outside bounds
135  virtual volumeType outsideVolumeType() const
136  {
137  return volumeType::UNKNOWN;
138  }
139 
140  //- Range of local indices that can be returned.
141  virtual label size() const
142  {
143  return 1;
144  }
145 
146  //- Get representative set of element coordinates
147  // Usually the element centres (should be of length size()).
148  virtual tmp<pointField> coordinates() const
149  {
151  }
152 
153  //- Get bounding spheres (centre and radius squared), one per element.
154  // Any point on element is guaranteed to be inside.
155  // Note: radius limited to sqr(GREAT)
156  virtual void boundingSpheres
157  (
158  pointField& centres,
159  scalarField& radiusSqr
160  ) const;
161 
162  //- Get the points that define the surface.
163  virtual tmp<pointField> points() const
164  {
165  return coordinates();
166  }
167 
168  //- Does any part of the surface overlap the supplied bound box?
169  virtual bool overlaps(const boundBox& bb) const
170  {
172  return false;
173  }
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>&,
219  ) const;
220 
221  //- Determine type (inside/outside/mixed) for point.
222  // Unknown if 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 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::searchablePlane::~searchablePlane
virtual ~searchablePlane()=default
Destructor.
Foam::plane::normal
const vector & normal() const
The plane unit normal.
Definition: planeI.H:39
Foam::searchablePlane::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point.
Definition: searchablePlane.C:257
Foam::searchablePlane::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchablePlane.H:178
searchableSurface.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::searchablePlane::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchablePlane.H:150
Foam::searchablePlane::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchablePlane.C:141
Foam::plane
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Definition: plane.H:89
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::searchablePlane::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchablePlane.H:144
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
plane.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
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::searchablePlane::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
Definition: searchablePlane.C:155
Foam::plane::origin
const point & origin() const
The plane base point.
Definition: planeI.H:45
Foam::searchablePlane::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchablePlane.H:172
Foam::searchablePlane::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchablePlane.H:241
Foam::Vector< scalar >
Foam::List< word >
Foam::searchablePlane::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchablePlane.C:129
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::searchablePlane::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchablePlane.C:235
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::searchablePlane::TypeName
TypeName("searchablePlane")
Runtime type information.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::searchablePlane::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchablePlane.H:138
Foam::searchablePlane
Searching on (infinite) plane. The dictionary specifications are identical to the Foam::plane require...
Definition: searchablePlane.H:73
Foam::searchablePlane::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: searchablePlane.C:198
Foam::searchablePlane::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchablePlane.C:246
Foam::searchablePlane::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
Definition: searchablePlane.C:209
Foam::searchablePlane::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchablePlane.H:157
sample
Minimal example by using system/controlDict.functions: