FreeFOAM The Cross-Platform CFD Toolkit
searchableSphere.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::searchableSphere
26 
27 Description
28  Searching on sphere
29 
30 SourceFiles
31  searchableSphere.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef searchableSphere_H
36 #define searchableSphere_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 searchableSphere Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public searchableSurface
55 {
56 private:
57 
58  // Private Member Data
59 
60  //- Centre point
61  const point centre_;
62 
63  //- Radius squared
64  const scalar radius_;
65 
66  //- Names of regions
67  mutable wordList regions_;
68 
69 
70  // Private Member Functions
71 
72  //- Find nearest point on sphere.
73  pointIndexHit findNearest
74  (
75  const point& sample,
76  const scalar nearestDistSqr
77  ) const;
78 
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;
87 
88 
89  //- Disallow default bitwise copy construct
91 
92  //- Disallow default bitwise assignment
93  void operator=(const searchableSphere&);
94 
95 
96 public:
97 
98  //- Runtime type information
99  TypeName("searchableSphere");
100 
101 
102  // Constructors
103 
104  //- Construct from components
105  searchableSphere(const IOobject& io, const point&, const scalar radius);
106 
107  //- Construct from dictionary (used by searchableSurface)
109  (
110  const IOobject& io,
111  const dictionary& dict
112  );
113 
114  // Destructor
115 
116  virtual ~searchableSphere();
117 
118 
119  // Member Functions
120 
121  virtual const wordList& regions() const;
122 
123  //- Whether supports volume type below
124  virtual bool hasVolumeType() const
125  {
126  return true;
127  }
128 
129  //- Range of local indices that can be returned.
130  virtual label size() const
131  {
132  return 1;
133  }
134 
135  //- Get representative set of element coordinates
136  // Usually the element centres (should be of length size()).
137  virtual pointField coordinates() const
138  {
139  return pointField(1, centre_);
140  }
141 
142 
143  // Multiple point queries.
144 
145  virtual void findNearest
146  (
147  const pointField& sample,
148  const scalarField& nearestDistSqr,
150  ) const;
151 
152  virtual void findLine
153  (
154  const pointField& start,
155  const pointField& end,
157  ) const;
158 
159  virtual void findLineAny
160  (
161  const pointField& start,
162  const pointField& end,
164  ) const;
165 
166  //- Get all intersections in order from start to end.
167  virtual void findLineAll
168  (
169  const pointField& start,
170  const pointField& end,
172  ) const;
173 
174  //- From a set of points and indices get the region
175  virtual void getRegion
176  (
177  const List<pointIndexHit>&,
178  labelList& region
179  ) const;
180 
181  //- From a set of points and indices get the normal
182  virtual void getNormal
183  (
184  const List<pointIndexHit>&,
186  ) const;
187 
188  //- Determine type (inside/outside/mixed) for point. unknown if
189  // cannot be determined (e.g. non-manifold surface)
190  virtual void getVolumeType
191  (
192  const pointField&,
194  ) const;
195 
196 
197  // regIOobject implementation
198 
199  bool writeData(Ostream&) const
200  {
201  notImplemented("searchableSphere::writeData(Ostream&) const");
202  return false;
203  }
204 
205 };
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace Foam
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #endif
215 
216 // ************************ vim: set sw=4 sts=4 et: ************************ //