initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / removeFaces.H
blob6d217a3f4f263ee33c181d29fb6e2fd1acc43cdb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::removeFaces
28 Description
29     Given list of faces to remove insert all the topology changes. Contains
30     helper function to get consistent set of faces to remove.
32     Not very well tested in parallel.
34 SourceFiles
35     removeFaces.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef removeFaces_H
40 #define removeFaces_H
42 #include "Pstream.H"
43 #include "HashSet.H"
44 #include "Map.H"
45 #include "boolList.H"
46 #include "indirectPrimitivePatch.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 // Forward declaration of classes
54 class polyMesh;
55 class polyTopoChange;
56 class face;
57 class mapPolyMesh;
58 class mapDistributePolyMesh;
60 /*---------------------------------------------------------------------------*\
61                            Class removeFaces Declaration
62 \*---------------------------------------------------------------------------*/
64 class removeFaces
66     // Private data
68         //- Reference to mesh
69         const polyMesh& mesh_;
71         //- Cosine of angles between boundary faces. Boundary faces can be
72         //  merged only if angle between faces > minCos.
73         const scalar minCos_;
76     // Private Member Functions
78         //- Change elements in cellRegion that are oldRegion to newRegion.
79         //  Recurses to cell neighbours.
80         void changeCellRegion
81         (
82             const label cellI,
83             const label oldRegion,
84             const label newRegion,
85             labelList& cellRegion
86         ) const;
88         //- Changes region of connected set of faces
89         label changeFaceRegion
90         (
91             const labelList& cellRegion,
92             const boolList& removedFace,
93             const labelList& nFacesPerEdge,
94             const label faceI,
95             const label newRegion,
96             const labelList& fEdges,
97             labelList& faceRegion
98         ) const;
100         //- Get all affected faces (including faces marked for removal)
101         boolList getFacesAffected
102         (
103             const labelList& cellRegion,
104             const labelList& cellRegionMaster,
105             const labelList& facesToRemove,
106             const labelHashSet& edgesToRemove,
107             const labelHashSet& pointsToRemove
108         ) const;
111         // Topological changes
113             //- Debug: write set of faces to file in obj format.
114             static void writeOBJ
115             (
116                 const indirectPrimitivePatch&,
117                 const fileName&
118             );
120             //- Merge faceLabels into single face.
121             void mergeFaces
122             (
123                 const labelList& cellRegion,
124                 const labelList& cellRegionMaster,
125                 const labelHashSet& pointsToRemove,
126                 const labelList& faceLabels,
127                 polyTopoChange& meshMod
128             ) const;
130             //- Get patch, zone info for faceI
131             void getFaceInfo
132             (
133                 const label faceI,
134                 label& patchID,
135                 label& zoneID,
136                 label& zoneFlip
137             ) const;
139             //- Return face with all pointsToRemove removed.
140             face filterFace(const labelHashSet& pointsToRemove, const label)
141              const;
143             //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
144             void modFace
145             (
146                 const face& f,
147                 const label masterFaceID,
148                 const label own,
149                 const label nei,
150                 const bool flipFaceFlux,
151                 const label newPatchID,
152                 const bool removeFromZone,
153                 const label zoneID,
154                 const bool zoneFlip,
156                 polyTopoChange& meshMod
157             ) const;
161         //- Disallow default bitwise copy construct
162         removeFaces(const removeFaces&);
164         //- Disallow default bitwise assignment
165         void operator=(const removeFaces&);
168 public:
170     //- Runtime type information
171     ClassName("removeFaces");
174     // Constructors
176         //- Construct from mesh and min cos of angle for boundary faces
177         //  to be considered aligned. Set to >= 1 to disable checking
178         //  and always merge (if on same patch)
179         removeFaces(const polyMesh&, const scalar minCos);
181     // Member Functions
183         //- Given set of faces to pierce calculates:
184         //  - region for connected cells
185         //  - mastercell for each region. This is the lowest numbered cell
186         //    of all cells that get merged.
187         //  - new set of faces which contains input set + additional ones
188         //    where cells on both sides would have same mastercell.
189         //  Returns number of regions.
190         label compatibleRemoves
191         (
192             const labelList& inPiercedFaces,
193             labelList& cellRegion,
194             labelList& cellRegionMaster,
195             labelList& outPiercedFaces
196         ) const;
199         //- Play commands into polyTopoChange to remove faces.
200         void setRefinement
201         (
202             const labelList& piercedFaces,
203             const labelList& cellRegion,
204             const labelList& cellRegionMaster,
205             polyTopoChange&
206         ) const;
208         //- Force recalculation of locally stored data on topological change
209         void updateMesh(const mapPolyMesh&)
210         {}
212         //- Force recalculation of locally stored data for mesh distribution
213         void distribute(const mapDistributePolyMesh&)
214         {}
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 } // End namespace Foam
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 #endif
226 // ************************************************************************* //