FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/UPtrList.H>
47 #include <OpenFOAM/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 meter
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  (
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 
125  virtual ~searchableSurfaceWithGaps();
126 
127 
128  // Member Functions
129 
130  const searchableSurface& surface() const
131  {
132  return subGeom_[0];
133  }
134 
135 
136  virtual const wordList& regions() const
137  {
138  return surface().regions();
139  }
140 
141  //- Whether supports volume type below
142  virtual bool hasVolumeType() const
143  {
144  return surface().hasVolumeType();
145  }
146 
147  //- Range of local indices that can be returned.
148  virtual label size() const
149  {
150  return surface().size();
151  }
152 
153  //- Get representative set of element coordinates
154  // Usually the element centres (should be of length size()).
155  virtual pointField coordinates() const
156  {
157  return surface().coordinates();
158  }
159 
160 
161  // Multiple point queries.
162 
163  //- Find nearest on original surface. Note:does not use perturbation
164  // and hence might be inconsistent with intersections.
165  virtual void findNearest
166  (
167  const pointField& sample,
168  const scalarField& nearestDistSqr,
169  List<pointIndexHit>& info
170  ) const
171  {
173  (
174  sample,
175  nearestDistSqr,
176  info
177  );
178  }
179 
180  virtual void findLine
181  (
182  const pointField& start,
183  const pointField& end,
185  ) const;
186 
187  virtual void findLineAny
188  (
189  const pointField& start,
190  const pointField& end,
192  ) const;
193 
194  //- Get all intersections in order from start to end.
195  virtual void findLineAll
196  (
197  const pointField& start,
198  const pointField& end,
200  ) const;
201 
202  //- From a set of points and indices get the region
203  virtual void getRegion
204  (
205  const List<pointIndexHit>& info,
206  labelList& region
207  ) const
208  {
209  surface().getRegion(info, region);
210  }
211 
212  //- From a set of points and indices get the normal
213  virtual void getNormal
214  (
215  const List<pointIndexHit>& info,
217  ) const
218  {
219  surface().getNormal(info, normal);
220  }
221 
222  //- Determine type (inside/outside/mixed) for point. unknown if
223  // cannot be determined (e.g. non-manifold surface)
224  virtual void getVolumeType
225  (
226  const pointField& samples,
227  List<volumeType>& info
228  ) const
229  {
230  surface().getVolumeType(samples, info);
231  }
232 
233 
234  // Other
235 
236  //- Set bounds of surface. Bounds currently set as list of
237  // bounding boxes. The bounds are hints to the surface as for
238  // the range of queries it can expect. faceMap/pointMap can be
239  // set if the surface has done any redistribution.
240  virtual void distribute
241  (
242  const List<treeBoundBox>& bbs,
243  const bool keepNonLocal,
244  autoPtr<mapDistribute>& faceMap,
245  autoPtr<mapDistribute>& pointMap
246  )
247  {
248  subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
249  }
250 
251  //- WIP. Store element-wise field.
252  virtual void setField(const labelList& values)
253  {
254  subGeom_[0].setField(values);
255  }
256 
257  //- WIP. From a set of hits (points and
258  // indices) get the specified field. Misses do not get set. Return
259  // empty field if not supported.
260  virtual void getField
261  (
262  const List<pointIndexHit>& info,
263  labelList& values
264  ) const
265  {
266  surface().getField(info, values);
267  }
268 
269  // regIOobject implementation
270 
271  bool writeData(Ostream& os) const
272  {
273  return surface().writeData(os);
274  }
275 
276 };
277 
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 } // End namespace Foam
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************ vim: set sw=4 sts=4 et: ************************ //