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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::searchableSurfaceCollection
29 
30 Description
31  Set of transformed searchableSurfaces. Does not do boolean operations
32  so when meshing might find parts 'inside'.
33 
34  \heading Dictionary parameters
35  \table
36  Property | Description | Required | Default
37  type | collection | selector |
38  mergeSubRegions | boolean | yes |
39  \endtable
40 
41 Note
42  Longer type name : \c searchableSurfaceCollection
43 
44 SourceFiles
45  searchableSurfaceCollection.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef searchableSurfaceCollection_H
50 #define searchableSurfaceCollection_H
51 
52 #include "searchableSurface.H"
53 #include "treeBoundBox.H"
54 #include "cartesianCS.H"
55 #include "UPtrList.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class searchableSurfaceCollection Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class searchableSurfaceCollection
67 :
68  public searchableSurface
69 {
70  // Private Member Data
71 
72  // Per instance data
73 
74  //- Instance name
75  wordList instance_;
76 
77  //- Scaling vector
78  vectorField scale_;
79 
80  //- Coordinate transformation
82 
84 
85  bool mergeSubRegions_;
86 
87  //- Offsets for indices coming from different surfaces
88  // (sized with size() of each surface)
89  labelList indexOffset_;
90 
91  //- Names of regions
92  mutable wordList regions_;
93 
94  //- From individual regions to collection regions
95  mutable labelList regionOffset_;
96 
97 
98  // Private Member Functions
99 
100  //- Inherit findNearest from searchableSurface
102 
103  //- Find point nearest to sample. Updates minDistSqr. Sets nearestInfo
104  // and surface index
105  void findNearest
106  (
107  const pointField& samples,
108  scalarField& minDistSqr,
109  List<pointIndexHit>& nearestInfo,
110  labelList& nearestSurf
111  ) const;
112 
113  //- Sort hits into per-surface bins. Misses are rejected.
114  // Maintains map back to position
115  void sortHits
116  (
117  const List<pointIndexHit>& info,
118  List<List<pointIndexHit>>& surfInfo,
119  labelListList& infoMap
120  ) const;
121 
122 
123  //- No copy construct
125  (
127  ) = delete;
128 
129  //- No copy assignment
130  void operator=(const searchableSurfaceCollection&) = delete;
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("searchableSurfaceCollection");
137 
138 
139  // Constructors
140 
141  //- Construct from dictionary (used by searchableSurface)
143  (
144  const IOobject& io,
145  const dictionary& dict
146  );
147 
148 
149  //- Destructor
151 
152 
153  // Member Functions
154 
155  //- Scaling vector per subsurface
156  const vectorField& scale() const
157  {
158  return scale_;
159  }
160 
161  //- Scaling vector per subsurface
162  vectorField& scale()
163  {
164  return scale_;
165  }
166 
167  //- Coordinate system per subsurface
168  const PtrList<coordSystem::cartesian>& transform() const
169  {
170  return transform_;
171  }
172 
173  //- Coordinate system per subsurface
175  {
176  return transform_;
177  }
178 
179  //- Names of regions
180  virtual const wordList& regions() const;
181 
182  //- Whether supports volume type (below)
183  virtual bool hasVolumeType() const
184  {
185  return false;
186  }
187 
188  //- What is type of points outside bounds
189  virtual volumeType outsideVolumeType() const
190  {
191  return volumeType::UNKNOWN;
192  }
193 
194  //- Range of local indices that can be returned.
195  virtual label size() const;
196 
197  //- Get representative set of element coordinates
198  // Usually the element centres (should be of length size()).
199  virtual tmp<pointField> coordinates() const;
200 
201  //- Get bounding spheres (centre and radius squared), one per element.
202  // Any point on element is guaranteed to be inside.
203  virtual void boundingSpheres
204  (
205  pointField& centres,
206  scalarField& radiusSqr
207  ) const;
208 
209  //- Get the points that define the surface.
210  virtual tmp<pointField> points() const;
211 
212  //- Does any part of the surface overlap the supplied bound box?
213  virtual bool overlaps(const boundBox& bb) const
214  {
216  return false;
217  }
218 
219 
220  // Multiple point queries.
221 
222  virtual void findNearest
223  (
224  const pointField& sample,
225  const scalarField& nearestDistSqr,
227  ) const;
228 
229  virtual void findLine
230  (
231  const pointField& start,
232  const pointField& end,
234  ) const;
235 
236  virtual void findLineAny
237  (
238  const pointField& start,
239  const pointField& end,
241  ) const;
242 
243  //- Get all intersections in order from start to end.
244  virtual void findLineAll
245  (
246  const pointField& start,
247  const pointField& end,
249  ) const;
250 
251  //- From a set of points and indices get the region
252  virtual void getRegion
253  (
254  const List<pointIndexHit>&,
255  labelList& region
256  ) const;
257 
258  //- From a set of points and indices get the normal
259  virtual void getNormal
260  (
261  const List<pointIndexHit>&,
262  vectorField& normal
263  ) const;
264 
265  //- Determine type (inside/outside/mixed) for point.
266  // Unknown if cannot be determined (e.g. non-manifold surface)
267  virtual void getVolumeType
268  (
269  const pointField& points,
270  List<volumeType>& volType
271  ) const;
272 
273  // Other
274 
275  //- Set bounds of surface. Bounds currently set as list of
276  // bounding boxes. The bounds are hints to the surface as for
277  // the range of queries it can expect. faceMap/pointMap can be
278  // set if the surface has done any redistribution.
279  virtual void distribute
280  (
281  const List<treeBoundBox>&,
282  const bool keepNonLocal,
284  autoPtr<mapDistribute>& pointMap
285  );
286 
287  //- WIP. Store element-wise field.
288  virtual void setField(const labelList& values);
289 
290  //- WIP. From a set of hits (points and
291  // indices) get the specified field. Misses do not get set. Return
292  // empty field if not supported.
293  virtual void getField(const List<pointIndexHit>&, labelList&) const;
294 
295  // regIOobject implementation
296 
297  bool writeData(Ostream&) const
298  {
300  return false;
301  }
302 };
303 
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 } // End namespace Foam
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #endif
312 
313 // ************************************************************************* //
Foam::searchableSurfaceCollection::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableSurfaceCollection.C:606
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::searchableSurfaceCollection::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type (below)
Definition: searchableSurfaceCollection.H:197
UPtrList.H
Foam::searchableSurfaceCollection::TypeName
TypeName("searchableSurfaceCollection")
Runtime type information.
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
searchableSurface.H
Foam::searchableSurfaceCollection::scale
const vectorField & scale() const
Scaling vector per subsurface.
Definition: searchableSurfaceCollection.H:170
Foam::searchableSurfaceCollection::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
Definition: searchableSurfaceCollection.C:714
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::searchableSurfaceCollection::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Definition: searchableSurfaceCollection.C:470
Foam::searchableSurfaceCollection::~searchableSurfaceCollection
virtual ~searchableSurfaceCollection()
Destructor.
Definition: searchableSurfaceCollection.C:299
Foam::searchableSurfaceCollection::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableSurfaceCollection.C:411
Foam::searchableSurfaceCollection::distribute
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.
Definition: searchableSurfaceCollection.C:726
Foam::searchableSurfaceCollection::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableSurfaceCollection.C:305
cartesianCS.H
Foam::searchableSurfaceCollection::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableSurfaceCollection.C:671
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:689
Foam::searchableSurfaceCollection::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableSurfaceCollection.C:374
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::searchableSurfaceCollection::transform
const PtrList< coordSystem::cartesian > & transform() const
Coordinate system per subsurface.
Definition: searchableSurfaceCollection.H:182
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::searchableSurfaceCollection::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
Definition: searchableSurfaceCollection.C:579
Foam::searchableSurfaceCollection::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableSurfaceCollection.C:337
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
treeBoundBox.H
Foam::volumeType::UNKNOWN
Unknown state.
Definition: volumeType.H:67
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::searchableSurfaceCollection::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableSurfaceCollection.C:344
Foam::searchableSurfaceCollection::getField
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Definition: searchableSurfaceCollection.C:777
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:62
Foam::searchableSurfaceCollection::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: searchableSurfaceCollection.C:567
Foam::searchableSurfaceCollection
Set of transformed searchableSurfaces. Does not do boolean operations so when meshing might find part...
Definition: searchableSurfaceCollection.H:80
samples
scalarField samples(nIntervals, Zero)
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::searchableSurfaceCollection::scale
vectorField & scale()
Scaling vector per subsurface.
Definition: searchableSurfaceCollection.H:176
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Foam::searchableSurfaceCollection::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableSurfaceCollection.H:203
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::searchableSurfaceCollection::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableSurfaceCollection.H:311
Foam::List< word >
Foam::searchableSurfaceCollection::transform
PtrList< coordSystem::cartesian > & transform()
Coordinate system per subsurface.
Definition: searchableSurfaceCollection.H:188
Foam::searchableSurfaceCollection::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableSurfaceCollection.H:227
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::searchableSurfaceCollection::setField
virtual void setField(const labelList &values)
WIP. Store element-wise field.
Definition: searchableSurfaceCollection.C:756
sample
Minimal example by using system/controlDict.functions: