initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / combineFaces.H
blobf78da37377f84cd69926b7d1f90dbc153c6a5431
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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             const labelList& cEdges,
107             Map<label>& faceRegion
108         ) const;
110         //- Does merging faces invalidate (unmerged) neighbouring faces?
111         bool faceNeighboursValid
112         (
113             const label cellI,
114             const Map<label>& faceRegion
115         ) const;
119         //- Disallow default bitwise copy construct
120         combineFaces(const combineFaces&);
122         //- Disallow default bitwise assignment
123         void operator=(const combineFaces&);
125 public:
127     //- Runtime type information
128     ClassName("combineFaces");
131     // Constructors
133         //- Construct from mesh
134         combineFaces(const polyMesh& mesh, const bool undoable = false);
137     // Member Functions
139         // Access
141             //- If undoable: masterface for every set.
142             const labelList& masterFace() const
143             {
144                 return masterFace_;
145             }
147             //- If undoable: set of original point labels of stored points
148             const labelList& savedPointLabels() const
149             {
150                 return savedPointLabels_;
151             }
154         // Helper functions
156             //- Extract lists of all (non-coupled) boundary faces on selected
157             //  cells that can be merged. Uses getFaceRegions.
158             labelListList getMergeSets
159             (
160                 const scalar featureCos,
161                 const scalar minConcaveCos,
162                 const labelHashSet& boundaryCells
163             ) const;
165             //- Extract lists of all (non-coupled) boundary faces that can
166             //  be merged. Uses getFaceRegions.
167             labelListList getMergeSets
168             (
169                 const scalar featureCos,
170                 const scalar minConcaveCos
171             ) const;
173             //- Gets outside of patch as a face (in mesh point labels)
174             static face getOutsideFace(const indirectPrimitivePatch&);
177         // Topology changes
179             //- Play commands into polyTopoChange to combine faces. Gets
180             //  labelListList of sets of faces to combine. Does no check
181             //  for whether resulting face is legal.
182             void setRefinement
183             (
184                 const labelListList&,
185                 polyTopoChange&
186             );
188             //- Force recalculation of locally stored data on topological change
189             void updateMesh(const mapPolyMesh&);
191             //- Play commands into polyTopoChange to reinsert original faces.
192             //  No other topo changes can be done inbetween setRefinement and
193             //  setUnrefinement. Can be called multiple times to undo parts
194             //  of the last setRefinement call.
195             //  Gets the master face labels whose sets need to be restored.
196             //  Returns maps from added restored point to
197             //  original point label (i.e. content of savedPointLabels_).
198             //  (only restoredPoints are actually set; rest are just for
199             //   generalness)
200             void setUnrefinement
201             (
202                 const labelList& masterFaces,
203                 polyTopoChange& meshMod,
204                 Map<label>& restoredPoints,
205                 Map<label>& restoredFaces,
206                 Map<label>& restoredCells
207             );
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 } // End namespace Foam
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 #endif
219 // ************************************************************************* //