|
|
|
cellMatcher.HGo 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::cellMatcher 00027 00028 Description 00029 Base class for cellshape matchers (hexMatch, prismMatch, etc.). These are 00030 classes which given a mesh and cell number find out the orientation of 00031 the cellShape and construct cell-vertex to mesh-vertex mapping and 00032 cell-face to mesh-face mapping. 00033 00034 For example, 00035 @verbatim 00036 hexMatcher hex(mesh); 00037 cellShape shape; 00038 .. 00039 bool isHex = hex.match(cellI, shape); 00040 @endverbatim 00041 Now shape is set to the correct Hex cellShape (if @a isHex is true) 00042 00043 Alternatively there is direct access to the vertex and face mapping: 00044 @verbatim 00045 const labelList& hexVertLabels = hex.vertLabels(); 00046 const labelList& hexFaceLabels = hex.faceLabels(); 00047 @endverbatim 00048 Now 00049 - @c hexVertLabels[n] is vertex label of hex vertex n 00050 - @c hexFaceLabels[n] is face label of hex vertex n 00051 00052 Process of cellShape recognition consists of following steps: 00053 - renumber vertices of cell to local vertex numbers 00054 - construct (local to cell) addressing edge-to-faces 00055 - construct (local to cell) addressing vertex and face to index in face 00056 - find most unique face shape (e.g. triangle for prism) 00057 - walk (following either vertices in face or jumping from face to other 00058 face) to other faces and checking face sizes. 00059 - if nessecary try other rotations of this face 00060 (only nessecary for wedge, tet-wedge) 00061 - if nessecary try other faces which most unique face shape 00062 (never nessecary for hex degenerates) 00063 00064 The whole calculation is done such that no lists are allocated during 00065 cell checking. E.g. localFaces_ are always sized to hold max. number 00066 of possible face vertices and a separate list is filled which holds 00067 the actusl face sizes. 00068 00069 For now all hex-degenerates implemented. Numbering taken from picture in 00070 demoGuide. 00071 00072 SourceFiles 00073 cellMatcherI.H 00074 cellMatcher.C 00075 00076 \*---------------------------------------------------------------------------*/ 00077 00078 #ifndef cellMatcher_H 00079 #define cellMatcher_H 00080 00081 #include "labelList.H" 00082 #include "faceList.H" 00083 #include "boolList.H" 00084 #include "Map.H" 00085 00086 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00087 00088 namespace Foam 00089 { 00090 00091 // Forward declaration of classes 00092 class primitiveMesh; 00093 class cell; 00094 class cellShape; 00095 class cellModel; 00096 00097 /*---------------------------------------------------------------------------*\ 00098 Class cellMatcher Declaration 00099 \*---------------------------------------------------------------------------*/ 00100 00101 class cellMatcher 00102 { 00103 protected: 00104 00105 // Static functions 00106 00107 //- Given start and end of edge generate unique key 00108 inline static label edgeKey 00109 ( 00110 const label numVert, 00111 const label v0, 00112 const label v1 00113 ); 00114 00115 //- Step along face either in righthand or lefthand direction 00116 inline static label nextVert(const label, const label, const bool); 00117 00118 // Protected data 00119 00120 // Map from mesh to local vertex numbering 00121 Map<label> localPoint_; 00122 00123 //- Faces using local vertex numbering 00124 faceList localFaces_; 00125 00126 //- Number of vertices per face in localFaces_ 00127 labelList faceSize_; 00128 00129 //- Map from local to mesh vertex numbering 00130 labelList pointMap_; 00131 00132 //- Map from local to mesh face numbering 00133 labelList faceMap_; 00134 00135 //- Map from 'edge' to neighbouring faces 00136 labelList edgeFaces_; 00137 00138 //- pointFaceIndex[localVertI][localFaceI] is index in localFace 00139 // where localVertI is. 00140 labelListList pointFaceIndex_; 00141 00142 //- After matching: holds mesh vertices in cellmodel order 00143 labelList vertLabels_; 00144 00145 //- After matching: holds mesh faces in cellmodel order 00146 labelList faceLabels_; 00147 00148 //- CellModel name 00149 const word cellModelName_; 00150 00151 mutable const cellModel* cellModelPtr_; 00152 00153 00154 // Protected Member Functions 00155 00156 //- Calculates localFaces. Returns number of local vertices (or -1 00157 // if more than vertPerCell). 00158 label calcLocalFaces(const faceList& faces, const labelList& myFaces); 00159 00160 //- Fill edge (start, end) to face number 00161 void calcEdgeAddressing(const label numVert); 00162 00163 //- Fill vertex/face to index in face data structure 00164 void calcPointFaceIndex(); 00165 00166 //- Given start,end of edge lookup both faces sharing it and return 00167 // face != localFaceI 00168 label otherFace 00169 ( 00170 const label numVert, 00171 const label v0, 00172 const label v1, 00173 const label localFaceI 00174 ) const; 00175 00176 00177 private: 00178 00179 // Private Member Functions 00180 00181 //- Disallow default bitwise copy construct and assignment 00182 cellMatcher(const cellMatcher&); 00183 void operator=(const cellMatcher&); 00184 00185 00186 public: 00187 00188 // Static functions 00189 00190 //- Create list with incrementing labels 00191 static labelList makeIdentity(const label nElems); 00192 00193 00194 // Constructors 00195 00196 //- Construct given mesh and shape factors 00197 cellMatcher 00198 ( 00199 const label vertPerCell, 00200 const label facePerCell, 00201 const label maxVertPerFace, 00202 const word& cellModelName 00203 ); 00204 00205 00206 // Destructor 00207 00208 virtual ~cellMatcher() 00209 {} 00210 00211 00212 // Member Functions 00213 00214 // Access 00215 00216 inline const Map<label>& localPoint() const; 00217 inline const faceList& localFaces() const; 00218 inline const labelList& faceSize() const; 00219 inline const labelList& pointMap() const; 00220 inline const labelList& faceMap() const; 00221 inline const labelList& edgeFaces() const; 00222 inline const labelListList& pointFaceIndex() const; 00223 inline const labelList& vertLabels() const; 00224 inline const labelList& faceLabels() const; 00225 inline const cellModel& model() const; 00226 00227 00228 // Write 00229 00230 void write(Ostream& os) const; 00231 00232 // Cell shape dependent 00233 00234 virtual label nVertPerCell() const = 0; 00235 00236 virtual label nFacePerCell() const = 0; 00237 00238 virtual label nMaxVertPerFace() const = 0; 00239 00240 //- Hash value of all face sizes of this shape. Can be used for 00241 // quick initial recognition. 00242 virtual label faceHashValue() const = 0; 00243 00244 //- Check whether number of face sizes match the shape. 00245 virtual bool faceSizeMatch(const faceList&, const labelList&) 00246 const = 0; 00247 00248 //- Low level shape recognition. Return true if matches. 00249 // Works in detection mode only (checkOnly=true) or in exact 00250 // matching. Returns true and sets vertLabels_. 00251 // Needs faces, faceOwner of all faces in 'mesh' and cell number 00252 // and labels of faces for this cell. 00253 // cellI only used in combination with faceOwner to detect owner 00254 // status. 00255 virtual bool matchShape 00256 ( 00257 const bool checkOnly, 00258 const faceList& faces, 00259 const labelList& faceOwner, 00260 const label cellI, 00261 const labelList& myFaces 00262 ) = 0; 00263 00264 //- Exact match. Uses faceSizeMatch. 00265 // Returns true if cell matches shape exactly. 00266 virtual bool isA(const primitiveMesh& mesh, const label cellI) = 0; 00267 00268 //- Exact match given all the faces forming a cell. No checks 00269 // on whether faces match up and form a closed shape. 00270 virtual bool isA(const faceList&) = 0; 00271 00272 //- Like isA but also constructs a cellShape (if shape matches) 00273 virtual bool matches 00274 ( 00275 const primitiveMesh& mesh, 00276 const label cellI, 00277 cellShape& shape 00278 ) = 0; 00279 00280 }; 00281 00282 00283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00284 00285 } // End namespace Foam 00286 00287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00288 00289 #include "cellMatcherI.H" 00290 00291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00292 00293 #endif 00294 00295 // ************************************************************************* // |