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) 2011-2016 OpenFOAM Foundation
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 "Pstream.H"
42 #include "HashSet.H"
43 #include "Map.H"
44 #include "boolList.H"
45 #include "indirectPrimitivePatch.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 
63 class removeFaces
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&, const label) const;
140 
141  //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
142  void modFace
143  (
144  const face& f,
145  const label masterFaceID,
146  const label own,
147  const label nei,
148  const bool flipFaceFlux,
149  const label newPatchID,
150  const bool removeFromZone,
151  const label zoneID,
152  const bool zoneFlip,
153 
154  polyTopoChange& meshMod
155  ) const;
156 
157 
158 
159  //- Disallow default bitwise copy construct
160  removeFaces(const removeFaces&);
161 
162  //- Disallow default bitwise assignment
163  void operator=(const removeFaces&);
164 
165 
166 public:
167 
168  //- Runtime type information
169  ClassName("removeFaces");
170 
171 
172  // Constructors
173 
174  //- Construct from mesh and min cos of angle for boundary faces
175  // to be considered aligned. Set to >= 1 to disable checking
176  // and always merge (if on same patch)
177  removeFaces(const polyMesh&, const scalar minCos);
178 
179  // Member Functions
180 
181  //- Find faces including those with cells which have the same mastercell
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.
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
212  void distribute(const mapDistributePolyMesh&)
213  {}
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #endif
224 
225 // ************************************************************************* //
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:62
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:69
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: removeFaces.H:207
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
void distribute(const mapDistributePolyMesh &)
Force recalculation of locally stored data for mesh distribution.
Definition: removeFaces.H:211
A list of faces which address into the list of points.
labelList f(nPoints)
ClassName("removeFaces")
Runtime type information.
Direct mesh changes based on v1.3 polyTopoChange syntax.
void setRefinement(const labelList &piercedFaces, const labelList &cellRegion, const labelList &cellRegionMaster, polyTopoChange &) const
Play commands into polyTopoChange to remove faces.
Definition: removeFaces.C:762
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
label compatibleRemoves(const labelList &inPiercedFaces, labelList &cellRegion, labelList &cellRegionMaster, labelList &outPiercedFaces) const
Find faces including those with cells which have the same mastercell.
Definition: removeFaces.C:581
Namespace for OpenFOAM.