undoableMeshCutter.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 public:
132 
133  //- Runtime type information
134  ClassName("undoableMeshCutter");
135 
136 
137 
138  // Constructors
139 
140  //- Construct from mesh and flag whether refinement pattern needs
141  // to be stored.
142  undoableMeshCutter(const polyMesh& mesh, const bool undoable = true);
143 
144  //- Disallow default bitwise copy construction
145  undoableMeshCutter(const undoableMeshCutter&) = delete;
146 
147 
148  //- Destructor
150 
151 
152  // Member Functions
153 
154  // Access
155 
156  //- All current live split cells. Warning: cell labels will change
157  // during morphing. Only this map is guaranteed to hold uptodate
158  // info.
159  const Map<splitCell*>& liveSplitCells() const
160  {
161  return liveSplitCells_;
162  }
164  const removeFaces& faceRemover() const
165  {
166  return faceRemover_;
167  }
168 
169 
170  // Edit
171 
172  //- Refine cells acc. to cellCuts. Plays topology changes
173  // into polyTopoChange.
174  void setRefinement(const cellCuts& cuts, polyTopoChange&);
175 
176  //- Update stored refinement pattern for changes to mesh. Only
177  // call if undoable set.
178  void updateMesh(const mapPolyMesh& morphMap);
179 
180  //- Calculate split faces from current liveCells. Only
181  // call if undoable set.
182  labelList getSplitFaces() const;
183 
184  //- Like getSplitFaces but returns map from original to added cell.
185  // Only call if undoable set.
186  Map<label> getAddedCells() const;
187 
188  //- Remove some refinement. Needs to be supplied subset of
189  // getSplitFaces() output. Returns list of faces removed
190  // (can be more or equal but never less than splitFaces - since
191  // removeFaces might decide to take down unnecessary faces)
192  // Only call if undoable set.
194  (
195  const labelList& splitFaces,
197  );
198 
199 
200  // Member Operators
201 
202  //- Disallow default bitwise assignment
203  void operator=(const undoableMeshCutter&) = delete;
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #endif
214 
215 // ************************************************************************* //
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:62
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
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
const removeFaces & faceRemover() const
ClassName("undoableMeshCutter")
Runtime type information.
Description of cuts across cells.
Definition: cellCuts.H:108
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
undoableMeshCutter(const polyMesh &mesh, const bool undoable=true)
Construct from mesh and flag whether refinement pattern needs.
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in...
Definition: splitCell.H:51
A class for handling words, derived from string.
Definition: word.H:59
Cuts (splits) cells.
Definition: meshCutter.H:134
void setRefinement(const cellCuts &cuts, polyTopoChange &)
Refine cells acc. to cellCuts. Plays topology changes.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
const polyMesh & mesh() const
Definition: edgeVertex.H:93
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void operator=(const undoableMeshCutter &)=delete
Disallow default bitwise assignment.
labelList removeSplitFaces(const labelList &splitFaces, polyTopoChange &)
Remove some refinement. Needs to be supplied subset of.
Direct mesh changes based on v1.3 polyTopoChange syntax.
void updateMesh(const mapPolyMesh &morphMap)
Update stored refinement pattern for changes to mesh. Only.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
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.
Namespace for OpenFOAM.
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49