FreeFOAM The Cross-Platform CFD Toolkit
removePoints.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::removePoints
26 
27 Description
28  Removes selected points from mesh and updates faces using these
29  points.
30 
31 SourceFiles
32  removePoints.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef removePoints_H
37 #define removePoints_H
38 
39 #include <OpenFOAM/typeInfo.H>
40 #include <OpenFOAM/boolList.H>
41 #include <OpenFOAM/pointField.H>
42 #include <OpenFOAM/faceList.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class polyMesh;
51 class polyTopoChange;
52 class mapPolyMesh;
53 class face;
54 
55 /*---------------------------------------------------------------------------*\
56  Class removePoints Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61 
62  // Private classes
63 
64  //- Combine-reduce operator to combine data on faces. Takes care
65  // of reverse orientation on coupled face.
66  template <class T, template<class> class CombineOp>
67  class faceEqOp
68  {
69 
70  public:
71 
72  void operator()(List<T>& x, const List<T>& y) const
73  {
74  if (y.size() > 0)
75  {
76  if (x.empty())
77  {
78  x = y;
79  }
80  else
81  {
82  label j = 0;
83  forAll(x, i)
84  {
85  CombineOp<T>()(x[i], y[j]);
86  j = y.rcIndex(j);
87  }
88  }
89  }
90  }
91  };
92 
93 
94  // Private data
95 
96  //- Reference to mesh
97  const polyMesh& mesh_;
98 
99  //- Whether undoable
100  const bool undoable_;
101 
102  //- If undoable: deleted points
103  pointField savedPoints_;
104 
105  //- If undoable: per stored face the original mesh face label
106  labelList savedFaceLabels_;
107 
108  //- If undoable: per stored face the vertices. Negative indices
109  // refer to deletedPoints_
110  faceList savedFaces_;
111 
112 
113  // Private Member Functions
114 
115  //- Change the vertices of the face whilst keeping everything else
116  // (patch, zone) the same.
117  void modifyFace
118  (
119  const label faceI,
120  const face&,
122  ) const;
123 
124 
125  //- Disallow default bitwise copy construct
126  removePoints(const removePoints&);
127 
128  //- Disallow default bitwise assignment
129  void operator=(const removePoints&);
130 
131 public:
132 
133  //- Runtime type information
134  ClassName("removePoints");
135 
136 
137  // Constructors
138 
139  //- Construct from mesh
140  removePoints(const polyMesh& mesh, const bool undoable = false);
141 
142 
143  // Member Functions
144 
145  //- If undoable: affected face labels. Already restored faces
146  // will be -1.
147  const labelList& savedFaceLabels() const
148  {
149  return savedFaceLabels_;
150  }
151 
152 
153  // Helper functions
154 
155  //- Mark in pointCanBeDeleted the points that can be deleted
156  // (parallel synchronised) and returns the global number of these
157  // points. (this number is the global number before synchronisation
158  // so might be off!)
159  // A point can be deleted if
160  // - it is not used by any edge.
161  // or
162  // - is not used by an internal edge
163  // - is used by only two boundary edges. (note that these two
164  // edges will always be boundary ones!)
165  // - these two edges are sufficiently in line (cos > minCos)
166  // - all processors agree that point can be deleted.
167  label countPointUsage
168  (
169  const scalar minCos,
170  boolList& pointCanBeDeleted
171  ) const;
172 
173  // Topology changes
174 
175  //- Play commands into polyTopoChange to remove points. Gets
176  // boolList (output of countPointUsage) as input.
177  // Does no check for whether resulting face is legal.
178  // Since pointCanBeDeleted is synced all coupled faces should
179  // decide the same.
180  void setRefinement(const boolList&, polyTopoChange&);
181 
182  //- Force recalculation of locally stored data on topological change
183  void updateMesh(const mapPolyMesh&);
184 
185  //- Given set of faces to restore calculates a consistent set of
186  // saved faces (indices into savedFaces_) and saved vertices
187  // (indices into savedPoints_) to restore. The undoFaces have to
188  // be synced.
189  void getUnrefimentSet
190  (
191  const labelList& undoFaces,
192  labelList& localFaces,
193  labelList& localPoints
194  ) const;
195 
196  //- Restore selected faces and vertices.
197  void setUnrefinement
198  (
199  const labelList& localFaces,
200  const labelList& localPoints,
202  );
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************ vim: set sw=4 sts=4 et: ************************ //