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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::combineFaces
29
30Description
31 Combines boundary faces into single face. The faces get the patch
32 of the first face ('the master')
33
34SourceFiles
35 combineFaces.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef combineFaces_H
40#define combineFaces_H
41
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class polyMesh;
51class polyTopoChange;
52class mapPolyMesh;
53class face;
54
55/*---------------------------------------------------------------------------*\
56 Class combineFaces Declaration
57\*---------------------------------------------------------------------------*/
59class 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 // Private Member Functions
83
84 //- Test if face is convex. Allow slight concavity through
85 // minConcaveCos.
86 static bool convexFace
87 (
88 const scalar minConcaveCos,
89 const pointField&,
90 const face&
91 );
92
93 //- Test if set of faces (in primitivePatch) can be combined into
94 // single face. Uses convexFace.
95 static bool validFace
96 (
97 const scalar minConcaveCos,
99 );
100
101 //- Create cell-local map from face to region (formed by merging faces
102 // across edges)
103 void regioniseFaces
104 (
105 const scalar minCos,
106 const bool mergeAcrossPatches,
107 const label celli,
108 const labelList& cEdges,
109 Map<label>& faceRegion
110 ) const;
111
112 //- Does merging faces invalidate (unmerged) neighbouring faces?
113 bool faceNeighboursValid
114 (
115 const label celli,
116 const Map<label>& faceRegion
117 ) const;
118
119
120 //- No copy construct
121 combineFaces(const combineFaces&) = delete;
122
123 //- No copy assignment
124 void operator=(const combineFaces&) = delete;
125
126public:
127
128 //- Runtime type information
129 ClassName("combineFaces");
130
131
132 // Constructors
133
134 //- Construct from mesh
135 explicit combineFaces(const polyMesh& mesh, const bool undoable=false);
136
137
138 // Member Functions
139
140 // Access
141
142 //- If undoable: masterface for every set.
143 const labelList& masterFace() const
144 {
145 return masterFace_;
146 }
147
148 //- If undoable: set of original point labels of stored points
149 const labelList& savedPointLabels() const
150 {
151 return savedPointLabels_;
152 }
153
154
155 // Helper functions
156
157 //- Extract lists of all (non-coupled) boundary faces on selected
158 // cells that can be merged. Uses getFaceRegions. Optionally
159 // allow faces-on-different-patches to be merged (into the largest
160 // area face - could be improved). Note: causes a problem in
161 // undoing - all restored faces get the patch/zone from the
162 // master face.
164 (
165 const scalar featureCos,
166 const scalar minConcaveCos,
167 const labelHashSet& boundaryCells,
168 const bool mergeAcrossPatches = false
169 ) const;
170
171 //- Extract lists of all (non-coupled) boundary faces that can
172 // be merged. Uses getFaceRegions. See note above about
173 // mergeAcrossPatches.
175 (
176 const scalar featureCos,
177 const scalar minConcaveCos,
178 const bool mergeAcrossPatches = false
179 ) const;
180
181 //- Gets outside of patch as a face (in mesh point labels)
183
184
185 // Topology changes
186
187 //- Play commands into polyTopoChange to combine faces. Gets
188 // labelListList of sets of faces to combine. Does no check
189 // for whether resulting face is legal.
190 void setRefinement
191 (
192 const labelListList&,
194 );
195
196 //- Force recalculation of locally stored data on topological change
197 void updateMesh(const mapPolyMesh&);
198
199 //- Play commands into polyTopoChange to reinsert original faces.
200 // No other topo changes can be done inbetween setRefinement and
201 // setUnrefinement. Can be called multiple times to undo parts
202 // of the last setRefinement call.
203 // Gets the master face labels whose sets need to be restored.
204 // Returns maps from added restored point to
205 // original point label (i.e. content of savedPointLabels_).
206 // (only restoredPoints are actually set; rest are just for
207 // generalness). See note above about restoring faces from
208 // different patches (mergeAcrossPatches)
209 void setUnrefinement
210 (
211 const labelList& masterFaces,
212 polyTopoChange& meshMod,
213 Map<label>& restoredPoints,
214 Map<label>& restoredFaces,
215 Map<label>& restoredCells
216 );
217};
218
219
220// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221
222} // End namespace Foam
223
224// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225
226#endif
227
228// ************************************************************************* //
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
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 ('the master')
Definition: combineFaces.H:59
ClassName("combineFaces")
Runtime type information.
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:300
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:857
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
Definition: combineFaces.C:583
const labelList & masterFace() const
If undoable: masterface for every set.
Definition: combineFaces.H:142
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
Definition: combineFaces.H:148
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: combineFaces.C:808
static face getOutsideFace(const indirectPrimitivePatch &)
Gets outside of patch as a face (in mesh point labels)
Definition: combineFaces.C:455
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Direct mesh changes based on v1.3 polyTopoChange syntax.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
dynamicFvMesh & mesh
Namespace for OpenFOAM.