FreeFOAM The Cross-Platform CFD Toolkit
removeFaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::removeFaces
26 
27 Description
28  Given list of faces to remove insert all the topology changes. Contains
29  helper function to get consistent set of faces to remove.
30 
31  Not very well tested in parallel.
32 
33 SourceFiles
34  removeFaces.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef removeFaces_H
39 #define removeFaces_H
40 
41 #include <OpenFOAM/Pstream.H>
42 #include <OpenFOAM/HashSet.H>
43 #include <OpenFOAM/Map.H>
44 #include <OpenFOAM/boolList.H>
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declaration of classes
53 class polyMesh;
54 class polyTopoChange;
55 class face;
56 class mapPolyMesh;
57 class mapDistributePolyMesh;
58 
59 /*---------------------------------------------------------------------------*\
60  Class removeFaces Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 {
65  // Private data
66 
67  //- Reference to mesh
68  const polyMesh& mesh_;
69 
70  //- Cosine of angles between boundary faces. Boundary faces can be
71  // merged only if angle between faces > minCos.
72  const scalar minCos_;
73 
74 
75  // Private Member Functions
76 
77  //- Change elements in cellRegion that are oldRegion to newRegion.
78  // Recurses to cell neighbours.
79  void changeCellRegion
80  (
81  const label cellI,
82  const label oldRegion,
83  const label newRegion,
84  labelList& cellRegion
85  ) const;
86 
87  //- Changes region of connected set of faces
88  label changeFaceRegion
89  (
90  const labelList& cellRegion,
91  const boolList& removedFace,
92  const labelList& nFacesPerEdge,
93  const label faceI,
94  const label newRegion,
95  const labelList& fEdges,
96  labelList& faceRegion
97  ) const;
98 
99  //- Get all affected faces (including faces marked for removal)
100  boolList getFacesAffected
101  (
102  const labelList& cellRegion,
103  const labelList& cellRegionMaster,
104  const labelList& facesToRemove,
105  const labelHashSet& edgesToRemove,
106  const labelHashSet& pointsToRemove
107  ) const;
108 
109 
110  // Topological changes
111 
112  //- Debug: write set of faces to file in obj format.
113  static void writeOBJ
114  (
115  const indirectPrimitivePatch&,
116  const fileName&
117  );
118 
119  //- Merge faceLabels into single face.
120  void mergeFaces
121  (
122  const labelList& cellRegion,
123  const labelList& cellRegionMaster,
124  const labelHashSet& pointsToRemove,
125  const labelList& faceLabels,
126  polyTopoChange& meshMod
127  ) const;
128 
129  //- Get patch, zone info for faceI
130  void getFaceInfo
131  (
132  const label faceI,
133  label& patchID,
134  label& zoneID,
135  label& zoneFlip
136  ) const;
137 
138  //- Return face with all pointsToRemove removed.
139  face filterFace(const labelHashSet& pointsToRemove, const label)
140  const;
141 
142  //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
143  void modFace
144  (
145  const face& f,
146  const label masterFaceID,
147  const label own,
148  const label nei,
149  const bool flipFaceFlux,
150  const label newPatchID,
151  const bool removeFromZone,
152  const label zoneID,
153  const bool zoneFlip,
154 
155  polyTopoChange& meshMod
156  ) const;
157 
158 
159 
160  //- Disallow default bitwise copy construct
161  removeFaces(const removeFaces&);
162 
163  //- Disallow default bitwise assignment
164  void operator=(const removeFaces&);
165 
166 
167 public:
168 
169  //- Runtime type information
170  ClassName("removeFaces");
171 
172 
173  // Constructors
174 
175  //- Construct from mesh and min cos of angle for boundary faces
176  // to be considered aligned. Set to >= 1 to disable checking
177  // and always merge (if on same patch)
178  removeFaces(const polyMesh&, const scalar minCos);
179 
180  // Member Functions
181 
182  //- Given set of faces to pierce calculates:
183  // - region for connected cells
184  // - mastercell for each region. This is the lowest numbered cell
185  // of all cells that get merged.
186  // - new set of faces which contains input set + additional ones
187  // where cells on both sides would have same mastercell.
188  // Returns number of regions.
189  label compatibleRemoves
190  (
191  const labelList& inPiercedFaces,
192  labelList& cellRegion,
193  labelList& cellRegionMaster,
194  labelList& outPiercedFaces
195  ) const;
196 
197 
198  //- Play commands into polyTopoChange to remove faces.
199  void setRefinement
200  (
201  const labelList& piercedFaces,
202  const labelList& cellRegion,
203  const labelList& cellRegionMaster,
205  ) const;
206 
207  //- Force recalculation of locally stored data on topological change
208  void updateMesh(const mapPolyMesh&)
209  {}
210 
211  //- Force recalculation of locally stored data for mesh distribution
213  {}
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #endif
224 
225 // ************************ vim: set sw=4 sts=4 et: ************************ //