OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

searchableSurfaceWithGaps.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::searchableSurfaceWithGaps
00027 
00028 Description
00029     searchableSurface using multiple slightly shifted underlying surfaces
00030     to make sure pierces don't go through gaps:
00031     - shift test vector with two small vectors (of size gap_) perpendicular
00032       to the original.
00033       Test with + and - this vector. Only if both register a hit is it seen
00034       as one.
00035     - extend the test vector slightly (with SMALL) to account for numerical
00036       inaccuracies.
00037 
00038 SourceFiles
00039     searchableSurfaceWithGaps.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef searchableSurfaceWithGaps_H
00044 #define searchableSurfaceWithGaps_H
00045 
00046 #include "searchableSurface.H"
00047 #include "UPtrList.H"
00048 #include "Pair.H"
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 namespace Foam
00053 {
00054 
00055 // Forward declaration of classes
00056 
00057 /*---------------------------------------------------------------------------*\
00058                            Class searchableSurfaceWithGaps Declaration
00059 \*---------------------------------------------------------------------------*/
00060 
00061 class searchableSurfaceWithGaps
00062 :
00063     public searchableSurface
00064 {
00065 private:
00066 
00067     // Private Member Data
00068 
00069         //- gap size in meter
00070         const scalar gap_;
00071 
00072         //- Underlying geometry (size 1)
00073         UPtrList<searchableSurface> subGeom_;
00074 
00075 
00076     // Private Member Functions
00077 
00078         Pair<vector> offsetVecs(const point&, const point&) const;
00079 
00080         void offsetVecs
00081         (
00082             const pointField& start,
00083             const pointField& end,
00084             pointField& offset0,
00085             pointField& offset1
00086         ) const;
00087 
00088         static label countMisses
00089         (
00090             const List<pointIndexHit>& info,
00091             labelList& missMap
00092         );
00093 
00094         static label countMisses
00095         (
00096             const List<pointIndexHit>& plusInfo,
00097             const List<pointIndexHit>& minInfo,
00098             labelList& missMap
00099         );
00100 
00101 
00102         //- Disallow default bitwise copy construct
00103         searchableSurfaceWithGaps(const searchableSurfaceWithGaps&);
00104 
00105         //- Disallow default bitwise assignment
00106         void operator=(const searchableSurfaceWithGaps&);
00107 
00108 
00109 public:
00110 
00111     //- Runtime type information
00112     TypeName("searchableSurfaceWithGaps");
00113 
00114 
00115     // Constructors
00116 
00117         //- Construct from dictionary (used by searchableSurface)
00118         searchableSurfaceWithGaps
00119         (
00120             const IOobject& io,
00121             const dictionary& dict
00122         );
00123 
00124     // Destructor
00125 
00126         virtual ~searchableSurfaceWithGaps();
00127 
00128 
00129     // Member Functions
00130 
00131         const searchableSurface& surface() const
00132         {
00133             return subGeom_[0];
00134         }
00135 
00136 
00137         virtual const wordList& regions() const
00138         {
00139             return surface().regions();
00140         }
00141 
00142         //- Whether supports volume type below
00143         virtual bool hasVolumeType() const
00144         {
00145             return surface().hasVolumeType();
00146         }
00147 
00148         //- Range of local indices that can be returned.
00149         virtual label size() const
00150         {
00151             return surface().size();
00152         }
00153 
00154 
00155         // Multiple point queries.
00156 
00157             //- Find nearest on original surface. Note:does not use perturbation
00158             //  and hence might be inconsistent with intersections.
00159             virtual void findNearest
00160             (
00161                 const pointField& sample,
00162                 const scalarField& nearestDistSqr,
00163                 List<pointIndexHit>& info
00164             ) const
00165             {
00166                 surface().findNearest
00167                 (
00168                     sample,
00169                     nearestDistSqr,
00170                     info
00171                 );
00172             }
00173 
00174             virtual void findLine
00175             (
00176                 const pointField& start,
00177                 const pointField& end,
00178                 List<pointIndexHit>&
00179             ) const;
00180 
00181             virtual void findLineAny
00182             (
00183                 const pointField& start,
00184                 const pointField& end,
00185                 List<pointIndexHit>&
00186             ) const;
00187 
00188             //- Get all intersections in order from start to end.
00189             virtual void findLineAll
00190             (
00191                 const pointField& start,
00192                 const pointField& end,
00193                 List<List<pointIndexHit> >&
00194             ) const;
00195 
00196             //- From a set of points and indices get the region
00197             virtual void getRegion
00198             (
00199                 const List<pointIndexHit>& info,
00200                 labelList& region
00201             ) const
00202             {
00203                 surface().getRegion(info, region);
00204             }
00205 
00206             //- From a set of points and indices get the normal
00207             virtual void getNormal
00208             (
00209                 const List<pointIndexHit>& info,
00210                 vectorField& normal
00211             ) const
00212             {
00213                 surface().getNormal(info, normal);
00214             }
00215 
00216             //- Determine type (inside/outside/mixed) for point. unknown if
00217             //  cannot be determined (e.g. non-manifold surface)
00218             virtual void getVolumeType
00219             (
00220                 const pointField& samples,
00221                 List<volumeType>& info
00222             ) const
00223             {
00224                 surface().getVolumeType(samples, info);
00225             }
00226 
00227 
00228         // regIOobject implementation
00229 
00230             bool writeData(Ostream& os) const
00231             {
00232                 return surface().writeData(os);
00233             }
00234 
00235 };
00236 
00237 
00238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00239 
00240 } // End namespace Foam
00241 
00242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00243 
00244 #endif
00245 
00246 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd