searchableSurfaceWithGaps.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-2020 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 Member Data
65 
66  //- Gap size in metre
67  const scalar gap_;
68 
69  //- Underlying geometry (size 1)
71 
72 
73  // Private Member Functions
74 
75  Pair<vector> offsetVecs(const point&, const point&) const;
76 
77  void offsetVecs
78  (
79  const pointField& start,
80  const pointField& end,
81  pointField& offset0,
82  pointField& offset1
83  ) const;
84 
85  static label countMisses
86  (
87  const List<pointIndexHit>& info,
88  labelList& missMap
89  );
90 
91  static label countMisses
92  (
93  const List<pointIndexHit>& plusInfo,
94  const List<pointIndexHit>& minInfo,
95  labelList& missMap
96  );
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("searchableSurfaceWithGaps");
103 
104 
105  // Constructors
106 
107  //- Construct from dictionary (used by searchableSurface)
109  (
110  const IOobject& io,
111  const dictionary& dict
112  );
113 
114  //- Disallow default bitwise copy construction
116 
117 
118  //- Destructor
119  virtual ~searchableSurfaceWithGaps();
120 
121 
122  // Member Functions
124  const searchableSurface& surface() const
125  {
126  return subGeom_[0];
127  }
128 
130  virtual const wordList& regions() const
131  {
132  return surface().regions();
133  }
134 
135  //- Whether supports volume type below
136  virtual bool hasVolumeType() const
137  {
138  return surface().hasVolumeType();
139  }
140 
141  //- Range of local indices that can be returned.
142  virtual label size() const
143  {
144  return surface().size();
145  }
146 
147  //- Get representative set of element coordinates
148  // Usually the element centres (should be of length size()).
149  virtual tmp<pointField> coordinates() const
150  {
151  return surface().coordinates();
152  }
153 
154  //- Get bounding spheres (centre and radius squared), one per element.
155  // Any point on element is guaranteed to be inside.
156  virtual void boundingSpheres
157  (
158  pointField& centres,
159  scalarField& radiusSqr
160  ) const
161  {
162  surface().boundingSpheres(centres, radiusSqr);
163  }
164 
165  //- Get the points that define the surface.
166  virtual tmp<pointField> points() const
167  {
168  return surface().points();
169  }
170 
171  //- Does any part of the surface overlap the supplied bound box?
172  // Note: use perturbed surface? Since uses boundbox of points and
173  // not actual intersection chosen to use unperturbed surface.
174  virtual bool overlaps(const boundBox& bb) const
175  {
176  return surface().overlaps(bb);
177  }
178 
179 
180  // Multiple point queries.
181 
182  //- Find nearest on original surface. Note:does not use perturbation
183  // and hence might be inconsistent with intersections.
184  virtual void findNearest
185  (
186  const pointField& sample,
187  const scalarField& nearestDistSqr,
188  List<pointIndexHit>& info
189  ) const
190  {
192  (
193  sample,
194  nearestDistSqr,
195  info
196  );
197  }
198 
199  virtual void findLine
200  (
201  const pointField& start,
202  const pointField& end,
204  ) const;
205 
206  virtual void findLineAny
207  (
208  const pointField& start,
209  const pointField& end,
211  ) const;
212 
213  //- Get all intersections in order from start to end.
214  virtual void findLineAll
215  (
216  const pointField& start,
217  const pointField& end,
219  ) const;
220 
221  //- From a set of points and indices get the region
222  virtual void getRegion
223  (
224  const List<pointIndexHit>& info,
225  labelList& region
226  ) const
227  {
228  surface().getRegion(info, region);
229  }
230 
231  //- From a set of points and indices get the normal
232  virtual void getNormal
233  (
234  const List<pointIndexHit>& info,
235  vectorField& normal
236  ) const
237  {
238  surface().getNormal(info, normal);
239  }
240 
241  //- Determine type (inside/outside/mixed) for point. unknown if
242  // cannot be determined (e.g. non-manifold surface)
243  virtual void getVolumeType
244  (
245  const pointField& samples,
246  List<volumeType>& info
247  ) const
248  {
249  surface().getVolumeType(samples, info);
250  }
251 
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>& bbs,
262  // const bool keepNonLocal,
263  // autoPtr<mapDistribute>& faceMap,
264  // autoPtr<mapDistribute>& pointMap
265  //)
266  //{
267  // subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
268  //}
269 
270  //- WIP. Store element-wise field.
271  virtual void setField(const labelList& values)
272  {
273  subGeom_[0].setField(values);
274  }
275 
276  //- WIP. From a set of hits (points and
277  // indices) get the specified field. Misses do not get set. Return
278  // empty field if not supported.
279  virtual void getField
280  (
281  const List<pointIndexHit>& info,
282  labelList& values
283  ) const
284  {
285  surface().getField(info, values);
286  }
287 
288  // regIOobject implementation
290  bool writeData(Ostream& os) const
291  {
292  return surface().writeData(os);
293  }
294 
295 
296  // Member Operators
297 
298  //- Disallow default bitwise assignment
299  void operator=(const searchableSurfaceWithGaps&) = delete;
300 };
301 
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace Foam
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #endif
310 
311 // ************************************************************************* //
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
searchableSurfaceWithGaps(const IOobject &io, const dictionary &dict)
Construct from dictionary (used by searchableSurface)
virtual bool hasVolumeType() const
Whether supports volume type below.
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...
virtual const wordList & regions() const =0
Names of regions.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
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:156
virtual const wordList & regions() const
Names of regions.
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
virtual void getRegion(const List< pointIndexHit > &info, labelList &region) const
From a set of points and indices get the region.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
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 getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
const searchableSurface & surface() const
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 void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Find nearest on original surface. Note:does not use perturbation.
virtual label size() const
Range of local indices that can be returned.
virtual void getField(const List< pointIndexHit > &info, labelList &values) const
WIP. From a set of hits (points and.
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:54
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual tmp< pointField > points() const =0
Get the points that define the surface.
virtual void getVolumeType(const pointField &samples, List< volumeType > &info) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual ~searchableSurfaceWithGaps()
Destructor.
virtual void getNormal(const List< pointIndexHit > &info, vectorField &normal) const
From a set of points and indices get the normal.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
void operator=(const searchableSurfaceWithGaps &)=delete
Disallow default bitwise assignment.
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 label size() const =0
Range of local indices that can be returned.
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
virtual bool hasVolumeType() const =0
Whether supports volume type below.
bool writeData(Ostream &os) const
Pure virtual writaData function.
Namespace for OpenFOAM.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.