searchableSurfaceCollection.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::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 public:
112 
113  //- Runtime type information
114  TypeName("searchableSurfaceCollection");
115 
116 
117  // Constructors
118 
119  //- Construct from dictionary (used by searchableSurface)
121  (
122  const IOobject& io,
123  const dictionary& dict
124  );
125 
126  //- Disallow default bitwise copy construction
128  (
130  ) = delete;
131 
132 
133  //- Destructor
135 
136 
137  // Member Functions
138 
139  //- Scaling vector per subsurface
140  const vectorField& scale() const
141  {
142  return scale_;
143  }
144 
145  //- Scaling vector per subsurface
146  vectorField& scale()
147  {
148  return scale_;
149  }
150 
151  //- Coordinate system per subsurface
152  const PtrList<coordinateSystem>& transform() const
153  {
154  return transform_;
155  }
156 
157  //- Coordinate system per subsurface
159  {
160  return transform_;
161  }
162 
163  virtual const wordList& regions() const;
164 
165  //- Whether supports volume type below
166  virtual bool hasVolumeType() const
167  {
168  return false;
169  }
170 
171  //- Range of local indices that can be returned.
172  virtual label size() const;
173 
174  //- Get representative set of element coordinates
175  // Usually the element centres (should be of length size()).
176  virtual tmp<pointField> coordinates() const;
177 
178  //- Get bounding spheres (centre and radius squared), one per element.
179  // Any point on element is guaranteed to be inside.
180  virtual void boundingSpheres
181  (
182  pointField& centres,
183  scalarField& radiusSqr
184  ) const;
185 
186  //- Get the points that define the surface.
187  virtual tmp<pointField> points() const;
188 
189  //- Does any part of the surface overlap the supplied bound box?
190  virtual bool overlaps(const boundBox& bb) const
191  {
193 
194  return false;
195  }
196 
197 
198  // Multiple point queries.
199 
200  virtual void findNearest
201  (
202  const pointField& sample,
203  const scalarField& nearestDistSqr,
205  ) const;
206 
207  virtual void findLine
208  (
209  const pointField& start,
210  const pointField& end,
212  ) const;
213 
214  virtual void findLineAny
215  (
216  const pointField& start,
217  const pointField& end,
219  ) const;
220 
221  //- Get all intersections in order from start to end.
222  virtual void findLineAll
223  (
224  const pointField& start,
225  const pointField& end,
227  ) const;
228 
229  //- From a set of points and indices get the region
230  virtual void getRegion
231  (
232  const List<pointIndexHit>&,
233  labelList& region
234  ) const;
235 
236  //- From a set of points and indices get the normal
237  virtual void getNormal
238  (
239  const List<pointIndexHit>&,
240  vectorField& normal
241  ) const;
242 
243  //- Determine type (inside/outside/mixed) for point. unknown if
244  // cannot be determined (e.g. non-manifold surface)
245  virtual void getVolumeType
246  (
247  const pointField&,
249  ) const;
250 
251  // Other
252 
253  //- Set bounds of surface. Bounds currently set as list of
254  // bounding boxes. The bounds are hints to the surface as for
255  // the range of queries it can expect. faceMap/pointMap can be
256  // set if the surface has done any redistribution.
257  virtual void distribute
258  (
259  const List<treeBoundBox>&,
260  const bool keepNonLocal,
262  autoPtr<mapDistribute>& pointMap
263  );
264 
265  //- WIP. Store element-wise field.
266  virtual void setField(const labelList& values);
267 
268  //- WIP. From a set of hits (points and
269  // indices) get the specified field. Misses do not get set. Return
270  // empty field if not supported.
271  virtual void getField(const List<pointIndexHit>&, labelList&) const;
272 
273  // regIOobject implementation
275  bool writeData(Ostream&) const
276  {
278  return false;
279  }
280 
281 
282  // Member Operators
283 
284  //- Disallow default bitwise assignment
285  void operator=(const searchableSurfaceCollection&) = delete;
286 };
287 
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 } // End namespace Foam
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #endif
296 
297 // ************************************************************************* //
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:156
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
searchableSurfaceCollection(const IOobject &io, const dictionary &dict)
Construct from dictionary (used by searchableSurface)
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/any.
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.
void operator=(const searchableSurfaceCollection &)=delete
Disallow default bitwise assignment.
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:54
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.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
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:490
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:370
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.