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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::combineFaces
29 
30 Description
31  Combines boundary faces into single face. The faces get the patch
32  of the first face ('the master')
33 
34 SourceFiles
35  combineFaces.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef combineFaces_H
40 #define combineFaces_H
41 
42 #include "indirectPrimitivePatch.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class polyMesh;
51 class polyTopoChange;
52 class mapPolyMesh;
53 class face;
54 
55 /*---------------------------------------------------------------------------*\
56  Class combineFaces Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class combineFaces
60 {
61  // Private data
62 
63  //- Reference to mesh
64  const polyMesh& mesh_;
65 
66  //- Whether undoable
67  const bool undoable_;
68 
69  //- If undoable: masterface for every set.
70  labelList masterFace_;
71 
72  //- If undoable: per set the vertices of all the faces in the set.
73  List<faceList> faceSetsVertices_;
74 
75  //- If undoable: saved point labels.
76  labelList savedPointLabels_;
77 
78  //- If undoable: saved coordinates of above points.
79  pointField savedPoints_;
80 
81 
82 
83  // Private Member Functions
84 
85  //- Test if face is convex. Allow slight concavity through
86  // minConcaveCos.
87  static bool convexFace
88  (
89  const scalar minConcaveCos,
90  const pointField&,
91  const face&
92  );
93 
94  //- Test if set of faces (in primitivePatch) can be combined into
95  // single face. Uses convexFace.
96  static bool validFace
97  (
98  const scalar minConcaveCos,
100  );
101 
102  //- Create cell-local map from face to region (formed by merging faces
103  // across edges)
104  void regioniseFaces
105  (
106  const scalar minCos,
107  const bool mergeAcrossPatches,
108  const label celli,
109  const labelList& cEdges,
110  Map<label>& faceRegion
111  ) const;
112 
113  //- Does merging faces invalidate (unmerged) neighbouring faces?
114  bool faceNeighboursValid
115  (
116  const label celli,
117  const Map<label>& faceRegion
118  ) const;
119 
120 
121 
122  //- No copy construct
123  combineFaces(const combineFaces&) = delete;
124 
125  //- No copy assignment
126  void operator=(const combineFaces&) = delete;
127 
128 public:
129 
130  //- Runtime type information
131  ClassName("combineFaces");
132 
133 
134  // Constructors
135 
136  //- Construct from mesh
137  combineFaces(const polyMesh& mesh, const bool undoable = false);
138 
139 
140  // Member Functions
141 
142  // Access
143 
144  //- If undoable: masterface for every set.
145  const labelList& masterFace() const
146  {
147  return masterFace_;
148  }
149 
150  //- If undoable: set of original point labels of stored points
151  const labelList& savedPointLabels() const
152  {
153  return savedPointLabels_;
154  }
155 
156 
157  // Helper functions
158 
159  //- Extract lists of all (non-coupled) boundary faces on selected
160  // cells that can be merged. Uses getFaceRegions. Optionally
161  // allow faces-on-different-patches to be merged (into the largest
162  // area face - could be improved). Note: causes a problem in
163  // undoing - all restored faces get the patch/zone from the
164  // master face.
166  (
167  const scalar featureCos,
168  const scalar minConcaveCos,
169  const labelHashSet& boundaryCells,
170  const bool mergeAcrossPatches = false
171  ) const;
172 
173  //- Extract lists of all (non-coupled) boundary faces that can
174  // be merged. Uses getFaceRegions. See note above about
175  // mergeAcrossPatches.
177  (
178  const scalar featureCos,
179  const scalar minConcaveCos,
180  const bool mergeAcrossPatches = false
181  ) const;
182 
183  //- Gets outside of patch as a face (in mesh point labels)
185 
186 
187  // Topology changes
188 
189  //- Play commands into polyTopoChange to combine faces. Gets
190  // labelListList of sets of faces to combine. Does no check
191  // for whether resulting face is legal.
192  void setRefinement
193  (
194  const labelListList&,
196  );
197 
198  //- Force recalculation of locally stored data on topological change
199  void updateMesh(const mapPolyMesh&);
200 
201  //- Play commands into polyTopoChange to reinsert original faces.
202  // No other topo changes can be done inbetween setRefinement and
203  // setUnrefinement. Can be called multiple times to undo parts
204  // of the last setRefinement call.
205  // Gets the master face labels whose sets need to be restored.
206  // Returns maps from added restored point to
207  // original point label (i.e. content of savedPointLabels_).
208  // (only restoredPoints are actually set; rest are just for
209  // generalness). See note above about restoring faces from
210  // different patches (mergeAcrossPatches)
211  void setUnrefinement
212  (
213  const labelList& masterFaces,
214  polyTopoChange& meshMod,
215  Map<label>& restoredPoints,
216  Map<label>& restoredFaces,
217  Map<label>& restoredCells
218  );
219 };
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #endif
229 
230 // ************************************************************************* //
Foam::combineFaces::getOutsideFace
static face getOutsideFace(const indirectPrimitivePatch &)
Gets outside of patch as a face (in mesh point labels)
Definition: combineFaces.C:463
Foam::combineFaces
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
Definition: combineFaces.H:58
Foam::combineFaces::savedPointLabels
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
Definition: combineFaces.H:150
Foam::combineFaces::getMergeSets
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &boundaryCells, const bool mergeAcrossPatches=false) const
Extract lists of all (non-coupled) boundary faces on selected.
Definition: combineFaces.C:308
Foam::combineFaces::ClassName
ClassName("combineFaces")
Runtime type information.
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:100
Foam::Map< label >
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::label
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:62
Foam::Field< vector >
Foam::combineFaces::updateMesh
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: combineFaces.C:816
Foam::combineFaces::setUnrefinement
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:865
indirectPrimitivePatch.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::combineFaces::masterFace
const labelList & masterFace() const
If undoable: masterface for every set.
Definition: combineFaces.H:144
Foam::List< label >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::combineFaces::setRefinement
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
Definition: combineFaces.C:591
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:74
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90