combineFaces.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-2026 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::combineFaces
26 
27 Description
28  Combines boundary faces into single face. The faces get the patch
29  of the first face ('the master')
30 
31 SourceFiles
32  combineFaces.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef combineFaces_H
37 #define combineFaces_H
38 
39 #include "indirectPrimitivePatch.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 class polyMesh;
48 class polyTopoChange;
49 class polyTopoChangeMap;
50 class face;
51 
52 /*---------------------------------------------------------------------------*\
53  Class combineFaces Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class combineFaces
57 {
58  // Private Data
59 
60  //- Reference to mesh
61  const polyMesh& mesh_;
62 
63  //- Whether undoable
64  const bool undoable_;
65 
66  //- If undoable: master face for every set.
67  labelList masterFace_;
68 
69  //- If undoable: per set the vertices of all the faces in the set.
70  List<faceList> faceSetsVertices_;
71 
72  //- If undoable: saved point labels.
73  labelList savedPointLabels_;
74 
75  //- If undoable: saved coordinates of above points.
76  pointField savedPoints_;
77 
78 
79  // Private Member Functions
80 
81  //- Test if face is convex. Allow slight concavity through
82  // minConcaveCos.
83  static bool convexFace
84  (
85  const scalar minConcaveCos,
86  const pointField&,
87  const face&
88  );
89 
90  //- Test if set of faces (in primitivePatch) can be combined into
91  // single face. Uses convexFace.
92  static bool validFace
93  (
94  const scalar minConcaveCos,
96  );
97 
98  //- Create cell-local map from face to region (formed by merging faces
99  // across edges)
100  void regioniseFaces
101  (
102  const scalar minCos,
103  const labelHashSet& patchIDs,
104  const label celli,
105  const labelList& cEdges,
106  Map<label>& faceRegion
107  ) const;
108 
109  //- Does merging faces invalidate (unmerged) neighbouring faces?
110  bool faceNeighboursValid
111  (
112  const label celli,
113  const Map<label>& faceRegion
114  ) const;
115 
116 
117 public:
118 
119  //- Runtime type information
120  ClassName("combineFaces");
121 
122 
123  // Constructors
124 
125  //- Construct from mesh
126  combineFaces(const polyMesh& mesh, const bool undoable = false);
127 
128  //- Disallow default bitwise copy construction
129  combineFaces(const combineFaces&) = delete;
130 
131 
132  // Member Functions
133 
134  // Access
135 
136  //- If undoable: master face for every set.
137  const labelList& masterFace() const
138  {
139  return masterFace_;
140  }
141 
142 
143  // Helper functions
144 
145  //- Extract lists of all (non-coupled) boundary faces on selected
146  // patches and cells that can be merged. Uses getFaceRegions.
148  (
149  const scalar featureCos,
150  const scalar minConcaveCos,
151  const labelHashSet& patchIDs,
152  const labelHashSet& boundaryCells
153  ) const;
154 
155  //- Extract lists of all (non-coupled) boundary faces on selected
156  // patches that can be merged. Uses getFaceRegions.
158  (
159  const scalar featureCos,
160  const scalar minConcaveCos,
161  const labelHashSet& patchIDs
162  ) const;
163 
164  //- Extract lists of all (non-coupled) boundary faces that can
165  // be merged. Uses getFaceRegions.
167  (
168  const scalar featureCos,
169  const scalar minConcaveCos
170  ) const;
171 
172  //- Gets outside of patch as a face (in mesh point labels)
174 
175 
176  // Topology changes
177 
178  //- Play commands into polyTopoChange to combine faces. Gets
179  // labelListList of sets of faces to combine. Does no check
180  // for whether resulting face is legal.
181  void setRefinement
182  (
183  const labelListList& faceSets,
184  polyTopoChange& meshMod
185  );
186 
187  //- Force recalculation of locally stored data on topological change
188  void topoChange(const polyTopoChangeMap& map);
189 
190  //- Play commands into polyTopoChange to reinsert original faces.
191  // No other topo changes can be done in between setRefinement and
192  // setUnrefinement. Can be called multiple times to undo parts
193  // of the last setRefinement call.
194  // Gets the master face labels whose sets need to be restored.
195  void setUnrefinement
196  (
197  const labelList& masterFaces,
198  polyTopoChange& meshMod,
199  Map<label>& restoredFaces
200  );
201 
202 
203  // Member Operators
204 
205  //- Disallow default bitwise assignment
206  void operator=(const combineFaces&) = delete;
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
Definition: combineFaces.H:56
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &patchIDs, const labelHashSet &boundaryCells) const
Extract lists of all (non-coupled) boundary faces on selected.
Definition: combineFaces.C:300
void setRefinement(const labelListList &faceSets, polyTopoChange &meshMod)
Play commands into polyTopoChange to combine faces. Gets.
Definition: combineFaces.C:558
ClassName("combineFaces")
Runtime type information.
void setUnrefinement(const labelList &masterFaces, polyTopoChange &meshMod, Map< label > &restoredFaces)
Play commands into polyTopoChange to reinsert original faces.
Definition: combineFaces.C:815
combineFaces(const polyMesh &mesh, const bool undoable=false)
Construct from mesh.
Definition: combineFaces.C:283
void operator=(const combineFaces &)=delete
Disallow default bitwise assignment.
void topoChange(const polyTopoChangeMap &map)
Force recalculation of locally stored data on topological change.
Definition: combineFaces.C:766
const labelList & masterFace() const
If undoable: master face for every set.
Definition: combineFaces.H:136
static face getOutsideFace(const indirectPrimitivePatch &)
Gets outside of patch as a face (in mesh point labels)
Definition: combineFaces.C:430
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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