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

searchableSurface.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::searchableSurface
00027 
00028 Description
00029     Base class of (analytical or triangulated) surface.
00030     Encapsulates all the search routines. WIP.
00031 
00032     Information returned is usually a pointIndexHit:
00033     - bool  : was intersection/nearest found?
00034     - point : intersection point or nearest point
00035     - index : unique index on surface (e.g. triangle for triSurfaceMesh)
00036 
00037 SourceFiles
00038     searchableSurface.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef searchableSurface_H
00043 #define searchableSurface_H
00044 
00045 #include "pointField.H"
00046 #include "typeInfo.H"
00047 #include "runTimeSelectionTables.H"
00048 #include "pointIndexHit.H"
00049 #include "linePointRef.H"
00050 #include "objectRegistry.H"
00051 
00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00053 
00054 namespace Foam
00055 {
00056 
00057 // Forward declaration of classes
00058 class objectRegistry;
00059 class mapDistribute;
00060 class treeBoundBox;
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class searchableSurface Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class searchableSurface
00067 :
00068     public regIOobject
00069 {
00070 public:
00071 
00072     // Data types
00073 
00074         //- volume types
00075         enum volumeType
00076         {
00077             UNKNOWN = 0,
00078             MIXED = 1,      // not used. only here to maintain consistency with
00079                             // indexedOctree volumeType.
00080             INSIDE = 2,
00081             OUTSIDE = 3
00082         };
00083 
00084 private:
00085 
00086     // Private data
00087 
00088         const word name_;
00089 
00090 
00091     // Private Member Functions
00092 
00093         //- Disallow default bitwise copy construct
00094         searchableSurface(const searchableSurface&);
00095 
00096         //- Disallow default bitwise assignment
00097         void operator=(const searchableSurface&);
00098 
00099 
00100 public:
00101 
00102     //- Runtime type information
00103     TypeName("searchableSurface");
00104 
00105     // Declare run-time constructor selection table
00106 
00107         // For the dictionary constructor
00108         declareRunTimeSelectionTable
00109         (
00110             autoPtr,
00111             searchableSurface,
00112             dict,
00113             (
00114                 const IOobject& io,
00115                 const dictionary& dict
00116             ),
00117             (io, dict)
00118         );
00119 
00120 
00121         //- Class used for the read-construction of
00122         //  PtrLists of searchableSurface.
00123         class iNew
00124         {
00125             IOobject& io_;
00126 
00127         public:
00128 
00129             iNew(IOobject& io)
00130             :
00131                 io_(io)
00132             {}
00133 
00134             autoPtr<searchableSurface> operator()(Istream& is) const
00135             {
00136                 word surfaceType(is);
00137                 word readName(is);
00138                 dictionary dict(is);
00139 
00140                 autoPtr<IOobject> namedIO(io_.clone());
00141                 namedIO().rename(readName);
00142                 return searchableSurface::New(surfaceType, namedIO(), dict);
00143             }
00144         };
00145 
00146 
00147     // Constructors
00148 
00149         searchableSurface(const IOobject& io);
00150 
00151         //- Clone
00152         virtual autoPtr<searchableSurface> clone() const
00153         {
00154             notImplemented("autoPtr<searchableSurface> clone() const");
00155             return autoPtr<searchableSurface>(NULL);
00156         }
00157 
00158 
00159     // Selectors
00160 
00161         //- Return a reference to the selected searchableSurface
00162         static autoPtr<searchableSurface> New
00163         (
00164             const word& surfaceType,
00165             const IOobject& io,
00166             const dictionary& dict
00167         );
00168 
00169 
00170     // Destructor
00171 
00172         virtual ~searchableSurface();
00173 
00174 
00175     // Member Functions
00176 
00177 
00178         //- Names of regions.
00179         virtual const wordList& regions() const = 0;
00180 
00181         //- Whether supports volume type below.
00182         virtual bool hasVolumeType() const = 0;
00183 
00184         //- Range of local indices that can be returned.
00185         virtual label size() const = 0;
00186 
00187         //- Range of global indices that can be returned.
00188         virtual label globalSize() const
00189         {
00190             return size();
00191         }
00192 
00193 
00194         // Single point queries.
00195 
00201             //virtual pointIndexHit findNearest
00202             //(
00203             //    const point& sample,
00204             //    const scalar nearestDistSqr
00205             //) const = 0;
00206             //
00212             //virtual pointIndexHit findNearestOnEdge
00213             //(
00214             //    const point& sample,
00215             //    const scalar nearestDistSqr
00216             //) const = 0;
00217             //
00226             //virtual pointIndexHit findNearest
00227             //(
00228             //    const linePointRef& ln,
00229             //    treeBoundBox& tightest,
00230             //    point& linePoint
00231             //) const = 0;
00232             //
00234             //virtual pointIndexHit findLine
00235             //(
00236             //    const point& start,
00237             //    const point& end
00238             //) const = 0;
00239             //
00241             //virtual pointIndexHit findLineAny
00242             //(
00243             //    const point& start,
00244             //    const point& end
00245             //) const = 0;
00246 
00247 
00248         // Multiple point queries. When surface is distributed the index
00249         // should be a global index. Not done yet.
00250 
00251             virtual void findNearest
00252             (
00253                 const pointField& sample,
00254                 const scalarField& nearestDistSqr,
00255                 List<pointIndexHit>&
00256             ) const = 0;
00257 
00258             //- Find first intersection on segment from start to end.
00259             //  Note: searchableSurfacesQueries expects no
00260             //  intersection to be found if start==end. Is problem?
00261             virtual void findLine
00262             (
00263                 const pointField& start,
00264                 const pointField& end,
00265                 List<pointIndexHit>&
00266             ) const = 0;
00267 
00268             //- Return any intersection on segment from start to end.
00269             virtual void findLineAny
00270             (
00271                 const pointField& start,
00272                 const pointField& end,
00273                 List<pointIndexHit>&
00274             ) const = 0;
00275 
00276             //- Get all intersections in order from start to end.
00277             virtual void findLineAll
00278             (
00279                 const pointField& start,
00280                 const pointField& end,
00281                 List<List<pointIndexHit> >&
00282             ) const = 0;
00283 
00284             //- From a set of points and indices get the region
00285             virtual void getRegion
00286             (
00287                 const List<pointIndexHit>&,
00288                 labelList& region
00289             ) const = 0;
00290 
00291             //- From a set of points and indices get the normal
00292             virtual void getNormal
00293             (
00294                 const List<pointIndexHit>&,
00295                 vectorField& normal
00296             ) const = 0;
00297 
00298             //- Determine type (inside/outside) for point. unknown if
00299             //  cannot be determined (e.g. non-manifold surface)
00300             virtual void getVolumeType
00301             (
00302                 const pointField&,
00303                 List<volumeType>&
00304             ) const = 0;
00305 
00306 
00307         // Other
00308 
00309             //- Set bounds of surface. Bounds currently set as list of
00310             //  bounding boxes. The bounds are hints to the surface as for
00311             //  the range of queries it can expect. faceMap/pointMap can be
00312             //  set if the surface has done any redistribution.
00313             virtual void distribute
00314             (
00315                 const List<treeBoundBox>&,
00316                 const bool keepNonLocal,
00317                 autoPtr<mapDistribute>& faceMap,
00318                 autoPtr<mapDistribute>& pointMap
00319             )
00320             {}
00321 
00322 
00323 };
00324 
00325 
00326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00327 
00328 } // End namespace Foam
00329 
00330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00331 
00332 #endif
00333 
00334 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd