00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::undoableMeshCutter 00026 00027 Description 00028 The main refinement handler. Gets cellCuts which is structure that 00029 describes which cells are to be cut and in what way. Maintains an undo 00030 list (if told so during construction). Apart from undo list is just 00031 wrapper around meshCutter. 00032 00033 Undo list: contains a refinement tree (of type splitCell; cell labels are 00034 of no consequence) and a list of visible splitCells, i.e. the top of the 00035 tree (where the cell labels are valid). Now every cell added gets put on 00036 the tree and every updateMesh action updates the labels of visible 00037 splitcells. 00038 00039 We can now ask this structure for a list of visible split cells or the list 00040 of faces between these. These can be passed to removeFaces for actual 00041 deletion and we delete the top splitCell and update the now newly visible 00042 underlying cells for the new cell number (passed back from removeFaces). 00043 00044 NOTE: Undoing note properly tested. Expect it to fail if the faces to 00045 be removed cause other faces to be additionally removed (i.e. removeFaces 00046 adds additional faces to remove). 00047 00048 splitCell: 00049 - original cell number. 00050 - pointer to parent (null for first level splitCell) 00051 - two pointers to splitCell children. Both null (unrefined=visible cell) or 00052 both non-null. 00053 00054 - live are: 00055 (-all unrefined cells (original cell without any splitCells)) 00056 -all splitCells with null children 00057 00058 - liveSplitCells contains pointers to splitCells with null children. 00059 00060 00061 00062 SourceFiles 00063 undoableMeshCutter.C 00064 00065 \*---------------------------------------------------------------------------*/ 00066 00067 #ifndef undoableMeshCutter_H 00068 #define undoableMeshCutter_H 00069 00070 #include <dynamicMesh/edgeVertex.H> 00071 #include <dynamicMesh/refineCell.H> 00072 #include <OpenFOAM/boolList.H> 00073 #include <dynamicMesh/cellLooper.H> 00074 #include <dynamicMesh/meshCutter.H> 00075 #include <OpenFOAM/Map.H> 00076 #include <OpenFOAM/typeInfo.H> 00077 #include <dynamicMesh/removeFaces.H> 00078 00079 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00080 00081 namespace Foam 00082 { 00083 00084 // Forward declaration of classes 00085 class polyMesh; 00086 class polyTopoChange; 00087 class refineCell; 00088 class splitCell; 00089 00090 /*---------------------------------------------------------------------------*\ 00091 Class undoableMeshCutter Declaration 00092 \*---------------------------------------------------------------------------*/ 00093 00094 class undoableMeshCutter 00095 : 00096 public meshCutter 00097 { 00098 // Private data 00099 00100 //- Whether or not to store actions for unplaying. 00101 const bool undoable_; 00102 00103 //- Current split cells which are 'visible'. Only set if undoable. 00104 Map<splitCell*> liveSplitCells_; 00105 00106 //- Face remover engine 00107 removeFaces faceRemover_; 00108 00109 00110 // Private Member Functions 00111 00112 //- Debug print 00113 void printCellRefTree(Ostream& os, const word&, const splitCell*) 00114 const; 00115 00116 //- Debug print 00117 void printRefTree(Ostream& os) const; 00118 00119 //- Find shared face between two cells 00120 label sharedFace 00121 ( 00122 const label cell0I, 00123 const label cell1I 00124 ) const; 00125 00126 00127 //- Update labels on splitCell structure after morphing. 00128 static void updateLabels(const labelList& map, Map<splitCell*>&); 00129 00130 00131 //- Disallow default bitwise copy construct 00132 undoableMeshCutter(const undoableMeshCutter&); 00133 00134 //- Disallow default bitwise assignment 00135 void operator=(const undoableMeshCutter&); 00136 00137 00138 public: 00139 00140 //- Runtime type information 00141 ClassName("undoableMeshCutter"); 00142 00143 00144 00145 // Constructors 00146 00147 //- Construct from mesh and flag whether refinement pattern needs 00148 // to be stored. 00149 undoableMeshCutter(const polyMesh& mesh, const bool undoable = true); 00150 00151 00152 // Destructor 00153 00154 ~undoableMeshCutter(); 00155 00156 00157 // Member Functions 00158 00159 // Access 00160 00161 //- All current live split cells. Warning: cell labels will change 00162 // during morphing. Only this map is guaranteed to hold uptodate 00163 // info. 00164 const Map<splitCell*>& liveSplitCells() const 00165 { 00166 return liveSplitCells_; 00167 } 00168 00169 const removeFaces& faceRemover() const 00170 { 00171 return faceRemover_; 00172 } 00173 00174 00175 // Edit 00176 00177 //- Refine cells acc. to cellCuts. Plays topology changes 00178 // into polyTopoChange. 00179 void setRefinement(const cellCuts& cuts, polyTopoChange&); 00180 00181 //- Update stored refinement pattern for changes to mesh. Only 00182 // call if undoable set. 00183 void updateMesh(const mapPolyMesh& morphMap); 00184 00185 //- Calculate split faces from current liveCells. Only 00186 // call if undoable set. 00187 labelList getSplitFaces() const; 00188 00189 //- Like getSplitFaces but returns map from original to added cell. 00190 // Only call if undoable set. 00191 Map<label> getAddedCells() const; 00192 00193 //- Remove some refinement. Needs to be supplied subset of 00194 // getSplitFaces() output. Returns list of faces removed 00195 // (can be more or equal but never less than splitFaces - since 00196 // removeFaces might decide to take down unnessecary faces) 00197 // Only call if undoable set. 00198 labelList removeSplitFaces 00199 ( 00200 const labelList& splitFaces, 00201 polyTopoChange& 00202 ); 00203 }; 00204 00205 00206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00207 00208 } // End namespace Foam 00209 00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00211 00212 #endif 00213 00214 // ************************ vim: set sw=4 sts=4 et: ************************ //