OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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     Foam::undoableMeshCutter
00027 
00028 Description
00029     The main refinement handler. Gets cellCuts which is structure that
00030     describes which cells are to be cut and in what way. Maintains an undo
00031     list (if told so during construction). Apart from undo list is just
00032     wrapper 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 
00063 SourceFiles
00064     undoableMeshCutter.C
00065 
00066 \*---------------------------------------------------------------------------*/
00067 
00068 #ifndef undoableMeshCutter_H
00069 #define undoableMeshCutter_H
00070 
00071 #include "edgeVertex.H"
00072 #include "refineCell.H"
00073 #include "boolList.H"
00074 #include "cellLooper.H"
00075 #include "meshCutter.H"
00076 #include "Map.H"
00077 #include "typeInfo.H"
00078 #include "removeFaces.H"
00079 
00080 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00081 
00082 namespace Foam
00083 {
00084 
00085 // Forward declaration of classes
00086 class polyMesh;
00087 class polyTopoChange;
00088 class refineCell;
00089 class splitCell;
00090 
00091 /*---------------------------------------------------------------------------*\
00092                            Class undoableMeshCutter Declaration
00093 \*---------------------------------------------------------------------------*/
00094 
00095 class undoableMeshCutter
00096 :
00097     public meshCutter
00098 {
00099     // Private data
00100 
00101         //- Whether or not to store actions for unplaying.
00102         const bool undoable_;
00103 
00104         //- Current split cells which are 'visible'. Only set if undoable.
00105         Map<splitCell*> liveSplitCells_;
00106 
00107         //- Face remover engine
00108         removeFaces faceRemover_;
00109 
00110 
00111     // Private Member Functions
00112 
00113         //- Debug print
00114         void printCellRefTree(Ostream& os, const word&, const splitCell*)
00115          const;
00116 
00117         //- Debug print
00118         void printRefTree(Ostream& os) const;
00119 
00120         //- Find shared face between two cells
00121         label sharedFace
00122         (
00123             const label cell0I,
00124             const label cell1I
00125         ) const;
00126 
00127 
00128         //- Update labels on splitCell structure after morphing.
00129         static void updateLabels(const labelList& map, Map<splitCell*>&);
00130 
00131 
00132         //- Disallow default bitwise copy construct
00133         undoableMeshCutter(const undoableMeshCutter&);
00134 
00135         //- Disallow default bitwise assignment
00136         void operator=(const undoableMeshCutter&);
00137 
00138 
00139 public:
00140 
00141     //- Runtime type information
00142     ClassName("undoableMeshCutter");
00143 
00144 
00145 
00146     // Constructors
00147 
00148         //- Construct from mesh and flag whether refinement pattern needs
00149         //  to be stored.
00150         undoableMeshCutter(const polyMesh& mesh, const bool undoable = true);
00151 
00152 
00153     // Destructor
00154 
00155         ~undoableMeshCutter();
00156 
00157 
00158     // Member Functions
00159 
00160         // Access
00161 
00162             //- All current live split cells. Warning: cell labels will change
00163             //  during morphing. Only this map is guaranteed to hold uptodate
00164             //  info.
00165             const Map<splitCell*>& liveSplitCells() const
00166             {
00167                 return liveSplitCells_;
00168             }
00169 
00170             const removeFaces& faceRemover() const
00171             {
00172                 return faceRemover_;
00173             }
00174 
00175 
00176         // Edit
00177 
00178             //- Refine cells acc. to cellCuts. Plays topology changes
00179             //  into polyTopoChange.
00180             void setRefinement(const cellCuts& cuts, polyTopoChange&);
00181 
00182             //- Update stored refinement pattern for changes to mesh. Only
00183             //  call if undoable set.
00184             void updateMesh(const mapPolyMesh& morphMap);
00185 
00186             //- Calculate split faces from current liveCells. Only
00187             //  call if undoable set.
00188             labelList getSplitFaces() const;
00189 
00190             //- Like getSplitFaces but returns map from original to added cell.
00191             //  Only call if undoable set.
00192             Map<label> getAddedCells() const;
00193 
00194             //- Remove some refinement. Needs to be supplied subset of
00195             //  getSplitFaces() output. Returns list of faces removed
00196             //  (can be more or equal but never less than splitFaces - since
00197             //  removeFaces might decide to take down unnessecary faces)
00198             //  Only call if undoable set.
00199             labelList removeSplitFaces
00200             (
00201                 const labelList& splitFaces,
00202                 polyTopoChange&
00203             );
00204 };
00205 
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 } // End namespace Foam
00210 
00211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00212 
00213 #endif
00214 
00215 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd