Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / searchableSurface / searchableCylinder.H
blob674bb1a82b05e74b15cb7bee7bbbdbdeb7183d8c
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::searchableCylinder
27 Description
28     Searching on cylinder
30 SourceFiles
31     searchableCylinder.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef searchableCylinder_H
36 #define searchableCylinder_H
38 #include "treeBoundBox.H"
39 #include "searchableSurface.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
48 /*---------------------------------------------------------------------------*\
49                            Class searchableCylinder Declaration
50 \*---------------------------------------------------------------------------*/
52 class searchableCylinder
54     public searchableSurface
56 private:
58     // Private Member Data
60         //- 'left' point
61         const point point1_;
63         //- 'right' point
64         const point point2_;
66         //- length of vector point2-point1
67         const scalar magDir_;
69         //- normalised vector point2-point1
70         const vector unitDir_;
72         //- Radius squared
73         const scalar radius_;
75         //- Names of regions
76         mutable wordList regions_;
79     // Private Member Functions
81         //- Find nearest point on cylinder.
82         pointIndexHit findNearest
83         (
84             const point& sample,
85             const scalar nearestDistSqr
86         ) const;
88         scalar radius2(const point& pt) const;
90         //- Find intersection with cylinder
91         void findLineAll
92         (
93             const point& start,
94             const point& end,
95             pointIndexHit& near,
96             pointIndexHit& far
97         ) const;
100         //- Disallow default bitwise copy construct
101         searchableCylinder(const searchableCylinder&);
103         //- Disallow default bitwise assignment
104         void operator=(const searchableCylinder&);
107 public:
109     //- Runtime type information
110     TypeName("searchableCylinder");
113     // Constructors
115         //- Construct from components
116         searchableCylinder
117         (
118             const IOobject& io,
119             const point&,
120             const point&,
121             const scalar radius
122         );
124         //- Construct from dictionary (used by searchableSurface)
125         searchableCylinder
126         (
127             const IOobject& io,
128             const dictionary& dict
129         );
131     //- Destructor
132     virtual ~searchableCylinder();
135     // Member Functions
137         virtual const wordList& regions() const;
139         //- Whether supports volume type below
140         virtual bool hasVolumeType() const
141         {
142             return true;
143         }
145         //- Range of local indices that can be returned.
146         virtual label size() const
147         {
148             return 1;
149         }
151         //- Get representative set of element coordinates
152         //  Usually the element centres (should be of length size()).
153         virtual pointField coordinates() const;
156         // Multiple point queries.
158             virtual void findNearest
159             (
160                 const pointField& sample,
161                 const scalarField& nearestDistSqr,
162                 List<pointIndexHit>&
163             ) const;
165             virtual void findLine
166             (
167                 const pointField& start,
168                 const pointField& end,
169                 List<pointIndexHit>&
170             ) const;
172             virtual void findLineAny
173             (
174                 const pointField& start,
175                 const pointField& end,
176                 List<pointIndexHit>&
177             ) const;
179             //- Get all intersections in order from start to end.
180             virtual void findLineAll
181             (
182                 const pointField& start,
183                 const pointField& end,
184                 List<List<pointIndexHit> >&
185             ) const;
187             //- From a set of points and indices get the region
188             virtual void getRegion
189             (
190                 const List<pointIndexHit>&,
191                 labelList& region
192             ) const;
194             //- From a set of points and indices get the normal
195             virtual void getNormal
196             (
197                 const List<pointIndexHit>&,
198                 vectorField& normal
199             ) const;
201             //- Determine type (inside/outside/mixed) for point. unknown if
202             //  cannot be determined (e.g. non-manifold surface)
203             virtual void getVolumeType
204             (
205                 const pointField&,
206                 List<volumeType>&
207             ) const;
210         // regIOobject implementation
212             bool writeData(Ostream&) const
213             {
214                 notImplemented("searchableCylinder::writeData(Ostream&) const");
215                 return false;
216             }
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 } // End namespace Foam
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 #endif
229 // ************************************************************************* //