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-2022 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 polyTopoChangeMap;
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 public:
94 
95  //- Runtime type information
96  ClassName("removePoints");
97 
98 
99  // Constructors
100 
101  //- Construct from mesh
102  removePoints(const polyMesh& mesh, const bool undoable = false);
103 
104  //- Disallow default bitwise copy construction
105  removePoints(const removePoints&) = delete;
106 
107 
108  // Member Functions
109 
110  //- If undoable: affected face labels. Already restored faces
111  // will be -1.
112  const labelList& savedFaceLabels() const
113  {
114  return savedFaceLabels_;
115  }
116 
117 
118  // Helper functions
119 
120  //- Mark in pointCanBeDeleted the points that can be deleted
121  // (parallel synchronised) and returns the global number of these
122  // points. (this number is the global number before synchronisation
123  // so might be off!)
124  // A point can be deleted if
125  // - it is not used by any edge.
126  // or
127  // - is used by only two edges
128  // - these two edges are sufficiently in line (cos > minCos)
129  // - all processors agree that point can be deleted.
131  (
132  const scalar minCos,
133  boolList& pointCanBeDeleted
134  ) const;
135 
136  // Topology changes
137 
138  //- Play commands into polyTopoChange to remove points. Gets
139  // boolList (output of countPointUsage) as input.
140  // Does no check for whether resulting face is legal.
141  // Since pointCanBeDeleted is synced all coupled faces should
142  // decide the same.
143  void setRefinement(const boolList&, polyTopoChange&);
144 
145  //- Force recalculation of locally stored data on topological change
146  void topoChange(const polyTopoChangeMap&);
147 
148  //- Given set of faces to restore calculates a consistent set of
149  // saved faces (indices into savedFaces_) and saved vertices
150  // (indices into savedPoints_) to restore. The undoFaces have to
151  // be synced.
152  void getUnrefimentSet
153  (
154  const labelList& undoFaces,
155  labelList& localFaces,
156  labelList& localPoints
157  ) const;
158 
159  //- Restore selected faces and vertices.
160  void setUnrefinement
161  (
162  const labelList& localFaces,
163  const labelList& localPoints,
165  );
166 
167 
168  // Member Operators
169 
170  //- Disallow default bitwise assignment
171  void operator=(const removePoints&) = delete;
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
Definition: removePoints.C:770
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
removePoints(const polyMesh &mesh, const bool undoable=false)
Construct from mesh.
Definition: removePoints.C:132
void operator=(const removePoints &)=delete
Disallow default bitwise assignment.
const labelList & savedFaceLabels() const
If undoable: affected face labels. Already restored faces.
Definition: removePoints.H:111
fvMesh & mesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
Definition: removePoints.C:456
Direct mesh changes based on v1.3 polyTopoChange syntax.
ClassName("removePoints")
Runtime type information.
Removes selected points from mesh and updates faces using these points.
Definition: removePoints.H:58
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
Namespace for OpenFOAM.