OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::searchableSurfacesQueries
00027 
00028 Description
00029     A collection of tools for searchableSurfaces.
00030 
00031 SourceFiles
00032     searchableSurfacesQueries.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef searchableSurfacesQueries_H
00037 #define searchableSurfacesQueries_H
00038 
00039 #include "searchableSurface.H"
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 // Forward declaration of classes
00047 class plane;
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class searchableSurfacesQueries Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 class searchableSurfacesQueries
00054 {
00055     // Private data
00056 
00057     // Private Member Functions
00058 
00059         //- Temporary wrapper around findNearest. Used in facesIntersection only
00060         static pointIndexHit tempFindNearest
00061         (
00062             const searchableSurface&,
00063             const point& pt,
00064             const scalar initDistSqr
00065         );
00066 
00067         //- Calculate sum of distances to nearest point on surfaces. Is used
00068         //  in minimisation to find intersection. Returns sum of (square of)
00069         //  distances to the surfaces.
00070         static scalar sumDistSqr
00071         (
00072             const PtrList<searchableSurface>&,
00073             const labelList& surfacesToTest,
00074             const scalar initialDistSqr,    // search box
00075             const point& pt
00076         );
00077 
00078         //- Takes the tet (points p) and reflects the point with the
00079         //  highest value around the centre (pSum). Checks if it gets closer
00080         //  and updates p, y if so.
00081         static scalar tryMorphTet
00082         (
00083             const PtrList<searchableSurface>&,
00084             const labelList& surfacesToTest,
00085             const scalar initialDistSqr,
00086             List<vector>& p,
00087             List<scalar>& y,
00088             vector& pSum,
00089             const label ihi,
00090             const scalar fac
00091         );
00092 
00093         //- Downhill simplex method: find the point with min cumulative
00094         //  distance to all surfaces. Does so by morphing a tet (points p).
00095         //  Returns the point on the 0th surface or hit if not reached within
00096         //  maxIters iterations.
00097         static bool morphTet
00098         (
00099             const PtrList<searchableSurface>&,
00100             const labelList& surfacesToTest,
00101             const scalar initialDistSqr,
00102             const scalar convergenceDistSqr,
00103             const label maxIter,
00104             List<vector>& p,
00105             List<scalar>& y
00106         );
00107 
00108         //static void findAllIntersections
00109         //(
00110         //    const searchableSurface& s,
00111         //    const pointField& start,
00112         //    const pointField& end,
00113         //    const vectorField& smallVec,
00114         //    List<List<pointIndexHit> >&
00115         //);
00116 
00117         static void mergeHits
00118         (
00119             const point& start,
00120             const scalar mergeDist,
00121 
00122             const label surfI,
00123             const List<pointIndexHit>& surfHits,
00124 
00125             labelList& allSurfaces,
00126             List<pointIndexHit>& allInfo,
00127             scalarList& allDistSqr
00128         );
00129 
00130 public:
00131 
00132     // Declare name of the class and its debug switch
00133     ClassName("searchableSurfacesQueries");
00134 
00135 
00136         // Multiple point queries.
00137 
00138             //- Find any intersection. Return hit point information and
00139             //  index in surfacesToTest. If multiple surfaces hit the first
00140             //  surface is returned, not necessarily the nearest (to start).
00141             static void findAnyIntersection
00142             (
00143                 const PtrList<searchableSurface>&,
00144                 const labelList& surfacesToTest,
00145                 const pointField& start,
00146                 const pointField& end,
00147                 labelList& surfaces,
00148                 List<pointIndexHit>&
00149             );
00150 
00151             //- Find all intersections in order from start to end. Returns for
00152             //  every hit the index in surfacesToTest and the hit info.
00153             static void findAllIntersections
00154             (
00155                 const PtrList<searchableSurface>&,
00156                 const labelList& surfacesToTest,
00157                 const pointField& start,
00158                 const pointField& end,
00159                 labelListList& surfaces,
00160                 List<List<pointIndexHit> >& surfaceHits
00161             );
00162 
00163             //- Find nearest. Return -1 (and a miss()) or surface and nearest
00164             //  point.
00165             static void findNearest
00166             (
00167                 const PtrList<searchableSurface>&,
00168                 const labelList& surfacesToTest,
00169                 const pointField&,
00170                 const scalarField& nearestDistSqr,
00171                 labelList& surfaces,
00172                 List<pointIndexHit>&
00173             );
00174 
00175 
00176         // Single point queries
00177 
00178             //- Calculate point which is on a set of surfaces. WIP.
00179             static pointIndexHit facesIntersection
00180             (
00181                 const PtrList<searchableSurface>& allSurfaces,
00182                 const labelList& surfacesToTest,
00183                 const scalar initDistSqr,
00184                 const scalar convergenceDistSqr,
00185                 const point& start
00186             );
00187 };
00188 
00189 
00190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00191 
00192 } // End namespace Foam
00193 
00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00195 
00196 #endif
00197 
00198 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd