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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::removeFaces
28 
29 Description
30  Given list of faces to remove insert all the topology changes. Contains
31  helper function to get consistent set of faces to remove.
32 
33  Not very well tested in parallel.
34 
35 SourceFiles
36  removeFaces.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef removeFaces_H
41 #define removeFaces_H
42 
43 #include "Pstream.H"
44 #include "HashSet.H"
45 #include "Map.H"
46 #include "boolList.H"
47 #include "indirectPrimitivePatch.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 class polyMesh;
56 class polyTopoChange;
57 class face;
58 class mapPolyMesh;
59 class mapDistributePolyMesh;
60 
61 /*---------------------------------------------------------------------------*\
62  Class removeFaces Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class removeFaces
66 {
67  // Private data
68 
69  //- Reference to mesh
70  const polyMesh& mesh_;
71 
72  //- Cosine of angles between boundary faces. Boundary faces can be
73  // merged only if angle between faces > minCos.
74  const scalar minCos_;
75 
76 
77  // Private Member Functions
78 
79  //- Change elements in cellRegion that are oldRegion to newRegion.
80  // Recurses to cell neighbours.
81  void changeCellRegion
82  (
83  const label celli,
84  const label oldRegion,
85  const label newRegion,
86  labelList& cellRegion
87  ) const;
88 
89  //- Changes region of connected set of faces
90  label changeFaceRegion
91  (
92  const labelList& cellRegion,
93  const boolList& removedFace,
94  const labelList& nFacesPerEdge,
95  const label facei,
96  const label newRegion,
97  const labelList& fEdges,
98  labelList& faceRegion
99  ) const;
100 
101  //- Get all affected faces (including faces marked for removal)
102  boolList getFacesAffected
103  (
104  const labelList& cellRegion,
105  const labelList& cellRegionMaster,
106  const labelList& facesToRemove,
107  const labelHashSet& edgesToRemove,
108  const labelHashSet& pointsToRemove
109  ) const;
110 
111 
112  // Topological changes
113 
114  //- Debug: write set of faces to file in obj format.
115  static void writeOBJ
116  (
117  const indirectPrimitivePatch&,
118  const fileName&
119  );
120 
121  //- Merge faceLabels into single face.
122  void mergeFaces
123  (
124  const labelList& cellRegion,
125  const labelList& cellRegionMaster,
126  const labelHashSet& pointsToRemove,
127  const labelList& faceLabels,
128  polyTopoChange& meshMod
129  ) const;
130 
131  //- Get patch, zone info for facei
132  void getFaceInfo
133  (
134  const label facei,
135  label& patchID,
136  label& zoneID,
137  label& zoneFlip
138  ) const;
139 
140  //- Return face with all pointsToRemove removed.
141  face filterFace(const labelHashSet&, const label) const;
142 
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,
155 
156  polyTopoChange& meshMod
157  ) const;
158 
159 
160 
161  //- No copy construct
162  removeFaces(const removeFaces&) = delete;
163 
164  //- No copy assignment
165  void operator=(const removeFaces&) = delete;
166 
167 
168 public:
169 
170  //- Runtime type information
171  ClassName("removeFaces");
172 
173 
174  // Constructors
175 
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);
180 
181 
182  // Member Functions
183 
184  //- Find faces including those with cells which have the same mastercell
185  // Given set of faces to pierce calculates:
186  // - region for connected cells
187  // - mastercell for each region. This is the lowest numbered cell
188  // of all cells that get merged.
189  // - new set of faces which contains input set + additional ones
190  // where cells on both sides would have same mastercell.
191  // Returns number of regions.
192  label compatibleRemoves
193  (
194  const labelList& inPiercedFaces,
195  labelList& cellRegion,
196  labelList& cellRegionMaster,
197  labelList& outPiercedFaces
198  ) const;
199 
200 
201  //- Play commands into polyTopoChange to remove faces.
202  void setRefinement
203  (
204  const labelList& piercedFaces,
205  const labelList& cellRegion,
206  const labelList& cellRegionMaster,
208  ) const;
209 
210  //- Force recalculation of locally stored data on topological change
211  void updateMesh(const mapPolyMesh&)
212  {}
213 
214  //- Force recalculation of locally stored data for mesh distribution
215  void distribute(const mapDistributePolyMesh&)
216  {}
217 };
218 
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace Foam
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
boolList.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:99
Foam::removeFaces::setRefinement
void setRefinement(const labelList &piercedFaces, const labelList &cellRegion, const labelList &cellRegionMaster, polyTopoChange &) const
Play commands into polyTopoChange to remove faces.
Definition: removeFaces.C:763
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Map.H
Foam::removeFaces
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:64
Foam::removeFaces::distribute
void distribute(const mapDistributePolyMesh &)
Force recalculation of locally stored data for mesh distribution.
Definition: removeFaces.H:214
patchID
label patchID
Definition: boundaryProcessorFaPatchPoints.H:5
Foam::removeFaces::updateMesh
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: removeFaces.H:210
indirectPrimitivePatch.H
HashSet.H
zoneID
const labelIOList & zoneID
Definition: interpolatedFaces.H:22
Pstream.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
f
labelList f(nPoints)
Foam::removeFaces::ClassName
ClassName("removeFaces")
Runtime type information.
Foam::List< label >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::mapDistributePolyMesh
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Definition: mapDistributePolyMesh.H:66
Foam::removeFaces::compatibleRemoves
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:582
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79