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