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-2017 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 /*---------------------------------------------------------------------------*\
51  Class searchableSurfaceCollection Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public searchableSurface
57 {
58  // Private Member Data
59 
60  // Per instance data
61 
62  //- Instance name
63  wordList instance_;
64 
65  //- Scaling vector
66  vectorField scale_;
67 
68  //- transformation
69  PtrList<coordinateSystem> transform_;
70 
72 
73  Switch mergeSubRegions_;
74 
75  //- Offsets for indices coming from different surfaces
76  // (sized with size() of each surface)
77  labelList indexOffset_;
78 
79  //- Region names
80  mutable wordList regions_;
81 
82  //- From individual regions to collection regions
83  mutable labelList regionOffset_;
84 
85 
86  // Private Member Functions
87 
88  //- Inherit findNearest from searchableSurface
90 
91  //- Find point nearest to sample. Updates minDistSqr. Sets nearestInfo
92  // and surface index
93  void findNearest
94  (
95  const pointField& samples,
96  scalarField& minDistSqr,
97  List<pointIndexHit>& nearestInfo,
98  labelList& nearestSurf
99  ) const;
100 
101  //- Sort hits into per-surface bins. Misses are rejected.
102  // Maintains map back to position
103  void sortHits
104  (
105  const List<pointIndexHit>& info,
106  List<List<pointIndexHit>>& surfInfo,
107  labelListList& infoMap
108  ) const;
109 
110 
111  //- Disallow default bitwise copy construct
113 
114  //- Disallow default bitwise assignment
115  void operator=(const searchableSurfaceCollection&);
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("searchableSurfaceCollection");
122 
123 
124  // Constructors
125 
126  //- Construct from dictionary (used by searchableSurface)
128  (
129  const IOobject& io,
130  const dictionary& dict
131  );
132 
133 
134  //- Destructor
136 
137 
138  // Member Functions
139 
140  //- Scaling vector per subsurface
141  const vectorField& scale() const
142  {
143  return scale_;
144  }
145 
146  //- Scaling vector per subsurface
147  vectorField& scale()
148  {
149  return scale_;
150  }
151 
152  //- Coordinate system per subsurface
153  const PtrList<coordinateSystem>& transform() const
154  {
155  return transform_;
156  }
157 
158  //- Coordinate system per subsurface
160  {
161  return transform_;
162  }
163 
164  virtual const wordList& regions() const;
165 
166  //- Whether supports volume type below
167  virtual bool hasVolumeType() const
168  {
169  return false;
170  }
171 
172  //- Range of local indices that can be returned.
173  virtual label size() const;
174 
175  //- Get representative set of element coordinates
176  // Usually the element centres (should be of length size()).
177  virtual tmp<pointField> coordinates() const;
178 
179  //- Get bounding spheres (centre and radius squared), one per element.
180  // Any point on element is guaranteed to be inside.
181  virtual void boundingSpheres
182  (
183  pointField& centres,
184  scalarField& radiusSqr
185  ) const;
186 
187  //- Get the points that define the surface.
188  virtual tmp<pointField> points() const;
189 
190  //- Does any part of the surface overlap the supplied bound box?
191  virtual bool overlaps(const boundBox& bb) const
192  {
194 
195  return false;
196  }
197 
198 
199  // Multiple point queries.
200 
201  virtual void findNearest
202  (
203  const pointField& sample,
204  const scalarField& nearestDistSqr,
206  ) const;
207 
208  virtual void findLine
209  (
210  const pointField& start,
211  const pointField& end,
213  ) const;
214 
215  virtual void findLineAny
216  (
217  const pointField& start,
218  const pointField& end,
220  ) const;
221 
222  //- Get all intersections in order from start to end.
223  virtual void findLineAll
224  (
225  const pointField& start,
226  const pointField& end,
228  ) const;
229 
230  //- From a set of points and indices get the region
231  virtual void getRegion
232  (
233  const List<pointIndexHit>&,
234  labelList& region
235  ) const;
236 
237  //- From a set of points and indices get the normal
238  virtual void getNormal
239  (
240  const List<pointIndexHit>&,
242  ) const;
243 
244  //- Determine type (inside/outside/mixed) for point. unknown if
245  // cannot be determined (e.g. non-manifold surface)
246  virtual void getVolumeType
247  (
248  const pointField&,
250  ) const;
251 
252  // Other
253 
254  //- Set bounds of surface. Bounds currently set as list of
255  // bounding boxes. The bounds are hints to the surface as for
256  // the range of queries it can expect. faceMap/pointMap can be
257  // set if the surface has done any redistribution.
258  virtual void distribute
259  (
260  const List<treeBoundBox>&,
261  const bool keepNonLocal,
263  autoPtr<mapDistribute>& pointMap
264  );
265 
266  //- WIP. Store element-wise field.
267  virtual void setField(const labelList& values);
268 
269  //- WIP. From a set of hits (points and
270  // indices) get the specified field. Misses do not get set. Return
271  // empty field if not supported.
272  virtual void getField(const List<pointIndexHit>&, labelList&) const;
273 
274  // regIOobject implementation
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 // ************************************************************************* //
dictionary dict
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
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 boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
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 void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
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.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
scalarField samples(nIntervals, 0)
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
virtual label size() const
Range of local indices that can be returned.
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 getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
A normal distribution model.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual bool hasVolumeType() const
Whether supports volume type below.
const PtrList< coordinateSystem > & transform() const
Coordinate system per subsurface.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:477
A class for managing temporary objects.
Definition: PtrList.H:53
bool writeData(Ostream &) const
Pure virtual writaData function.
#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
const vectorField & scale() const
Scaling vector per subsurface.
Namespace for OpenFOAM.
virtual const wordList & regions() const
Names of regions.