initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / edgeCollapser.H
blobed3d5f5dd9aed2e28bf2d70913ce5fc0b1b9a27b
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::edgeCollapser
28 Description
29     Does polyTopoChanges to remove edges. Can remove faces due to edge
30     collapse but can not remove cells due to face removal!
31     Also removes unused points.
33 SourceFiles
34     edgeCollapser.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef edgeCollapser_H
39 #define edgeCollapser_H
41 #include "labelList.H"
42 #include "DynamicList.H"
43 #include "typeInfo.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of classes
51 class polyMesh;
52 class polyTopoChange;
53 class face;
54 class mapPolyMesh;
56 /*---------------------------------------------------------------------------*\
57                            Class edgeCollapser Declaration
58 \*---------------------------------------------------------------------------*/
60 class edgeCollapser
62     // Private data
64         //- Reference to mesh
65         const polyMesh& mesh_;
67         //- For every point -1 or region number
68         labelList pointRegion_;
70         //- -1 or master vertex for region number
71         DynamicList<label> pointRegionMaster_;
73         //- Stack of free region numbers. Corresponds to -1 in pointRegionMaster
74         SLList<label> freeRegions_;
77     // Static Functions
79         //- Find val in list. Search starts at start, continues to size-1.
80         static label findIndex
81         (
82             const labelList&,
83             const label start,
84             const label size,
85             const label val
86         );
89     // Private Member Functions
91         //- Determine points connected through edgesToRemove_.
92         //  Note: Only routine that uses edgesToRemove!
93         label changePointRegion
94         (
95             const label pointI,
96             const label oldRegion,
97             const label newRegion
98         );
100         //- Whether point is master of region or has been removed
101         bool pointRemoved(const label) const;
103         //- Renumber f with new vertices. Removes duplicates.
104         void filterFace(const label faceI, face&) const;
106         //- Some debugging printing
107         void printRegions() const;
109         //- Collapse list of edges. Tries to find master to collapse to.
110         void collapseEdges(const labelList& edgeLabels);
112         //- Disallow default bitwise copy construct
113         edgeCollapser(const edgeCollapser&);
115         //- Disallow default bitwise assignment
116         void operator=(const edgeCollapser&);
119 public:
121     //- Runtime type information
122     ClassName("edgeCollapser");
125     // Constructors
127         //- Construct from mesh.
128         edgeCollapser(const polyMesh& mesh);
131     // Member Functions
133         // Access
135             //- For every point the region it belongs to or -1.
136             const labelList& pointRegion() const
137             {
138                 return pointRegion_;
139             }
141             //- For every region the master (i.e. the point the region will
142             //  be replaced by)
143             const DynamicList<label>& pointRegionMaster() const
144             {
145                 return pointRegionMaster_;
146             }
148             //- Check that edge is not marked for anything
149             bool unaffectedEdge(const label edgeI) const;
152         // Edit
154             //- Set edge to collapse and point to collapse it to.
155             //  Return true if collapse is valid.
156             //  (always true at the moment)
157             bool collapseEdge(const label edgeI, const label master);
159             //- Play commands into polyTopoChange to create mesh. Return true
160             //  if anything changed.
161             bool setRefinement(polyTopoChange&);
163             void updateMesh(const mapPolyMesh&);
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 #endif
175 // ************************************************************************* //