searchableSurfaceWithGaps.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-2016 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::searchableSurfaceWithGaps
26 
27 Description
28  searchableSurface using multiple slightly shifted underlying surfaces
29  to make sure pierces don't go through gaps:
30  - shift test vector with two small vectors (of size gap_) perpendicular
31  to the original.
32  Test with + and - this vector. Only if both register a hit is it seen
33  as one.
34  - extend the test vector slightly (with SMALL) to account for numerical
35  inaccuracies.
36 
37 SourceFiles
38  searchableSurfaceWithGaps.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef searchableSurfaceWithGaps_H
43 #define searchableSurfaceWithGaps_H
44 
45 #include "searchableSurface.H"
46 #include "UPtrList.H"
47 #include "Pair.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of classes
55 
56 /*---------------------------------------------------------------------------*\
57  Class searchableSurfaceWithGaps Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public searchableSurface
63 {
64 private:
65 
66  // Private Member Data
67 
68  //- Gap size in metre
69  const scalar gap_;
70 
71  //- Underlying geometry (size 1)
73 
74 
75  // Private Member Functions
76 
77  Pair<vector> offsetVecs(const point&, const point&) const;
78 
79  void offsetVecs
80  (
81  const pointField& start,
82  const pointField& end,
83  pointField& offset0,
84  pointField& offset1
85  ) const;
86 
87  static label countMisses
88  (
89  const List<pointIndexHit>& info,
90  labelList& missMap
91  );
92 
93  static label countMisses
94  (
95  const List<pointIndexHit>& plusInfo,
96  const List<pointIndexHit>& minInfo,
97  labelList& missMap
98  );
99 
100 
101  //- Disallow default bitwise copy construct
103 
104  //- Disallow default bitwise assignment
105  void operator=(const searchableSurfaceWithGaps&);
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("searchableSurfaceWithGaps");
112 
113 
114  // Constructors
115 
116  //- Construct from dictionary (used by searchableSurface)
118  (
119  const IOobject& io,
120  const dictionary& dict
121  );
122 
123  //- Destructor
124  virtual ~searchableSurfaceWithGaps();
125 
126 
127  // Member Functions
129  const searchableSurface& surface() const
130  {
131  return subGeom_[0];
132  }
133 
135  virtual const wordList& regions() const
136  {
137  return surface().regions();
138  }
139 
140  //- Whether supports volume type below
141  virtual bool hasVolumeType() const
142  {
143  return surface().hasVolumeType();
144  }
145 
146  //- Range of local indices that can be returned.
147  virtual label size() const
148  {
149  return surface().size();
150  }
151 
152  //- Get representative set of element coordinates
153  // Usually the element centres (should be of length size()).
154  virtual tmp<pointField> coordinates() const
155  {
156  return surface().coordinates();
157  }
158 
159  //- Get bounding spheres (centre and radius squared), one per element.
160  // Any point on element is guaranteed to be inside.
161  virtual void boundingSpheres
162  (
163  pointField& centres,
164  scalarField& radiusSqr
165  ) const
166  {
167  surface().boundingSpheres(centres, radiusSqr);
168  }
169 
170  //- Get the points that define the surface.
171  virtual tmp<pointField> points() const
172  {
173  return surface().points();
174  }
175 
176  //- Does any part of the surface overlap the supplied bound box?
177  // Note: use perturbed surface? Since uses boundbox of points and
178  // not actual intersection chosen to use unperturbed surface.
179  virtual bool overlaps(const boundBox& bb) const
180  {
181  return surface().overlaps(bb);
182  }
183 
184 
185  // Multiple point queries.
186 
187  //- Find nearest on original surface. Note:does not use perturbation
188  // and hence might be inconsistent with intersections.
189  virtual void findNearest
190  (
191  const pointField& sample,
192  const scalarField& nearestDistSqr,
193  List<pointIndexHit>& info
194  ) const
195  {
197  (
198  sample,
199  nearestDistSqr,
200  info
201  );
202  }
203 
204  virtual void findLine
205  (
206  const pointField& start,
207  const pointField& end,
209  ) const;
210 
211  virtual void findLineAny
212  (
213  const pointField& start,
214  const pointField& end,
216  ) const;
217 
218  //- Get all intersections in order from start to end.
219  virtual void findLineAll
220  (
221  const pointField& start,
222  const pointField& end,
224  ) const;
225 
226  //- From a set of points and indices get the region
227  virtual void getRegion
228  (
229  const List<pointIndexHit>& info,
230  labelList& region
231  ) const
232  {
233  surface().getRegion(info, region);
234  }
235 
236  //- From a set of points and indices get the normal
237  virtual void getNormal
238  (
239  const List<pointIndexHit>& info,
240  vectorField& normal
241  ) const
242  {
243  surface().getNormal(info, normal);
244  }
245 
246  //- Determine type (inside/outside/mixed) for point. unknown if
247  // cannot be determined (e.g. non-manifold surface)
248  virtual void getVolumeType
249  (
250  const pointField& samples,
251  List<volumeType>& info
252  ) const
253  {
254  surface().getVolumeType(samples, info);
255  }
256 
257 
258  // Other
259 
260  //- Set bounds of surface. Bounds currently set as list of
261  // bounding boxes. The bounds are hints to the surface as for
262  // the range of queries it can expect. faceMap/pointMap can be
263  // set if the surface has done any redistribution.
264  //virtual void distribute
265  //(
266  // const List<treeBoundBox>& bbs,
267  // const bool keepNonLocal,
268  // autoPtr<mapDistribute>& faceMap,
269  // autoPtr<mapDistribute>& pointMap
270  //)
271  //{
272  // subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
273  //}
274 
275  //- WIP. Store element-wise field.
276  virtual void setField(const labelList& values)
277  {
278  subGeom_[0].setField(values);
279  }
280 
281  //- WIP. From a set of hits (points and
282  // indices) get the specified field. Misses do not get set. Return
283  // empty field if not supported.
284  virtual void getField
285  (
286  const List<pointIndexHit>& info,
287  labelList& values
288  ) const
289  {
290  surface().getField(info, values);
291  }
292 
293  // regIOobject implementation
295  bool writeData(Ostream& os) const
296  {
297  return surface().writeData(os);
298  }
299 
300 };
301 
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace Foam
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #endif
310 
311 // ************************************************************************* //
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
searchableSurface using multiple slightly shifted underlying surfaces to make sure pierces don&#39;t go t...
bool writeData(Ostream &os) const
Pure virtual writaData function.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual const wordList & regions() const =0
Names of regions.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual tmp< pointField > coordinates() const =0
Get representative set of element coordinates.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual const wordList & regions() const
Names of regions.
virtual void getField(const List< pointIndexHit > &info, labelList &values) const
WIP. From a set of hits (points and.
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
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:58
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual void setField(const labelList &values)
Set bounds of surface. Bounds currently set as list of.
TypeName("searchableSurfaceWithGaps")
Runtime type information.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Find nearest on original surface. Note:does not use perturbation.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
scalarField samples(nIntervals, 0)
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual bool overlaps(const boundBox &bb) const =0
Does any part of the surface overlap the supplied bound box?
virtual label size() const
Range of local indices that can be returned.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
virtual void getNormal(const List< pointIndexHit > &info, vectorField &normal) const
From a set of points and indices get the normal.
const searchableSurface & surface() const
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:53
virtual bool hasVolumeType() const
Whether supports volume type below.
virtual tmp< pointField > points() const =0
Get the points that define the surface.
virtual ~searchableSurfaceWithGaps()
Destructor.
virtual void getRegion(const List< pointIndexHit > &info, labelList &region) const
From a set of points and indices get the region.
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point. unknown if.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const =0
From a set of points and indices get the region.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual label size() const =0
Range of local indices that can be returned.
A class for managing temporary objects.
Definition: PtrList.H:54
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
virtual void getVolumeType(const pointField &samples, List< volumeType > &info) const
Determine type (inside/outside/mixed) for point. unknown if.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual bool hasVolumeType() const =0
Whether supports volume type below.
Namespace for OpenFOAM.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.