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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::removePoints
28 
29 Description
30  Removes selected points from mesh and updates faces using these
31  points.
32 
33 SourceFiles
34  removePoints.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef removePoints_H
39 #define removePoints_H
40 
41 #include "typeInfo.H"
42 #include "boolList.H"
43 #include "pointField.H"
44 #include "faceList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 class polyMesh;
53 class polyTopoChange;
54 class mapPolyMesh;
55 class face;
56 
57 /*---------------------------------------------------------------------------*\
58  Class removePoints Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class removePoints
62 {
63  // Private Data
64 
65  //- Reference to mesh
66  const polyMesh& mesh_;
67 
68  //- Whether undoable
69  const bool undoable_;
70 
71  //- If undoable: deleted points
72  pointField savedPoints_;
73 
74  //- If undoable: per stored face the original mesh face label
75  labelList savedFaceLabels_;
76 
77  //- If undoable: per stored face the vertices. Negative indices
78  // refer to deletedPoints_
79  faceList savedFaces_;
80 
81 
82  // Private Member Functions
83 
84  //- Change the vertices of the face whilst keeping everything else
85  // (patch, zone) the same.
86  void modifyFace
87  (
88  const label facei,
89  const face&,
91  ) const;
92 
93 
94  //- No copy construct
95  removePoints(const removePoints&) = delete;
96 
97  //- No copy assignment
98  void operator=(const removePoints&) = delete;
99 
100 public:
101 
102  //- Runtime type information
103  ClassName("removePoints");
104 
105 
106  // Constructors
107 
108  //- Construct from mesh
109  explicit removePoints(const polyMesh& mesh, const bool undoable=false);
110 
111 
112  // Member Functions
113 
114  //- If undoable: affected face labels.
115  //- Already restored faces will be -1.
116  const labelList& savedFaceLabels() const
117  {
118  return savedFaceLabels_;
119  }
120 
121 
122  // Helper functions
123 
124  //- Mark in pointCanBeDeleted the points that can be deleted
125  // (parallel synchronised) and returns the global number of these
126  // points. (this number is the global number before synchronisation
127  // so might be off!)
128  // A point can be deleted if
129  // - it is not used by any edge.
130  // or
131  // - is used by only two edges
132  // - these two edges are sufficiently in line (cos > minCos)
133  // - all processors agree that point can be deleted.
134  label countPointUsage
135  (
136  const scalar minCos,
137  boolList& pointCanBeDeleted
138  ) const;
139 
140  // Topology changes
141 
142  //- Play commands into polyTopoChange to remove points. Gets
143  // boolList (output of countPointUsage) as input.
144  // Does no check for whether resulting face is legal.
145  // Since pointCanBeDeleted is synced all coupled faces should
146  // decide the same.
147  void setRefinement(const boolList&, polyTopoChange&);
148 
149  //- Force recalculation of locally stored data on topological change
150  void updateMesh(const mapPolyMesh&);
151 
152  //- Given set of faces to restore calculates a consistent set of
153  // saved faces (indices into savedFaces_) and saved vertices
154  // (indices into savedPoints_) to restore. The undoFaces have to
155  // be synced.
156  void getUnrefimentSet
157  (
158  const labelList& undoFaces,
159  labelList& localFaces,
160  labelList& localPoints
161  ) const;
162 
163  //- Restore selected faces and vertices.
164  void setUnrefinement
165  (
166  const labelList& localFaces,
167  const labelList& localPoints,
169  );
170 };
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
boolList.H
typeInfo.H
Foam::removePoints
Removes selected points from mesh and updates faces using these points.
Definition: removePoints.H:60
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:99
Foam::removePoints::getUnrefimentSet
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
Definition: removePoints.C:553
Foam::removePoints::ClassName
ClassName("removePoints")
Runtime type information.
faceList.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::Field< vector >
Foam::removePoints::savedFaceLabels
const labelList & savedFaceLabels() const
Definition: removePoints.H:115
Foam::removePoints::setUnrefinement
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
Definition: removePoints.C:765
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
pointField.H
Foam::List< label >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::removePoints::updateMesh
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: removePoints.C:451
Foam::removePoints::setRefinement
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
Definition: removePoints.C:296
Foam::removePoints::countPointUsage
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
Definition: removePoints.C:148