searchableSurface.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-2016 OpenFOAM Foundation
9 Copyright (C) 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::searchableSurface
29
30Description
31 Base class of (analytical or triangulated) surface.
32 Encapsulates all the search routines. WIP.
33
34 Information returned is usually a pointIndexHit:
35 - bool : was intersection/nearest found?
36 - point : intersection point or nearest point
37 - index : unique index on surface (e.g. triangle for triSurfaceMesh)
38
39SourceFiles
40 searchableSurface.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef searchableSurface_H
45#define searchableSurface_H
46
47#include "pointField.H"
48#include "boundBox.H"
49#include "typeInfo.H"
51#include "pointIndexHit.H"
52#include "linePointRef.H"
53#include "objectRegistry.H"
54#include "volumeType.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61// Forward declarations
62class objectRegistry;
63class mapDistribute;
64class treeBoundBox;
65
66/*---------------------------------------------------------------------------*\
67 Class searchableSurface Declaration
68\*---------------------------------------------------------------------------*/
71:
72 public regIOobject
73{
74 // Private data
75
76 const word name_;
77
78 boundBox bounds_;
79
80
81 // Private Member Functions
82
83 //- No copy construct
84 searchableSurface(const searchableSurface&) = delete;
85
86 //- No copy assignment
87 void operator=(const searchableSurface&) = delete;
88
89
90public:
91
92 //- Runtime type information
93 TypeName("searchableSurface");
94
95 // Declare run-time constructor selection table
96
97 // For the dictionary constructor
99 (
100 autoPtr,
102 dict,
103 (
104 const IOobject& io,
105 const dictionary& dict
106 ),
107 (io, dict)
108 );
109
110
111 //- Class used for the read-construction of
112 // PtrLists of searchableSurface.
113 class iNew
114 {
115 IOobject& io_;
116
117 public:
120 :
121 io_(io)
122 {}
125 {
126 word surfaceType(is);
127 word readName(is);
128 dictionary dict(is);
129
130 autoPtr<IOobject> namedIO(io_.clone());
131 namedIO().rename(readName);
132 return searchableSurface::New(surfaceType, namedIO(), dict);
133 }
134 };
135
136
137 // Constructors
138
140
141 //- Clone
142 virtual autoPtr<searchableSurface> clone() const
143 {
145 return nullptr;
146 }
147
148
149 // Selectors
150
151 //- Return a reference to the selected searchableSurface
153 (
154 const word& surfaceType,
155 const IOobject& io,
156 const dictionary& dict
157 );
158
159
160 //- Destructor
161 virtual ~searchableSurface() = default;
162
163
164 // Member Functions
165
166 //- Is object global
167 virtual bool global() const
168 {
169 return true;
170 }
171
172 //- Return complete path + object name if the file exists
173 // either in the case/processor or case otherwise null
174 virtual fileName filePath() const
175 {
176 return globalFilePath(type());
177 }
178
179 //- Return const reference to boundBox
180 virtual const boundBox& bounds() const
181 {
182 return bounds_;
183 }
184
185 //- Return non-const access to the boundBox to allow it to be set.
186 virtual boundBox& bounds()
187 {
188 return bounds_;
189 }
190
191 //- Names of regions
192 virtual const wordList& regions() const = 0;
193
194 //- Whether supports volume type (below).
195 // This is false for the base class.
196 virtual bool hasVolumeType() const;
197
198 //- If surface supports volume queries, what is type of points outside
199 // bounds
200 virtual volumeType outsideVolumeType() const = 0;
201
202 //- Range of local indices that can be returned
203 virtual label size() const = 0;
204
205 //- Range of global indices that can be returned
206 virtual label globalSize() const
207 {
208 return size();
209 }
210
211 //- Get representative set of element coordinates
212 // Usually the element centres (should be of length size()).
213 virtual tmp<pointField> coordinates() const = 0;
214
215 //- Get bounding spheres (centre and radius squared), one per element.
216 // Any point on element is guaranteed to be inside.
217 virtual void boundingSpheres
218 (
219 pointField& centres,
220 scalarField& radiusSqr
221 ) const = 0;
222
223 //- Get the points that define the surface.
224 virtual tmp<pointField> points() const = 0;
225
226 //- Does any part of the surface overlap the supplied bound box?
227 virtual bool overlaps(const boundBox& bb) const = 0;
228
229 // Single point queries.
230
236 //virtual pointIndexHit findNearest
237 //(
238 // const point& sample,
239 // const scalar nearestDistSqr
240 //) const = 0;
241 //
247 //virtual pointIndexHit findNearestOnEdge
248 //(
249 // const point& sample,
250 // const scalar nearestDistSqr
251 //) const = 0;
252 //
261 //virtual pointIndexHit findNearest
262 //(
263 // const linePointRef& ln,
264 // treeBoundBox& tightest,
265 // point& linePoint
266 //) const = 0;
267 //
269 //virtual pointIndexHit findLine
270 //(
271 // const point& start,
272 // const point& end
273 //) const = 0;
274 //
276 //virtual pointIndexHit findLineAny
277 //(
278 // const point& start,
279 // const point& end
280 //) const = 0;
281
282
283 // Multiple point queries. When surface is distributed the index
284 // should be a global index. Not done yet.
286 virtual void findNearest
287 (
288 const pointField& sample,
289 const scalarField& nearestDistSqr,
291 ) const = 0;
292
293 //- Find the nearest locations for the supplied points to a
294 // particular region in the searchable surface.
295 virtual void findNearest
296 (
297 const pointField& samples,
298 const scalarField& nearestDistSqr,
299 const labelList& regionIndices,
301 ) const
302 {
303 findNearest(samples, nearestDistSqr, info);
304 }
305
306 //- Find first intersection on segment from start to end.
307 // Note: searchableSurfacesQueries expects no
308 // intersection to be found if start==end. Is problem?
309 virtual void findLine
310 (
311 const pointField& start,
312 const pointField& end,
314 ) const = 0;
315
316 //- Return any intersection on segment from start to end.
317 virtual void findLineAny
318 (
319 const pointField& start,
320 const pointField& end,
322 ) const = 0;
323
324 //- Get all intersections in order from start to end.
325 virtual void findLineAll
326 (
327 const pointField& start,
328 const pointField& end,
330 ) const = 0;
331
332 //- From a set of points and indices get the region
333 virtual void getRegion
334 (
335 const List<pointIndexHit>&,
336 labelList& region
337 ) const = 0;
338
339 //- From a set of points and indices get the normal
340 virtual void getNormal
341 (
342 const List<pointIndexHit>&,
343 vectorField& normal
344 ) const = 0;
345
346 //- Determine type (inside/outside) for point.
347 // Unknown if cannot be determined (e.g. non-manifold surface)
348 virtual void getVolumeType
349 (
350 const pointField&,
352 ) const = 0;
353
354 //- Find nearest, normal and region. Can be overridden with
355 // optimised implementation
356 virtual void findNearest
357 (
358 const pointField& sample,
359 const scalarField& nearestDistSqr,
361 vectorField& normal,
362 labelList& region
363 ) const;
364
365
366 // Other
367
368 //- Set bounds of surface. Bounds currently set as list of
369 // bounding boxes. The bounds are hints to the surface as for
370 // the range of queries it can expect. faceMap/pointMap can be
371 // set if the surface has done any redistribution.
372 virtual void distribute
373 (
374 const List<treeBoundBox>&,
375 const bool keepNonLocal,
377 autoPtr<mapDistribute>& pointMap
378 )
379 {}
380
381 //- WIP. Store element-wise field.
382 virtual void setField(const labelList& values)
383 {}
384
385 //- WIP. From a set of hits (points and
386 // indices) get the specified field. Misses do not get set. Return
387 // empty field if not supported.
388 virtual void getField(const List<pointIndexHit>&, labelList& values)
389 const
390 {
391 values.clear();
392 }
393};
394
395
396//- Template function for obtaining global status
397template<>
399{
400 return true;
401}
402
403
404// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
405
406} // End namespace Foam
407
408// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
409
410#endif
411
412// ************************************************************************* //
Minimal example by using system/controlDict.functions:
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:593
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:459
InfoProxy< IOobject > info() const
Return info proxy, for printing information to a stream.
Definition: IOobject.H:690
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.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
A class for handling file names.
Definition: fileName.H:76
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
Class used for the read-construction of.
autoPtr< searchableSurface > operator()(Istream &is) const
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual autoPtr< searchableSurface > clone() const
Clone.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const =0
From a set of points and indices get the region.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const =0
Get all intersections in order from start to end.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Find first intersection on segment from start to end.
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void distribute(const List< treeBoundBox > &, const bool keepNonLocal, autoPtr< mapDistribute > &faceMap, autoPtr< mapDistribute > &pointMap)
Set bounds of surface. Bounds currently set as list of.
virtual volumeType outsideVolumeType() const =0
If surface supports volume queries, what is type of points outside.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual bool global() const
Is object global.
declareRunTimeSelectionTable(autoPtr, searchableSurface, dict,(const IOobject &io, const dictionary &dict),(io, dict))
virtual boundBox & bounds()
Return non-const access to the boundBox to allow it to be set.
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
virtual bool overlaps(const boundBox &bb) const =0
Does any part of the surface overlap the supplied bound box?
virtual const wordList & regions() const =0
Names of regions.
TypeName("searchableSurface")
Runtime type information.
virtual ~searchableSurface()=default
Destructor.
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
virtual fileName filePath() const
Return complete path + object name if the file exists.
virtual tmp< pointField > points() const =0
Get the points that define the surface.
virtual label size() const =0
Range of local indices that can be returned.
virtual bool hasVolumeType() const
Whether supports volume type (below).
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const =0
Return any intersection on segment from start to end.
virtual label globalSize() const
Range of global indices that can be returned.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.
virtual const boundBox & bounds() const
Return const reference to boundBox.
virtual tmp< pointField > coordinates() const =0
Get representative set of element coordinates.
A class for managing temporary objects.
Definition: tmp.H:65
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
A class for handling words, derived from Foam::string.
Definition: word.H:68
#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.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
bool typeGlobal< searchableSurface >()
Template function for obtaining global status.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
scalarField samples(nIntervals, Zero)