initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / conversion / polyDualMesh / meshDualiser.H
blob00937b3449f1870bd00b57782a604edbafb8322d
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     meshDualiser
28 Description
29     Creates dual of polyMesh. Every point becomes a cell (or multiple cells
30     for feature points), a walk around every edge creates faces between them.
32     Put all points you want in the final mesh into featurePoints; all edge(mid)s
33     you want in the final mesh into featureEdges; all face(centre)s in
34     faceFaces.
36     Usually to preserve boundaries:
37         - all boundary faces are featureFaces
38         - all edges and points inbetween different patches are
39           featureEdges/points.
41     In same way you can also preserve internal faces (e.g. faceZones)
43 SourceFiles
44     meshDualiser.C
46 \*---------------------------------------------------------------------------*/
48 #ifndef meshDualiser_H
49 #define meshDualiser_H
51 #include "DynamicList.H"
52 #include "PackedBoolList.H"
53 #include "boolList.H"
54 #include "typeInfo.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 namespace Foam
61 class polyMesh;
62 class polyTopoChange;
64 /*---------------------------------------------------------------------------*\
65                            Class meshDualiser Declaration
66 \*---------------------------------------------------------------------------*/
68 class meshDualiser
70     // Private data
72         const polyMesh& mesh_;
74         //- From point on cell to dual cell. Either single entry or
75         //  one entry per pointCells
76         labelListList pointToDualCells_;
78         //- From point to dual point (or -1 if not feature point).
79         labelList pointToDualPoint_;
81         //- From cell to dual point. All cells become point
82         labelList cellToDualPoint_;
84         //- From face to dual point (or -1 if not feature face)
85         labelList faceToDualPoint_;
87         //- From edge to dual point (or -1 if not feature edge)
88         labelList edgeToDualPoint_;
91     // Private Member Functions
93         static void checkPolyTopoChange(const polyTopoChange&);
95         static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
97         //- Find dual cell given point and cell
98         label findDualCell(const label cellI, const label pointI) const;
100         //- Helper function to generate dualpoints on all boundary edges
101         //  emanating from (boundary & feature) point
102         void generateDualBoundaryEdges
103         (
104             const PackedBoolList&,
105             const label pointI,
106             polyTopoChange&
107         );
109         //- Check that owner and neighbour of face have same dual cell
110         bool sameDualCell
111         (
112             const label faceI,
113             const label pointI
114         ) const;
116         //- Add internal face
117         label addInternalFace
118         (
119             const label masterPointI,
120             const label masterEdgeI,
121             const label masterFaceI,
123             const bool edgeOrder,
124             const label dualCell0,
125             const label dualCell1,
126             const DynamicList<label>& verts,
127             polyTopoChange& meshMod
128         ) const;
130         //- Add boundary face
131         label addBoundaryFace
132         (
133             const label masterPointI,
134             const label masterEdgeI,
135             const label masterFaceI,
137             const label dualCellI,
138             const label patchI,
139             const DynamicList<label>& verts,
140             polyTopoChange& meshMod
141         ) const;
143         //- Create internal faces walking around edge
144         void createFacesAroundEdge
145         (
146             const bool splitFace,
147             const PackedBoolList&,
148             const label edgeI,
149             const label startFaceI,
150             polyTopoChange&,
151             boolList& doneEFaces
152         ) const;
154         //- Create single internal face from internal face
155         void createFaceFromInternalFace
156         (
157             const label faceI,
158             label& fp,
159             polyTopoChange&
160         ) const;
162         //- Creates boundary faces walking around point on patchI.
163         void createFacesAroundBoundaryPoint
164         (
165             const label patchI,
166             const label patchPointI,
167             const label startFaceI,
168             polyTopoChange&,
169             boolList& donePFaces            // pFaces visited
170         ) const;
172         //- Disallow default bitwise copy construct
173         meshDualiser(const meshDualiser&);
175         //- Disallow default bitwise assignment
176         void operator=(const meshDualiser&);
179 public:
181     //- Runtime type information
182     ClassName("meshDualiser");
185     // Constructors
187         //- Construct from mesh
188         meshDualiser(const polyMesh&);
191     // Member Functions
193         // Access
195             //- From point on cell to dual cell. Either single entry or
196             //  one entry per pointCells.
197             const labelListList& pointToDualCells() const
198             {
199                 return pointToDualCells_;
200             }
202             //- From point to dual point (or -1 if not feature point).
203             const labelList& pointToDualPoint() const
204             {
205                 return pointToDualPoint_;
206             }
208             //- From cell to dual point (at cell centre). All cells become
209             //  points.
210             const labelList& cellToDualPoint() const
211             {
212                 return cellToDualPoint_;
213             }
215             //- From face to dual point (at face centre; or -1 if not
216             //  feature face).
217             const labelList& faceToDualPoint() const
218             {
219                 return faceToDualPoint_;
220             }
222             //- From edge to dual point (at edge mid; or -1 if not feature
223             //  edge).
224             const labelList& edgeToDualPoint() const
225             {
226                 return edgeToDualPoint_;
227             }
230         // Edit
233             //- Insert all changes into meshMod to convert the polyMesh into
234             //  its dual.
235             //  featureFaces  : faces where we want a point at the face centre
236             //  featureEdges  : edges           ,,                 edge mid
237             //  featurePoints : points          ,,    point. Two variants:
238             //      singleCellFeaturePoints : point becomes one dualcell.
239             //          Use this for e.g. convex boundary points.
240             //      multiCellFeaturePoints : one dualcell per original cell
241             //          around point. Use this for e.g. concave boundary points
242             //          since it prevents big concave boundary cells.
243             void setRefinement
244             (
245                 const bool splitFace,
246                 const labelList& featureFaces,
247                 const labelList& featureEdges,
248                 const labelList& singleCellFeaturePoints,
249                 const labelList& multiCellFeaturePoints,
250                 polyTopoChange& meshMod
251             );
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 } // End namespace Foam
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 #endif
262 // ************************************************************************* //