1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::searchableSurface
29 Base class of (analytical or triangulated) surface.
30 Encapsulates all the search routines. WIP.
32 Information returned is usually a pointIndexHit:
33 - bool : was intersection/nearest found?
34 - point : intersection point or nearest point
35 - index : unique index on surface (e.g. triangle for triSurfaceMesh)
40 \*---------------------------------------------------------------------------*/
42 #ifndef searchableSurface_H
43 #define searchableSurface_H
45 #include "pointField.H"
47 #include "runTimeSelectionTables.H"
48 #include "pointIndexHit.H"
49 #include "linePointRef.H"
50 #include "objectRegistry.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 // Forward declaration of classes
62 /*---------------------------------------------------------------------------*\
63 Class searchableSurface Declaration
64 \*---------------------------------------------------------------------------*/
66 class searchableSurface
78 MIXED = 1, // not used. only here to maintain consistency with
79 // indexedOctree volumeType.
91 // Private Member Functions
93 //- Disallow default bitwise copy construct
94 searchableSurface(const searchableSurface&);
96 //- Disallow default bitwise assignment
97 void operator=(const searchableSurface&);
102 //- Runtime type information
103 TypeName("searchableSurface");
105 // Declare run-time constructor selection table
107 // For the dictionary constructor
108 declareRunTimeSelectionTable
115 const dictionary& dict
121 //- Class used for the read-construction of
122 // PtrLists of searchableSurface.
134 autoPtr<searchableSurface> operator()(Istream& is) const
136 word surfaceType(is);
140 autoPtr<IOobject> namedIO(io_.clone());
141 namedIO().rename(readName);
142 return searchableSurface::New(surfaceType, namedIO(), dict);
149 searchableSurface(const IOobject& io);
152 virtual autoPtr<searchableSurface> clone() const
154 notImplemented("autoPtr<searchableSurface> clone() const");
155 return autoPtr<searchableSurface>(NULL);
161 //- Return a reference to the selected searchableSurface
162 static autoPtr<searchableSurface> New
164 const word& surfaceType,
166 const dictionary& dict
172 virtual ~searchableSurface();
178 //- Names of regions.
179 virtual const wordList& regions() const = 0;
181 //- Whether supports volume type below.
182 virtual bool hasVolumeType() const = 0;
184 //- Range of local indices that can be returned.
185 virtual label size() const = 0;
187 //- Range of global indices that can be returned.
188 virtual label globalSize() const
193 //- Get representative set of element coordinates
194 // Usually the element centres (should be of length size()).
195 virtual pointField coordinates() const = 0;
198 // Single point queries.
200 ////- Calculate nearest point on surface. Returns
201 //// - bool : any point found nearer than nearestDistSqr
202 //// - label: relevant index in surface
203 //// - label: region in surface
204 //// - point: actual nearest point found
205 //virtual pointIndexHit findNearest
207 // const point& sample,
208 // const scalar nearestDistSqr
211 ////- Calculate nearest point on edge. Returns
212 //// - bool : any point found nearer than nearestDistSqr
213 //// - label: relevant index in surface
214 //// - label: region in surface
215 //// - point: actual nearest point found
216 //virtual pointIndexHit findNearestOnEdge
218 // const point& sample,
219 // const scalar nearestDistSqr
222 ////- Find nearest to segment. Returns
223 //// - bool : any point found?
224 //// - label: relevant index in shapes
225 //// - label: region in surface
226 //// - point: actual nearest point found
228 //// - tightest : bounding box
229 //// - linePoint : corresponding nearest point on line
230 //virtual pointIndexHit findNearest
232 // const linePointRef& ln,
233 // treeBoundBox& tightest,
237 ////- Find nearest intersection of line between start and end.
238 //virtual pointIndexHit findLine
240 // const point& start,
244 ////- Find any intersection of line between start and end.
245 //virtual pointIndexHit findLineAny
247 // const point& start,
252 // Multiple point queries. When surface is distributed the index
253 // should be a global index. Not done yet.
255 virtual void findNearest
257 const pointField& sample,
258 const scalarField& nearestDistSqr,
262 //- Find first intersection on segment from start to end.
263 // Note: searchableSurfacesQueries expects no
264 // intersection to be found if start==end. Is problem?
265 virtual void findLine
267 const pointField& start,
268 const pointField& end,
272 //- Return any intersection on segment from start to end.
273 virtual void findLineAny
275 const pointField& start,
276 const pointField& end,
280 //- Get all intersections in order from start to end.
281 virtual void findLineAll
283 const pointField& start,
284 const pointField& end,
285 List<List<pointIndexHit> >&
288 //- From a set of points and indices get the region
289 virtual void getRegion
291 const List<pointIndexHit>&,
295 //- From a set of points and indices get the normal
296 virtual void getNormal
298 const List<pointIndexHit>&,
302 //- Determine type (inside/outside) for point. unknown if
303 // cannot be determined (e.g. non-manifold surface)
304 virtual void getVolumeType
313 //- Set bounds of surface. Bounds currently set as list of
314 // bounding boxes. The bounds are hints to the surface as for
315 // the range of queries it can expect. faceMap/pointMap can be
316 // set if the surface has done any redistribution.
317 virtual void distribute
319 const List<treeBoundBox>&,
320 const bool keepNonLocal,
321 autoPtr<mapDistribute>& faceMap,
322 autoPtr<mapDistribute>& pointMap
326 //- WIP. Store element-wise field.
327 virtual void setField(const labelList& values)
330 //- WIP. From a set of hits (points and
331 // indices) get the specified field. Misses do not get set. Return
332 // empty field if not supported.
333 virtual void getField(const List<pointIndexHit>&, labelList& values)
342 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 } // End namespace Foam
346 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 // ************************************************************************* //