correction to d4edb38234db8268907f04836d49bb93461b8a88
[OpenFOAM-1.5.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / combineFaces.H
blob208407dff34b55f5463dfd68b8b8f9d4d5ce2289
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::combineFaces
28 Description
29     Combines boundary faces into single face. The faces get the patch
30     of the first face ('the master')
32 SourceFiles
33     combineFaces.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef combineFaces_H
38 #define combineFaces_H
40 #include "indirectPrimitivePatch.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
48 class polyMesh;
49 class polyTopoChange;
50 class mapPolyMesh;
51 class face;
53 /*---------------------------------------------------------------------------*\
54                            Class combineFaces Declaration
55 \*---------------------------------------------------------------------------*/
57 class combineFaces
59     // Private data
61         //- Reference to mesh
62         const polyMesh& mesh_;
64         //- Whether undoable
65         const bool undoable_;
67         //- If undoable: masterface for every set.
68         labelList masterFace_;
70         //- If undoable: per set the vertices of all the faces in the set.
71         List<faceList> faceSetsVertices_;
73         //- If undoable: saved point labels.
74         labelList savedPointLabels_;
76         //- If undoable: saved coordinates of above points.
77         pointField savedPoints_;
81     // Private Member Functions
83         //- Test if face is convex. Allow slight concavity through
84         //  minConcaveCos.
85         static bool convexFace
86         (
87             const scalar minConcaveCos,
88             const pointField&,
89             const face&
90         );
92         //- Test if set of faces (in primitivePatch) can be combined into
93         //  single face. Uses convexFace.
94         static bool validFace
95         (
96             const scalar minConcaveCos,
97             const indirectPrimitivePatch&
98         );
100         //- Create cell-local map from face to region (formed by merging faces
101         //  across edges)
102         void regioniseFaces
103         (
104             const scalar minCos,
105             const label cellI,
106             Map<label>& faceRegion
107         ) const;
109         //- Does merging faces invalidate (unmerged) neighbouring faces?
110         bool faceNeighboursValid
111         (
112             const label cellI,
113             const Map<label>& faceRegion
114         ) const;
118         //- Disallow default bitwise copy construct
119         combineFaces(const combineFaces&);
121         //- Disallow default bitwise assignment
122         void operator=(const combineFaces&);
124 public:
126     //- Runtime type information
127     ClassName("combineFaces");
130     // Constructors
132         //- Construct from mesh
133         combineFaces(const polyMesh& mesh, const bool undoable = false);
136     // Member Functions
138         // Access
140             //- If undoable: masterface for every set.
141             const labelList& masterFace() const
142             {
143                 return masterFace_;
144             }
146             //- If undoable: set of original point labels of stored points
147             const labelList& savedPointLabels() const
148             {
149                 return savedPointLabels_;
150             }
153         // Helper functions
155             //- Extract lists of all (non-coupled) boundary faces on selected
156             //  cells that can be merged. Uses getFaceRegions.
157             labelListList getMergeSets
158             (
159                 const scalar featureCos,
160                 const scalar minConcaveCos,
161                 const labelHashSet& boundaryCells
162             ) const;
164             //- Extract lists of all (non-coupled) boundary faces that can
165             //  be merged. Uses getFaceRegions.
166             labelListList getMergeSets
167             (
168                 const scalar featureCos,
169                 const scalar minConcaveCos
170             ) const;
172             //- Gets outside of patch as a face (in mesh point labels)
173             static face getOutsideFace(const indirectPrimitivePatch&);
176         // Topology changes
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&,
184                 polyTopoChange&
185             );
187             //- Force recalculation of locally stored data on topological change
188             void updateMesh(const mapPolyMesh&);
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             );
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 } // End namespace Foam
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 #endif
218 // ************************************************************************* //