searchableRotatedBox.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) 2014 OpenFOAM Foundation
9  Copyright (C) 2015-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::searchableRotatedBox
29 
30 Description
31  Searching on a rotated box
32 
33  Box defined as min and max coordinate. Rotation by coordinate system
34  at box middle.
35 
36  E.g. box with sides 1 1 1 rotated 45 degrees around z-axis at
37  origin (0.5 0.5 0.5)
38 
39  \verbatim
40  span (1 1 1);
41  origin (0.5 0.5 0.5);
42  e1 (1 1 0);
43  e3 (0 0 1);
44  \endverbatim
45 
46  \heading Dictionary parameters
47  \table
48  Property | Description | Required | Default
49  type | rotatedBox / searchableRotatedBox | selector |
50  span | The box dimensions | yes |
51  origin | The box corner | yes |
52  e1 | Local x-axis of the box | yes |
53  e3 | Local z-axis of the box | yes |
54  \endtable
55 
56 SourceFiles
57  searchableRotatedBox.C
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef searchableRotatedBox_H
62 #define searchableRotatedBox_H
63 
64 #include "searchableSurface.H"
65 #include "searchableBox.H"
66 #include "cartesianCS.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class searchableRotatedBox Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class searchableRotatedBox
78 :
79  public searchableSurface
80 {
81 private:
82 
83  // Private Member Data
84 
85  //- Box in local coordinate system
86  searchableBox box_;
87 
88  //- Transformation from local to global coordinates
89  coordSystem::cartesian transform_;
90 
91  //- The (global) corner points (in treeBoundBox order)
92  pointField points_;
93 
94 
95  // Private Member Functions
96 
97  //- No copy construct
98  searchableRotatedBox(const searchableRotatedBox&) = delete;
99 
100  //- No copy assignment
101  void operator=(const searchableRotatedBox&) = delete;
102 
103 
104 public:
105 
106  //- Runtime type information
107  TypeName("searchableRotatedBox");
108 
109 
110  // Constructors
111 
112  //- Construct from dictionary (used by searchableSurface)
114  (
115  const IOobject& io,
116  const dictionary& dict
117  );
118 
119 
120  //- Destructor
121  virtual ~searchableRotatedBox() = default;
122 
123 
124  // Member Functions
125 
126  //- Names of regions
127  virtual const wordList& regions() const;
128 
129  //- Whether supports volume type below
130  virtual bool hasVolumeType() const
131  {
132  return true;
133  }
134 
135  //- What is type of points outside bounds
136  virtual volumeType outsideVolumeType() const
137  {
138  return volumeType::OUTSIDE;
139  }
140 
141  //- Range of local indices that can be returned.
142  virtual label size() const
143  {
144  return 6;
145  }
146 
147  //- Get representative set of element coordinates
148  // Usually the element centres (should be of length size()).
149  virtual tmp<pointField> coordinates() const;
150 
151  //- Get bounding spheres (centre and radius squared), one per element.
152  // Any point on element is guaranteed to be inside.
153  virtual void boundingSpheres
154  (
155  pointField& centres,
156  scalarField& radiusSqr
157  ) const;
158 
159  //- Get the points that define the surface.
160  virtual tmp<pointField> points() const;
161 
162  // Does any part of the surface overlap the supplied bound box?
163  virtual bool overlaps(const boundBox& bb) const;
164 
165  // Single point queries.
166 
167  //- Inherit findNearest from searchableSurface
169 
170  //- Calculate nearest point on surface.
171  // Returns
172  // - bool : any point found nearer than nearestDistSqr
173  // - label: relevant index in surface (=face 0..5)
174  // - point: actual nearest point found
176  (
177  const point& sample,
178  const scalar nearestDistSqr
179  ) const;
180 
181  //- Find nearest to segment.
182  // Returns
183  // - bool : any point found?
184  // - label: relevant index in shapes (=face 0..5)
185  // - point: actual nearest point found
186  // sets:
187  // - tightest : bounding box
188  // - linePoint : corresponding nearest point on line
190  (
191  const linePointRef& ln,
192  treeBoundBox& tightest,
193  point& linePoint
194  ) const;
195 
196  //- Find nearest intersection of line between start and end.
198  (
199  const point& start,
200  const point& end
201  ) const;
202 
203  //- Find any intersection of line between start and end.
205  (
206  const point& start,
207  const point& end
208  ) const;
209 
210 
211  // Multiple point queries.
212 
213  virtual void findNearest
214  (
215  const pointField& sample,
216  const scalarField& nearestDistSqr,
218  ) const;
219 
220  virtual void findLine
221  (
222  const pointField& start,
223  const pointField& end,
225  ) const;
226 
227  virtual void findLineAny
228  (
229  const pointField& start,
230  const pointField& end,
232  ) const;
233 
234  //- Get all intersections in order from start to end.
235  virtual void findLineAll
236  (
237  const pointField& start,
238  const pointField& end,
240  ) const;
241 
242  //- From a set of points and indices get the region
243  virtual void getRegion
244  (
245  const List<pointIndexHit>&,
246  labelList& region
247  ) const;
248 
249  //- From a set of points and indices get the normal
250  virtual void getNormal
251  (
252  const List<pointIndexHit>&,
253  vectorField& normal
254  ) const;
255 
256  //- Determine type (inside/outside/mixed) for point. unknown if
257  // cannot be determined (e.g. non-manifold surface)
258  virtual void getVolumeType
259  (
260  const pointField& points,
261  List<volumeType>& volType
262  ) const;
263 
264 
265  // regIOobject implementation
266 
267  bool writeData(Ostream&) const
268  {
270  return false;
271  }
272 };
273 
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 } // End namespace Foam
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #endif
282 
283 // ************************************************************************* //
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:104
Foam::searchableRotatedBox::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableRotatedBox.C:89
searchableSurface.H
Foam::searchableRotatedBox::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableRotatedBox.C:112
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::searchableRotatedBox::~searchableRotatedBox
virtual ~searchableRotatedBox()=default
Destructor.
Foam::searchableRotatedBox::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableRotatedBox.H:165
searchableBox.H
Foam::searchableRotatedBox::findLineAny
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
Definition: searchableRotatedBox.C:239
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:87
Foam::searchableRotatedBox::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableRotatedBox.C:365
Foam::searchableRotatedBox::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableRotatedBox.C:376
Foam::searchableRotatedBox::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableRotatedBox.H:296
cartesianCS.H
Foam::searchableRotatedBox::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableRotatedBox.C:95
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::searchableRotatedBox::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableRotatedBox.C:118
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
Foam::searchableRotatedBox::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
Definition: searchableRotatedBox.C:297
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::searchableRotatedBox::TypeName
TypeName("searchableRotatedBox")
Runtime type information.
Foam::searchableRotatedBox::findNearest
pointIndexHit findNearest(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on surface.
Definition: searchableRotatedBox.C:185
Foam::searchableRotatedBox::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableRotatedBox.H:159
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
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::searchableRotatedBox::findLine
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
Definition: searchableRotatedBox.C:218
Foam::searchableRotatedBox::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableRotatedBox.C:102
Foam::searchableRotatedBox::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: searchableRotatedBox.C:389
Foam::coordSystem::cartesian
A Cartesian coordinate system.
Definition: cartesianCS.H:69
Foam::Vector< scalar >
Foam::searchableRotatedBox
Searching on a rotated box.
Definition: searchableRotatedBox.H:106
Foam::List< word >
Foam::line
A line primitive.
Definition: line.H:59
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:915
Foam::searchableBox
Searching on bounding box.
Definition: searchableBox.H:80
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::volumeType::OUTSIDE
A location outside the volume.
Definition: volumeType.H:69
Foam::searchableRotatedBox::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableRotatedBox.H:171