1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
30 Description of cut is given as a loop of 'cuts' per cell (see cellCuts).
31 setRefinement() takes this cut description and inserts the nessecary
32 topoActions (add points/faces/cells) into the polyTopoChange.
34 Stores added cells/faces/points.
36 Cut description gives orientation to cut by calculating 'anchorPoints'.
37 The side of the cell that contains the anchorPoints is the master cell.
38 Likewise the cells' edges will have the split added as a duplicate of the
39 master (anchor) point.
40 Think of it as the cell with the anchor points at the bottom. Add a face
41 at the bottom to split the cell and then sweep this face up to be through
42 the middle of the cell (inflation).
46 cell with anchor points at bottom
62 splitface introduced at bottom of cell, introducing a new
63 cell and splitting the side faces into two.
72 +-------+ <- splitFace
73 +-------+ <- original cell
79 splitface shifted up to middle of cell (or wherever cut was)
85 +-------+ <- splitFace
93 Anyway this was the original idea. Inflation was meant to handle
94 conservative properties distribution without interpolation.
95 (just face sweeping through space). But problem was that
96 only if the introduced splitface was exactly the same shape as bottom face
97 (so same 2D topo or perfectly flat) the volume between them was 0.
99 This meshCutting still uses anchorPoints though:
100 - the master cell is the one without the anchor points. The added cell
101 (on top of the splitFace) is the with.
102 - the splitFace is owned by the master cell (since it has the lower number)
103 - the side faces get split and get either the original cell as neighbour
104 or the added cell (if the faces contain the cell anchor points)
109 \*---------------------------------------------------------------------------*/
114 #include "edgeVertex.H"
115 #include "labelList.H"
116 #include "typeInfo.H"
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 // Forward declaration of classes
126 class polyTopoChange;
131 /*---------------------------------------------------------------------------*\
132 Class meshCutter Declaration
133 \*---------------------------------------------------------------------------*/
141 //- Cells added in last setRefinement. Per splitcell label of added
143 Map<label> addedCells_;
145 //- Faces added in last setRefinement. Per split cell label of added
147 Map<label> addedFaces_;
149 //- Points added in last setRefinement. Per split edge label of added
151 HashTable<label, edge, Hash<edge> > addedPoints_;
154 // Private Static Functions
156 //- Do list 1 and 2 share elements?
157 static bool uses(const labelList& elems1, const labelList& elems2);
159 //- Do the elements of edge appear in consecutive order in the list
160 static bool isIn(const edge&, const labelList&);
163 // Private Member Functions
165 //- Returns -1 or the cell in cellLabels that is cut.
166 label findCutCell(const cellCuts&, const labelList&) const;
168 //- Returns first pointI in pointLabels that uses an internal
169 // face. Used to find point to inflate cell/face from (has to be
170 // connected to internal face)
171 label findInternalFacePoint(const labelList& pointLabels) const;
173 //- Get new owner and neighbour of face. Checks anchor points to see if
174 // need to get original or added cell.
177 const cellCuts& cuts,
183 //- Get patch information for face.
192 //- Adds a face on top of existing faceI. Flips face
193 // if owner>neighbour
196 polyTopoChange& meshMod,
200 const label neighbour
203 //- Modifies existing faceI for either new owner/neighbour or
204 // new face points. Checks if anything changed and flips face
205 // if owner>neighbour
208 polyTopoChange& meshMod,
212 const label neighbour
216 // Copies face starting from startFp. Jumps cuts. Marks visited
217 // vertices in visited.
226 //- Split face along cut into two faces. Faces are in same point
227 // order as original face (i.e. maintain normal direction)
238 //- Add cuts of edges to face
239 face addEdgeCutsToFace(const label faceI) const;
241 //- Convert loop of cuts into face.
245 const labelList& loop
249 //- Get elements of cell.
250 void getFacesEdgesPoints
260 //- Disallow default bitwise copy construct
261 meshCutter(const meshCutter&);
263 //- Disallow default bitwise assignment
264 void operator=(const meshCutter&);
268 //- Runtime type information
269 ClassName("meshCutter");
273 //- Construct from mesh
274 meshCutter(const polyMesh& mesh);
285 //- Do actual cutting with cut description. Inserts mesh changes
287 void setRefinement(const cellCuts& cuts, polyTopoChange& meshMod);
289 //- Force recalculation of locally stored data on topological change
290 void updateMesh(const mapPolyMesh&);
294 //- Cells added. Per split cell label of added cell
295 const Map<label>& addedCells() const
300 //- Faces added. Per split cell label of added face
301 const Map<label>& addedFaces() const
306 //- Points added. Per split edge label of added point
307 const HashTable<label, edge, Hash<edge> >& addedPoints() const
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 } // End namespace Foam
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
322 // ************************************************************************* //