Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / meshTools / searchableSurface / searchableSurfaceWithGaps.H
blobcc212924e5a9fdd603340c3d1f789bdbae041cf1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::searchableSurfaceWithGaps
28 Description
29     searchableSurface using multiple slightly shifted underlying surfaces
30     to make sure pierces don't go through gaps:
31     - shift test vector with two small vectors (of size gap_) perpendicular
32       to the original.
33       Test with + and - this vector. Only if both register a hit is it seen
34       as one.
35     - extend the test vector slightly (with SMALL) to account for numerical
36       inaccuracies.
38 SourceFiles
39     searchableSurfaceWithGaps.C
41 \*---------------------------------------------------------------------------*/
43 #ifndef searchableSurfaceWithGaps_H
44 #define searchableSurfaceWithGaps_H
46 #include "searchableSurface.H"
47 #include "UPtrList.H"
48 #include "Pair.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 // Forward declaration of classes
57 /*---------------------------------------------------------------------------*\
58                            Class searchableSurfaceWithGaps Declaration
59 \*---------------------------------------------------------------------------*/
61 class searchableSurfaceWithGaps
63     public searchableSurface
65 private:
67     // Private Member Data
69         //- gap size in meter
70         const scalar gap_;
72         //- Underlying geometry (size 1)
73         UPtrList<searchableSurface> subGeom_;
76     // Private Member Functions
78         Pair<vector> offsetVecs(const point&, const point&) const;
80         void offsetVecs
81         (
82             const pointField& start,
83             const pointField& end,
84             pointField& offset0,
85             pointField& offset1
86         ) const;
88         static label countMisses
89         (
90             const List<pointIndexHit>& info,
91             labelList& missMap
92         );
94         static label countMisses
95         (
96             const List<pointIndexHit>& plusInfo,
97             const List<pointIndexHit>& minInfo,
98             labelList& missMap
99         );
102         //- Disallow default bitwise copy construct
103         searchableSurfaceWithGaps(const searchableSurfaceWithGaps&);
105         //- Disallow default bitwise assignment
106         void operator=(const searchableSurfaceWithGaps&);
109 public:
111     //- Runtime type information
112     TypeName("searchableSurfaceWithGaps");
115     // Constructors
117         //- Construct from dictionary (used by searchableSurface)
118         searchableSurfaceWithGaps
119         (
120             const IOobject& io,
121             const dictionary& dict
122         );
124     // Destructor
126         virtual ~searchableSurfaceWithGaps();
129     // Member Functions
131         const searchableSurface& surface() const
132         {
133             return subGeom_[0];
134         }
137         virtual const wordList& regions() const
138         {
139             return surface().regions();
140         }
142         //- Whether supports volume type below
143         virtual bool hasVolumeType() const
144         {
145             return surface().hasVolumeType();
146         }
148         //- Range of local indices that can be returned.
149         virtual label size() const
150         {
151             return surface().size();
152         }
154         //- Get representative set of element coordinates
155         //  Usually the element centres (should be of length size()).
156         virtual pointField coordinates() const
157         {
158             return surface().coordinates();
159         }
162         // Multiple point queries.
164             //- Find nearest on original surface. Note:does not use perturbation
165             //  and hence might be inconsistent with intersections.
166             virtual void findNearest
167             (
168                 const pointField& sample,
169                 const scalarField& nearestDistSqr,
170                 List<pointIndexHit>& info
171             ) const
172             {
173                 surface().findNearest
174                 (
175                     sample,
176                     nearestDistSqr,
177                     info
178                 );
179             }
181             virtual void findLine
182             (
183                 const pointField& start,
184                 const pointField& end,
185                 List<pointIndexHit>&
186             ) const;
188             virtual void findLineAny
189             (
190                 const pointField& start,
191                 const pointField& end,
192                 List<pointIndexHit>&
193             ) const;
195             //- Get all intersections in order from start to end.
196             virtual void findLineAll
197             (
198                 const pointField& start,
199                 const pointField& end,
200                 List<List<pointIndexHit> >&
201             ) const;
203             //- From a set of points and indices get the region
204             virtual void getRegion
205             (
206                 const List<pointIndexHit>& info,
207                 labelList& region
208             ) const
209             {
210                 surface().getRegion(info, region);
211             }
213             //- From a set of points and indices get the normal
214             virtual void getNormal
215             (
216                 const List<pointIndexHit>& info,
217                 vectorField& normal
218             ) const
219             {
220                 surface().getNormal(info, normal);
221             }
223             //- Determine type (inside/outside/mixed) for point. unknown if
224             //  cannot be determined (e.g. non-manifold surface)
225             virtual void getVolumeType
226             (
227                 const pointField& samples,
228                 List<volumeType>& info
229             ) const
230             {
231                 surface().getVolumeType(samples, info);
232             }
235         // Other
237             //- Set bounds of surface. Bounds currently set as list of
238             //  bounding boxes. The bounds are hints to the surface as for
239             //  the range of queries it can expect. faceMap/pointMap can be
240             //  set if the surface has done any redistribution.
241             virtual void distribute
242             (
243                 const List<treeBoundBox>& bbs,
244                 const bool keepNonLocal,
245                 autoPtr<mapDistribute>& faceMap,
246                 autoPtr<mapDistribute>& pointMap
247             )
248             {
249                 subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
250             }
252             //- WIP. Store element-wise field.
253             virtual void setField(const labelList& values)
254             {
255                 subGeom_[0].setField(values);
256             }
258             //- WIP. From a set of hits (points and
259             //  indices) get the specified field. Misses do not get set. Return
260             //  empty field if not supported.
261             virtual void getField
262             (
263                 const List<pointIndexHit>& info,
264                 labelList& values
265             ) const
266             {
267                 surface().getField(info, values);
268             }
270         // regIOobject implementation
272             bool writeData(Ostream& os) const
273             {
274                 return surface().writeData(os);
275             }
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 } // End namespace Foam
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 #endif
288 // ************************************************************************* //