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-2018 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  // Private Member Functions
78 
79  //- Disallow default bitwise copy construct
81 
82  //- Disallow default bitwise assignment
83  void operator=(const searchableSurface&);
84 
85 
86 public:
87 
88  //- Runtime type information
89  TypeName("searchableSurface");
90 
91  // Declare run-time constructor selection table
92 
93  // For the dictionary constructor
95  (
96  autoPtr,
98  dict,
99  (
100  const IOobject& io,
101  const dictionary& dict
102  ),
103  (io, dict)
104  );
105 
106 
107  //- Class used for the read-construction of
108  // PtrLists of searchableSurface.
109  class iNew
110  {
111  IOobject& io_;
112 
113  public:
115  iNew(IOobject& io)
116  :
117  io_(io)
118  {}
121  {
122  word surfaceType(is);
123  word readName(is);
124  dictionary dict(is);
125 
126  autoPtr<IOobject> namedIO(io_.clone());
127  namedIO().rename(readName);
128  return searchableSurface::New(surfaceType, namedIO(), dict);
129  }
130  };
131 
132 
133  // Constructors
134 
135  searchableSurface(const IOobject& io);
136 
137  //- Clone
138  virtual autoPtr<searchableSurface> clone() const
139  {
141  return autoPtr<searchableSurface>(nullptr);
142  }
143 
144 
145  // Selectors
146 
147  //- Return a reference to the selected searchableSurface
149  (
150  const word& surfaceType,
151  const IOobject& io,
152  const dictionary& dict
153  );
154 
155 
156  //- Destructor
157  virtual ~searchableSurface();
158 
159 
160  // Member Functions
161 
162  //- Return const reference to boundBox
163  const boundBox& bounds() const
164  {
165  return bounds_;
166  }
167 
168  //- Return non-const access to the boundBox to allow it to be set.
169  boundBox& bounds()
170  {
171  return bounds_;
172  }
173 
174  //- Names of regions
175  virtual const wordList& regions() const = 0;
176 
177  //- Whether supports volume type below
178  virtual bool hasVolumeType() const = 0;
179 
180  //- Range of local indices that can be returned
181  virtual label size() const = 0;
182 
183  //- Range of global indices that can be returned
184  virtual label globalSize() const
185  {
186  return size();
187  }
188 
189  //- Get representative set of element coordinates
190  // Usually the element centres (should be of length size()).
191  virtual tmp<pointField> coordinates() const = 0;
192 
193  //- Get bounding spheres (centre and radius squared), one per element.
194  // Any point on element is guaranteed to be inside.
195  virtual void boundingSpheres
196  (
197  pointField& centres,
198  scalarField& radiusSqr
199  ) const = 0;
200 
201  //- Get the points that define the surface.
202  virtual tmp<pointField> points() const = 0;
203 
204  //- Does any part of the surface overlap the supplied bound box?
205  virtual bool overlaps(const boundBox& bb) const = 0;
206 
207  // Single point queries.
208 
214  // virtual pointIndexHit findNearest
215  //(
216  // const point& sample,
217  // const scalar nearestDistSqr
218  //) const = 0;
219  //
225  // virtual pointIndexHit findNearestOnEdge
226  //(
227  // const point& sample,
228  // const scalar nearestDistSqr
229  //) const = 0;
230  //
239  // virtual pointIndexHit findNearest
240  //(
241  // const linePointRef& ln,
242  // treeBoundBox& tightest,
243  // point& linePoint
244  //) const = 0;
245  //
247  // virtual pointIndexHit findLine
248  //(
249  // const point& start,
250  // const point& end
251  //) const = 0;
252  //
254  // virtual pointIndexHit findLineAny
255  //(
256  // const point& start,
257  // const point& end
258  //) const = 0;
259 
260 
261  // Multiple point queries. When surface is distributed the index
262  // should be a global index. Not done yet.
263 
264  virtual void findNearest
265  (
266  const pointField& sample,
267  const scalarField& nearestDistSqr,
269  ) const = 0;
270 
271  //- Find the nearest locations for the supplied points to a
272  // particular region in the searchable surface.
273  virtual void findNearest
274  (
275  const pointField& samples,
276  const scalarField& nearestDistSqr,
277  const labelList& regionIndices,
279  ) const
280  {
281  findNearest(samples, nearestDistSqr, info);
282  }
283 
284  //- Find first intersection on segment from start to end.
285  // Note: searchableSurfacesQueries expects no
286  // intersection to be found if start==end. Is problem?
287  virtual void findLine
288  (
289  const pointField& start,
290  const pointField& end,
292  ) const = 0;
293 
294  //- Return any intersection on segment from start to end.
295  virtual void findLineAny
296  (
297  const pointField& start,
298  const pointField& end,
300  ) const = 0;
301 
302  //- Get all intersections in order from start to end.
303  virtual void findLineAll
304  (
305  const pointField& start,
306  const pointField& end,
308  ) const = 0;
309 
310  //- From a set of points and indices get the region
311  virtual void getRegion
312  (
313  const List<pointIndexHit>&,
314  labelList& region
315  ) const = 0;
316 
317  //- From a set of points and indices get the normal
318  virtual void getNormal
319  (
320  const List<pointIndexHit>&,
321  vectorField& normal
322  ) const = 0;
323 
324  //- Determine type (inside/outside) for point. unknown if
325  // cannot be determined (e.g. non-manifold surface)
326  virtual void getVolumeType
327  (
328  const pointField&,
330  ) const = 0;
331 
332  //- Find nearest, normal and region. Can be overridden with
333  // optimised implementation
334  virtual void findNearest
335  (
336  const pointField& sample,
337  const scalarField& nearestDistSqr,
339  vectorField& normal,
340  labelList& region
341  ) const;
342 
343 
344  // Other
345 
346  //- Set bounds of surface. Bounds currently set as list of
347  // bounding boxes. The bounds are hints to the surface as for
348  // the range of queries it can expect. faceMap/pointMap can be
349  // set if the surface has done any redistribution.
350  virtual void distribute
351  (
352  const List<treeBoundBox>&,
353  const bool keepNonLocal,
355  autoPtr<mapDistribute>& pointMap
356  )
357  {}
358 
359  //- WIP. Store element-wise field.
360  virtual void setField(const labelList& values)
361  {}
362 
363  //- WIP. From a set of hits (points and
364  // indices) get the specified field. Misses do not get set. Return
365  // empty field if not supported.
366  virtual void getField(const List<pointIndexHit>&, labelList& values)
367  const
368  {
369  values.clear();
370  }
371 };
372 
373 
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 
376 } // End namespace Foam
377 
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 
380 #endif
381 
382 // ************************************************************************* //
dictionary dict
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:270
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:137
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?
virtual label globalSize() const
Range of global indices that can be returned.
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:65
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:483
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.