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