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

searchableSphere.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::searchableSphere
00026 
00027 Description
00028     Searching on sphere
00029 
00030 SourceFiles
00031     searchableSphere.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef searchableSphere_H
00036 #define searchableSphere_H
00037 
00038 #include <meshTools/treeBoundBox.H>
00039 #include "searchableSurface.H"
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 // Forward declaration of classes
00047 
00048 /*---------------------------------------------------------------------------*\
00049                            Class searchableSphere Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class searchableSphere
00053 :
00054     public searchableSurface
00055 {
00056 private:
00057 
00058     // Private Member Data
00059 
00060         //- Centre point
00061         const point centre_;
00062 
00063         //- Radius squared
00064         const scalar radius_;
00065 
00066         //- Names of regions
00067         mutable wordList regions_;
00068 
00069 
00070     // Private Member Functions
00071 
00072         //- Find nearest point on sphere.
00073         pointIndexHit findNearest
00074         (
00075             const point& sample,
00076             const scalar nearestDistSqr
00077         ) const;
00078 
00079         //- Find intersection with sphere
00080         void findLineAll
00081         (
00082             const point& start,
00083             const point& end,
00084             pointIndexHit& near,
00085             pointIndexHit& far
00086         ) const;
00087 
00088 
00089         //- Disallow default bitwise copy construct
00090         searchableSphere(const searchableSphere&);
00091 
00092         //- Disallow default bitwise assignment
00093         void operator=(const searchableSphere&);
00094 
00095 
00096 public:
00097 
00098     //- Runtime type information
00099     TypeName("searchableSphere");
00100 
00101 
00102     // Constructors
00103 
00104         //- Construct from components
00105         searchableSphere(const IOobject& io, const point&, const scalar radius);
00106 
00107         //- Construct from dictionary (used by searchableSurface)
00108         searchableSphere
00109         (
00110             const IOobject& io,
00111             const dictionary& dict
00112         );
00113 
00114     // Destructor
00115 
00116         virtual ~searchableSphere();
00117 
00118 
00119     // Member Functions
00120 
00121         virtual const wordList& regions() const;
00122 
00123         //- Whether supports volume type below
00124         virtual bool hasVolumeType() const
00125         {
00126             return true;
00127         }
00128 
00129         //- Range of local indices that can be returned.
00130         virtual label size() const
00131         {
00132             return 1;
00133         }
00134 
00135         //- Get representative set of element coordinates
00136         //  Usually the element centres (should be of length size()).
00137         virtual pointField coordinates() const
00138         {
00139             return pointField(1, centre_);
00140         }
00141 
00142 
00143         // Multiple point queries.
00144 
00145             virtual void findNearest
00146             (
00147                 const pointField& sample,
00148                 const scalarField& nearestDistSqr,
00149                 List<pointIndexHit>&
00150             ) const;
00151 
00152             virtual void findLine
00153             (
00154                 const pointField& start,
00155                 const pointField& end,
00156                 List<pointIndexHit>&
00157             ) const;
00158 
00159             virtual void findLineAny
00160             (
00161                 const pointField& start,
00162                 const pointField& end,
00163                 List<pointIndexHit>&
00164             ) const;
00165 
00166             //- Get all intersections in order from start to end.
00167             virtual void findLineAll
00168             (
00169                 const pointField& start,
00170                 const pointField& end,
00171                 List<List<pointIndexHit> >&
00172             ) const;
00173 
00174             //- From a set of points and indices get the region
00175             virtual void getRegion
00176             (
00177                 const List<pointIndexHit>&,
00178                 labelList& region
00179             ) const;
00180 
00181             //- From a set of points and indices get the normal
00182             virtual void getNormal
00183             (
00184                 const List<pointIndexHit>&,
00185                 vectorField& normal
00186             ) const;
00187 
00188             //- Determine type (inside/outside/mixed) for point. unknown if
00189             //  cannot be determined (e.g. non-manifold surface)
00190             virtual void getVolumeType
00191             (
00192                 const pointField&,
00193                 List<volumeType>&
00194             ) const;
00195 
00196 
00197         // regIOobject implementation
00198 
00199             bool writeData(Ostream&) const
00200             {
00201                 notImplemented("searchableSphere::writeData(Ostream&) const");
00202                 return false;
00203             }
00204 
00205 };
00206 
00207 
00208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00209 
00210 } // End namespace Foam
00211 
00212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00213 
00214 #endif
00215 
00216 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines