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

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