![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 cellClassification 00027 00028 Description 00029 'Cuts' a mesh with a surface. Divides cells into three types 00030 - cut, i.e. any of the edges of the cell is split or any edge of the 00031 surface pierces any of the faces of the cell. 00032 - outside:cell can be reached by meshwave from any of the supplied 00033 outside points (without crossing any cut cell) 00034 - inside:all other. 00035 00036 Used in various meshing programs. 00037 00038 Has various utility functions to deal with 'features' on this level 00039 where the mesh still has all inside and outside cells. 00040 00041 Concepts 00042 -------- 00043 00044 - point classification: 00045 - point used by meshType cells only 00046 - point used by non-meshType cells only 00047 - point used by both types ('mixed') 00048 00049 - hanging cells: meshType cells using mixed points only. These cells would 00050 have all their vertices on the surface when extracting the meshType cells. 00051 00052 - regionEdges: edges where the cells using it are of mixed type. Or more 00053 precise when walking around the edge and looking at the different 00054 types of the cells there are more than two regions with same type. 00055 00056 Seen from above: 00057 00058 Ok: 00059 A | A 00060 | 00061 --+--- 00062 | 00063 B | B 00064 00065 Not ok: 00066 A | B 00067 | 00068 ---+--- 00069 | 00070 B | A 00071 00072 because this latter situation would cause the surface after subsetting 00073 type A or B to be multiply connected across this edge. And also when 00074 snapping the edge end points to the surface it might cause some twisted 00075 faces if the surface is normal to the edge (and smoothing the surface 00076 would not help since the points on the edge would be 'pulled' from two 00077 different sides) 00078 00079 - regionPoints: like regionEdges but now for points. Points where subsetting 00080 the mesh would cause a multiply connected outside surface (connected across 00081 point, not edge) 00082 00083 00084 00085 SourceFiles 00086 cellClassification.C 00087 00088 \*---------------------------------------------------------------------------*/ 00089 00090 #ifndef cellClassification_H 00091 #define cellClassification_H 00092 00093 #include "pointField.H" 00094 #include "Map.H" 00095 #include "boolList.H" 00096 #include "labelList.H" 00097 #include "faceList.H" 00098 00099 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00100 00101 namespace Foam 00102 { 00103 00104 // Class forward declarations 00105 class triSurfaceSearch; 00106 class meshSearch; 00107 class polyMesh; 00108 class polyMesh; 00109 class primitiveMesh; 00110 class triSurface; 00111 00112 /*---------------------------------------------------------------------------*\ 00113 Class cellClassification Declaration 00114 \*---------------------------------------------------------------------------*/ 00115 00116 class cellClassification 00117 : 00118 public labelList 00119 { 00120 00121 public: 00122 00123 // Public data types 00124 00125 //- Type of cell. 00126 enum cType 00127 { 00128 NOTSET, 00129 INSIDE, // Inside of surface 00130 OUTSIDE, // Outside ,, 00131 CUT // cut by surface 00132 }; 00133 00134 00135 //- Enumeration defining the whether points are use by cells of 00136 // a certain type. 00137 enum pointStatus 00138 { 00139 UNSET, 00140 MESH, // points used by meshType cells 00141 NONMESH, // ,, non-mesh type cells 00142 MIXED // ,, both types of cell 00143 }; 00144 00145 private: 00146 00147 // Private data 00148 00149 //- Reference to mesh 00150 const polyMesh& mesh_; 00151 00152 00153 // Private Static Functions 00154 00155 //- Count number of occurrences of elem in list 00156 static label count(const labelList& elems, const label elem); 00157 00158 // Private Member Functions 00159 00160 //- Mark all faces intersected by or intersecting surface 00161 boolList markFaces(const triSurfaceSearch&) const; 00162 00163 //- Divide cells into cut/inside/outside by using meshWave from cut 00164 // faces. No check is done on whether outsidePts are in different 00165 // domains. 00166 void markCells 00167 ( 00168 const meshSearch& queryMesh, 00169 const boolList& piercedFace, 00170 const pointField& outsidePts 00171 ); 00172 00173 //- Use cell status to classify points as being internal to meshType, 00174 // internal to non-meshType or on border of both. 00175 void classifyPoints 00176 ( 00177 const label meshType, 00178 const labelList& cellType, 00179 List<pointStatus>& pointSide 00180 ) const; 00181 00182 //- Return true if cell uses only points with status=mixed 00183 bool usesMixedPointsOnly 00184 ( 00185 const List<pointStatus>&, 00186 const label cellI 00187 ) const; 00188 00189 //- Get faces (and its 'owner') inbetween cells of differing type 00190 // (meshType and non-meshType). 00191 void getMeshOutside(const label meshType, faceList&, labelList&) const; 00192 00193 public: 00194 00195 // Static data members 00196 ClassName("cellClassification"); 00197 00198 // Constructors 00199 00200 //- Construct from mesh and surface and point(s) on outside 00201 cellClassification 00202 ( 00203 const polyMesh& mesh, 00204 const meshSearch& meshQuery, 00205 const triSurfaceSearch& surfQuery, 00206 const pointField& outsidePoints 00207 ); 00208 00209 //- Construct from mesh and type for every cell. 00210 // Used to be able to reuse filling routines below. 00211 cellClassification(const polyMesh& mesh, const labelList& cellType); 00212 00213 //- Construct as copy 00214 cellClassification(const cellClassification&); 00215 00216 00217 // Member Functions 00218 00219 const polyMesh& mesh() const 00220 { 00221 return mesh_; 00222 } 00223 00224 label trimCutCells 00225 ( 00226 const label nLayers, 00227 const label meshType, 00228 const label fillType 00229 ); 00230 00231 //- Sets vertex neighbours of meshType cells to fillType 00232 label growSurface(const label meshType, const label fillType); 00233 00234 //- Find hanging cells (cells with all points on outside) and set their 00235 // type to fillType. 00236 // Iterate until nothing changed. Returns total number of cells 00237 // changed (in all iterations) 00238 label fillHangingCells 00239 ( 00240 const label meshType, 00241 const label fillType, 00242 const label maxIter 00243 ); 00244 00245 //- Find regionEdges and fill one neighbour. Iterate until nothing 00246 // changes. Returns total number of cells changed. 00247 label fillRegionEdges 00248 ( 00249 const label meshType, 00250 const label fillType, 00251 const label maxIter 00252 ); 00253 00254 //- Find regionPoints and fill all neighbours. Iterate until nothing 00255 // changes. Returns total number of cells changed. 00256 label fillRegionPoints 00257 ( 00258 const label meshType, 00259 const label fillType, 00260 const label maxIter 00261 ); 00262 00263 //- Write statistics on cell types to Ostream 00264 void writeStats(Ostream& os) const; 00265 00266 00267 // Member Operators 00268 00269 void operator=(const cellClassification&); 00270 00271 }; 00272 00273 00274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00275 00276 } // End namespace Foam 00277 00278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00279 00280 #endif 00281 00282 // ************************************************************************* //