OpenFOAM logo
Open Source CFD Toolkit

undoableMeshCutter.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     undoableMeshCutter
00027 
00028 Description
00029     Is main refinement handler. Gets cellCuts which is structure that describes
00030     which cells are to be cut and in what way. Maintains an undo list
00031     (if told so during construction). Apart from undo list is just wrapper
00032     around meshCutter.
00033 
00034     Undo list: contains a refinement tree (of type splitCell; cell labels are
00035     of no consequence) and a list of visible splitCells, i.e. the top of the
00036     tree (where the cell labels are valid). Now every cell added gets put on
00037     the tree and every updateMesh action updates the labels of visible
00038     splitcells.
00039 
00040     We can now ask this structure for a list of visible split cells or the list
00041     of faces between these. These can be passed to removeFaces for actual
00042     deletion and we delete the top splitCell and update the now newly visible
00043     underlying cells for the new cell number (passed back from removeFaces).
00044 
00045     NOTE: Undoing note properly tested. Expect it to fail if the faces to
00046     be removed cause other faces to be additionally removed (i.e. removeFaces
00047     adds additional faces to remove).
00048 
00049     splitCell:
00050     - original cell number.
00051     - pointer to parent (null for first level splitCell)
00052     - two pointers to splitCell children. Both null (unrefined=visible cell) or
00053       both non-null.
00054 
00055     - live are:
00056         (-all unrefined cells (original cell without any splitCells))
00057         -all splitCells with null children
00058 
00059     - liveSplitCells contains pointers to splitCells with null children.
00060 
00061 
00062 SourceFiles
00063     undoableMeshCutter.C
00064 
00065 \*---------------------------------------------------------------------------*/
00066 
00067 #ifndef undoableMeshCutter_H
00068 #define undoableMeshCutter_H
00069 
00070 #include "edgeVertex.H"
00071 #include "refineCell.H"
00072 #include "boolList.H"
00073 #include "cellLooper.H"
00074 #include "meshCutter.H"
00075 #include "Map.H"
00076 #include "typeInfo.H"
00077 #include "removeFaces.H"
00078 
00079 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00080 
00081 namespace Foam
00082 {
00083 
00084 // Class forward declarations
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 // ************************************************************************* //
For further information go to www.openfoam.org