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::meshCutAndRemove 00026 00027 Description 00028 like meshCutter but also removes non-anchor side of cell. 00029 00030 SourceFiles 00031 meshCutAndRemove.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef meshCutAndRemove_H 00036 #define meshCutAndRemove_H 00037 00038 #include <dynamicMesh/edgeVertex.H> 00039 #include <OpenFOAM/boolList.H> 00040 #include <OpenFOAM/labelList.H> 00041 #include <OpenFOAM/typeInfo.H> 00042 #include <OpenFOAM/Map.H> 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 // Forward declaration of classes 00050 class Time; 00051 class polyTopoChange; 00052 class cellCuts; 00053 class polyMesh; 00054 class face; 00055 class mapPolyMesh; 00056 00057 /*---------------------------------------------------------------------------*\ 00058 Class meshCutAndRemove Declaration 00059 \*---------------------------------------------------------------------------*/ 00060 00061 class meshCutAndRemove 00062 : 00063 public edgeVertex 00064 { 00065 // Private data 00066 00067 //- Faces added in last setRefinement. Per split cell label of added 00068 // face 00069 Map<label> addedFaces_; 00070 00071 //- Points added in last setRefinement. Per split edge label of added 00072 // point 00073 HashTable<label, edge, Hash<edge> > addedPoints_; 00074 00075 00076 // Private Static Functions 00077 00078 // Returns -1 or index in elems1 of first shared element. 00079 static label firstCommon(const labelList& lst1, const labelList& lst2); 00080 00081 //- Do the elements of edge appear in consecutive order in the list 00082 static bool isIn(const edge&, const labelList&); 00083 00084 00085 // Private Member Functions 00086 00087 //- Returns -1 or the cell in cellLabels that is cut. 00088 label findCutCell(const cellCuts&, const labelList&) const; 00089 00090 //- Returns first pointI in pointLabels that uses an internal 00091 // face. Used to find point to inflate cell/face from (has to be 00092 // connected to internal face) 00093 label findInternalFacePoint(const labelList& pointLabels) const; 00094 00095 //- Find point on face that is part of original mesh and that is 00096 // point connected to the patch 00097 label findPatchFacePoint(const face& f, const label patchI) const; 00098 00099 //- Get new owner and neighbour of face. Checks anchor points to see if 00100 // need to get original or added cell. 00101 void faceCells 00102 ( 00103 const cellCuts& cuts, 00104 const label exposedPatchI, 00105 const label faceI, 00106 label& own, 00107 label& nei, 00108 label& patchID 00109 ) const; 00110 00111 //- Get zone information for face. 00112 void getZoneInfo 00113 ( 00114 const label faceI, 00115 label& zoneID, 00116 bool& zoneFlip 00117 ) const; 00118 00119 //- Adds a face from point. Flips face if owner>neighbour 00120 void addFace 00121 ( 00122 polyTopoChange& meshMod, 00123 const label faceI, 00124 const label masterPointI, 00125 const face& newFace, 00126 const label owner, 00127 const label neighbour, 00128 const label patchID 00129 ); 00130 00131 //- Modifies existing faceI for either new owner/neighbour or 00132 // new face points. Checks if anything changed and flips face 00133 // if owner>neighbour 00134 void modFace 00135 ( 00136 polyTopoChange& meshMod, 00137 const label faceI, 00138 const face& newFace, 00139 const label owner, 00140 const label neighbour, 00141 const label patchID 00142 ); 00143 00144 // Copies face starting from startFp. Jumps cuts. Marks visited 00145 // vertices in visited. 00146 void copyFace 00147 ( 00148 const face& f, 00149 const label startFp, 00150 const label endFp, 00151 face& newFace 00152 ) const; 00153 00154 //- Split face along cut into two faces. Faces are in same point 00155 // order as original face (i.e. maintain normal direction) 00156 void splitFace 00157 ( 00158 const face& f, 00159 const label v0, 00160 const label v1, 00161 00162 face& f0, 00163 face& f1 00164 ) const; 00165 00166 //- Add cuts of edges to face 00167 face addEdgeCutsToFace(const label faceI) const; 00168 00169 //- Convert loop of cuts into face. 00170 face loopToFace 00171 ( 00172 const label cellI, 00173 const labelList& loop 00174 ) const; 00175 00176 00177 00178 //- Disallow default bitwise copy construct 00179 meshCutAndRemove(const meshCutAndRemove&); 00180 00181 //- Disallow default bitwise assignment 00182 void operator=(const meshCutAndRemove&); 00183 00184 public: 00185 00186 //- Runtime type information 00187 ClassName("meshCutAndRemove"); 00188 00189 00190 // Constructors 00191 00192 //- Construct from mesh 00193 meshCutAndRemove(const polyMesh& mesh); 00194 00195 00196 // Member Functions 00197 00198 // Edit 00199 00200 //- Do actual cutting with cut description. Inserts mesh changes 00201 // into meshMod. 00202 // cuts: all loops and topological information 00203 // cutPatch: for every cell that has loop the patch number 00204 // exposedPatch: patch for other exposed faces 00205 void setRefinement 00206 ( 00207 const label exposedPatchI, 00208 const cellCuts& cuts, 00209 const labelList& cutPatch, 00210 polyTopoChange& meshMod 00211 ); 00212 00213 //- Force recalculation of locally stored data on topological change 00214 void updateMesh(const mapPolyMesh&); 00215 00216 00217 // Access 00218 00219 //- Faces added. Per split cell label of added face 00220 const Map<label>& addedFaces() const 00221 { 00222 return addedFaces_; 00223 } 00224 00225 //- Points added. Per split edge label of added point. 00226 // (note: fairly useless across topology changes since one of the 00227 // points of the edge will probably disappear) 00228 const HashTable<label, edge, Hash<edge> >& addedPoints() const 00229 { 00230 return addedPoints_; 00231 } 00232 }; 00233 00234 00235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00236 00237 } // End namespace Foam 00238 00239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00240 00241 #endif 00242 00243 // ************************ vim: set sw=4 sts=4 et: ************************ //