FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::searchableSurfaceWithGaps
00026 
00027 Description
00028     searchableSurface using multiple slightly shifted underlying surfaces
00029     to make sure pierces don't go through gaps:
00030     - shift test vector with two small vectors (of size gap_) perpendicular
00031       to the original.
00032       Test with + and - this vector. Only if both register a hit is it seen
00033       as one.
00034     - extend the test vector slightly (with SMALL) to account for numerical
00035       inaccuracies.
00036 
00037 SourceFiles
00038     searchableSurfaceWithGaps.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef searchableSurfaceWithGaps_H
00043 #define searchableSurfaceWithGaps_H
00044 
00045 #include "searchableSurface.H"
00046 #include <OpenFOAM/UPtrList.H>
00047 #include <OpenFOAM/Pair.H>
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 // Forward declaration of classes
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class searchableSurfaceWithGaps Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class searchableSurfaceWithGaps
00061 :
00062     public searchableSurface
00063 {
00064 private:
00065 
00066     // Private Member Data
00067 
00068         //- gap size in meter
00069         const scalar gap_;
00070 
00071         //- Underlying geometry (size 1)
00072         UPtrList<searchableSurface> subGeom_;
00073 
00074 
00075     // Private Member Functions
00076 
00077         Pair<vector> offsetVecs(const point&, const point&) const;
00078 
00079         void offsetVecs
00080         (
00081             const pointField& start,
00082             const pointField& end,
00083             pointField& offset0,
00084             pointField& offset1
00085         ) const;
00086 
00087         static label countMisses
00088         (
00089             const List<pointIndexHit>& info,
00090             labelList& missMap
00091         );
00092 
00093         static label countMisses
00094         (
00095             const List<pointIndexHit>& plusInfo,
00096             const List<pointIndexHit>& minInfo,
00097             labelList& missMap
00098         );
00099 
00100 
00101         //- Disallow default bitwise copy construct
00102         searchableSurfaceWithGaps(const searchableSurfaceWithGaps&);
00103 
00104         //- Disallow default bitwise assignment
00105         void operator=(const searchableSurfaceWithGaps&);
00106 
00107 
00108 public:
00109 
00110     //- Runtime type information
00111     TypeName("searchableSurfaceWithGaps");
00112 
00113 
00114     // Constructors
00115 
00116         //- Construct from dictionary (used by searchableSurface)
00117         searchableSurfaceWithGaps
00118         (
00119             const IOobject& io,
00120             const dictionary& dict
00121         );
00122 
00123     // Destructor
00124 
00125         virtual ~searchableSurfaceWithGaps();
00126 
00127 
00128     // Member Functions
00129 
00130         const searchableSurface& surface() const
00131         {
00132             return subGeom_[0];
00133         }
00134 
00135 
00136         virtual const wordList& regions() const
00137         {
00138             return surface().regions();
00139         }
00140 
00141         //- Whether supports volume type below
00142         virtual bool hasVolumeType() const
00143         {
00144             return surface().hasVolumeType();
00145         }
00146 
00147         //- Range of local indices that can be returned.
00148         virtual label size() const
00149         {
00150             return surface().size();
00151         }
00152 
00153         //- Get representative set of element coordinates
00154         //  Usually the element centres (should be of length size()).
00155         virtual pointField coordinates() const
00156         {
00157             return surface().coordinates();
00158         }
00159 
00160 
00161         // Multiple point queries.
00162 
00163             //- Find nearest on original surface. Note:does not use perturbation
00164             //  and hence might be inconsistent with intersections.
00165             virtual void findNearest
00166             (
00167                 const pointField& sample,
00168                 const scalarField& nearestDistSqr,
00169                 List<pointIndexHit>& info
00170             ) const
00171             {
00172                 surface().findNearest
00173                 (
00174                     sample,
00175                     nearestDistSqr,
00176                     info
00177                 );
00178             }
00179 
00180             virtual void findLine
00181             (
00182                 const pointField& start,
00183                 const pointField& end,
00184                 List<pointIndexHit>&
00185             ) const;
00186 
00187             virtual void findLineAny
00188             (
00189                 const pointField& start,
00190                 const pointField& end,
00191                 List<pointIndexHit>&
00192             ) const;
00193 
00194             //- Get all intersections in order from start to end.
00195             virtual void findLineAll
00196             (
00197                 const pointField& start,
00198                 const pointField& end,
00199                 List<List<pointIndexHit> >&
00200             ) const;
00201 
00202             //- From a set of points and indices get the region
00203             virtual void getRegion
00204             (
00205                 const List<pointIndexHit>& info,
00206                 labelList& region
00207             ) const
00208             {
00209                 surface().getRegion(info, region);
00210             }
00211 
00212             //- From a set of points and indices get the normal
00213             virtual void getNormal
00214             (
00215                 const List<pointIndexHit>& info,
00216                 vectorField& normal
00217             ) const
00218             {
00219                 surface().getNormal(info, normal);
00220             }
00221 
00222             //- Determine type (inside/outside/mixed) for point. unknown if
00223             //  cannot be determined (e.g. non-manifold surface)
00224             virtual void getVolumeType
00225             (
00226                 const pointField& samples,
00227                 List<volumeType>& info
00228             ) const
00229             {
00230                 surface().getVolumeType(samples, info);
00231             }
00232 
00233 
00234         // Other
00235 
00236             //- Set bounds of surface. Bounds currently set as list of
00237             //  bounding boxes. The bounds are hints to the surface as for
00238             //  the range of queries it can expect. faceMap/pointMap can be
00239             //  set if the surface has done any redistribution.
00240             virtual void distribute
00241             (
00242                 const List<treeBoundBox>& bbs,
00243                 const bool keepNonLocal,
00244                 autoPtr<mapDistribute>& faceMap,
00245                 autoPtr<mapDistribute>& pointMap
00246             )
00247             {
00248                 subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
00249             }
00250 
00251             //- WIP. Store element-wise field.
00252             virtual void setField(const labelList& values)
00253             {
00254                 subGeom_[0].setField(values);
00255             }
00256 
00257             //- WIP. From a set of hits (points and
00258             //  indices) get the specified field. Misses do not get set. Return
00259             //  empty field if not supported.
00260             virtual void getField
00261             (
00262                 const List<pointIndexHit>& info,
00263                 labelList& values
00264             ) const
00265             {
00266                 surface().getField(info, values);
00267             }
00268 
00269         // regIOobject implementation
00270 
00271             bool writeData(Ostream& os) const
00272             {
00273                 return surface().writeData(os);
00274             }
00275 
00276 };
00277 
00278 
00279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00280 
00281 } // End namespace Foam
00282 
00283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00284 
00285 #endif
00286 
00287 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines