FreeFOAM The Cross-Platform CFD Toolkit
searchableCylinder.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::searchableCylinder
26 
27 Description
28  Searching on cylinder
29 
30 SourceFiles
31  searchableCylinder.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef searchableCylinder_H
36 #define searchableCylinder_H
37 
38 #include <meshTools/treeBoundBox.H>
39 #include "searchableSurface.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 
48 /*---------------------------------------------------------------------------*\
49  Class searchableCylinder Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public searchableSurface
55 {
56 private:
57 
58  // Private Member Data
59 
60  //- 'left' point
61  const point point1_;
62 
63  //- 'right' point
64  const point point2_;
65 
66  //- length of vector point2-point1
67  const scalar magDir_;
68 
69  //- normalised vector point2-point1
70  const vector unitDir_;
71 
72  //- Radius squared
73  const scalar radius_;
74 
75  //- Names of regions
76  mutable wordList regions_;
77 
78 
79  // Private Member Functions
80 
81  //- Find nearest point on cylinder.
82  pointIndexHit findNearest
83  (
84  const point& sample,
85  const scalar nearestDistSqr
86  ) const;
87 
88  scalar radius2(const point& pt) const;
89 
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;
98 
99 
100  //- Disallow default bitwise copy construct
102 
103  //- Disallow default bitwise assignment
104  void operator=(const searchableCylinder&);
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("searchableCylinder");
111 
112 
113  // Constructors
114 
115  //- Construct from components
117  (
118  const IOobject& io,
119  const point&,
120  const point&,
121  const scalar radius
122  );
123 
124  //- Construct from dictionary (used by searchableSurface)
126  (
127  const IOobject& io,
128  const dictionary& dict
129  );
130 
131  // Destructor
132 
133  virtual ~searchableCylinder();
134 
135 
136  // Member Functions
137 
138  virtual const wordList& regions() const;
139 
140  //- Whether supports volume type below
141  virtual bool hasVolumeType() const
142  {
143  return true;
144  }
145 
146  //- Range of local indices that can be returned.
147  virtual label size() const
148  {
149  return 1;
150  }
151 
152  //- Get representative set of element coordinates
153  // Usually the element centres (should be of length size()).
154  virtual pointField coordinates() const;
155 
156 
157  // Multiple point queries.
158 
159  virtual void findNearest
160  (
161  const pointField& sample,
162  const scalarField& nearestDistSqr,
164  ) const;
165 
166  virtual void findLine
167  (
168  const pointField& start,
169  const pointField& end,
171  ) const;
172 
173  virtual void findLineAny
174  (
175  const pointField& start,
176  const pointField& end,
178  ) const;
179 
180  //- Get all intersections in order from start to end.
181  virtual void findLineAll
182  (
183  const pointField& start,
184  const pointField& end,
186  ) const;
187 
188  //- From a set of points and indices get the region
189  virtual void getRegion
190  (
191  const List<pointIndexHit>&,
192  labelList& region
193  ) const;
194 
195  //- From a set of points and indices get the normal
196  virtual void getNormal
197  (
198  const List<pointIndexHit>&,
200  ) const;
201 
202  //- Determine type (inside/outside/mixed) for point. unknown if
203  // cannot be determined (e.g. non-manifold surface)
204  virtual void getVolumeType
205  (
206  const pointField&,
208  ) const;
209 
210 
211  // regIOobject implementation
212 
213  bool writeData(Ostream&) const
214  {
215  notImplemented("searchableCylinder::writeData(Ostream&) const");
216  return false;
217  }
218 
219 };
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #endif
229 
230 // ************************ vim: set sw=4 sts=4 et: ************************ //