|
|
|
meshCutter.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::meshCutter 00027 00028 Description 00029 Cuts (splits) cells. 00030 00031 Description of cut is given as a loop of 'cuts' per cell (see cellCuts). 00032 setRefinement() takes this cut description and inserts the nessecary 00033 topoActions (add points/faces/cells) into the polyTopoChange. 00034 00035 Stores added cells/faces/points. 00036 00037 Cut description gives orientation to cut by calculating 'anchorPoints'. 00038 The side of the cell that contains the anchorPoints is the master cell. 00039 Likewise the cells' edges will have the split added as a duplicate of the 00040 master (anchor) point. 00041 Think of it as the cell with the anchor points at the bottom. Add a face 00042 at the bottom to split the cell and then sweep this face up to be through 00043 the middle of the cell (inflation). 00044 00045 00046 -# Start: 00047 cell with anchor points at bottom 00048 @verbatim 00049 +-------+ 00050 | + 00051 | + 00052 | + 00053 | + 00054 | + 00055 | + 00056 | + 00057 +-------+ 00058 anchor anchor 00059 @endverbatim 00060 00061 00062 -# Topo change: 00063 splitface introduced at bottom of cell, introducing a new 00064 cell and splitting the side faces into two. 00065 @verbatim 00066 +-------+ 00067 | + 00068 | + 00069 | + <- addedCell 00070 | + 00071 | + 00072 | + 00073 +-------+ <- splitFace 00074 +-------+ <- original cell 00075 anchor anchor 00076 @endverbatim 00077 00078 00079 -# Inflation: 00080 splitface shifted up to middle of cell (or wherever cut was) 00081 @verbatim 00082 +-------+ 00083 | + 00084 | + <- addedCell 00085 | + 00086 +-------+ <- splitFace 00087 | + 00088 | + <- original cell 00089 | + 00090 +-------+ 00091 anchor anchor 00092 @endverbatim 00093 00094 Anyway this was the original idea. Inflation was meant to handle 00095 conservative properties distribution without interpolation. 00096 (just face sweeping through space). But problem was that 00097 only if the introduced splitface was exactly the same shape as bottom face 00098 (so same 2D topo or perfectly flat) the volume between them was 0. 00099 00100 This meshCutting still uses anchorPoints though: 00101 - the master cell is the one without the anchor points. The added cell 00102 (on top of the splitFace) is the with. 00103 - the splitFace is owned by the master cell (since it has the lower number) 00104 - the side faces get split and get either the original cell as neighbour 00105 or the added cell (if the faces contain the cell anchor points) 00106 00107 SourceFiles 00108 meshCutter.C 00109 00110 \*---------------------------------------------------------------------------*/ 00111 00112 #ifndef meshCutter_H 00113 #define meshCutter_H 00114 00115 #include "edgeVertex.H" 00116 #include "labelList.H" 00117 #include "typeInfo.H" 00118 #include "Map.H" 00119 00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00121 00122 namespace Foam 00123 { 00124 00125 // Forward declaration of classes 00126 class Time; 00127 class polyTopoChange; 00128 class cellCuts; 00129 class polyMesh; 00130 class face; 00131 00132 /*---------------------------------------------------------------------------*\ 00133 Class meshCutter Declaration 00134 \*---------------------------------------------------------------------------*/ 00135 00136 class meshCutter 00137 : 00138 public edgeVertex 00139 { 00140 // Private data 00141 00142 //- Cells added in last setRefinement. Per splitcell label of added 00143 // cell 00144 Map<label> addedCells_; 00145 00146 //- Faces added in last setRefinement. Per split cell label of added 00147 // face 00148 Map<label> addedFaces_; 00149 00150 //- Points added in last setRefinement. Per split edge label of added 00151 // point 00152 HashTable<label, edge, Hash<edge> > addedPoints_; 00153 00154 00155 // Private Static Functions 00156 00157 //- Do list 1 and 2 share elements? 00158 static bool uses(const labelList& elems1, const labelList& elems2); 00159 00160 //- Do the elements of edge appear in consecutive order in the list 00161 static bool isIn(const edge&, const labelList&); 00162 00163 00164 // Private Member Functions 00165 00166 //- Returns -1 or the cell in cellLabels that is cut. 00167 label findCutCell(const cellCuts&, const labelList&) const; 00168 00169 //- Returns first pointI in pointLabels that uses an internal 00170 // face. Used to find point to inflate cell/face from (has to be 00171 // connected to internal face) 00172 label findInternalFacePoint(const labelList& pointLabels) const; 00173 00174 //- Get new owner and neighbour of face. Checks anchor points to see if 00175 // need to get original or added cell. 00176 void faceCells 00177 ( 00178 const cellCuts& cuts, 00179 const label faceI, 00180 label& own, 00181 label& nei 00182 ) const; 00183 00184 //- Get patch information for face. 00185 void getFaceInfo 00186 ( 00187 const label faceI, 00188 label& patchID, 00189 label& zoneID, 00190 label& zoneFlip 00191 ) const; 00192 00193 //- Adds a face on top of existing faceI. Flips face 00194 // if owner>neighbour 00195 void addFace 00196 ( 00197 polyTopoChange& meshMod, 00198 const label faceI, 00199 const face& newFace, 00200 const label owner, 00201 const label neighbour 00202 ); 00203 00204 //- Modifies existing faceI for either new owner/neighbour or 00205 // new face points. Checks if anything changed and flips face 00206 // if owner>neighbour 00207 void modFace 00208 ( 00209 polyTopoChange& meshMod, 00210 const label faceI, 00211 const face& newFace, 00212 const label owner, 00213 const label neighbour 00214 ); 00215 00216 00217 // Copies face starting from startFp. Jumps cuts. Marks visited 00218 // vertices in visited. 00219 void copyFace 00220 ( 00221 const face& f, 00222 const label startFp, 00223 const label endFp, 00224 face& newFace 00225 ) const; 00226 00227 //- Split face along cut into two faces. Faces are in same point 00228 // order as original face (i.e. maintain normal direction) 00229 void splitFace 00230 ( 00231 const face& f, 00232 const label v0, 00233 const label v1, 00234 00235 face& f0, 00236 face& f1 00237 ) const; 00238 00239 //- Add cuts of edges to face 00240 face addEdgeCutsToFace(const label faceI) const; 00241 00242 //- Convert loop of cuts into face. 00243 face loopToFace 00244 ( 00245 const label cellI, 00246 const labelList& loop 00247 ) const; 00248 00249 00250 //- Get elements of cell. 00251 void getFacesEdgesPoints 00252 ( 00253 const label cellI, 00254 labelHashSet& faces, 00255 labelHashSet& edges, 00256 labelHashSet& points 00257 ) const; 00258 00259 00260 00261 //- Disallow default bitwise copy construct 00262 meshCutter(const meshCutter&); 00263 00264 //- Disallow default bitwise assignment 00265 void operator=(const meshCutter&); 00266 00267 public: 00268 00269 //- Runtime type information 00270 ClassName("meshCutter"); 00271 00272 // Constructors 00273 00274 //- Construct from mesh 00275 meshCutter(const polyMesh& mesh); 00276 00277 00278 // Destructor 00279 00280 ~meshCutter(); 00281 00282 00283 // Member Functions 00284 00285 // Edit 00286 00287 //- Do actual cutting with cut description. Inserts mesh changes 00288 // into meshMod. 00289 void setRefinement(const cellCuts& cuts, polyTopoChange& meshMod); 00290 00291 //- Force recalculation of locally stored data on topological change 00292 void updateMesh(const mapPolyMesh&); 00293 00294 // Access 00295 00296 //- Cells added. Per split cell label of added cell 00297 const Map<label>& addedCells() const 00298 { 00299 return addedCells_; 00300 } 00301 00302 //- Faces added. Per split cell label of added face 00303 const Map<label>& addedFaces() const 00304 { 00305 return addedFaces_; 00306 } 00307 00308 //- Points added. Per split edge label of added point 00309 const HashTable<label, edge, Hash<edge> >& addedPoints() const 00310 { 00311 return addedPoints_; 00312 } 00313 }; 00314 00315 00316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00317 00318 } // End namespace Foam 00319 00320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00321 00322 #endif 00323 00324 // ************************************************************************* // |