Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / searchableSurface / searchableSphere.H
blobbb82d4fc4aa47e9ec1727924a05fcbb8d0a0605d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::searchableSphere
27 Description
28     Searching on sphere
30 SourceFiles
31     searchableSphere.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef searchableSphere_H
36 #define searchableSphere_H
38 #include "treeBoundBox.H"
39 #include "searchableSurface.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
48 /*---------------------------------------------------------------------------*\
49                            Class searchableSphere Declaration
50 \*---------------------------------------------------------------------------*/
52 class searchableSphere
54     public searchableSurface
56 private:
58     // Private Member Data
60         //- Centre point
61         const point centre_;
63         //- Radius squared
64         const scalar radius_;
66         //- Names of regions
67         mutable wordList regions_;
70     // Private Member Functions
72         //- Find nearest point on sphere.
73         pointIndexHit findNearest
74         (
75             const point& sample,
76             const scalar nearestDistSqr
77         ) const;
79         //- Find intersection with sphere
80         void findLineAll
81         (
82             const point& start,
83             const point& end,
84             pointIndexHit& near,
85             pointIndexHit& far
86         ) const;
89         //- Disallow default bitwise copy construct
90         searchableSphere(const searchableSphere&);
92         //- Disallow default bitwise assignment
93         void operator=(const searchableSphere&);
96 public:
98     //- Runtime type information
99     TypeName("searchableSphere");
102     // Constructors
104         //- Construct from components
105         searchableSphere(const IOobject& io, const point&, const scalar radius);
107         //- Construct from dictionary (used by searchableSurface)
108         searchableSphere
109         (
110             const IOobject& io,
111             const dictionary& dict
112         );
114     //- Destructor
115     virtual ~searchableSphere();
118     // Member Functions
120         virtual const wordList& regions() const;
122         //- Whether supports volume type below
123         virtual bool hasVolumeType() const
124         {
125             return true;
126         }
128         //- Range of local indices that can be returned.
129         virtual label size() const
130         {
131             return 1;
132         }
134         //- Get representative set of element coordinates
135         //  Usually the element centres (should be of length size()).
136         virtual pointField coordinates() const
137         {
138             return pointField(1, centre_);
139         }
142         // Multiple point queries.
144             virtual void findNearest
145             (
146                 const pointField& sample,
147                 const scalarField& nearestDistSqr,
148                 List<pointIndexHit>&
149             ) const;
151             virtual void findLine
152             (
153                 const pointField& start,
154                 const pointField& end,
155                 List<pointIndexHit>&
156             ) const;
158             virtual void findLineAny
159             (
160                 const pointField& start,
161                 const pointField& end,
162                 List<pointIndexHit>&
163             ) const;
165             //- Get all intersections in order from start to end.
166             virtual void findLineAll
167             (
168                 const pointField& start,
169                 const pointField& end,
170                 List<List<pointIndexHit> >&
171             ) const;
173             //- From a set of points and indices get the region
174             virtual void getRegion
175             (
176                 const List<pointIndexHit>&,
177                 labelList& region
178             ) const;
180             //- From a set of points and indices get the normal
181             virtual void getNormal
182             (
183                 const List<pointIndexHit>&,
184                 vectorField& normal
185             ) const;
187             //- Determine type (inside/outside/mixed) for point. unknown if
188             //  cannot be determined (e.g. non-manifold surface)
189             virtual void getVolumeType
190             (
191                 const pointField&,
192                 List<volumeType>&
193             ) const;
196         // regIOobject implementation
198             bool writeData(Ostream&) const
199             {
200                 notImplemented("searchableSphere::writeData(Ostream&) const");
201                 return false;
202             }
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 } // End namespace Foam
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 #endif
215 // ************************************************************************* //