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

removeFaces.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::removeFaces
00027 
00028 Description
00029     Given list of faces to remove insert all the topology changes. Contains
00030     helper function to get consistent set of faces to remove.
00031 
00032     Not very well tested in parallel.
00033 
00034 SourceFiles
00035     removeFaces.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef removeFaces_H
00040 #define removeFaces_H
00041 
00042 #include "Pstream.H"
00043 #include "HashSet.H"
00044 #include "Map.H"
00045 #include "boolList.H"
00046 #include "indirectPrimitivePatch.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 // Forward declaration of classes
00054 class polyMesh;
00055 class polyTopoChange;
00056 class face;
00057 class mapPolyMesh;
00058 class mapDistributePolyMesh;
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class removeFaces Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 class removeFaces
00065 {
00066     // Private data
00067 
00068         //- Reference to mesh
00069         const polyMesh& mesh_;
00070 
00071         //- Cosine of angles between boundary faces. Boundary faces can be
00072         //  merged only if angle between faces > minCos.
00073         const scalar minCos_;
00074 
00075 
00076     // Private Member Functions
00077 
00078         //- Change elements in cellRegion that are oldRegion to newRegion.
00079         //  Recurses to cell neighbours.
00080         void changeCellRegion
00081         (
00082             const label cellI,
00083             const label oldRegion,
00084             const label newRegion,
00085             labelList& cellRegion
00086         ) const;
00087 
00088         //- Changes region of connected set of faces
00089         label changeFaceRegion
00090         (
00091             const labelList& cellRegion,
00092             const boolList& removedFace,
00093             const labelList& nFacesPerEdge,
00094             const label faceI,
00095             const label newRegion,
00096             const labelList& fEdges,
00097             labelList& faceRegion
00098         ) const;
00099 
00100         //- Get all affected faces (including faces marked for removal)
00101         boolList getFacesAffected
00102         (
00103             const labelList& cellRegion,
00104             const labelList& cellRegionMaster,
00105             const labelList& facesToRemove,
00106             const labelHashSet& edgesToRemove,
00107             const labelHashSet& pointsToRemove
00108         ) const;
00109 
00110 
00111         // Topological changes
00112 
00113             //- Debug: write set of faces to file in obj format.
00114             static void writeOBJ
00115             (
00116                 const indirectPrimitivePatch&,
00117                 const fileName&
00118             );
00119 
00120             //- Merge faceLabels into single face.
00121             void mergeFaces
00122             (
00123                 const labelList& cellRegion,
00124                 const labelList& cellRegionMaster,
00125                 const labelHashSet& pointsToRemove,
00126                 const labelList& faceLabels,
00127                 polyTopoChange& meshMod
00128             ) const;
00129 
00130             //- Get patch, zone info for faceI
00131             void getFaceInfo
00132             (
00133                 const label faceI,
00134                 label& patchID,
00135                 label& zoneID,
00136                 label& zoneFlip
00137             ) const;
00138 
00139             //- Return face with all pointsToRemove removed.
00140             face filterFace(const labelHashSet& pointsToRemove, const label)
00141              const;
00142 
00143             //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
00144             void modFace
00145             (
00146                 const face& f,
00147                 const label masterFaceID,
00148                 const label own,
00149                 const label nei,
00150                 const bool flipFaceFlux,
00151                 const label newPatchID,
00152                 const bool removeFromZone,
00153                 const label zoneID,
00154                 const bool zoneFlip,
00155 
00156                 polyTopoChange& meshMod
00157             ) const;
00158 
00159 
00160 
00161         //- Disallow default bitwise copy construct
00162         removeFaces(const removeFaces&);
00163 
00164         //- Disallow default bitwise assignment
00165         void operator=(const removeFaces&);
00166 
00167 
00168 public:
00169 
00170     //- Runtime type information
00171     ClassName("removeFaces");
00172 
00173 
00174     // Constructors
00175 
00176         //- Construct from mesh and min cos of angle for boundary faces
00177         //  to be considered aligned. Set to >= 1 to disable checking
00178         //  and always merge (if on same patch)
00179         removeFaces(const polyMesh&, const scalar minCos);
00180 
00181     // Member Functions
00182 
00183         //- Given set of faces to pierce calculates:
00184         //  - region for connected cells
00185         //  - mastercell for each region. This is the lowest numbered cell
00186         //    of all cells that get merged.
00187         //  - new set of faces which contains input set + additional ones
00188         //    where cells on both sides would have same mastercell.
00189         //  Returns number of regions.
00190         label compatibleRemoves
00191         (
00192             const labelList& inPiercedFaces,
00193             labelList& cellRegion,
00194             labelList& cellRegionMaster,
00195             labelList& outPiercedFaces
00196         ) const;
00197 
00198 
00199         //- Play commands into polyTopoChange to remove faces.
00200         void setRefinement
00201         (
00202             const labelList& piercedFaces,
00203             const labelList& cellRegion,
00204             const labelList& cellRegionMaster,
00205             polyTopoChange&
00206         ) const;
00207 
00208         //- Force recalculation of locally stored data on topological change
00209         void updateMesh(const mapPolyMesh&)
00210         {}
00211 
00212         //- Force recalculation of locally stored data for mesh distribution
00213         void distribute(const mapDistributePolyMesh&)
00214         {}
00215 };
00216 
00217 
00218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00219 
00220 } // End namespace Foam
00221 
00222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00223 
00224 #endif
00225 
00226 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd