FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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