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 | 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 Note
57  Longer type name : \c searchableRotatedBox
58 
59 SourceFiles
60  searchableRotatedBox.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef searchableRotatedBox_H
65 #define searchableRotatedBox_H
66 
67 #include "searchableSurface.H"
68 #include "searchableBox.H"
69 #include "cartesianCS.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class searchableRotatedBox Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 class searchableRotatedBox
81 :
82  public searchableSurface
83 {
84  // Private Member Data
85 
86  //- Box in local coordinate system
87  searchableBox box_;
88 
89  //- Transformation from local to global coordinates
90  coordSystem::cartesian transform_;
91 
92  //- The (global) corner points (in treeBoundBox order)
93  pointField points_;
94 
95 
96  // Private Member Functions
97 
98  //- No copy construct
99  searchableRotatedBox(const searchableRotatedBox&) = delete;
100 
101  //- No copy assignment
102  void operator=(const searchableRotatedBox&) = delete;
103 
104 
105 public:
106 
107  //- Runtime type information
108  TypeName("searchableRotatedBox");
109 
110 
111  // Constructors
112 
113  //- Construct from components
115  (
116  const IOobject& io,
117  const vector& span,
119  );
120 
121  //- Construct from dictionary (used by searchableSurface)
123  (
124  const IOobject& io,
125  const dictionary& dict
126  );
127 
128 
129  //- Destructor
130  virtual ~searchableRotatedBox() = default;
131 
132 
133  // Member Functions
134 
135  //- Names of regions
136  virtual const wordList& regions() const;
137 
138  //- Whether supports volume type below
139  virtual bool hasVolumeType() const
140  {
141  return true;
142  }
143 
144  //- What is type of points outside bounds
145  virtual volumeType outsideVolumeType() const
146  {
147  return volumeType::OUTSIDE;
148  }
149 
150  //- Range of local indices that can be returned.
151  virtual label size() const
152  {
153  return 6;
154  }
155 
156  //- Get representative set of element coordinates
157  // Usually the element centres (should be of length size()).
158  virtual tmp<pointField> coordinates() const;
159 
160  //- Get bounding spheres (centre and radius squared), one per element.
161  // Any point on element is guaranteed to be inside.
162  virtual void boundingSpheres
163  (
164  pointField& centres,
165  scalarField& radiusSqr
166  ) const;
167 
168  //- Get the points that define the surface.
169  virtual tmp<pointField> points() const;
170 
171  // Does any part of the surface overlap the supplied bound box?
172  virtual bool overlaps(const boundBox& bb) const;
173 
174  // Single point queries.
175 
176  //- Inherit findNearest from searchableSurface
178 
179  //- Calculate nearest point on surface.
180  // Returns
181  // - bool : any point found nearer than nearestDistSqr
182  // - label: relevant index in surface (=face 0..5)
183  // - point: actual nearest point found
185  (
186  const point& sample,
187  const scalar nearestDistSqr
188  ) const;
189 
190  //- Find nearest to segment.
191  // Returns
192  // - bool : any point found?
193  // - label: relevant index in shapes (=face 0..5)
194  // - point: actual nearest point found
195  // sets:
196  // - tightest : bounding box
197  // - linePoint : corresponding nearest point on line
199  (
200  const linePointRef& ln,
201  treeBoundBox& tightest,
202  point& linePoint
203  ) const;
204 
205  //- Find nearest intersection of line between start and end.
207  (
208  const point& start,
209  const point& end
210  ) const;
211 
212  //- Find any intersection of line between start and end.
214  (
215  const point& start,
216  const point& end
217  ) const;
218 
219 
220  // Multiple point queries.
221 
222  virtual void findNearest
223  (
224  const pointField& sample,
225  const scalarField& nearestDistSqr,
227  ) const;
228 
229  virtual void findLine
230  (
231  const pointField& start,
232  const pointField& end,
234  ) const;
235 
236  virtual void findLineAny
237  (
238  const pointField& start,
239  const pointField& end,
241  ) const;
242 
243  //- Get all intersections in order from start to end.
244  virtual void findLineAll
245  (
246  const pointField& start,
247  const pointField& end,
249  ) const;
250 
251  //- From a set of points and indices get the region
252  virtual void getRegion
253  (
254  const List<pointIndexHit>&,
255  labelList& region
256  ) const;
257 
258  //- From a set of points and indices get the normal
259  virtual void getNormal
260  (
261  const List<pointIndexHit>&,
262  vectorField& normal
263  ) const;
264 
265  //- Determine type (inside/outside/mixed) for point. unknown if
266  // cannot be determined (e.g. non-manifold surface)
267  virtual void getVolumeType
268  (
269  const pointField& points,
270  List<volumeType>& volType
271  ) const;
272 
273 
274  // regIOobject implementation
275 
276  bool writeData(Ostream&) const
277  {
279  return false;
280  }
281 };
282 
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
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::searchableRotatedBox::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableRotatedBox.C:105
searchableSurface.H
Foam::searchableRotatedBox::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableRotatedBox.C:128
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::searchableRotatedBox::~searchableRotatedBox
virtual ~searchableRotatedBox()=default
Destructor.
Foam::searchableRotatedBox::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableRotatedBox.H:174
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:250
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
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:376
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:387
Foam::searchableRotatedBox::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableRotatedBox.H:305
cartesianCS.H
Foam::searchableRotatedBox::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableRotatedBox.C:111
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::searchableRotatedBox::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableRotatedBox.C:134
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:308
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:196
Foam::searchableRotatedBox::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableRotatedBox.H:168
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::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:229
Foam::searchableRotatedBox::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableRotatedBox.C:118
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:400
Foam::coordSystem::cartesian
A Cartesian coordinate system.
Definition: cartesianCS.H:69
Foam::Vector< scalar >
Foam::searchableRotatedBox
Searching on a rotated box.
Definition: searchableRotatedBox.H:109
Foam::List< word >
Foam::line
A line primitive.
Definition: line.H:53
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:925
Foam::searchableBox
Searching on bounding box.
Definition: searchableBox.H:93
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:180
sample
Minimal example by using system/controlDict.functions: