searchableSurface.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::searchableSurface
26 
27 Description
28  Base class of (analytical or triangulated) surface.
29  Encapsulates all the search routines. WIP.
30 
31  Information returned is usually a pointIndexHit:
32  - bool : was intersection/nearest found?
33  - point : intersection point or nearest point
34  - index : unique index on surface (e.g. triangle for triSurfaceMesh)
35 
36 SourceFiles
37  searchableSurface.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef searchableSurface_H
42 #define searchableSurface_H
43 
44 #include "pointField.H"
45 #include "boundBox.H"
46 #include "typeInfo.H"
47 #include "runTimeSelectionTables.H"
48 #include "pointIndexHit.H"
49 #include "linePointRef.H"
50 #include "objectRegistry.H"
51 #include "volumeType.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward declaration of classes
59 class objectRegistry;
60 class mapDistribute;
61 class treeBoundBox;
62 
63 /*---------------------------------------------------------------------------*\
64  Class searchableSurface Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 :
69  public regIOobject
70 {
71  // Private Data
72 
73  const word name_;
74 
75  boundBox bounds_;
76 
77 
78 public:
79 
80  //- Runtime type information
81  TypeName("searchableSurface");
82 
83  // Declare run-time constructor selection table
84 
85  // For the dictionary constructor
87  (
88  autoPtr,
90  dict,
91  (
92  const IOobject& io,
93  const dictionary& dict
94  ),
95  (io, dict)
96  );
97 
98 
99  //- Class used for the read-construction of
100  // PtrLists of searchableSurface.
101  class iNew
102  {
103  IOobject& io_;
104 
105  public:
107  iNew(IOobject& io)
108  :
109  io_(io)
110  {}
113  {
114  word surfaceType(is);
115  word readName(is);
116  dictionary dict(is);
117 
118  autoPtr<IOobject> namedIO(io_.clone());
119  namedIO().rename(readName);
120  return searchableSurface::New(surfaceType, namedIO(), dict);
121  }
122  };
123 
124 
125  // Constructors
126 
127  searchableSurface(const IOobject& io);
128 
129  //- Disallow default bitwise copy construction
130  searchableSurface(const searchableSurface&) = delete;
131 
132  //- Clone
133  virtual autoPtr<searchableSurface> clone() const
134  {
136  return autoPtr<searchableSurface>(nullptr);
137  }
138 
139 
140  // Selectors
141 
142  //- Return a reference to the selected searchableSurface
144  (
145  const word& surfaceType,
146  const IOobject& io,
147  const dictionary& dict
148  );
149 
150 
151  //- Destructor
152  virtual ~searchableSurface();
153 
154 
155  // Member Functions
156 
157  //- Return const reference to boundBox
158  const boundBox& bounds() const
159  {
160  return bounds_;
161  }
162 
163  //- Return non-const access to the boundBox to allow it to be set.
164  boundBox& bounds()
165  {
166  return bounds_;
167  }
168 
169  //- Names of regions
170  virtual const wordList& regions() const = 0;
171 
172  //- Whether supports volume type below
173  virtual bool hasVolumeType() const = 0;
174 
175  //- Range of local indices that can be returned
176  virtual label size() const = 0;
177 
178  //- Range of global indices that can be returned
179  virtual label globalSize() const
180  {
181  return size();
182  }
183 
184  //- Get representative set of element coordinates
185  // Usually the element centres (should be of length size()).
186  virtual tmp<pointField> coordinates() const = 0;
187 
188  //- Get bounding spheres (centre and radius squared), one per element.
189  // Any point on element is guaranteed to be inside.
190  virtual void boundingSpheres
191  (
192  pointField& centres,
193  scalarField& radiusSqr
194  ) const = 0;
195 
196  //- Get the points that define the surface.
197  virtual tmp<pointField> points() const = 0;
198 
199  //- Does any part of the surface overlap the supplied bound box?
200  virtual bool overlaps(const boundBox& bb) const = 0;
201 
202  // Single point queries.
203 
209  // virtual pointIndexHit findNearest
210  //(
211  // const point& sample,
212  // const scalar nearestDistSqr
213  //) const = 0;
214  //
220  // virtual pointIndexHit findNearestOnEdge
221  //(
222  // const point& sample,
223  // const scalar nearestDistSqr
224  //) const = 0;
225  //
234  // virtual pointIndexHit findNearest
235  //(
236  // const linePointRef& ln,
237  // treeBoundBox& tightest,
238  // point& linePoint
239  //) const = 0;
240  //
242  // virtual pointIndexHit findLine
243  //(
244  // const point& start,
245  // const point& end
246  //) const = 0;
247  //
249  // virtual pointIndexHit findLineAny
250  //(
251  // const point& start,
252  // const point& end
253  //) const = 0;
254 
255 
256  // Multiple point queries. When surface is distributed the index
257  // should be a global index. Not done yet.
258 
259  virtual void findNearest
260  (
261  const pointField& sample,
262  const scalarField& nearestDistSqr,
264  ) const = 0;
265 
266  //- Find the nearest locations for the supplied points to a
267  // particular region in the searchable surface.
268  virtual void findNearest
269  (
270  const pointField& samples,
271  const scalarField& nearestDistSqr,
272  const labelList& regionIndices,
274  ) const
275  {
276  findNearest(samples, nearestDistSqr, info);
277  }
278 
279  //- Find first intersection on segment from start to end.
280  // Note: searchableSurfacesQueries expects no
281  // intersection to be found if start==end. Is problem?
282  virtual void findLine
283  (
284  const pointField& start,
285  const pointField& end,
287  ) const = 0;
288 
289  //- Return any intersection on segment from start to end.
290  virtual void findLineAny
291  (
292  const pointField& start,
293  const pointField& end,
295  ) const = 0;
296 
297  //- Get all intersections in order from start to end.
298  virtual void findLineAll
299  (
300  const pointField& start,
301  const pointField& end,
303  ) const = 0;
304 
305  //- From a set of points and indices get the region
306  virtual void getRegion
307  (
308  const List<pointIndexHit>&,
309  labelList& region
310  ) const = 0;
311 
312  //- From a set of points and indices get the normal
313  virtual void getNormal
314  (
315  const List<pointIndexHit>&,
316  vectorField& normal
317  ) const = 0;
318 
319  //- Determine type (inside/outside) for point. unknown if
320  // cannot be determined (e.g. non-manifold surface)
321  virtual void getVolumeType
322  (
323  const pointField&,
325  ) const = 0;
326 
327  //- Find nearest, normal and region. Can be overridden with
328  // optimised implementation
329  virtual void findNearest
330  (
331  const pointField& sample,
332  const scalarField& nearestDistSqr,
334  vectorField& normal,
335  labelList& region
336  ) const;
337 
338 
339  // Other
340 
341  //- Set bounds of surface. Bounds currently set as list of
342  // bounding boxes. The bounds are hints to the surface as for
343  // the range of queries it can expect. faceMap/pointMap can be
344  // set if the surface has done any redistribution.
345  virtual void distribute
346  (
347  const List<treeBoundBox>&,
348  const bool keepNonLocal,
350  autoPtr<mapDistribute>& pointMap
351  )
352  {}
353 
354  //- WIP. Store element-wise field.
355  virtual void setField(const labelList& values)
356  {}
357 
358  //- WIP. From a set of hits (points and
359  // indices) get the specified field. Misses do not get set. Return
360  // empty field if not supported.
361  virtual void getField(const List<pointIndexHit>&, labelList& values)
362  const
363  {
364  values.clear();
365  }
366 
367 
368  // Member Operators
369 
370  //- Disallow default bitwise assignment
371  void operator=(const searchableSurface&) = delete;
372 };
373 
374 
375 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 
377 } // End namespace Foam
378 
379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 
381 #endif
382 
383 // ************************************************************************* //
dictionary dict
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:268
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual const wordList & regions() const =0
Names of regions.
virtual tmp< pointField > coordinates() const =0
Get representative set of element coordinates.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
TypeName("searchableSurface")
Runtime type information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
declareRunTimeSelectionTable(autoPtr, searchableSurface, dict,(const IOobject &io, const dictionary &dict),(io, dict))
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:58
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
Class used for the read-construction of.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Return any intersection on segment from start to end.
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
scalarField samples(nIntervals, 0)
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:124
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const =0
Get all intersections in order from start to end.
A class for handling words, derived from string.
Definition: word.H:59
virtual bool overlaps(const boundBox &bb) const =0
Does any part of the surface overlap the supplied bound box?
void operator=(const searchableSurface &)=delete
Disallow default bitwise assignment.
virtual label globalSize() const
Range of global indices that can be returned.
searchableSurface(const IOobject &io)
virtual autoPtr< searchableSurface > clone() const
Clone.
virtual tmp< pointField > points() const =0
Get the points that define the surface.
virtual ~searchableSurface()
Destructor.
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point. unknown if.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const =0
From a set of points and indices get the region.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
const boundBox & bounds() const
Return const reference to boundBox.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
virtual label size() const =0
Range of local indices that can be returned.
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:469
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual void distribute(const List< treeBoundBox > &, const bool keepNonLocal, autoPtr< mapDistribute > &faceMap, autoPtr< mapDistribute > &pointMap)
Set bounds of surface. Bounds currently set as list of.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
autoPtr< searchableSurface > operator()(Istream &is) const
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Find first intersection on segment from start to end.
virtual bool hasVolumeType() const =0
Whether supports volume type below.
Namespace for OpenFOAM.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.