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 | Copyright (C) 2011-2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::undoableMeshCutter
26 
27 Description
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.
32 
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
37  splitcells.
38 
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).
43 
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).
47 
48  splitCell:
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
52  both non-null.
53 
54  - live are:
55  (-all unrefined cells (original cell without any splitCells))
56  -all splitCells with null children
57 
58  - liveSplitCells contains pointers to splitCells with null children.
59 
60 
61 
62 SourceFiles
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 
81 namespace Foam
82 {
83 
84 // Forward declaration of classes
85 class polyMesh;
86 class polyTopoChange;
87 class refineCell;
88 class splitCell;
89 
90 /*---------------------------------------------------------------------------*\
91  Class undoableMeshCutter Declaration
92 \*---------------------------------------------------------------------------*/
93 
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  //- Disallow default bitwise copy construct
133 
134  //- Disallow default bitwise assignment
135  void operator=(const undoableMeshCutter&);
136 
137 
138 public:
139 
140  //- Runtime type information
141  ClassName("undoableMeshCutter");
142 
143 
144 
145  // Constructors
146 
147  //- Construct from mesh and flag whether refinement pattern needs
148  // to be stored.
149  undoableMeshCutter(const polyMesh& mesh, const bool undoable = true);
150 
151 
152  //- Destructor
154 
155 
156  // Member Functions
157 
158  // Access
159 
160  //- All current live split cells. Warning: cell labels will change
161  // during morphing. Only this map is guaranteed to hold uptodate
162  // info.
163  const Map<splitCell*>& liveSplitCells() const
164  {
165  return liveSplitCells_;
166  }
168  const removeFaces& faceRemover() const
169  {
170  return faceRemover_;
171  }
172 
173 
174  // Edit
175 
176  //- Refine cells acc. to cellCuts. Plays topology changes
177  // into polyTopoChange.
178  void setRefinement(const cellCuts& cuts, polyTopoChange&);
179 
180  //- Update stored refinement pattern for changes to mesh. Only
181  // call if undoable set.
182  void updateMesh(const mapPolyMesh& morphMap);
183 
184  //- Calculate split faces from current liveCells. Only
185  // call if undoable set.
186  labelList getSplitFaces() const;
187 
188  //- Like getSplitFaces but returns map from original to added cell.
189  // Only call if undoable set.
190  Map<label> getAddedCells() const;
191 
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 unnecessary faces)
196  // Only call if undoable set.
198  (
199  const labelList& splitFaces,
201  );
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #endif
212 
213 // ************************************************************************* //
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in...
Definition: splitCell.H:51
void updateMesh(const mapPolyMesh &morphMap)
Update stored refinement pattern for changes to mesh. Only.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void setRefinement(const cellCuts &cuts, polyTopoChange &)
Refine cells acc. to cellCuts. Plays topology changes.
ClassName("undoableMeshCutter")
Runtime type information.
Namespace for OpenFOAM.
const removeFaces & faceRemover() const
labelList getSplitFaces() const
Calculate split faces from current liveCells. Only.
const Map< splitCell * > & liveSplitCells() const
All current live split cells. Warning: cell labels will change.
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:62
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const polyMesh & mesh() const
Definition: edgeVertex.H:98
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Cuts (splits) cells.
Definition: meshCutter.H:134
Direct mesh changes based on v1.3 polyTopoChange syntax.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
labelList removeSplitFaces(const labelList &splitFaces, polyTopoChange &)
Remove some refinement. Needs to be supplied subset of.
Description of cuts across cells.
Definition: cellCuts.H:108