OpenFOAM logo
Open Source CFD Toolkit

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