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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2015-2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::searchableCylinder
29
30Description
31 Searching on a cylinder.
32
33 \heading Dictionary parameters
34 \table
35 Property | Description | Required | Default
36 type | cylinder | selector |
37 point1 | coordinate of endpoint | yes |
38 point2 | coordinate of endpoint | yes |
39 radius | cylinder radius | yes |
40 \endtable
41
42Note
43 Longer type name : \c searchableCylinder
44
45SourceFiles
46 searchableCylinder.C
47
48\*---------------------------------------------------------------------------*/
49
50#ifndef searchableCylinder_H
51#define searchableCylinder_H
52
53#include "treeBoundBox.H"
54#include "searchableSurface.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61/*---------------------------------------------------------------------------*\
62 Class searchableCylinder Declaration
63\*---------------------------------------------------------------------------*/
64
65class searchableCylinder
66:
67 public searchableSurface
68{
69private:
70
71 // Private Member Data
72
73 //- The 'left' point
74 const point point1_;
75
76 //- The 'right' point
77 const point point2_;
78
79 //- Length of vector point2-point1
80 const scalar magDir_;
81
82 //- Normalised vector point2-point1
83 const vector unitDir_;
84
85 //- The radius
86 const scalar radius_;
87
88 //- Names of regions
89 mutable wordList regions_;
90
91
92 // Private Member Functions
93
94 //- Inherit findNearest from searchableSurface
96
97 //- Find nearest point on cylinder.
98 pointIndexHit findNearest
99 (
100 const point& sample,
101 const scalar nearestDistSqr
102 ) const;
103
104 scalar radius2(const point& pt) const;
105
106 //- Find intersection with cylinder
107 void findLineAll
108 (
109 const point& start,
110 const point& end,
111 pointIndexHit& near,
112 pointIndexHit& far
113 ) const;
114
115 //- Return the boundBox of the cylinder
116 boundBox calcBounds() const;
117
118 //- No copy construct
119 searchableCylinder(const searchableCylinder&) = delete;
120
121 //- No copy assignment
122 void operator=(const searchableCylinder&) = delete;
123
124
125public:
126
127 //- Runtime type information
128 TypeName("searchableCylinder");
129
130
131 // Constructors
132
133 //- Construct from components
135 (
136 const IOobject& io,
137 const point& point1,
138 const point& point2,
139 const scalar radius
140 );
141
142 //- Construct from dictionary (used by searchableSurface)
144 (
145 const IOobject& io,
146 const dictionary& dict
147 );
148
149
150 //- Destructor
151 virtual ~searchableCylinder() = default;
153
154 // Member Functions
155
156 //- Names of regions
157 virtual const wordList& regions() const;
158
159 //- Whether supports volume type below
160 virtual bool hasVolumeType() const
161 {
162 return true;
163 }
164
165 //- What is type of points outside bounds
166 virtual volumeType outsideVolumeType() const
167 {
168 return volumeType::OUTSIDE;
169 }
170
171 //- Range of local indices that can be returned.
172 virtual label size() const
173 {
174 return 1;
176
177 //- Get representative set of element coordinates
178 // Usually the element centres (should be of length size()).
179 virtual tmp<pointField> coordinates() const;
180
181 //- Get bounding spheres (centre and radius squared), one per element.
182 // Any point on element is guaranteed to be inside.
183 virtual void boundingSpheres
185 pointField& centres,
186 scalarField& radiusSqr
187 ) const;
188
189 //- Get the points that define the surface.
190 virtual tmp<pointField> points() const;
191
192 //- Does any part of the surface overlap the supplied bound box?
193 virtual bool overlaps(const boundBox& bb) const
194 {
196 return false;
197 }
198
199
200 // Multiple point queries.
201
202 virtual void findNearest
203 (
204 const pointField& sample,
205 const scalarField& nearestDistSqr,
207 ) const;
208
209 virtual void findLine
210 (
211 const pointField& start,
212 const pointField& end,
214 ) const;
215
216 virtual void findLineAny
218 const pointField& start,
219 const pointField& end,
221 ) const;
222
223 //- Get all intersections in order from start to end.
224 virtual void findLineAll
225 (
226 const pointField& start,
227 const pointField& end,
229 ) const;
230
231 //- From a set of points and indices get the region
232 virtual void getRegion
233 (
234 const List<pointIndexHit>&,
235 labelList& region
236 ) const;
237
238 //- From a set of points and indices get the normal
239 virtual void getNormal
240 (
241 const List<pointIndexHit>&,
242 vectorField& normal
243 ) const;
244
245 //- Determine type (inside/outside/mixed) for point.
246 // Unknown if cannot be determined (e.g. non-manifold surface)
247 virtual void getVolumeType
248 (
249 const pointField& points,
250 List<volumeType>& volType
251 ) const;
252
253
254 // regIOobject implementation
255
256 bool writeData(Ostream&) const
257 {
259 return false;
260 }
261
262};
263
264
265// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266
267} // End namespace Foam
268
269// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270
271#endif
272
273// ************************************************************************* //
Minimal example by using system/controlDict.functions:
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Searching on a cylinder.
virtual label size() const
Range of local indices that can be returned.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
bool writeData(Ostream &) const
Pure virtual writeData function.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual bool hasVolumeType() const
Whether supports volume type below.
TypeName("searchableCylinder")
Runtime type information.
virtual ~searchableCylinder()=default
Destructor.
virtual tmp< pointField > points() const
Get the points that define the surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
A class for managing temporary objects.
Definition: tmp.H:65
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
@ OUTSIDE
A location outside the volume.
Definition: volumeType.H:69
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition: point.H:43
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73