BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / meshTools / searchableSurface / searchableSurfacesQueries.H
blobf819926d04f2bf91e2041944daa5f93fceabb918
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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/>.
24 Class
25     Foam::searchableSurfacesQueries
27 Description
28     A collection of tools for searchableSurfaces.
30 SourceFiles
31     searchableSurfacesQueries.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef searchableSurfacesQueries_H
36 #define searchableSurfacesQueries_H
38 #include "searchableSurface.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 // Forward declaration of classes
46 class plane;
48 /*---------------------------------------------------------------------------*\
49                            Class searchableSurfacesQueries Declaration
50 \*---------------------------------------------------------------------------*/
52 class searchableSurfacesQueries
54     // Private data
56     // Private Member Functions
58         //- Temporary wrapper around findNearest. Used in facesIntersection only
59         static pointIndexHit tempFindNearest
60         (
61             const searchableSurface&,
62             const point& pt,
63             const scalar initDistSqr
64         );
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
70         (
71             const PtrList<searchableSurface>&,
72             const labelList& surfacesToTest,
73             const scalar initialDistSqr,    // search box
74             const point& pt
75         );
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
81         (
82             const PtrList<searchableSurface>&,
83             const labelList& surfacesToTest,
84             const scalar initialDistSqr,
85             List<vector>& p,
86             List<scalar>& y,
87             vector& pSum,
88             const label ihi,
89             const scalar fac
90         );
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.
96         static bool morphTet
97         (
98             const PtrList<searchableSurface>&,
99             const labelList& surfacesToTest,
100             const scalar initialDistSqr,
101             const scalar convergenceDistSqr,
102             const label maxIter,
103             List<vector>& p,
104             List<scalar>& y
105         );
107         //static void findAllIntersections
108         //(
109         //    const searchableSurface& s,
110         //    const pointField& start,
111         //    const pointField& end,
112         //    const vectorField& smallVec,
113         //    List<List<pointIndexHit> >&
114         //);
116         static void mergeHits
117         (
118             const point& start,
119             const scalar mergeDist,
121             const label surfI,
122             const List<pointIndexHit>& surfHits,
124             labelList& allSurfaces,
125             List<pointIndexHit>& allInfo,
126             scalarList& allDistSqr
127         );
129 public:
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
141             (
142                 const PtrList<searchableSurface>&,
143                 const labelList& surfacesToTest,
144                 const pointField& start,
145                 const pointField& end,
146                 labelList& surfaces,
147                 List<pointIndexHit>&
148             );
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
153             (
154                 const PtrList<searchableSurface>&,
155                 const labelList& surfacesToTest,
156                 const pointField& start,
157                 const pointField& end,
158                 labelListList& surfaces,
159                 List<List<pointIndexHit> >& surfaceHits
160             );
162             //- Find nearest. Return -1 (and a miss()) or surface and nearest
163             //  point.
164             static void findNearest
165             (
166                 const PtrList<searchableSurface>&,
167                 const labelList& surfacesToTest,
168                 const pointField&,
169                 const scalarField& nearestDistSqr,
170                 labelList& surfaces,
171                 List<pointIndexHit>&
172             );
175         // Single point queries
177             //- Calculate point which is on a set of surfaces. WIP.
178             static pointIndexHit facesIntersection
179             (
180                 const PtrList<searchableSurface>& allSurfaces,
181                 const labelList& surfacesToTest,
182                 const scalar initDistSqr,
183                 const scalar convergenceDistSqr,
184                 const point& start
185             );
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 } // End namespace Foam
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 #endif
197 // ************************************************************************* //