OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

cellClassification.H

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