initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / meshCut / meshModifiers / meshCutter / meshCutter.H
blob1651c7474b36f47f0ec21a9a2b6a602441490e5d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::meshCutter
28 Description
29     Cuts (splits) cells.
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).
46     -# Start:
47        cell with anchor points at bottom
48     @verbatim
49     +-------+
50     |       +
51     |       +
52     |       +
53     |       +
54     |       +
55     |       +
56     |       +
57     +-------+
58     anchor  anchor
59     @endverbatim
62     -# Topo change:
63        splitface introduced at bottom of cell, introducing a new
64        cell and splitting the side faces into two.
65     @verbatim
66     +-------+
67     |       +
68     |       +
69     |       + <- addedCell
70     |       +
71     |       +
72     |       +
73     +-------+ <- splitFace
74     +-------+ <- original cell
75     anchor  anchor
76     @endverbatim
79     -# Inflation:
80        splitface shifted up to middle of cell (or wherever cut was)
81     @verbatim
82     +-------+
83     |       +
84     |       + <- addedCell
85     |       +
86     +-------+ <- splitFace
87     |       +
88     |       + <- original cell
89     |       +
90     +-------+
91     anchor  anchor
92     @endverbatim
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)
107 SourceFiles
108     meshCutter.C
110 \*---------------------------------------------------------------------------*/
112 #ifndef meshCutter_H
113 #define meshCutter_H
115 #include "edgeVertex.H"
116 #include "labelList.H"
117 #include "typeInfo.H"
118 #include "Map.H"
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 namespace Foam
125 // Forward declaration of classes
126 class Time;
127 class polyTopoChange;
128 class cellCuts;
129 class polyMesh;
130 class face;
132 /*---------------------------------------------------------------------------*\
133                            Class meshCutter Declaration
134 \*---------------------------------------------------------------------------*/
136 class meshCutter
138     public edgeVertex
140     // Private data
142         //- Cells added in last setRefinement. Per splitcell label of added
143         //  cell
144         Map<label> addedCells_;
146         //- Faces added in last setRefinement. Per split cell label of added
147         //  face
148         Map<label> addedFaces_;
150         //- Points added in last setRefinement. Per split edge label of added
151         //  point
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.
176         void faceCells
177         (
178             const cellCuts& cuts,
179             const label faceI,
180             label& own,
181             label& nei
182         ) const;
184         //- Get patch information for face.
185         void getFaceInfo
186         (
187             const label faceI,
188             label& patchID,
189             label& zoneID,
190             label& zoneFlip
191         ) const;
193         //- Adds a face on top of existing faceI. Flips face
194         //  if owner>neighbour
195         void addFace
196         (
197             polyTopoChange& meshMod,
198             const label faceI,
199             const face& newFace,
200             const label owner,
201             const label neighbour
202         );
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
207         void modFace
208         (
209             polyTopoChange& meshMod,
210             const label faceI,
211             const face& newFace,
212             const label owner,
213             const label neighbour
214         );
217         // Copies face starting from startFp. Jumps cuts. Marks visited
218         // vertices in visited.
219         void copyFace
220         (
221             const face& f,
222             const label startFp,
223             const label endFp,
224             face& newFace
225         ) const;
227         //- Split face along cut into two faces. Faces are in same point
228         //  order as original face (i.e. maintain normal direction)
229         void splitFace
230         (
231             const face& f,
232             const label v0,
233             const label v1,
235             face& f0,
236             face& f1
237         ) const;
239         //- Add cuts of edges to face
240         face addEdgeCutsToFace(const label faceI) const;
242         //- Convert loop of cuts into face.
243         face loopToFace
244         (
245             const label cellI,
246             const labelList& loop
247         ) const;
250         //- Get elements of cell.
251         void getFacesEdgesPoints
252         (
253             const label cellI,
254             labelHashSet& faces,
255             labelHashSet& edges,
256             labelHashSet& points
257         ) const;
261         //- Disallow default bitwise copy construct
262         meshCutter(const meshCutter&);
264         //- Disallow default bitwise assignment
265         void operator=(const meshCutter&);
267 public:
269     //- Runtime type information
270     ClassName("meshCutter");
272     // Constructors
274         //- Construct from mesh
275         meshCutter(const polyMesh& mesh);
278     // Destructor
280         ~meshCutter();
283     // Member Functions
285         // Edit
287             //- Do actual cutting with cut description. Inserts mesh changes
288             //  into meshMod.
289             void setRefinement(const cellCuts& cuts, polyTopoChange& meshMod);
291             //- Force recalculation of locally stored data on topological change
292             void updateMesh(const mapPolyMesh&);
294         // Access
296             //- Cells added. Per split cell label of added cell
297             const Map<label>& addedCells() const
298             {
299                 return addedCells_;
300             }
302             //- Faces added. Per split cell label of added face
303             const Map<label>& addedFaces() const
304             {
305                 return addedFaces_;
306             }
308             //- Points added. Per split edge label of added point
309             const HashTable<label, edge, Hash<edge> >& addedPoints() const
310             {
311                 return addedPoints_;
312             }
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 } // End namespace Foam
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
322 #endif
324 // ************************************************************************* //