FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

searchableSurfacesQueries.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::searchableSurfacesQueries
00026 
00027 Description
00028     A collection of tools for searchableSurfaces.
00029 
00030 SourceFiles
00031     searchableSurfacesQueries.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef searchableSurfacesQueries_H
00036 #define searchableSurfacesQueries_H
00037 
00038 #include <meshTools/searchableSurface.H>
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 // Forward declaration of classes
00046 class plane;
00047 
00048 /*---------------------------------------------------------------------------*\
00049                            Class searchableSurfacesQueries Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class searchableSurfacesQueries
00053 {
00054     // Private data
00055 
00056     // Private Member Functions
00057 
00058         //- Temporary wrapper around findNearest. Used in facesIntersection only
00059         static pointIndexHit tempFindNearest
00060         (
00061             const searchableSurface&,
00062             const point& pt,
00063             const scalar initDistSqr
00064         );
00065 
00066         //- Calculate sum of distances to nearest point on surfaces. Is used
00067         //  in minimisation to find intersection. Returns sum of (square of)
00068         //  distances to the surfaces.
00069         static scalar sumDistSqr
00070         (
00071             const PtrList<searchableSurface>&,
00072             const labelList& surfacesToTest,
00073             const scalar initialDistSqr,    // search box
00074             const point& pt
00075         );
00076 
00077         //- Takes the tet (points p) and reflects the point with the
00078         //  highest value around the centre (pSum). Checks if it gets closer
00079         //  and updates p, y if so.
00080         static scalar tryMorphTet
00081         (
00082             const PtrList<searchableSurface>&,
00083             const labelList& surfacesToTest,
00084             const scalar initialDistSqr,
00085             List<vector>& p,
00086             List<scalar>& y,
00087             vector& pSum,
00088             const label ihi,
00089             const scalar fac
00090         );
00091 
00092         //- Downhill simplex method: find the point with min cumulative
00093         //  distance to all surfaces. Does so by morphing a tet (points p).
00094         //  Returns the point on the 0th surface or hit if not reached within
00095         //  maxIters iterations.
00096         static bool morphTet
00097         (
00098             const PtrList<searchableSurface>&,
00099             const labelList& surfacesToTest,
00100             const scalar initialDistSqr,
00101             const scalar convergenceDistSqr,
00102             const label maxIter,
00103             List<vector>& p,
00104             List<scalar>& y
00105         );
00106 
00107         //static void findAllIntersections
00108         //(
00109         //    const searchableSurface& s,
00110         //    const pointField& start,
00111         //    const pointField& end,
00112         //    const vectorField& smallVec,
00113         //    List<List<pointIndexHit> >&
00114         //);
00115 
00116         static void mergeHits
00117         (
00118             const point& start,
00119             const scalar mergeDist,
00120 
00121             const label surfI,
00122             const List<pointIndexHit>& surfHits,
00123 
00124             labelList& allSurfaces,
00125             List<pointIndexHit>& allInfo,
00126             scalarList& allDistSqr
00127         );
00128 
00129 public:
00130 
00131     // Declare name of the class and its debug switch
00132     ClassName("searchableSurfacesQueries");
00133 
00134 
00135         // Multiple point queries.
00136 
00137             //- Find any intersection. Return hit point information and
00138             //  index in surfacesToTest. If multiple surfaces hit the first
00139             //  surface is returned, not necessarily the nearest (to start).
00140             static void findAnyIntersection
00141             (
00142                 const PtrList<searchableSurface>&,
00143                 const labelList& surfacesToTest,
00144                 const pointField& start,
00145                 const pointField& end,
00146                 labelList& surfaces,
00147                 List<pointIndexHit>&
00148             );
00149 
00150             //- Find all intersections in order from start to end. Returns for
00151             //  every hit the index in surfacesToTest and the hit info.
00152             static void findAllIntersections
00153             (
00154                 const PtrList<searchableSurface>&,
00155                 const labelList& surfacesToTest,
00156                 const pointField& start,
00157                 const pointField& end,
00158                 labelListList& surfaces,
00159                 List<List<pointIndexHit> >& surfaceHits
00160             );
00161 
00162             //- Find nearest. Return -1 (and a miss()) or surface and nearest
00163             //  point.
00164             static void findNearest
00165             (
00166                 const PtrList<searchableSurface>&,
00167                 const labelList& surfacesToTest,
00168                 const pointField&,
00169                 const scalarField& nearestDistSqr,
00170                 labelList& surfaces,
00171                 List<pointIndexHit>&
00172             );
00173 
00174 
00175         // Single point queries
00176 
00177             //- Calculate point which is on a set of surfaces. WIP.
00178             static pointIndexHit facesIntersection
00179             (
00180                 const PtrList<searchableSurface>& allSurfaces,
00181                 const labelList& surfacesToTest,
00182                 const scalar initDistSqr,
00183                 const scalar convergenceDistSqr,
00184                 const point& start
00185             );
00186 };
00187 
00188 
00189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00190 
00191 } // End namespace Foam
00192 
00193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00194 
00195 #endif
00196 
00197 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines