searchableSurfaceCollection.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 | Copyright (C) 2011-2016 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::searchableSurfaceCollection
26 
27 Description
28  Set of transformed searchableSurfaces. Does not do boolean operations.
29  So when meshing might find parts 'inside'.
30 
31 SourceFiles
32  searchableSurfaceCollection.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef searchableSurfaceCollection_H
37 #define searchableSurfaceCollection_H
38 
39 #include "searchableSurface.H"
40 #include "treeBoundBox.H"
41 #include "coordinateSystem.H"
42 #include "UPtrList.H"
43 #include "Switch.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 
52 /*---------------------------------------------------------------------------*\
53  Class searchableSurfaceCollection Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public searchableSurface
59 {
60 private:
61 
62  // Private Member Data
63 
64  // Per instance data
65 
66  //- Instance name
67  wordList instance_;
68 
69  //- Scaling vector
70  vectorField scale_;
71 
72  //- transformation
73  PtrList<coordinateSystem> transform_;
74 
76 
77  Switch mergeSubRegions_;
78 
79  //- Offsets for indices coming from different surfaces
80  // (sized with size() of each surface)
81  labelList indexOffset_;
82 
83  //- Region names
84  mutable wordList regions_;
85  //- From individual regions to collection regions
86  mutable labelList regionOffset_;
87 
88 
89  // Private Member Functions
90 
91  //- Inherit findNearest from searchableSurface
93 
94  //- Find point nearest to sample. Updates minDistSqr. Sets nearestInfo
95  // and surface index
96  void findNearest
97  (
98  const pointField& samples,
99  scalarField& minDistSqr,
100  List<pointIndexHit>& nearestInfo,
101  labelList& nearestSurf
102  ) const;
103 
104  //- Sort hits into per-surface bins. Misses are rejected.
105  // Maintains map back to position
106  void sortHits
107  (
108  const List<pointIndexHit>& info,
109  List<List<pointIndexHit>>& surfInfo,
110  labelListList& infoMap
111  ) const;
112 
113 
114  //- Disallow default bitwise copy construct
116 
117  //- Disallow default bitwise assignment
118  void operator=(const searchableSurfaceCollection&);
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("searchableSurfaceCollection");
125 
126 
127  // Constructors
128 
129  //- Construct from dictionary (used by searchableSurface)
131  (
132  const IOobject& io,
133  const dictionary& dict
134  );
135 
136  //- Destructor
138 
139 
140  // Member Functions
141 
142  //- Scaling vector per subsurface
143  const vectorField& scale() const
144  {
145  return scale_;
146  }
147 
148  //- Scaling vector per subsurface
149  vectorField& scale()
150  {
151  return scale_;
152  }
153 
154  //- Coordinate system per subsurface
155  const PtrList<coordinateSystem>& transform() const
156  {
157  return transform_;
158  }
159 
160  //- Coordinate system per subsurface
162  {
163  return transform_;
164  }
165 
166 
167  virtual const wordList& regions() const;
168 
169  //- Whether supports volume type below
170  virtual bool hasVolumeType() const
171  {
172  return false;
173  }
174 
175  //- Range of local indices that can be returned.
176  virtual label size() const;
177 
178  //- Get representative set of element coordinates
179  // Usually the element centres (should be of length size()).
180  virtual tmp<pointField> coordinates() const;
181 
182  //- Get bounding spheres (centre and radius squared), one per element.
183  // Any point on element is guaranteed to be inside.
184  virtual void boundingSpheres
185  (
186  pointField& centres,
187  scalarField& radiusSqr
188  ) const;
189 
190  //- Get the points that define the surface.
191  virtual tmp<pointField> points() const;
192 
193  //- Does any part of the surface overlap the supplied bound box?
194  virtual bool overlaps(const boundBox& bb) const
195  {
197 
198  return false;
199  }
200 
201 
202  // Multiple point queries.
203 
204  virtual void findNearest
205  (
206  const pointField& sample,
207  const scalarField& nearestDistSqr,
209  ) const;
210 
211  virtual void findLine
212  (
213  const pointField& start,
214  const pointField& end,
216  ) const;
217 
218  virtual void findLineAny
219  (
220  const pointField& start,
221  const pointField& end,
223  ) const;
224 
225  //- Get all intersections in order from start to end.
226  virtual void findLineAll
227  (
228  const pointField& start,
229  const pointField& end,
231  ) const;
232 
233  //- From a set of points and indices get the region
234  virtual void getRegion
235  (
236  const List<pointIndexHit>&,
237  labelList& region
238  ) const;
239 
240  //- From a set of points and indices get the normal
241  virtual void getNormal
242  (
243  const List<pointIndexHit>&,
245  ) const;
246 
247  //- Determine type (inside/outside/mixed) for point. unknown if
248  // cannot be determined (e.g. non-manifold surface)
249  virtual void getVolumeType
250  (
251  const pointField&,
253  ) const;
254 
255  // Other
256 
257  //- Set bounds of surface. Bounds currently set as list of
258  // bounding boxes. The bounds are hints to the surface as for
259  // the range of queries it can expect. faceMap/pointMap can be
260  // set if the surface has done any redistribution.
261  virtual void distribute
262  (
263  const List<treeBoundBox>&,
264  const bool keepNonLocal,
266  autoPtr<mapDistribute>& pointMap
267  );
268 
269  //- WIP. Store element-wise field.
270  virtual void setField(const labelList& values);
271 
272  //- WIP. From a set of hits (points and
273  // indices) get the specified field. Misses do not get set. Return
274  // empty field if not supported.
275  virtual void getField(const List<pointIndexHit>&, labelList&) const;
276 
277  // regIOobject implementation
279  bool writeData(Ostream&) const
280  {
282  return false;
283  }
284 
285 };
286 
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 } // End namespace Foam
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 #endif
295 
296 // ************************************************************************* //
virtual label size() const
Range of local indices that can be returned.
dictionary dict
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.
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 void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
virtual const wordList & regions() const
Names of regions.
const vectorField & scale() const
Scaling vector per subsurface.
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:58
Set of transformed searchableSurfaces. Does not do boolean operations. So when meshing might find par...
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
TypeName("searchableSurfaceCollection")
Runtime type information.
bool writeData(Ostream &) const
Pure virtual writaData function.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual bool hasVolumeType() const
Whether supports volume type below.
scalarField samples(nIntervals, 0)
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:421
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void setField(const labelList &values)
WIP. Store element-wise field.
A normal distribution model.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
A class for managing temporary objects.
Definition: PtrList.H:54
#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:91
Namespace for OpenFOAM.
const PtrList< coordinateSystem > & transform() const
Coordinate system per subsurface.