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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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:
59 
60  // Private Member Data
61 
62  // Per instance data
63 
64  //- Instance name
66 
67  //- Scaling vector
69 
70  //- transformation
72 
74 
76 
77  //- Offsets for indices coming from different surfaces
78  // (sized with size() of each surface)
80 
81  //- Region names
82  mutable wordList regions_;
83  //- From individual regions to collection regions
84  mutable labelList regionOffset_;
85 
86 
87  // Private Member Functions
88 
89  //- Inherit findNearest from searchableSurface
91 
92  //- Find point nearest to sample. Updates minDistSqr. Sets nearestInfo
93  // and surface index
94  void findNearest
95  (
96  const pointField& samples,
97  scalarField& minDistSqr,
98  List<pointIndexHit>& nearestInfo,
99  labelList& nearestSurf
100  ) const;
101 
102  //- Sort hits into per-surface bins. Misses are rejected.
103  // Maintains map back to position
104  void sortHits
105  (
106  const List<pointIndexHit>& info,
107  List<List<pointIndexHit> >& surfInfo,
108  labelListList& infoMap
109  ) const;
110 
111 
112  //- Disallow default bitwise copy construct
114 
115  //- Disallow default bitwise assignment
117 
118 
119 public:
120 
121  //- Runtime type information
122  TypeName("searchableSurfaceCollection");
123 
124 
125  // Constructors
126 
127  //- Construct from dictionary (used by searchableSurface)
129  (
130  const IOobject& io,
131  const dictionary& dict
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 
165  virtual const wordList& regions() const;
166 
167  //- Whether supports volume type below
168  virtual bool hasVolumeType() const
169  {
170  return false;
171  }
172 
173  //- Range of local indices that can be returned.
174  virtual label size() const;
175 
176  //- Get representative set of element coordinates
177  // Usually the element centres (should be of length size()).
178  virtual tmp<pointField> coordinates() const;
179 
180  //- Get bounding spheres (centre and radius squared), one per element.
181  // Any point on element is guaranteed to be inside.
182  virtual void boundingSpheres
183  (
184  pointField& centres,
185  scalarField& radiusSqr
186  ) const;
187 
188  //- Get the points that define the surface.
189  virtual tmp<pointField> points() const;
190 
191  //- Does any part of the surface overlap the supplied bound box?
192  virtual bool overlaps(const boundBox& bb) const
193  {
195 
196  return false;
197  }
198 
199 
200  // Multiple point queries.
201 
202  virtual void findNearest
203  (
204  const pointField& sample,
205  const scalarField& nearestDistSqr,
207  ) const;
208 
209  virtual void findLine
210  (
211  const pointField& start,
212  const pointField& end,
214  ) const;
215 
216  virtual void findLineAny
217  (
218  const pointField& start,
219  const pointField& end,
221  ) const;
222 
223  //- Get all intersections in order from start to end.
224  virtual void findLineAll
225  (
226  const pointField& start,
227  const pointField& end,
229  ) const;
230 
231  //- From a set of points and indices get the region
232  virtual void getRegion
233  (
234  const List<pointIndexHit>&,
235  labelList& region
236  ) const;
237 
238  //- From a set of points and indices get the normal
239  virtual void getNormal
240  (
241  const List<pointIndexHit>&,
243  ) const;
244 
245  //- Determine type (inside/outside/mixed) for point. unknown if
246  // cannot be determined (e.g. non-manifold surface)
247  virtual void getVolumeType
248  (
249  const pointField&,
251  ) const;
252 
253  // Other
254 
255  //- Set bounds of surface. Bounds currently set as list of
256  // bounding boxes. The bounds are hints to the surface as for
257  // the range of queries it can expect. faceMap/pointMap can be
258  // set if the surface has done any redistribution.
259  virtual void distribute
260  (
261  const List<treeBoundBox>&,
262  const bool keepNonLocal,
264  autoPtr<mapDistribute>& pointMap
265  );
266 
267  //- WIP. Store element-wise field.
268  virtual void setField(const labelList& values);
269 
270  //- WIP. From a set of hits (points and
271  // indices) get the specified field. Misses do not get set. Return
272  // empty field if not supported.
273  virtual void getField(const List<pointIndexHit>&, labelList&) const;
274 
275  // regIOobject implementation
276 
277  bool writeData(Ostream&) const
278  {
280  return false;
281  }
282 
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #endif
293 
294 // ************************************************************************* //
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:587
Foam::searchableSurfaceCollection::sortHits
void sortHits(const List< pointIndexHit > &info, List< List< pointIndexHit > > &surfInfo, labelListList &infoMap) const
Sort hits into per-surface bins. Misses are rejected.
Definition: searchableSurfaceCollection.C:119
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::searchableSurfaceCollection::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableSurfaceCollection.H:167
UPtrList.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::searchableSurfaceCollection::TypeName
TypeName("searchableSurfaceCollection")
Runtime type information.
Foam::searchableSurfaceCollection::transform
const PtrList< coordinateSystem > & transform() const
Coordinate system per subsurface.
Definition: searchableSurfaceCollection.H:152
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
Foam::searchableSurfaceCollection::subGeom_
UPtrList< searchableSurface > subGeom_
Definition: searchableSurfaceCollection.H:72
searchableSurface.H
Foam::searchableSurfaceCollection::searchableSurfaceCollection
searchableSurfaceCollection(const searchableSurfaceCollection &)
Disallow default bitwise copy construct.
Foam::searchableSurfaceCollection::scale
const vectorField & scale() const
Scaling vector per subsurface.
Definition: searchableSurfaceCollection.H:140
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
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:451
Foam::searchableSurfaceCollection::~searchableSurfaceCollection
virtual ~searchableSurfaceCollection()
Destructor.
Definition: searchableSurfaceCollection.C:280
Foam::searchableSurfaceCollection::indexOffset_
labelList indexOffset_
Offsets for indices coming from different surfaces.
Definition: searchableSurfaceCollection.H:78
Foam::searchableSurfaceCollection::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableSurfaceCollection.C:392
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:707
Foam::searchableSurfaceCollection::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableSurfaceCollection.C:286
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:652
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:434
coordinateSystem.H
Foam::searchableSurfaceCollection::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableSurfaceCollection.C:355
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:560
Foam::searchableSurfaceCollection::regionOffset_
labelList regionOffset_
From individual regions to collection regions.
Definition: searchableSurfaceCollection.H:83
Foam::searchableSurfaceCollection::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableSurfaceCollection.C:318
samples
scalarField samples(nIntervals, 0)
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
treeBoundBox.H
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
Foam::searchableSurfaceCollection::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableSurfaceCollection.C:325
Foam::searchableSurfaceCollection::getField
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Definition: searchableSurfaceCollection.C:761
Switch.H
Foam::UPtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:53
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:548
Foam::searchableSurfaceCollection
Set of transformed searchableSurfaces. Does not do boolean operations so when meshing might find part...
Definition: searchableSurfaceCollection.H:53
Foam::searchableSurfaceCollection::findNearest
void findNearest(const pointField &samples, scalarField &minDistSqr, List< pointIndexHit > &nearestInfo, labelList &nearestSurf) const
Find point nearest to sample. Updates minDistSqr. Sets nearestInfo.
Definition: searchableSurfaceCollection.C:51
Foam::PtrList< coordinateSystem >
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::searchableSurfaceCollection::scale
vectorField & scale()
Scaling vector per subsurface.
Definition: searchableSurfaceCollection.H:146
Foam::searchableSurfaceCollection::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: searchableSurfaceCollection.C:695
Foam::searchableSurfaceCollection::operator=
void operator=(const searchableSurfaceCollection &)
Disallow default bitwise assignment.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::searchableSurfaceCollection::mergeSubRegions_
Switch mergeSubRegions_
Definition: searchableSurfaceCollection.H:74
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Foam::searchableSurfaceCollection::transform
PtrList< coordinateSystem > & transform()
Coordinate system per subsurface.
Definition: searchableSurfaceCollection.H:158
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::searchableSurfaceCollection::transform_
PtrList< coordinateSystem > transform_
transformation
Definition: searchableSurfaceCollection.H:70
Foam::searchableSurfaceCollection::writeData
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: searchableSurfaceCollection.H:276
Foam::searchableSurfaceCollection::scale_
vectorField scale_
Scaling vector.
Definition: searchableSurfaceCollection.H:67
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::searchableSurfaceCollection::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableSurfaceCollection.H:191
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::searchableSurfaceCollection::regions_
wordList regions_
Region names.
Definition: searchableSurfaceCollection.H:81
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::searchableSurfaceCollection::instance_
wordList instance_
Instance name.
Definition: searchableSurfaceCollection.H:64
Foam::searchableSurfaceCollection::setField
virtual void setField(const labelList &values)
WIP. Store element-wise field.
Definition: searchableSurfaceCollection.C:740
normal
A normal distribution model.