undoableMeshCutter.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-2012 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::undoableMeshCutter
28
29Description
30 The main refinement handler. Gets cellCuts which is structure that
31 describes which cells are to be cut and in what way. Maintains an undo
32 list (if told so during construction). Apart from undo list is just
33 wrapper around meshCutter.
34
35 Undo list: contains a refinement tree (of type splitCell; cell labels are
36 of no consequence) and a list of visible splitCells, i.e. the top of the
37 tree (where the cell labels are valid). Now every cell added gets put on
38 the tree and every updateMesh action updates the labels of visible
39 splitcells.
40
41 We can now ask this structure for a list of visible split cells or the list
42 of faces between these. These can be passed to removeFaces for actual
43 deletion and we delete the top splitCell and update the now newly visible
44 underlying cells for the new cell number (passed back from removeFaces).
45
46 NOTE: Undoing note properly tested. Expect it to fail if the faces to
47 be removed cause other faces to be additionally removed (i.e. removeFaces
48 adds additional faces to remove).
49
50 splitCell:
51 - original cell number.
52 - pointer to parent (null for first level splitCell)
53 - two pointers to splitCell children. Both null (unrefined=visible cell) or
54 both non-null.
55
56 - live are:
57 (-all unrefined cells (original cell without any splitCells))
58 -all splitCells with null children
59
60 - liveSplitCells contains pointers to splitCells with null children.
61
62SourceFiles
63 undoableMeshCutter.C
64
65\*---------------------------------------------------------------------------*/
66
67#ifndef undoableMeshCutter_H
68#define undoableMeshCutter_H
69
70#include "edgeVertex.H"
71#include "refineCell.H"
72#include "boolList.H"
73#include "cellLooper.H"
74#include "meshCutter.H"
75#include "Map.H"
76#include "typeInfo.H"
77#include "removeFaces.H"
78
79// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80
81namespace Foam
82{
83
84// Forward Declarations
85class polyMesh;
86class polyTopoChange;
87class refineCell;
88class splitCell;
89
90/*---------------------------------------------------------------------------*\
91 Class undoableMeshCutter Declaration
92\*---------------------------------------------------------------------------*/
95:
96 public meshCutter
97{
98 // Private Data
99
100 //- Whether or not to store actions for unplaying.
101 const bool undoable_;
102
103 //- Current split cells which are 'visible'. Only set if undoable.
104 Map<splitCell*> liveSplitCells_;
105
106 //- Face remover engine
107 removeFaces faceRemover_;
108
109
110 // Private Member Functions
111
112 //- Debug print
113 void printCellRefTree(Ostream& os, const word&, const splitCell*)
114 const;
115
116 //- Debug print
117 void printRefTree(Ostream& os) const;
118
119 //- Find shared face between two cells
120 label sharedFace
121 (
122 const label cell0I,
123 const label cell1I
124 ) const;
125
126
127 //- Update labels on splitCell structure after morphing.
128 static void updateLabels(const labelList& map, Map<splitCell*>&);
129
130
131 //- No copy construct
132 undoableMeshCutter(const undoableMeshCutter&) = delete;
133
134 //- No copy assignment
135 void operator=(const undoableMeshCutter&) = delete;
136
137
138public:
139
140 //- Runtime type information
141 ClassName("undoableMeshCutter");
142
143
144 // Constructors
145
146 //- Construct from mesh and flag whether refinement pattern needs
147 //- to be stored.
148 explicit undoableMeshCutter
149 (
150 const polyMesh& mesh,
151 const bool undoable = true
152 );
153
154
155 //- Destructor
157
158
159 // Member Functions
160
161 // Access
162
163 //- All current live split cells. Warning: cell labels will change
164 // during morphing. Only this map is guaranteed to hold uptodate
165 // info.
166 const Map<splitCell*>& liveSplitCells() const
167 {
168 return liveSplitCells_;
169 }
171 const removeFaces& faceRemover() const
172 {
173 return faceRemover_;
174 }
175
176
177 // Edit
178
179 //- Refine cells acc. to cellCuts. Plays topology changes
180 // into polyTopoChange.
181 void setRefinement(const cellCuts& cuts, polyTopoChange&);
182
183 //- Update stored refinement pattern for changes to mesh. Only
184 // call if undoable set.
185 void updateMesh(const mapPolyMesh& morphMap);
186
187 //- Calculate split faces from current liveCells. Only
188 // call if undoable set.
189 labelList getSplitFaces() const;
190
191 //- Like getSplitFaces but returns map from original to added cell.
192 // Only call if undoable set.
194
195 //- Remove some refinement. Needs to be supplied subset of
196 // getSplitFaces() output. Returns list of faces removed
197 // (can be more or equal but never less than splitFaces - since
198 // removeFaces might decide to take down unnecessary faces)
199 // Only call if undoable set.
201 (
202 const labelList& splitFaces,
204 );
205};
206
207
208// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209
210} // End namespace Foam
211
212// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213
214#endif
215
216// ************************************************************************* //
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Description of cuts across cells.
Definition: cellCuts.H:113
const polyMesh & mesh() const
Definition: edgeVertex.H:101
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Cuts (splits) cells.
Definition: meshCutter.H:141
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Direct mesh changes based on v1.3 polyTopoChange syntax.
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:65
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in....
Definition: splitCell.H:52
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
labelList getSplitFaces() const
Calculate split faces from current liveCells. Only.
const removeFaces & faceRemover() const
ClassName("undoableMeshCutter")
Runtime type information.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
void updateMesh(const mapPolyMesh &morphMap)
Update stored refinement pattern for changes to mesh. Only.
const Map< splitCell * > & liveSplitCells() const
All current live split cells. Warning: cell labels will change.
void setRefinement(const cellCuts &cuts, polyTopoChange &)
Refine cells acc. to cellCuts. Plays topology changes.
labelList removeSplitFaces(const labelList &splitFaces, polyTopoChange &)
Remove some refinement. Needs to be supplied subset of.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.