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 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 | searchableSurfaceCollection | selector |
38  mergeSubRegions | boolean | yes |
39  \endtable
40 
41 SourceFiles
42  searchableSurfaceCollection.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef searchableSurfaceCollection_H
47 #define searchableSurfaceCollection_H
48 
49 #include "searchableSurface.H"
50 #include "treeBoundBox.H"
51 #include "cartesianCS.H"
52 #include "UPtrList.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class searchableSurfaceCollection Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class searchableSurfaceCollection
64 :
65  public searchableSurface
66 {
67  // Private Member Data
68 
69  // Per instance data
70 
71  //- Instance name
72  wordList instance_;
73 
74  //- Scaling vector
75  vectorField scale_;
76 
77  //- Coordinate transformation
79 
81 
82  bool mergeSubRegions_;
83 
84  //- Offsets for indices coming from different surfaces
85  // (sized with size() of each surface)
86  labelList indexOffset_;
87 
88  //- Names of regions
89  mutable wordList regions_;
90 
91  //- From individual regions to collection regions
92  mutable labelList regionOffset_;
93 
94 
95  // Private Member Functions
96 
97  //- Inherit findNearest from searchableSurface
99 
100  //- Find point nearest to sample. Updates minDistSqr. Sets nearestInfo
101  // and surface index
102  void findNearest
103  (
104  const pointField& samples,
105  scalarField& minDistSqr,
106  List<pointIndexHit>& nearestInfo,
107  labelList& nearestSurf
108  ) const;
109 
110  //- Sort hits into per-surface bins. Misses are rejected.
111  // Maintains map back to position
112  void sortHits
113  (
114  const List<pointIndexHit>& info,
115  List<List<pointIndexHit>>& surfInfo,
116  labelListList& infoMap
117  ) const;
118 
119 
120  //- No copy construct
122  (
124  ) = delete;
125 
126  //- No copy assignment
127  void operator=(const searchableSurfaceCollection&) = delete;
128 
129 
130 public:
131 
132  //- Runtime type information
133  TypeName("searchableSurfaceCollection");
134 
135 
136  // Constructors
137 
138  //- Construct from dictionary (used by searchableSurface)
140  (
141  const IOobject& io,
142  const dictionary& dict
143  );
144 
145 
146  //- Destructor
148 
149 
150  // Member Functions
151 
152  //- Scaling vector per subsurface
153  const vectorField& scale() const
154  {
155  return scale_;
156  }
157 
158  //- Scaling vector per subsurface
159  vectorField& scale()
160  {
161  return scale_;
162  }
163 
164  //- Coordinate system per subsurface
165  const PtrList<coordSystem::cartesian>& transform() const
166  {
167  return transform_;
168  }
169 
170  //- Coordinate system per subsurface
172  {
173  return transform_;
174  }
175 
176  //- Names of regions
177  virtual const wordList& regions() const;
178 
179  //- Whether supports volume type (below)
180  virtual bool hasVolumeType() const
181  {
182  return false;
183  }
184 
185  //- What is type of points outside bounds
186  virtual volumeType outsideVolumeType() const
187  {
188  return volumeType::UNKNOWN;
189  }
190 
191  //- Range of local indices that can be returned.
192  virtual label size() const;
193 
194  //- Get representative set of element coordinates
195  // Usually the element centres (should be of length size()).
196  virtual tmp<pointField> coordinates() const;
197 
198  //- Get bounding spheres (centre and radius squared), one per element.
199  // Any point on element is guaranteed to be inside.
200  virtual void boundingSpheres
201  (
202  pointField& centres,
203  scalarField& radiusSqr
204  ) const;
205 
206  //- Get the points that define the surface.
207  virtual tmp<pointField> points() const;
208 
209  //- Does any part of the surface overlap the supplied bound box?
210  virtual bool overlaps(const boundBox& bb) const
211  {
213  return false;
214  }
215 
216 
217  // Multiple point queries.
218 
219  virtual void findNearest
220  (
221  const pointField& sample,
222  const scalarField& nearestDistSqr,
224  ) const;
225 
226  virtual void findLine
227  (
228  const pointField& start,
229  const pointField& end,
231  ) const;
232 
233  virtual void findLineAny
234  (
235  const pointField& start,
236  const pointField& end,
238  ) const;
239 
240  //- Get all intersections in order from start to end.
241  virtual void findLineAll
242  (
243  const pointField& start,
244  const pointField& end,
246  ) const;
247 
248  //- From a set of points and indices get the region
249  virtual void getRegion
250  (
251  const List<pointIndexHit>&,
252  labelList& region
253  ) const;
254 
255  //- From a set of points and indices get the normal
256  virtual void getNormal
257  (
258  const List<pointIndexHit>&,
259  vectorField& normal
260  ) const;
261 
262  //- Determine type (inside/outside/mixed) for point.
263  // Unknown if cannot be determined (e.g. non-manifold surface)
264  virtual void getVolumeType
265  (
266  const pointField& points,
267  List<volumeType>& volType
268  ) const;
269 
270  // Other
271 
272  //- Set bounds of surface. Bounds currently set as list of
273  // bounding boxes. The bounds are hints to the surface as for
274  // the range of queries it can expect. faceMap/pointMap can be
275  // set if the surface has done any redistribution.
276  virtual void distribute
277  (
278  const List<treeBoundBox>&,
279  const bool keepNonLocal,
281  autoPtr<mapDistribute>& pointMap
282  );
283 
284  //- WIP. Store element-wise field.
285  virtual void setField(const labelList& values);
286 
287  //- WIP. From a set of hits (points and
288  // indices) get the specified field. Misses do not get set. Return
289  // empty field if not supported.
290  virtual void getField(const List<pointIndexHit>&, labelList&) const;
291 
292  // regIOobject implementation
293 
294  bool writeData(Ostream&) const
295  {
297  return false;
298  }
299 };
300 
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 } // End namespace Foam
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #endif
309 
310 // ************************************************************************* //
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:600
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::searchableSurfaceCollection::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type (below)
Definition: searchableSurfaceCollection.H:194
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:167
Foam::searchableSurfaceCollection::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
Definition: searchableSurfaceCollection.C:708
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
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:464
Foam::searchableSurfaceCollection::~searchableSurfaceCollection
virtual ~searchableSurfaceCollection()
Destructor.
Definition: searchableSurfaceCollection.C:293
Foam::searchableSurfaceCollection::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableSurfaceCollection.C:405
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:720
Foam::searchableSurfaceCollection::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableSurfaceCollection.C:299
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:665
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:532
Foam::searchableSurfaceCollection::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableSurfaceCollection.C:368
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:179
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
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:573
Foam::searchableSurfaceCollection::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableSurfaceCollection.C:331
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
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:338
Foam::searchableSurfaceCollection::getField
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Definition: searchableSurfaceCollection.C:771
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:63
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:561
Foam::searchableSurfaceCollection
Set of transformed searchableSurfaces. Does not do boolean operations so when meshing might find part...
Definition: searchableSurfaceCollection.H:77
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:62
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:121
Foam::searchableSurfaceCollection::scale
vectorField & scale()
Scaling vector per subsurface.
Definition: searchableSurfaceCollection.H:173
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:200
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:308
Foam::List< word >
Foam::searchableSurfaceCollection::transform
PtrList< coordSystem::cartesian > & transform()
Coordinate system per subsurface.
Definition: searchableSurfaceCollection.H:185
Foam::searchableSurfaceCollection::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableSurfaceCollection.H:224
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:750