1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::searchableSurfacesQueries
28 A collection of tools for searchableSurfaces.
31 searchableSurfacesQueries.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef searchableSurfacesQueries_H
36 #define searchableSurfacesQueries_H
38 #include "searchableSurface.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 // Forward declaration of classes
48 /*---------------------------------------------------------------------------*\
49 Class searchableSurfacesQueries Declaration
50 \*---------------------------------------------------------------------------*/
52 class searchableSurfacesQueries
56 // Private Member Functions
58 //- Temporary wrapper around findNearest. Used in facesIntersection only
59 static pointIndexHit tempFindNearest
61 const searchableSurface&,
63 const scalar initDistSqr
66 //- Calculate sum of distances to nearest point on surfaces. Is used
67 // in minimisation to find intersection. Returns sum of (square of)
68 // distances to the surfaces.
69 static scalar sumDistSqr
71 const PtrList<searchableSurface>&,
72 const labelList& surfacesToTest,
73 const scalar initialDistSqr, // search box
77 //- Takes the tet (points p) and reflects the point with the
78 // highest value around the centre (pSum). Checks if it gets closer
79 // and updates p, y if so.
80 static scalar tryMorphTet
82 const PtrList<searchableSurface>&,
83 const labelList& surfacesToTest,
84 const scalar initialDistSqr,
92 //- Downhill simplex method: find the point with min cumulative
93 // distance to all surfaces. Does so by morphing a tet (points p).
94 // Returns the point on the 0th surface or hit if not reached within
95 // maxIters iterations.
98 const PtrList<searchableSurface>&,
99 const labelList& surfacesToTest,
100 const scalar initialDistSqr,
101 const scalar convergenceDistSqr,
107 //static void findAllIntersections
109 // const searchableSurface& s,
110 // const pointField& start,
111 // const pointField& end,
112 // const vectorField& smallVec,
113 // List<List<pointIndexHit> >&
116 static void mergeHits
119 const scalar mergeDist,
122 const List<pointIndexHit>& surfHits,
124 labelList& allSurfaces,
125 List<pointIndexHit>& allInfo,
126 scalarList& allDistSqr
131 // Declare name of the class and its debug switch
132 ClassName("searchableSurfacesQueries");
135 // Multiple point queries.
137 //- Find any intersection. Return hit point information and
138 // index in surfacesToTest. If multiple surfaces hit the first
139 // surface is returned, not necessarily the nearest (to start).
140 static void findAnyIntersection
142 const PtrList<searchableSurface>&,
143 const labelList& surfacesToTest,
144 const pointField& start,
145 const pointField& end,
150 //- Find all intersections in order from start to end. Returns for
151 // every hit the index in surfacesToTest and the hit info.
152 static void findAllIntersections
154 const PtrList<searchableSurface>&,
155 const labelList& surfacesToTest,
156 const pointField& start,
157 const pointField& end,
158 labelListList& surfaces,
159 List<List<pointIndexHit> >& surfaceHits
162 //- Find nearest. Return -1 (and a miss()) or surface and nearest
164 static void findNearest
166 const PtrList<searchableSurface>&,
167 const labelList& surfacesToTest,
169 const scalarField& nearestDistSqr,
175 // Single point queries
177 //- Calculate point which is on a set of surfaces. WIP.
178 static pointIndexHit facesIntersection
180 const PtrList<searchableSurface>& allSurfaces,
181 const labelList& surfacesToTest,
182 const scalar initDistSqr,
183 const scalar convergenceDistSqr,
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 } // End namespace Foam
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 // ************************************************************************* //