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

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-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::removeFaces
00026 
00027 Description
00028     Given list of faces to remove insert all the topology changes. Contains
00029     helper function to get consistent set of faces to remove.
00030 
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 <OpenFOAM/Pstream.H>
00042 #include <OpenFOAM/HashSet.H>
00043 #include <OpenFOAM/Map.H>
00044 #include <OpenFOAM/boolList.H>
00045 #include <OpenFOAM/indirectPrimitivePatch.H>
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 // Forward declaration of classes
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             const labelList& fEdges,
00096             labelList& faceRegion
00097         ) const;
00098 
00099         //- Get all affected faces (including faces marked for removal)
00100         boolList getFacesAffected
00101         (
00102             const labelList& cellRegion,
00103             const labelList& cellRegionMaster,
00104             const labelList& facesToRemove,
00105             const labelHashSet& edgesToRemove,
00106             const labelHashSet& pointsToRemove
00107         ) const;
00108 
00109 
00110         // Topological changes
00111 
00112             //- Debug: write set of faces to file in obj format.
00113             static void writeOBJ
00114             (
00115                 const indirectPrimitivePatch&,
00116                 const fileName&
00117             );
00118 
00119             //- Merge faceLabels into single face.
00120             void mergeFaces
00121             (
00122                 const labelList& cellRegion,
00123                 const labelList& cellRegionMaster,
00124                 const labelHashSet& pointsToRemove,
00125                 const labelList& faceLabels,
00126                 polyTopoChange& meshMod
00127             ) const;
00128 
00129             //- Get patch, zone info for faceI
00130             void getFaceInfo
00131             (
00132                 const label faceI,
00133                 label& patchID,
00134                 label& zoneID,
00135                 label& zoneFlip
00136             ) const;
00137 
00138             //- Return face with all pointsToRemove removed.
00139             face filterFace(const labelHashSet& pointsToRemove, const label)
00140              const;
00141 
00142             //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
00143             void modFace
00144             (
00145                 const face& f,
00146                 const label masterFaceID,
00147                 const label own,
00148                 const label nei,
00149                 const bool flipFaceFlux,
00150                 const label newPatchID,
00151                 const bool removeFromZone,
00152                 const label zoneID,
00153                 const bool zoneFlip,
00154 
00155                 polyTopoChange& meshMod
00156             ) const;
00157 
00158 
00159 
00160         //- Disallow default bitwise copy construct
00161         removeFaces(const removeFaces&);
00162 
00163         //- Disallow default bitwise assignment
00164         void operator=(const removeFaces&);
00165 
00166 
00167 public:
00168 
00169     //- Runtime type information
00170     ClassName("removeFaces");
00171 
00172 
00173     // Constructors
00174 
00175         //- Construct from mesh and min cos of angle for boundary faces
00176         //  to be considered aligned. Set to >= 1 to disable checking
00177         //  and always merge (if on same patch)
00178         removeFaces(const polyMesh&, const scalar minCos);
00179 
00180     // Member Functions
00181 
00182         //- Given set of faces to pierce calculates:
00183         //  - region for connected cells
00184         //  - mastercell for each region. This is the lowest numbered cell
00185         //    of all cells that get merged.
00186         //  - new set of faces which contains input set + additional ones
00187         //    where cells on both sides would have same mastercell.
00188         //  Returns number of regions.
00189         label compatibleRemoves
00190         (
00191             const labelList& inPiercedFaces,
00192             labelList& cellRegion,
00193             labelList& cellRegionMaster,
00194             labelList& outPiercedFaces
00195         ) const;
00196 
00197 
00198         //- Play commands into polyTopoChange to remove faces.
00199         void setRefinement
00200         (
00201             const labelList& piercedFaces,
00202             const labelList& cellRegion,
00203             const labelList& cellRegionMaster,
00204             polyTopoChange&
00205         ) const;
00206 
00207         //- Force recalculation of locally stored data on topological change
00208         void updateMesh(const mapPolyMesh&)
00209         {}
00210 
00211         //- Force recalculation of locally stored data for mesh distribution
00212         void distribute(const mapDistributePolyMesh&)
00213         {}
00214 };
00215 
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 } // End namespace Foam
00220 
00221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00222 
00223 #endif
00224 
00225 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines