Small improvements to searchableSurface
[OpenFOAM-1.6.x.git] / src / meshTools / searchableSurface / searchableCylinder.H
blob98b4d91e4117eceb782b45a976928820a211c759
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::searchableCylinder
28 Description
29     Searching on cylinder
31 SourceFiles
32     searchableCylinder.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef searchableCylinder_H
37 #define searchableCylinder_H
39 #include "treeBoundBox.H"
40 #include "searchableSurface.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
49 /*---------------------------------------------------------------------------*\
50                            Class searchableCylinder Declaration
51 \*---------------------------------------------------------------------------*/
53 class searchableCylinder
55     public searchableSurface
57 private:
59     // Private Member Data
61         //- 'left' point
62         const point point1_;
64         //- 'right' point
65         const point point2_;
67         //- length of vector point2-point1
68         const scalar magDir_;
70         //- normalised vector point2-point1
71         const vector unitDir_;
73         //- Radius squared
74         const scalar radius_;
76         //- Names of regions
77         mutable wordList regions_;
80     // Private Member Functions
82         //- Find nearest point on cylinder.
83         pointIndexHit findNearest
84         (
85             const point& sample,
86             const scalar nearestDistSqr
87         ) const;
89         scalar radius2(const point& pt) const;
91         //- Find intersection with cylinder
92         void findLineAll
93         (
94             const point& start,
95             const point& end,
96             pointIndexHit& near,
97             pointIndexHit& far
98         ) const;
101         //- Disallow default bitwise copy construct
102         searchableCylinder(const searchableCylinder&);
104         //- Disallow default bitwise assignment
105         void operator=(const searchableCylinder&);
108 public:
110     //- Runtime type information
111     TypeName("searchableCylinder");
114     // Constructors
116         //- Construct from components
117         searchableCylinder
118         (
119             const IOobject& io,
120             const point&,
121             const point&,
122             const scalar radius
123         );
125         //- Construct from dictionary (used by searchableSurface)
126         searchableCylinder
127         (
128             const IOobject& io,
129             const dictionary& dict
130         );
132     // Destructor
134         virtual ~searchableCylinder();
137     // Member Functions
139         virtual const wordList& regions() const;
141         //- Whether supports volume type below
142         virtual bool hasVolumeType() const
143         {
144             return true;
145         }
147         //- Range of local indices that can be returned.
148         virtual label size() const
149         {
150             return 1;
151         }
153         //- Get representative set of element coordinates
154         //  Usually the element centres (should be of length size()).
155         virtual pointField coordinates() const;
158         // Multiple point queries.
160             virtual void findNearest
161             (
162                 const pointField& sample,
163                 const scalarField& nearestDistSqr,
164                 List<pointIndexHit>&
165             ) const;
167             virtual void findLine
168             (
169                 const pointField& start,
170                 const pointField& end,
171                 List<pointIndexHit>&
172             ) const;
174             virtual void findLineAny
175             (
176                 const pointField& start,
177                 const pointField& end,
178                 List<pointIndexHit>&
179             ) const;
181             //- Get all intersections in order from start to end.
182             virtual void findLineAll
183             (
184                 const pointField& start,
185                 const pointField& end,
186                 List<List<pointIndexHit> >&
187             ) const;
189             //- From a set of points and indices get the region
190             virtual void getRegion
191             (
192                 const List<pointIndexHit>&,
193                 labelList& region
194             ) const;
196             //- From a set of points and indices get the normal
197             virtual void getNormal
198             (
199                 const List<pointIndexHit>&,
200                 vectorField& normal
201             ) const;
203             //- Determine type (inside/outside/mixed) for point. unknown if
204             //  cannot be determined (e.g. non-manifold surface)
205             virtual void getVolumeType
206             (
207                 const pointField&,
208                 List<volumeType>&
209             ) const;
212         // regIOobject implementation
214             bool writeData(Ostream&) const
215             {
216                 notImplemented("searchableCylinder::writeData(Ostream&) const");
217                 return false;
218             }
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 } // End namespace Foam
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 #endif
231 // ************************************************************************* //