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/>.
25 Foam::undoableMeshCutter
28 The main refinement handler. Gets cellCuts which is structure that
29 describes which cells are to be cut and in what way. Maintains an undo
30 list (if told so during construction). Apart from undo list is just
31 wrapper around meshCutter.
33 Undo list: contains a refinement tree (of type splitCell; cell labels are
34 of no consequence) and a list of visible splitCells, i.e. the top of the
35 tree (where the cell labels are valid). Now every cell added gets put on
36 the tree and every updateMesh action updates the labels of visible
39 We can now ask this structure for a list of visible split cells or the list
40 of faces between these. These can be passed to removeFaces for actual
41 deletion and we delete the top splitCell and update the now newly visible
42 underlying cells for the new cell number (passed back from removeFaces).
44 NOTE: Undoing note properly tested. Expect it to fail if the faces to
45 be removed cause other faces to be additionally removed (i.e. removeFaces
46 adds additional faces to remove).
49 - original cell number.
50 - pointer to parent (null for first level splitCell)
51 - two pointers to splitCell children. Both null (unrefined=visible cell) or
55 (-all unrefined cells (original cell without any splitCells))
56 -all splitCells with null children
58 - liveSplitCells contains pointers to splitCells with null children.
65 \*---------------------------------------------------------------------------*/
67 #ifndef undoableMeshCutter_H
68 #define undoableMeshCutter_H
70 #include "edgeVertex.H"
71 #include "refineCell.H"
73 #include "cellLooper.H"
74 #include "meshCutter.H"
77 #include "removeFaces.H"
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 // Forward declaration of classes
90 /*---------------------------------------------------------------------------*\
91 Class undoableMeshCutter Declaration
92 \*---------------------------------------------------------------------------*/
94 class undoableMeshCutter
100 //- Whether or not to store actions for unplaying.
101 const bool undoable_;
103 //- Current split cells which are 'visible'. Only set if undoable.
104 Map<splitCell*> liveSplitCells_;
106 //- Face remover engine
107 removeFaces faceRemover_;
110 // Private Member Functions
113 void printCellRefTree(Ostream& os, const word&, const splitCell*)
117 void printRefTree(Ostream& os) const;
119 //- Find shared face between two cells
127 //- Update labels on splitCell structure after morphing.
128 static void updateLabels(const labelList& map, Map<splitCell*>&);
131 //- Disallow default bitwise copy construct
132 undoableMeshCutter(const undoableMeshCutter&);
134 //- Disallow default bitwise assignment
135 void operator=(const undoableMeshCutter&);
140 //- Runtime type information
141 ClassName("undoableMeshCutter");
147 //- Construct from mesh and flag whether refinement pattern needs
149 undoableMeshCutter(const polyMesh& mesh, const bool undoable = true);
153 ~undoableMeshCutter();
160 //- All current live split cells. Warning: cell labels will change
161 // during morphing. Only this map is guaranteed to hold uptodate
163 const Map<splitCell*>& liveSplitCells() const
165 return liveSplitCells_;
168 const removeFaces& faceRemover() const
176 //- Refine cells acc. to cellCuts. Plays topology changes
177 // into polyTopoChange.
178 void setRefinement(const cellCuts& cuts, polyTopoChange&);
180 //- Update stored refinement pattern for changes to mesh. Only
181 // call if undoable set.
182 void updateMesh(const mapPolyMesh& morphMap);
184 //- Calculate split faces from current liveCells. Only
185 // call if undoable set.
186 labelList getSplitFaces() const;
188 //- Like getSplitFaces but returns map from original to added cell.
189 // Only call if undoable set.
190 Map<label> getAddedCells() const;
192 //- Remove some refinement. Needs to be supplied subset of
193 // getSplitFaces() output. Returns list of faces removed
194 // (can be more or equal but never less than splitFaces - since
195 // removeFaces might decide to take down unnessecary faces)
196 // Only call if undoable set.
197 labelList removeSplitFaces
199 const labelList& splitFaces,
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 } // End namespace Foam
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 // ************************************************************************* //