initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / searchableSurface / searchableSurfaceWithGaps.H
blob312c74b1d77b66ce6cb4bff37b6ccbac15068b2e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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         }
155         // Multiple point queries.
157             //- Find nearest on original surface. Note:does not use perturbation
158             //  and hence might be inconsistent with intersections.
159             virtual void findNearest
160             (
161                 const pointField& sample,
162                 const scalarField& nearestDistSqr,
163                 List<pointIndexHit>& info
164             ) const
165             {
166                 surface().findNearest
167                 (
168                     sample,
169                     nearestDistSqr,
170                     info
171                 );
172             }
174             virtual void findLine
175             (
176                 const pointField& start,
177                 const pointField& end,
178                 List<pointIndexHit>&
179             ) const;
181             virtual void findLineAny
182             (
183                 const pointField& start,
184                 const pointField& end,
185                 List<pointIndexHit>&
186             ) const;
188             //- Get all intersections in order from start to end.
189             virtual void findLineAll
190             (
191                 const pointField& start,
192                 const pointField& end,
193                 List<List<pointIndexHit> >&
194             ) const;
196             //- From a set of points and indices get the region
197             virtual void getRegion
198             (
199                 const List<pointIndexHit>& info,
200                 labelList& region
201             ) const
202             {
203                 surface().getRegion(info, region);
204             }
206             //- From a set of points and indices get the normal
207             virtual void getNormal
208             (
209                 const List<pointIndexHit>& info,
210                 vectorField& normal
211             ) const
212             {
213                 surface().getNormal(info, normal);
214             }
216             //- Determine type (inside/outside/mixed) for point. unknown if
217             //  cannot be determined (e.g. non-manifold surface)
218             virtual void getVolumeType
219             (
220                 const pointField& samples,
221                 List<volumeType>& info
222             ) const
223             {
224                 surface().getVolumeType(samples, info);
225             }
228         // regIOobject implementation
230             bool writeData(Ostream& os) const
231             {
232                 return surface().writeData(os);
233             }
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 } // End namespace Foam
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 #endif
246 // ************************************************************************* //