combineFaces.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 | Copyright (C) 2011 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 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 
118  //- Disallow default bitwise copy construct
119  combineFaces(const combineFaces&);
120 
121  //- Disallow default bitwise assignment
122  void operator=(const combineFaces&);
123 
124 public:
125 
126  //- Runtime type information
127  ClassName("combineFaces");
128 
129 
130  // Constructors
131 
132  //- Construct from mesh
133  combineFaces(const polyMesh& mesh, const bool undoable = false);
134 
135 
136  // Member Functions
137 
138  // Access
139 
140  //- If undoable: masterface for every set.
141  const labelList& masterFace() const
142  {
143  return masterFace_;
144  }
145 
146  //- If undoable: set of original point labels of stored points
147  const labelList& savedPointLabels() const
148  {
149  return savedPointLabels_;
150  }
151 
152 
153  // Helper functions
154 
155  //- Extract lists of all (non-coupled) boundary faces on selected
156  // cells that can be merged. Uses getFaceRegions.
158  (
159  const scalar featureCos,
160  const scalar minConcaveCos,
161  const labelHashSet& boundaryCells
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&,
185  );
186 
187  //- Force recalculation of locally stored data on topological change
188  void updateMesh(const mapPolyMesh&);
189 
190  //- Play commands into polyTopoChange to reinsert original faces.
191  // No other topo changes can be done inbetween 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  // Returns maps from added restored point to
196  // original point label (i.e. content of savedPointLabels_).
197  // (only restoredPoints are actually set; rest are just for
198  // generalness)
199  void setUnrefinement
200  (
201  const labelList& masterFaces,
202  polyTopoChange& meshMod,
203  Map<label>& restoredPoints,
204  Map<label>& restoredFaces,
205  Map<label>& restoredCells
206  );
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
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:842
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
Definition: combineFaces.H:146
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
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
dynamicFvMesh & mesh
Namespace for OpenFOAM.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
Definition: combineFaces.C:558
Combines boundary faces into single face. The faces get the patch of the first face (&#39;the master&#39;) ...
Definition: combineFaces.H:55
A list of faces which address into the list of points.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const labelList & masterFace() const
If undoable: masterface for every set.
Definition: combineFaces.H:140
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: combineFaces.C:790
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("combineFaces")
Runtime type information.
static face getOutsideFace(const indirectPrimitivePatch &)
Gets outside of patch as a face (in mesh point labels)
Definition: combineFaces.C:414
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &boundaryCells) const
Extract lists of all (non-coupled) boundary faces on selected.
Definition: combineFaces.C:299