1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 Description of cut is given as a loop of 'cuts' per cell (see cellCuts).
32 setRefinement() takes this cut description and inserts the nessecary
33 topoActions (add points/faces/cells) into the polyTopoChange.
35 Stores added cells/faces/points.
37 Cut description gives orientation to cut by calculating 'anchorPoints'.
38 The side of the cell that contains the anchorPoints is the master cell.
39 Likewise the cells' edges will have the split added as a duplicate of the
40 master (anchor) point.
41 Think of it as the cell with the anchor points at the bottom. Add a face
42 at the bottom to split the cell and then sweep this face up to be through
43 the middle of the cell (inflation).
47 cell with anchor points at bottom
63 splitface introduced at bottom of cell, introducing a new
64 cell and splitting the side faces into two.
73 +-------+ <- splitFace
74 +-------+ <- original cell
80 splitface shifted up to middle of cell (or wherever cut was)
86 +-------+ <- splitFace
94 Anyway this was the original idea. Inflation was meant to handle
95 conservative properties distribution without interpolation.
96 (just face sweeping through space). But problem was that
97 only if the introduced splitface was exactly the same shape as bottom face
98 (so same 2D topo or perfectly flat) the volume between them was 0.
100 This meshCutting still uses anchorPoints though:
101 - the master cell is the one without the anchor points. The added cell
102 (on top of the splitFace) is the with.
103 - the splitFace is owned by the master cell (since it has the lower number)
104 - the side faces get split and get either the original cell as neighbour
105 or the added cell (if the faces contain the cell anchor points)
110 \*---------------------------------------------------------------------------*/
115 #include "edgeVertex.H"
116 #include "labelList.H"
117 #include "typeInfo.H"
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 // Forward declaration of classes
127 class polyTopoChange;
132 /*---------------------------------------------------------------------------*\
133 Class meshCutter Declaration
134 \*---------------------------------------------------------------------------*/
142 //- Cells added in last setRefinement. Per splitcell label of added
144 Map<label> addedCells_;
146 //- Faces added in last setRefinement. Per split cell label of added
148 Map<label> addedFaces_;
150 //- Points added in last setRefinement. Per split edge label of added
152 HashTable<label, edge, Hash<edge> > addedPoints_;
155 // Private Static Functions
157 //- Do list 1 and 2 share elements?
158 static bool uses(const labelList& elems1, const labelList& elems2);
160 //- Do the elements of edge appear in consecutive order in the list
161 static bool isIn(const edge&, const labelList&);
164 // Private Member Functions
166 //- Returns -1 or the cell in cellLabels that is cut.
167 label findCutCell(const cellCuts&, const labelList&) const;
169 //- Returns first pointI in pointLabels that uses an internal
170 // face. Used to find point to inflate cell/face from (has to be
171 // connected to internal face)
172 label findInternalFacePoint(const labelList& pointLabels) const;
174 //- Get new owner and neighbour of face. Checks anchor points to see if
175 // need to get original or added cell.
178 const cellCuts& cuts,
184 //- Get patch information for face.
193 //- Adds a face on top of existing faceI. Flips face
194 // if owner>neighbour
197 polyTopoChange& meshMod,
201 const label neighbour
204 //- Modifies existing faceI for either new owner/neighbour or
205 // new face points. Checks if anything changed and flips face
206 // if owner>neighbour
209 polyTopoChange& meshMod,
213 const label neighbour
217 // Copies face starting from startFp. Jumps cuts. Marks visited
218 // vertices in visited.
227 //- Split face along cut into two faces. Faces are in same point
228 // order as original face (i.e. maintain normal direction)
239 //- Add cuts of edges to face
240 face addEdgeCutsToFace(const label faceI) const;
242 //- Convert loop of cuts into face.
246 const labelList& loop
250 //- Get elements of cell.
251 void getFacesEdgesPoints
261 //- Disallow default bitwise copy construct
262 meshCutter(const meshCutter&);
264 //- Disallow default bitwise assignment
265 void operator=(const meshCutter&);
269 //- Runtime type information
270 ClassName("meshCutter");
274 //- Construct from mesh
275 meshCutter(const polyMesh& mesh);
287 //- Do actual cutting with cut description. Inserts mesh changes
289 void setRefinement(const cellCuts& cuts, polyTopoChange& meshMod);
291 //- Force recalculation of locally stored data on topological change
292 void updateMesh(const mapPolyMesh&);
296 //- Cells added. Per split cell label of added cell
297 const Map<label>& addedCells() const
302 //- Faces added. Per split cell label of added face
303 const Map<label>& addedFaces() const
308 //- Points added. Per split edge label of added point
309 const HashTable<label, edge, Hash<edge> >& addedPoints() const
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 } // End namespace Foam
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 // ************************************************************************* //