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::addPatchCellLayer 00026 00027 Description 00028 Adds layers of cells to outside of polyPatch. 00029 00030 Call setRefinement with offset vector for every patch point and number 00031 of layers per patch face and number of layers per patch point. 00032 - offset vector should be zero for any non-manifold point and synchronised 00033 on coupled points before calling this. 00034 - offset vector of zero will not add any points. 00035 - gets supplied the number of extruded layers both per face and per 00036 point. Usually the point nlayers is the max of surrounding face nlayers. 00037 00038 point nlayers: 00039 - 0 : no extrusion. Any surrounding face being extruded becomes 'prism' 00040 - >0 : should be max of surrounding face nlayers. 00041 00042 - differing face nlayers: 'termination' : (e.g. from 2 to 4 layers) match 00043 at original patch face side. 00044 00045 E.g. 2 boundary faces on patches a,b. 2 layers for a, 3 for b. 00046 00047 @verbatim 00048 Was: 00049 00050 a b <- patch of boundary face 00051 +------+------+ 00052 | | | <- original cells 00053 +------+------+ 00054 00055 Becomes: 00056 00057 a b <- patch of boundary face 00058 +------+------+ 00059 + +------+ 00060 +------+------+ 00061 +------+------+ 00062 | | | <- original cells 00063 +------+------+ 00064 @endverbatim 00065 00066 00067 - added faces get same patchID as face they are extruded from 00068 - 'side' faces (i.e. on the edge of pp) get the patchID of the 00069 other patch they are connected to. 00070 00071 00072 E.g. 3 boundary faces on patches a,b. b gets extruded, a doesn't. 00073 00074 @verbatim 00075 a b b <- patch of boundary face 00076 +------+------+------+ 00077 | | | | <- cells 00078 +------+------+------+ 00079 00080 00081 ^ ^ <- wanted extrusion vector (none at far right) 00082 a | b | b <- patch of boundary face 00083 +------+------+------+ 00084 | | | | <- cells 00085 +------+------+------+ 00086 00087 b 00088 +------+\ b 1. prism cell added onto second b face since 00089 a a| | ----\ only one side gets extruded. 00090 +------+------+------+ 2. side-face gets patch a, not b. 00091 | | | | 00092 +------+------+------+ 00093 @endverbatim 00094 00095 00096 SourceFiles 00097 addPatchCellLayer.C 00098 00099 \*---------------------------------------------------------------------------*/ 00100 00101 #ifndef addPatchCellLayer_H 00102 #define addPatchCellLayer_H 00103 00104 #include <OpenFOAM/labelList.H> 00105 #include <OpenFOAM/typeInfo.H> 00106 #include <OpenFOAM/labelPair.H> 00107 #include <OpenFOAM/indirectPrimitivePatch.H> 00108 00109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00110 00111 namespace Foam 00112 { 00113 00114 // Forward declaration of classes 00115 class polyMesh; 00116 class polyTopoChange; 00117 class mapPolyMesh; 00118 class primitiveMesh; 00119 class globalIndex; 00120 00121 /*---------------------------------------------------------------------------*\ 00122 Class addPatchCellLayer Declaration 00123 \*---------------------------------------------------------------------------*/ 00124 00125 class addPatchCellLayer 00126 { 00127 // Private classes 00128 00129 // To combineReduce a labelList. Filters out duplicates. 00130 class uniqueEqOp 00131 { 00132 00133 public: 00134 00135 void operator()(labelList& x, const labelList& y) const 00136 { 00137 if (x.empty()) 00138 { 00139 if (y.size()) 00140 { 00141 x = y; 00142 } 00143 } 00144 else 00145 { 00146 forAll(y, yi) 00147 { 00148 if (findIndex(x, y[yi]) == -1) 00149 { 00150 label sz = x.size(); 00151 x.setSize(sz+1); 00152 x[sz] = y[yi]; 00153 } 00154 } 00155 } 00156 } 00157 }; 00158 00159 00160 00161 // Private data 00162 00163 //- Reference to mesh 00164 const polyMesh& mesh_; 00165 00166 //- For all patchpoints: list of added points (size 0 or nLayers) 00167 // First point in list is one nearest to original point in patch, 00168 // last one is the new point on the surface. 00169 labelListList addedPoints_; 00170 00171 //- For all patchfaces: list of layer faces. 00172 // - empty if no face extruded 00173 // - first face is original boundary face 00174 // - last one is new boundary face. 00175 labelListList layerFaces_; 00176 00177 00178 // Private Member Functions 00179 00180 //- Per patch edge the pp faces (in global indices) using it. Uses 00181 // uniqueEqOp() to remove duplicates. 00182 labelListList calcGlobalEdgeFaces 00183 ( 00184 const polyMesh& mesh, 00185 const globalIndex& globalFaces, 00186 const indirectPrimitivePatch& pp, 00187 const labelList& meshEdges 00188 ); 00189 00190 //- Get the face on the other side of the edge. 00191 static label nbrFace 00192 ( 00193 const labelListList& edgeFaces, 00194 const label edgeI, 00195 const label faceI 00196 ); 00197 00198 //- Add vertex to face if unique. 00199 static void addVertex(const label, face&, label& fp); 00200 00201 bool sameEdgeNeighbour 00202 ( 00203 const indirectPrimitivePatch& pp, 00204 const labelListList& globalEdgeFaces, 00205 const boolList& doneEdge, 00206 const label thisGlobalFaceI, 00207 const label nbrGlobalFaceI, 00208 const label edgeI 00209 ) const; 00210 00211 labelPair getEdgeString 00212 ( 00213 const indirectPrimitivePatch& pp, 00214 const labelListList& globalEdgeFaces, 00215 const boolList& doneEdge, 00216 const label patchFaceI, 00217 const label globalFaceI 00218 ) const; 00219 00220 00221 //- Add face between layer-1 and layer. 00222 label addSideFace 00223 ( 00224 const indirectPrimitivePatch&, 00225 const labelList& patchID, 00226 const labelListList& addedCells, 00227 const face& newFace, 00228 const label ownFaceI, 00229 const label nbrFaceI, 00230 const label patchEdgeI, 00231 const label meshEdgeI, 00232 const label layerI, 00233 const label numEdgeFaces, 00234 const labelList& meshFaces, 00235 polyTopoChange& 00236 ) const; 00237 00238 00239 //- Disallow default bitwise copy construct 00240 addPatchCellLayer(const addPatchCellLayer&); 00241 00242 //- Disallow default bitwise assignment 00243 void operator=(const addPatchCellLayer&); 00244 00245 00246 public: 00247 00248 //- Runtime type information 00249 ClassName("addPatchCellLayer"); 00250 00251 00252 // Constructors 00253 00254 //- Construct from mesh. 00255 addPatchCellLayer(const polyMesh& mesh); 00256 00257 00258 // Member Functions 00259 00260 00261 // Access 00262 00263 //- Added points per patch point. 00264 const labelListList& addedPoints() const 00265 { 00266 return addedPoints_; 00267 } 00268 00269 //- Layer faces per patch face. See above. 00270 const labelListList& layerFaces() const 00271 { 00272 return layerFaces_; 00273 } 00274 00275 //- Helper: get added cells per patch face. 00276 // addedCells[patchFace] is list of cells added. Last element is 00277 // the top cells (i.e. the boundary cell) 00278 static labelListList addedCells 00279 ( 00280 const polyMesh&, 00281 const labelListList& layerFaces 00282 ); 00283 00284 //- added cells given current mesh & layerfaces. 00285 labelListList addedCells() const; 00286 00287 00288 // Edit 00289 00290 //- Play commands into polyTopoChange to create layers on top 00291 // of indirectPrimitivePatch (have to be outside faces). 00292 // Gets displacement per patch point. 00293 // - nPointLayers : number of layers per (patch)point 00294 // - nFaceLayers : number of layers per (patch) face 00295 // - firstDisplacement : displacement per point for first 00296 // layer of points (i.e. nearest to original mesh). If zero 00297 // do not add point. 00298 // Layer thicknesses are calculated to constant geometric 00299 // expansion. Use expansionRatio 1 for constant size. 00300 // Sets addedPoints_ which is per pp point a list of points 00301 // added. 00302 // Note: firstDisplacement has to be parallel synchronised before 00303 // calling this routine. Only if all procs sharing a point 00304 // get a cell should firstDisplacement be <> 0 00305 // Note: cells get added from owner cells of patch faces 00306 // (instead of e.g. from patch faces) 00307 void setRefinement 00308 ( 00309 const scalarField& expansionRatio, 00310 const indirectPrimitivePatch& pp, 00311 const labelList& nFaceLayers, 00312 const labelList& nPointLayers, 00313 const vectorField& firstLayerDisp, 00314 polyTopoChange& meshMod 00315 ); 00316 00317 00318 //- Add with constant expansion ratio and same nLayers everywhere 00319 void setRefinement 00320 ( 00321 const label nLayers, 00322 const indirectPrimitivePatch& pp, 00323 const vectorField& overallDisplacement, 00324 polyTopoChange& meshMod 00325 ) 00326 { 00327 setRefinement 00328 ( 00329 scalarField(pp.nPoints(), 1.0), // expansion ration 00330 pp, 00331 labelList(pp.size(), nLayers), 00332 labelList(pp.nPoints(), nLayers), 00333 overallDisplacement / nLayers, 00334 meshMod 00335 ); 00336 } 00337 00338 00339 //- Update any locally stored mesh information. Gets additional 00340 // map from new to old patch (since patch needs to be 00341 // recreated since has to be on outside). 00342 void updateMesh 00343 ( 00344 const mapPolyMesh&, 00345 const labelList& faceMap, // new to old patch faces 00346 const labelList& pointMap // new to old patch points 00347 ); 00348 00349 // Helper 00350 00351 //- Per patch edge the corresponding mesh edge 00352 static labelList calcMeshEdges 00353 ( 00354 const primitiveMesh& mesh, 00355 const indirectPrimitivePatch& 00356 ); 00357 }; 00358 00359 00360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00361 00362 } // End namespace Foam 00363 00364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00365 00366 #endif 00367 00368 // ************************ vim: set sw=4 sts=4 et: ************************ //