Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / meshTools / searchableSurface / searchableSurfacesQueries.H
blob102ea1292b974ec8765660ad446f031500403afb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::searchableSurfacesQueries
28 Description
29     A collection of tools for searchableSurfaces.
31 SourceFiles
32     searchableSurfacesQueries.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef searchableSurfacesQueries_H
37 #define searchableSurfacesQueries_H
39 #include "searchableSurface.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
47 class plane;
49 /*---------------------------------------------------------------------------*\
50                            Class searchableSurfacesQueries Declaration
51 \*---------------------------------------------------------------------------*/
53 class searchableSurfacesQueries
55     // Private data
57     // Private Member Functions
59         //- Temporary wrapper around findNearest. Used in facesIntersection only
60         static pointIndexHit tempFindNearest
61         (
62             const searchableSurface&,
63             const point& pt,
64             const scalar initDistSqr
65         );
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
71         (
72             const PtrList<searchableSurface>&,
73             const labelList& surfacesToTest,
74             const scalar initialDistSqr,    // search box
75             const point& pt
76         );
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
82         (
83             const PtrList<searchableSurface>&,
84             const labelList& surfacesToTest,
85             const scalar initialDistSqr,
86             List<vector>& p,
87             List<scalar>& y,
88             vector& pSum,
89             const label ihi,
90             const scalar fac
91         );
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.
97         static bool morphTet
98         (
99             const PtrList<searchableSurface>&,
100             const labelList& surfacesToTest,
101             const scalar initialDistSqr,
102             const scalar convergenceDistSqr,
103             const label maxIter,
104             List<vector>& p,
105             List<scalar>& y
106         );
108         //static void findAllIntersections
109         //(
110         //    const searchableSurface& s,
111         //    const pointField& start,
112         //    const pointField& end,
113         //    const vectorField& smallVec,
114         //    List<List<pointIndexHit> >&
115         //);
117         static void mergeHits
118         (
119             const point& start,
120             const scalar mergeDist,
122             const label surfI,
123             const List<pointIndexHit>& surfHits,
125             labelList& allSurfaces,
126             List<pointIndexHit>& allInfo,
127             scalarList& allDistSqr
128         );
130 public:
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
142             (
143                 const PtrList<searchableSurface>&,
144                 const labelList& surfacesToTest,
145                 const pointField& start,
146                 const pointField& end,
147                 labelList& surfaces,
148                 List<pointIndexHit>&
149             );
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
154             (
155                 const PtrList<searchableSurface>&,
156                 const labelList& surfacesToTest,
157                 const pointField& start,
158                 const pointField& end,
159                 labelListList& surfaces,
160                 List<List<pointIndexHit> >& surfaceHits
161             );
163             //- Find nearest. Return -1 (and a miss()) or surface and nearest
164             //  point.
165             static void findNearest
166             (
167                 const PtrList<searchableSurface>&,
168                 const labelList& surfacesToTest,
169                 const pointField&,
170                 const scalarField& nearestDistSqr,
171                 labelList& surfaces,
172                 List<pointIndexHit>&
173             );
176         // Single point queries
178             //- Calculate point which is on a set of surfaces. WIP.
179             static pointIndexHit facesIntersection
180             (
181                 const PtrList<searchableSurface>& allSurfaces,
182                 const labelList& surfacesToTest,
183                 const scalar initDistSqr,
184                 const scalar convergenceDistSqr,
185                 const point& start
186             );
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 #endif
198 // ************************************************************************* //