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-2023 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  Makes a collection of surface geometries by copying from an existing
29  defined surface geometry. There are no boolean operations, e.g.
30  overlapping surfaces are not intersected.
31 
32 Usage
33  searchableSurfaceCollection requires a surface geometry to be defined
34  initially, e.g. \c buildingA in the example below. The collection then
35  defines copies of buildingA which each can be scaled using the mandatory
36  \c scale parameter and then rotated and translated by the mandatory
37  \c transform. In the example below, two geometries are included named
38  \c buildingB and \c buildingC which are both formed by a translation
39  of \c buildingA according to the \c origin parameter. No rotation is
40  applied (by setting e1 and e2 to the global x and y axis directions,
41  respectively).
42 
43  Example specification in snappyHexMeshDict/geometry:
44 
45  \verbatim
46  buildingA
47  {
48  type searchableBox;
49  min (100 100 0);
50  max (120 120 100);
51  }
52 
53  moreBuildings
54  {
55  type searchableSurfaceCollection;
56 
57  mergeSubRegions true;
58 
59  buildingB
60  {
61  surface buildingA;
62  scale (1 1 1);
63  transform
64  {
65  coordinateSystem
66  {
67  type cartesian;
68  coordinateRotation
69  {
70  type axesRotation;
71  e1 (1 0 0);
72  e2 (0 1 0);
73  }
74  origin (40 40 0);
75  }
76  }
77  }
78 
79  buildingC
80  {
81  $buildingB;
82  transform
83  {
84  coordinateSystem { origin (30 -40 0); }
85  }
86  }
87  }
88  \endverbatim
89 
90 SourceFiles
91  searchableSurfaceCollection.C
92 
93 \*---------------------------------------------------------------------------*/
94 
95 #ifndef searchableSurfaceCollection_H
96 #define searchableSurfaceCollection_H
97 
98 #include "searchableSurface.H"
99 #include "treeBoundBox.H"
100 #include "coordinateSystem.H"
101 #include "UPtrList.H"
102 #include "Switch.H"
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 namespace Foam
107 {
108 
109 /*---------------------------------------------------------------------------*\
110  Class searchableSurfaceCollection Declaration
111 \*---------------------------------------------------------------------------*/
112 
114 :
115  public searchableSurface
116 {
117  // Private Member Data
118 
119  // Per instance data
120 
121  //- Instance name
122  wordList instance_;
123 
124  //- Scaling vector
125  vectorField scale_;
126 
127  //- transformation
128  PtrList<coordinateSystem> transform_;
129 
131 
132  Switch mergeSubRegions_;
133 
134  //- Offsets for indices coming from different surfaces
135  // (sized with size() of each surface)
136  labelList indexOffset_;
137 
138  //- Region names
139  mutable wordList regions_;
140 
141  //- From individual regions to collection regions
142  mutable labelList regionOffset_;
143 
144 
145  // Private Member Functions
146 
147  //- Inherit findNearest from searchableSurface
149 
150  //- Find point nearest to sample. Updates minDistSqr. Sets nearestInfo
151  // and surface index
152  void findNearest
153  (
154  const pointField& samples,
155  scalarField& minDistSqr,
156  List<pointIndexHit>& nearestInfo,
157  labelList& nearestSurf
158  ) const;
159 
160  //- Sort hits into per-surface bins. Misses are rejected.
161  // Maintains map back to position
162  void sortHits
163  (
164  const List<pointIndexHit>& info,
165  List<List<pointIndexHit>>& surfInfo,
166  labelListList& infoMap
167  ) const;
168 
169 
170 public:
171 
172  //- Runtime type information
173  TypeName("searchableSurfaceCollection");
174 
175 
176  // Constructors
177 
178  //- Construct from dictionary (used by searchableSurface)
180  (
181  const IOobject& io,
182  const dictionary& dict
183  );
184 
185  //- Disallow default bitwise copy construction
187  (
189  ) = delete;
190 
191 
192  //- Destructor
194 
195 
196  // Member Functions
197 
198  //- Scaling vector per subsurface
199  const vectorField& scale() const
200  {
201  return scale_;
202  }
203 
204  //- Scaling vector per subsurface
205  vectorField& scale()
206  {
207  return scale_;
208  }
209 
210  //- Coordinate system per subsurface
211  const PtrList<coordinateSystem>& transform() const
212  {
213  return transform_;
214  }
215 
216  //- Coordinate system per subsurface
218  {
219  return transform_;
220  }
221 
222  virtual const wordList& regions() const;
223 
224  //- Whether supports volume type below
225  virtual bool hasVolumeType() const
226  {
227  return false;
228  }
229 
230  //- Range of local indices that can be returned.
231  virtual label size() const;
232 
233  //- Get representative set of element coordinates
234  // Usually the element centres (should be of length size()).
235  virtual tmp<pointField> coordinates() const;
236 
237  //- Get bounding spheres (centre and radius squared), one per element.
238  // Any point on element is guaranteed to be inside.
239  virtual void boundingSpheres
240  (
241  pointField& centres,
242  scalarField& radiusSqr
243  ) const;
244 
245  //- Get the points that define the surface.
246  virtual tmp<pointField> points() const;
247 
248  //- Does any part of the surface overlap the supplied bound box?
249  virtual bool overlaps(const boundBox& bb) const
250  {
252 
253  return false;
254  }
255 
256 
257  // Multiple point queries.
258 
259  virtual void findNearest
260  (
261  const pointField& sample,
262  const scalarField& nearestDistSqr,
264  ) const;
265 
266  virtual void findLine
267  (
268  const pointField& start,
269  const pointField& end,
271  ) const;
272 
273  virtual void findLineAny
274  (
275  const pointField& start,
276  const pointField& end,
278  ) const;
279 
280  //- Get all intersections in order from start to end.
281  virtual void findLineAll
282  (
283  const pointField& start,
284  const pointField& end,
286  ) const;
287 
288  //- From a set of points and indices get the region
289  virtual void getRegion
290  (
291  const List<pointIndexHit>&,
292  labelList& region
293  ) const;
294 
295  //- From a set of points and indices get the normal
296  virtual void getNormal
297  (
298  const List<pointIndexHit>&,
299  vectorField& normal
300  ) const;
301 
302  //- Determine type (inside/outside/mixed) for point. unknown if
303  // cannot be determined (e.g. non-manifold surface)
304  virtual void getVolumeType
305  (
306  const pointField&,
308  ) const;
309 
310  // Other
311 
312  //- Set bounds of surface. Bounds currently set as list of
313  // bounding boxes. The bounds are hints to the surface as for
314  // the range of queries it can expect. faceMap/pointMap can be
315  // set if the surface has done any redistribution.
316  virtual void distribute
317  (
318  const List<treeBoundBox>&,
319  const bool keepNonLocal,
321  autoPtr<distributionMap>& pointMap
322  );
323 
324  //- WIP. Store element-wise field.
325  virtual void setField(const labelList& values);
326 
327  //- WIP. From a set of hits (points and
328  // indices) get the specified field. Misses do not get set. Return
329  // empty field if not supported.
330  virtual void getField(const List<pointIndexHit>&, labelList&) const;
331 
332  // regIOobject implementation
333 
334  bool writeData(Ostream&) const
335  {
337  return false;
338  }
339 
340 
341  // Member Operators
342 
343  //- Disallow default bitwise assignment
344  void operator=(const searchableSurfaceCollection&) = delete;
345 };
346 
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 } // End namespace Foam
351 
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 
354 #endif
355 
356 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:486
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Makes a collection of surface geometries by copying from an existing defined surface geometry....
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
const vectorField & scale() const
Scaling vector per subsurface.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
TypeName("searchableSurfaceCollection")
Runtime type information.
bool writeData(Ostream &) const
Pure virtual writaData function.
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.
void operator=(const searchableSurfaceCollection &)=delete
Disallow default bitwise assignment.
virtual label size() const
Range of local indices that can be returned.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
const PtrList< coordinateSystem > & transform() const
Coordinate system per subsurface.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
searchableSurfaceCollection(const IOobject &io, const dictionary &dict)
Construct from dictionary (used by searchableSurface)
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
virtual void distribute(const List< treeBoundBox > &, const bool keepNonLocal, autoPtr< distributionMap > &faceMap, autoPtr< distributionMap > &pointMap)
Set bounds of surface. Bounds currently set as list of.
virtual bool hasVolumeType() const
Whether supports volume type below.
virtual tmp< pointField > points() const
Get the points that define the surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
A class for managing temporary objects.
Definition: tmp.H:55
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
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
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
dictionary dict
scalarField samples(nIntervals, 0)