meshCutAndRemove.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::meshCutAndRemove
26 
27 Description
28  like meshCutter but also removes non-anchor side of cell.
29 
30 SourceFiles
31  meshCutAndRemove.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef meshCutAndRemove_H
36 #define meshCutAndRemove_H
37 
38 #include "edgeVertex.H"
39 #include "boolList.H"
40 #include "labelList.H"
41 #include "typeInfo.H"
42 #include "Map.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class Time;
51 class polyTopoChange;
52 class cellCuts;
53 class polyMesh;
54 class face;
55 class polyTopoChangeMap;
56 
57 /*---------------------------------------------------------------------------*\
58  Class meshCutAndRemove Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class meshCutAndRemove
62 :
63  public edgeVertex
64 {
65  // Private Data
66 
67  //- Faces added in last setRefinement. Per split cell label of added
68  // face
69  Map<label> addedFaces_;
70 
71  //- Points added in last setRefinement. Per split edge label of added
72  // point
74 
75 
76  // Private Static Functions
77 
78  // Returns -1 or index in elems1 of first shared element.
79  static label firstCommon(const labelList& lst1, const labelList& lst2);
80 
81  //- Do the elements of edge appear in consecutive order in the list
82  static bool isIn(const edge&, const labelList&);
83 
84 
85  // Private Member Functions
86 
87  //- Returns -1 or the cell in cellLabels that is cut.
88  label findCutCell(const cellCuts&, const labelList&) const;
89 
90  //- Returns first pointi in pointLabels that uses an internal
91  // face. Used to find point to inflate cell/face from (has to be
92  // connected to internal face)
93  label findInternalFacePoint(const labelList& pointLabels) const;
94 
95  //- Find point on face that is part of original mesh and that is
96  // point connected to the patch
97  label findPatchFacePoint(const face& f, const label patchi) const;
98 
99  //- Get new owner and neighbour of face. Checks anchor points to see if
100  // need to get original or added cell.
101  void faceCells
102  (
103  const cellCuts& cuts,
104  const label exposedPatchi,
105  const label facei,
106  label& own,
107  label& nei,
108  label& patchID
109  ) const;
110 
111  //- Get zone information for face.
112  void getZoneInfo
113  (
114  const label facei,
115  label& zoneID,
116  bool& zoneFlip
117  ) const;
118 
119  //- Adds a face from point. Flips face if owner>neighbour
120  void addFace
121  (
122  polyTopoChange& meshMod,
123  const label facei,
124  const label masterPointi,
125  const face& newFace,
126  const label owner,
127  const label neighbour,
128  const label patchID
129  );
130 
131  //- Modifies existing facei for either new owner/neighbour or
132  // new face points. Checks if anything changed and flips face
133  // if owner>neighbour
134  void modFace
135  (
136  polyTopoChange& meshMod,
137  const label facei,
138  const face& newFace,
139  const label owner,
140  const label neighbour,
141  const label patchID
142  );
143 
144  // Copies face starting from startFp. Jumps cuts. Marks visited
145  // vertices in visited.
146  void copyFace
147  (
148  const face& f,
149  const label startFp,
150  const label endFp,
151  face& newFace
152  ) const;
153 
154  //- Split face along cut into two faces. Faces are in same point
155  // order as original face (i.e. maintain normal direction)
156  void splitFace
157  (
158  const face& f,
159  const label v0,
160  const label v1,
161 
162  face& f0,
163  face& f1
164  ) const;
165 
166  //- Add cuts of edges to face
167  face addEdgeCutsToFace(const label facei) const;
168 
169  //- Convert loop of cuts into face.
170  face loopToFace
171  (
172  const label celli,
173  const labelList& loop
174  ) const;
175 
176 
177 public:
178 
179  //- Runtime type information
180  ClassName("meshCutAndRemove");
181 
182 
183  // Constructors
184 
185  //- Construct from mesh
187 
188  //- Disallow default bitwise copy construction
189  meshCutAndRemove(const meshCutAndRemove&) = delete;
190 
191 
192  // Member Functions
193 
194  // Edit
195 
196  //- Do actual cutting with cut description. Inserts mesh changes
197  // into meshMod.
198  // cuts: all loops and topological information
199  // cutPatch: for every cell that has loop the patch number
200  // exposedPatch: patch for other exposed faces
201  void setRefinement
202  (
203  const label exposedPatchi,
204  const cellCuts& cuts,
205  const labelList& cutPatch,
206  polyTopoChange& meshMod
207  );
208 
209  //- Force recalculation of locally stored data on topological change
210  void topoChange(const polyTopoChangeMap&);
211 
212 
213  // Access
214 
215  //- Faces added. Per split cell label of added face
216  const Map<label>& addedFaces() const
217  {
218  return addedFaces_;
219  }
220 
221  //- Points added. Per split edge label of added point.
222  // (note: fairly useless across topology changes since one of the
223  // points of the edge will probably disappear)
225  {
226  return addedPoints_;
227  }
228 
229 
230  // Member Operators
231 
232  //- Disallow default bitwise assignment
233  void operator=(const meshCutAndRemove&) = delete;
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
const Map< label > & addedFaces() const
Faces added. Per split cell label of added face.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
labelList pointLabels(nPoints, -1)
const HashTable< label, edge, Hash< edge > > & addedPoints() const
Points added. Per split edge label of added point.
Description of cuts across cells.
Definition: cellCuts.H:108
scalar f1
Definition: createFields.H:15
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Definition: edgeVertex.H:52
void setRefinement(const label exposedPatchi, const cellCuts &cuts, const labelList &cutPatch, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
An STL-conforming hash table.
Definition: HashTable.H:61
const polyMesh & mesh() const
Definition: edgeVertex.H:93
ClassName("meshCutAndRemove")
Runtime type information.
labelList f(nPoints)
label patchi
like meshCutter but also removes non-anchor side of cell.
void operator=(const meshCutAndRemove &)=delete
Disallow default bitwise assignment.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
meshCutAndRemove(const polyMesh &mesh)
Construct from mesh.
Namespace for OpenFOAM.