removePoints.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "typeInfo.H"
40 #include "boolList.H"
41 #include "pointField.H"
42 #include "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 
59 class removePoints
60 {
61 
62  // Private data
63 
64  //- Reference to mesh
65  const polyMesh& mesh_;
66 
67  //- Whether undoable
68  const bool undoable_;
69 
70  //- If undoable: deleted points
71  pointField savedPoints_;
72 
73  //- If undoable: per stored face the original mesh face label
74  labelList savedFaceLabels_;
75 
76  //- If undoable: per stored face the vertices. Negative indices
77  // refer to deletedPoints_
78  faceList savedFaces_;
79 
80 
81  // Private Member Functions
82 
83  //- Change the vertices of the face whilst keeping everything else
84  // (patch, zone) the same.
85  void modifyFace
86  (
87  const label facei,
88  const face&,
90  ) const;
91 
92 
93  //- Disallow default bitwise copy construct
94  removePoints(const removePoints&);
95 
96  //- Disallow default bitwise assignment
97  void operator=(const removePoints&);
98 
99 public:
100 
101  //- Runtime type information
102  ClassName("removePoints");
103 
104 
105  // Constructors
106 
107  //- Construct from mesh
108  removePoints(const polyMesh& mesh, const bool undoable = false);
109 
110 
111  // Member Functions
112 
113  //- If undoable: affected face labels. Already restored faces
114  // will be -1.
115  const labelList& savedFaceLabels() const
116  {
117  return savedFaceLabels_;
118  }
119 
120 
121  // Helper functions
122 
123  //- Mark in pointCanBeDeleted the points that can be deleted
124  // (parallel synchronised) and returns the global number of these
125  // points. (this number is the global number before synchronisation
126  // so might be off!)
127  // A point can be deleted if
128  // - it is not used by any edge.
129  // or
130  // - is used by only two edges
131  // - these two edges are sufficiently in line (cos > minCos)
132  // - all processors agree that point can be deleted.
134  (
135  const scalar minCos,
136  boolList& pointCanBeDeleted
137  ) const;
138 
139  // Topology changes
140 
141  //- Play commands into polyTopoChange to remove points. Gets
142  // boolList (output of countPointUsage) as input.
143  // Does no check for whether resulting face is legal.
144  // Since pointCanBeDeleted is synced all coupled faces should
145  // decide the same.
146  void setRefinement(const boolList&, polyTopoChange&);
147 
148  //- Force recalculation of locally stored data on topological change
149  void updateMesh(const mapPolyMesh&);
150 
151  //- Given set of faces to restore calculates a consistent set of
152  // saved faces (indices into savedFaces_) and saved vertices
153  // (indices into savedPoints_) to restore. The undoFaces have to
154  // be synced.
155  void getUnrefimentSet
156  (
157  const labelList& undoFaces,
158  labelList& localFaces,
159  labelList& localPoints
160  ) const;
161 
162  //- Restore selected faces and vertices.
163  void setUnrefinement
164  (
165  const labelList& localFaces,
166  const labelList& localPoints,
168  );
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #endif
179 
180 // ************************************************************************* //
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
Definition: removePoints.C:770
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
Definition: removePoints.C:558
const labelList & savedFaceLabels() const
If undoable: affected face labels. Already restored faces.
Definition: removePoints.H:114
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
dynamicFvMesh & mesh
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
Definition: removePoints.C:296
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
Definition: removePoints.C:145
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("removePoints")
Runtime type information.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: removePoints.C:456
Removes selected points from mesh and updates faces using these points.
Definition: removePoints.H:58
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.