![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 meshSearch 00027 00028 Description 00029 Various searches on polyMesh; uses (demand driven) octree to search. 00030 00031 SourceFiles 00032 meshSearch.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef meshSearch_H 00037 #define meshSearch_H 00038 00039 #include "octreeDataCell.H" 00040 #include "octreeDataFace.H" 00041 #include "octreeDataPoint.H" 00042 #include "pointIndexHit.H" 00043 #include "className.H" 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 // Class forward declarations 00051 class polyMesh; 00052 00053 /*---------------------------------------------------------------------------*\ 00054 Class meshSearch Declaration 00055 \*---------------------------------------------------------------------------*/ 00056 00057 class meshSearch 00058 { 00059 // Private data 00060 00061 //- Reference to mesh 00062 const polyMesh& mesh_; 00063 00064 //- Whether to use face decomposition for all geometric tests 00065 const bool faceDecomp_; 00066 00067 //- demand driven octrees 00068 00069 mutable octree<octreeDataFace>* boundaryTreePtr_; 00070 mutable octree<octreeDataCell>* cellTreePtr_; 00071 mutable octree<octreeDataPoint>* cellCentreTreePtr_; 00072 00073 00074 // Private Member Functions 00075 00076 //- nearest cell centre using octree 00077 label findNearestCellTree(const point& location) const; 00078 00079 //- nearest cell centre going through all cells 00080 label findNearestCellLinear(const point& location) const; 00081 00082 //- walk from seed. Does not 'go around' boundary, just returns 00083 // last cell before boundary. 00084 label findNearestCellWalk 00085 ( 00086 const point& location, 00087 const label seedCellI 00088 ) const; 00089 00090 //- cell containing location. Linear search. 00091 label findCellLinear(const point& location) const; 00092 00093 //- walk from seed to find nearest boundary face. Gets stuck in 00094 // local minimum. 00095 label findNearestBoundaryFaceWalk 00096 ( 00097 const point& location, 00098 const label seedFaceI 00099 ) const; 00100 00101 //- Calculate offset vector in direction dir with as length a fraction 00102 // of the cell size (of the cell straddling boundary face) 00103 vector offset 00104 ( 00105 const point& bPoint, 00106 const label bFaceI, 00107 const vector& dir 00108 ) const; 00109 00110 00111 //- Disallow default bitwise copy construct 00112 meshSearch(const meshSearch&); 00113 00114 //- Disallow default bitwise assignment 00115 void operator=(const meshSearch&); 00116 00117 00118 public: 00119 00120 // Declare name of the class and it's debug switch 00121 ClassName("meshSearch"); 00122 00123 00124 // Static data members 00125 00126 //- tolerance on linear dimensions 00127 static scalar tol_; 00128 00129 00130 // Constructors 00131 00132 //- Construct from components 00133 meshSearch(const polyMesh& mesh, const bool faceDecomp = true); 00134 00135 00136 // Destructor 00137 00138 ~meshSearch(); 00139 00140 00141 // Member Functions 00142 00143 // Access 00144 00145 const polyMesh& mesh() const 00146 { 00147 return mesh_; 00148 } 00149 00150 //- Get (demand driven) reference to octree holding all 00151 // boundary faces 00152 const octree<octreeDataFace>& boundaryTree() const; 00153 00154 //- Get (demand driven) reference to octree holding all cells 00155 const octree<octreeDataCell>& cellTree() const; 00156 00157 //- Get (demand driven) reference to octree holding all cell centres 00158 const octree<octreeDataPoint>& cellCentreTree() const; 00159 00160 00161 // Queries 00162 00163 //- test for point in cell. Does not handle cells with center 00164 // outside cell. 00165 bool pointInCell(const point& p, const label celli) const; 00166 00167 //- Find nearest cell in terms of cell centre. 00168 // - use octree 00169 // - use linear search 00170 // - if seed is provided walk. (uses findNearestCellWalk; 00171 // does not handle holes in domain) 00172 label findNearestCell 00173 ( 00174 const point& location, 00175 const label seedCellI = -1, 00176 const bool useTreeSearch = true 00177 ) const; 00178 00179 //- Find cell containing (using pointInCell) location. 00180 // If seed provided walks and falls back to linear/tree search. 00181 // (so handles holes correctly)s 00182 // Returns -1 if not in domain. 00183 label findCell 00184 ( 00185 const point& location, 00186 const label seedCellI = -1, 00187 const bool useTreeSearch = true 00188 ) const; 00189 00190 //- Find nearest boundary face 00191 // If seed provided walks but then does not pass local minima 00192 // in distance. Also does not jump from one connected region to 00193 // the next. 00194 label findNearestBoundaryFace 00195 ( 00196 const point& location, 00197 const label seedFaceI = -1, 00198 const bool useTreeSearch = true 00199 ) const; 00200 00201 //- Find first intersection of boundary in segment [pStart, pEnd] 00202 // (so inclusive of endpoints). Always octree for now 00203 pointIndexHit intersection(const point& pStart, const point& pEnd) 00204 const; 00205 00206 //- Find all intersections of boundary within segment pStart .. pEnd 00207 // Always octree for now 00208 List<pointIndexHit> intersections 00209 ( 00210 const point& pStart, 00211 const point& pEnd 00212 ) const; 00213 00214 //- Determine inside/outside status 00215 bool isInside(const point&) const; 00216 00217 00218 //- delete all storage 00219 void clearOut(); 00220 00221 //- Correct for mesh geom/topo changes 00222 void correct(); 00223 }; 00224 00225 00226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00227 00228 } // End namespace Foam 00229 00230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00231 00232 #endif 00233 00234 // ************************************************************************* //