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-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::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 mapPolyMesh;
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: masterface 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 
80  // Private Member Functions
81 
82  //- Test if face is convex. Allow slight concavity through
83  // minConcaveCos.
84  static bool convexFace
85  (
86  const scalar minConcaveCos,
87  const pointField&,
88  const face&
89  );
90 
91  //- Test if set of faces (in primitivePatch) can be combined into
92  // single face. Uses convexFace.
93  static bool validFace
94  (
95  const scalar minConcaveCos,
97  );
98 
99  //- Create cell-local map from face to region (formed by merging faces
100  // across edges)
101  void regioniseFaces
102  (
103  const scalar minCos,
104  const labelHashSet& patchIDs,
105  const label celli,
106  const labelList& cEdges,
107  Map<label>& faceRegion
108  ) const;
109 
110  //- Does merging faces invalidate (unmerged) neighbouring faces?
111  bool faceNeighboursValid
112  (
113  const label celli,
114  const Map<label>& faceRegion
115  ) const;
116 
117 
118 public:
119 
120  //- Runtime type information
121  ClassName("combineFaces");
122 
123 
124  // Constructors
125 
126  //- Construct from mesh
127  combineFaces(const polyMesh& mesh, const bool undoable = false);
128 
129  //- Disallow default bitwise copy construction
130  combineFaces(const combineFaces&) = delete;
131 
132 
133  // Member Functions
134 
135  // Access
136 
137  //- If undoable: masterface for every set.
138  const labelList& masterFace() const
139  {
140  return masterFace_;
141  }
142 
143  //- If undoable: set of original point labels of stored points
144  const labelList& savedPointLabels() const
145  {
146  return savedPointLabels_;
147  }
148 
149 
150  // Helper functions
151 
152  //- Extract lists of all (non-coupled) boundary faces on selected
153  // patches and cells that can be merged. Uses getFaceRegions.
155  (
156  const scalar featureCos,
157  const scalar minConcaveCos,
158  const labelHashSet& patchIDs,
159  const labelHashSet& boundaryCells
160  ) const;
161 
162  //- Extract lists of all (non-coupled) boundary faces on selected
163  // patches that can be merged. Uses getFaceRegions.
165  (
166  const scalar featureCos,
167  const scalar minConcaveCos,
168  const labelHashSet& patchIDs
169  ) const;
170 
171  //- Extract lists of all (non-coupled) boundary faces that can
172  // be merged. Uses getFaceRegions.
174  (
175  const scalar featureCos,
176  const scalar minConcaveCos
177  ) const;
178 
179  //- Gets outside of patch as a face (in mesh point labels)
181 
182 
183  // Topology changes
184 
185  //- Play commands into polyTopoChange to combine faces. Gets
186  // labelListList of sets of faces to combine. Does no check
187  // for whether resulting face is legal.
188  void setRefinement
189  (
190  const labelListList&,
192  );
193 
194  //- Force recalculation of locally stored data on topological change
195  void updateMesh(const mapPolyMesh&);
196 
197  //- Play commands into polyTopoChange to reinsert original faces.
198  // No other topo changes can be done in between setRefinement and
199  // setUnrefinement. Can be called multiple times to undo parts
200  // of the last setRefinement call.
201  // Gets the master face labels whose sets need to be restored.
202  // Returns maps from added restored point to
203  // original point label (i.e. content of savedPointLabels_).
204  // (only restoredPoints are actually set; rest are just for
205  // generalness)
206  void setUnrefinement
207  (
208  const labelList& masterFaces,
209  polyTopoChange& meshMod,
210  Map<label>& restoredPoints,
211  Map<label>& restoredFaces,
212  Map<label>& restoredCells
213  );
214 
215 
216  // Member Operators
217 
218  //- Disallow default bitwise assignment
219  void operator=(const combineFaces&) = delete;
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
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
void setUnrefinement(const labelList &masterFaces, polyTopoChange &meshMod, Map< label > &restoredPoints, Map< label > &restoredFaces, Map< label > &restoredCells)
Play commands into polyTopoChange to reinsert original faces.
Definition: combineFaces.C:837
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
combineFaces(const polyMesh &mesh, const bool undoable=false)
Construct from mesh.
Definition: combineFaces.C:288
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
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:305
static face getOutsideFace(const indirectPrimitivePatch &)
Gets outside of patch as a face (in mesh point labels)
Definition: combineFaces.C:435
A list of faces which address into the list of points.
Combines boundary faces into single face. The faces get the patch of the first face (&#39;the master&#39;) ...
Definition: combineFaces.H:55
dynamicFvMesh & mesh
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
Definition: combineFaces.C:563
const labelList & masterFace() const
If undoable: masterface for every set.
Definition: combineFaces.H:137
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
Definition: combineFaces.H:143
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("combineFaces")
Runtime type information.
void operator=(const combineFaces &)=delete
Disallow default bitwise assignment.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: combineFaces.C:788
Namespace for OpenFOAM.