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