FreeFOAM The Cross-Platform CFD Toolkit
edgeCollapser.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::edgeCollapser
26 
27 Description
28  Does polyTopoChanges to remove edges. Can remove faces due to edge
29  collapse but can not remove cells due to face removal!
30  Also removes unused points.
31 
32 SourceFiles
33  edgeCollapser.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef edgeCollapser_H
38 #define edgeCollapser_H
39 
40 #include <OpenFOAM/labelList.H>
41 #include <OpenFOAM/DynamicList.H>
42 #include <OpenFOAM/typeInfo.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class polyMesh;
51 class polyTopoChange;
52 class face;
53 class mapPolyMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class edgeCollapser Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61  // Private data
62 
63  //- Reference to mesh
64  const polyMesh& mesh_;
65 
66  //- For every point -1 or region number
67  labelList pointRegion_;
68 
69  //- -1 or master vertex for region number
70  DynamicList<label> pointRegionMaster_;
71 
72  //- Stack of free region numbers. Corresponds to -1 in pointRegionMaster
73  SLList<label> freeRegions_;
74 
75 
76  // Static Functions
77 
78  //- Find val in list. Search starts at start, continues to size-1.
79  static label findIndex
80  (
81  const labelList&,
82  const label start,
83  const label size,
84  const label val
85  );
86 
87 
88  // Private Member Functions
89 
90  //- Determine points connected through edgesToRemove_.
91  // Note: Only routine that uses edgesToRemove!
92  label changePointRegion
93  (
94  const label pointI,
95  const label oldRegion,
96  const label newRegion
97  );
98 
99  //- Whether point is master of region or has been removed
100  bool pointRemoved(const label) const;
101 
102  //- Renumber f with new vertices. Removes duplicates.
103  void filterFace(const label faceI, face&) const;
104 
105  //- Some debugging printing
106  void printRegions() const;
107 
108  //- Collapse list of edges. Tries to find master to collapse to.
109  void collapseEdges(const labelList& edgeLabels);
110 
111  //- Disallow default bitwise copy construct
113 
114  //- Disallow default bitwise assignment
115  void operator=(const edgeCollapser&);
116 
117 
118 public:
119 
120  //- Runtime type information
121  ClassName("edgeCollapser");
122 
123 
124  // Constructors
125 
126  //- Construct from mesh.
127  edgeCollapser(const polyMesh& mesh);
128 
129 
130  // Member Functions
131 
132  // Access
133 
134  //- For every point the region it belongs to or -1.
135  const labelList& pointRegion() const
136  {
137  return pointRegion_;
138  }
139 
140  //- For every region the master (i.e. the point the region will
141  // be replaced by)
143  {
144  return pointRegionMaster_;
145  }
146 
147  //- Check that edge is not marked for anything
148  bool unaffectedEdge(const label edgeI) const;
149 
150 
151  // Edit
152 
153  //- Set edge to collapse and point to collapse it to.
154  // Return true if collapse is valid.
155  // (always true at the moment)
156  bool collapseEdge(const label edgeI, const label master);
157 
158  //- Play commands into polyTopoChange to create mesh. Return true
159  // if anything changed.
161 
162  void updateMesh(const mapPolyMesh&);
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************ vim: set sw=4 sts=4 et: ************************ //