removeFaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 public:
159 
160  //- Runtime type information
161  ClassName("removeFaces");
162 
163 
164  // Constructors
165 
166  //- Construct from mesh and min cos of angle for boundary faces
167  // to be considered aligned. Set to >= 1 to disable checking
168  // and always merge (if on same patch)
169  removeFaces(const polyMesh&, const scalar minCos);
170 
171  //- Disallow default bitwise copy construction
172  removeFaces(const removeFaces&) = delete;
173 
174 
175  // Member Functions
176 
177  //- Find faces including those with cells which have the same mastercell
178  // Given set of faces to pierce calculates:
179  // - region for connected cells
180  // - mastercell for each region. This is the lowest numbered cell
181  // of all cells that get merged.
182  // - new set of faces which contains input set + additional ones
183  // where cells on both sides would have same mastercell.
184  // Returns number of regions.
186  (
187  const labelList& inPiercedFaces,
188  labelList& cellRegion,
189  labelList& cellRegionMaster,
190  labelList& outPiercedFaces
191  ) const;
192 
193 
194  //- Play commands into polyTopoChange to remove faces.
195  void setRefinement
196  (
197  const labelList& piercedFaces,
198  const labelList& cellRegion,
199  const labelList& cellRegionMaster,
201  ) const;
202 
203  //- Force recalculation of locally stored data on topological change
204  void updateMesh(const mapPolyMesh&)
205  {}
206 
207  //- Force recalculation of locally stored data for mesh distribution
208  void distribute(const mapDistributePolyMesh&)
209  {}
210 
211 
212  // Member Operators
213 
214  //- Disallow default bitwise assignment
215  void operator=(const removeFaces&) = delete;
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
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:79
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:203
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
removeFaces(const polyMesh &, const scalar minCos)
Construct from mesh and min cos of angle for boundary faces.
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:207
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.
label compatibleRemoves(const labelList &inPiercedFaces, labelList &cellRegion, labelList &cellRegionMaster, labelList &outPiercedFaces) const
Find faces including those with cells which have the same mastercell.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
void operator=(const removeFaces &)=delete
Disallow default bitwise assignment.