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::searchableSurfacesQueries
29 A collection of tools for searchableSurfaces.
32 searchableSurfacesQueries.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef searchableSurfacesQueries_H
37 #define searchableSurfacesQueries_H
39 #include "searchableSurface.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 // Forward declaration of classes
49 /*---------------------------------------------------------------------------*\
50 Class searchableSurfacesQueries Declaration
51 \*---------------------------------------------------------------------------*/
53 class searchableSurfacesQueries
57 // Private Member Functions
59 //- Temporary wrapper around findNearest. Used in facesIntersection only
60 static pointIndexHit tempFindNearest
62 const searchableSurface&,
64 const scalar initDistSqr
67 //- Calculate sum of distances to nearest point on surfaces. Is used
68 // in minimisation to find intersection. Returns sum of (square of)
69 // distances to the surfaces.
70 static scalar sumDistSqr
72 const PtrList<searchableSurface>&,
73 const labelList& surfacesToTest,
74 const scalar initialDistSqr, // search box
78 //- Takes the tet (points p) and reflects the point with the
79 // highest value around the centre (pSum). Checks if it gets closer
80 // and updates p, y if so.
81 static scalar tryMorphTet
83 const PtrList<searchableSurface>&,
84 const labelList& surfacesToTest,
85 const scalar initialDistSqr,
93 //- Downhill simplex method: find the point with min cumulative
94 // distance to all surfaces. Does so by morphing a tet (points p).
95 // Returns the point on the 0th surface or hit if not reached within
96 // maxIters iterations.
99 const PtrList<searchableSurface>&,
100 const labelList& surfacesToTest,
101 const scalar initialDistSqr,
102 const scalar convergenceDistSqr,
108 //static void findAllIntersections
110 // const searchableSurface& s,
111 // const pointField& start,
112 // const pointField& end,
113 // const vectorField& smallVec,
114 // List<List<pointIndexHit> >&
117 static void mergeHits
120 const scalar mergeDist,
123 const List<pointIndexHit>& surfHits,
125 labelList& allSurfaces,
126 List<pointIndexHit>& allInfo,
127 scalarList& allDistSqr
132 // Declare name of the class and its debug switch
133 ClassName("searchableSurfacesQueries");
136 // Multiple point queries.
138 //- Find any intersection. Return hit point information and
139 // index in surfacesToTest. If multiple surfaces hit the first
140 // surface is returned, not necessarily the nearest (to start).
141 static void findAnyIntersection
143 const PtrList<searchableSurface>&,
144 const labelList& surfacesToTest,
145 const pointField& start,
146 const pointField& end,
151 //- Find all intersections in order from start to end. Returns for
152 // every hit the index in surfacesToTest and the hit info.
153 static void findAllIntersections
155 const PtrList<searchableSurface>&,
156 const labelList& surfacesToTest,
157 const pointField& start,
158 const pointField& end,
159 labelListList& surfaces,
160 List<List<pointIndexHit> >& surfaceHits
163 //- Find nearest. Return -1 (and a miss()) or surface and nearest
165 static void findNearest
167 const PtrList<searchableSurface>&,
168 const labelList& surfacesToTest,
170 const scalarField& nearestDistSqr,
176 // Single point queries
178 //- Calculate point which is on a set of surfaces. WIP.
179 static pointIndexHit facesIntersection
181 const PtrList<searchableSurface>& allSurfaces,
182 const labelList& surfacesToTest,
183 const scalar initDistSqr,
184 const scalar convergenceDistSqr,
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 // ************************************************************************* //