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-2024 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 polyTopoChangeMap;
57 class polyDistributionMap;
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 index
130  label getPatchIndex(const label facei) const;
131 
132  //- Return face with all pointsToRemove removed.
133  face filterFace(const labelHashSet&, const label) const;
134 
135  //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
136  void modifyFace
137  (
138  const face& f,
139  const label masterFaceID,
140  const label own,
141  const label nei,
142  const bool flipFaceFlux,
143  const label newPatchID,
144 
145  polyTopoChange& meshMod
146  ) const;
147 
148 
149 public:
150 
151  //- Runtime type information
152  ClassName("removeFaces");
153 
154 
155  // Constructors
156 
157  //- Construct from mesh and min cos of angle for boundary faces
158  // to be considered aligned. Set to >= 1 to disable checking
159  // and always merge (if on same patch)
160  removeFaces(const polyMesh&, const scalar minCos);
161 
162  //- Disallow default bitwise copy construction
163  removeFaces(const removeFaces&) = delete;
164 
165 
166  // Member Functions
167 
168  //- Find faces including those with cells which have the same mastercell
169  // Given set of faces to pierce calculates:
170  // - region for connected cells
171  // - mastercell for each region. This is the lowest numbered cell
172  // of all cells that get merged.
173  // - new set of faces which contains input set + additional ones
174  // where cells on both sides would have same mastercell.
175  // Returns number of regions.
177  (
178  const labelList& inPiercedFaces,
179  labelList& cellRegion,
180  labelList& cellRegionMaster,
181  labelList& outPiercedFaces
182  ) const;
183 
184 
185  //- Play commands into polyTopoChange to remove faces.
186  void setRefinement
187  (
188  const labelList& piercedFaces,
189  const labelList& cellRegion,
190  const labelList& cellRegionMaster,
192  ) const;
193 
194  //- Force recalculation of locally stored data on topological change
195  void topoChange(const polyTopoChangeMap&)
196  {}
197 
198  //- Force recalculation of locally stored data for mesh distribution
199  void distribute(const polyDistributionMap&)
200  {}
201 
202 
203  // Member Operators
204 
205  //- Disallow default bitwise assignment
206  void operator=(const removeFaces&) = delete;
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
A class for handling file names.
Definition: fileName.H:82
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:63
removeFaces(const polyMesh &, const scalar minCos)
Construct from mesh and min cos of angle for boundary faces.
void operator=(const removeFaces &)=delete
Disallow default bitwise assignment.
label compatibleRemoves(const labelList &inPiercedFaces, labelList &cellRegion, labelList &cellRegionMaster, labelList &outPiercedFaces) const
Find faces including those with cells which have the same mastercell.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
Definition: removeFaces.H:194
void distribute(const polyDistributionMap &)
Force recalculation of locally stored data for mesh distribution.
Definition: removeFaces.H:198
void setRefinement(const labelList &piercedFaces, const labelList &cellRegion, const labelList &cellRegionMaster, polyTopoChange &) const
Play commands into polyTopoChange to remove faces.
ClassName("removeFaces")
Runtime type information.
Namespace for OpenFOAM.
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
labelList f(nPoints)