FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

multiDirRefinement.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-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::multiDirRefinement
00026 
00027 Description
00028     Does multiple pass refinement to refine cells in multiple directions.
00029 
00030     Gets a list of cells to refine and vectorFields for the whole mesh.
00031     It then tries to refine in one direction after the other the wanted cells.
00032     After construction the mesh will have been refined in multiple directions.
00033 
00034     Holds the list of cells to refine and the map from original to added for
00035     every refinement level.
00036 
00037     Gets constructed from a dictionary or from components.
00038     Uses an undoableMeshCutter which does the actual cutting. Undo facility
00039     is switched of unless constructed from external one which allows this.
00040 
00041     The cut cells get stored in addedCells which is for every vectorField
00042     to cut with the map from uncut to added cell (i.e. from master to slave).
00043     Note: map is only valid for a given direction.
00044 
00045     Parallel: should be ok. Uses 'reduce' whenever it needs to make a
00046     local decision.
00047 
00048 SourceFiles
00049     multiDirRefinement.C
00050 
00051 \*---------------------------------------------------------------------------*/
00052 
00053 #ifndef multiDirRefinement_H
00054 #define multiDirRefinement_H
00055 
00056 #include <dynamicMesh/refinementIterator.H>
00057 #include <OpenFOAM/vectorField.H>
00058 #include <OpenFOAM/Map.H>
00059 #include <OpenFOAM/className.H>
00060 
00061 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00062 
00063 namespace Foam
00064 {
00065 
00066 // Forward declaration of classes
00067 class undoableMeshCutter;
00068 class cellLooper;
00069 class topoSet;
00070 
00071 /*---------------------------------------------------------------------------*\
00072                            Class multiDirRefinement Declaration
00073 \*---------------------------------------------------------------------------*/
00074 
00075 class multiDirRefinement
00076 {
00077     // Private data
00078 
00079         //- Current set of cells to refine. Extended with added cells.
00080         labelList cellLabels_;
00081 
00082         //- from original to added cells.
00083         //  Gives for every cell in the original mesh an empty list or the
00084         //  list of cells this one has been split into (note: will include
00085         //  itself so e.g. for hex will be 8 if 2x2x2 refinement)
00086         labelListList addedCells_;
00087 
00088 
00089     // Private Static Functions
00090 
00091         //- Given map from original to added cell set the refineCell for
00092         //  the added cells to be equal to the one on the original cells.
00093         static void addCells(const Map<label>&, List<refineCell>&);
00094         
00095         //- Given map from original to added cell set the vectorField for
00096         //  the added cells to be equal to the one on the original cells.
00097         static void update(const Map<label>&, vectorField&);
00098 
00099         //- Given map from original to added cell add the added cell to the
00100         //  list of labels
00101         static void addCells(const Map<label>&, labelList& labels);
00102 
00103 
00104     // Private Member Functions
00105 
00106         //- Add new cells from map to overall list (addedCells_).
00107         void addCells(const primitiveMesh&, const Map<label>&);
00108 
00109         //- Remove hexes from cellLabels_ and return these in a list.
00110         labelList splitOffHex(const primitiveMesh& mesh);
00111 
00112 
00113         //- Refine cells (hex only) in all 3 directions.
00114         void refineHex8
00115         (
00116             polyMesh& mesh,
00117             const labelList& hexCells,
00118             const bool writeMesh
00119         );
00120 
00121         //- Refine cells in cellLabels_ in directions mentioned.
00122         void refineAllDirs
00123         (
00124             polyMesh& mesh,
00125             List<vectorField>& cellDirections,
00126             const cellLooper& cellWalker,
00127             undoableMeshCutter& cutter,
00128             const bool writeMesh
00129         );
00130 
00131         //- Refine based on dictionary. Calls refineAllDirs.
00132         void refineFromDict
00133         (
00134             polyMesh& mesh,
00135             List<vectorField>& cellDirections,
00136             const dictionary& dict,
00137             const bool writeMesh
00138         );
00139 
00140 
00141         //- Disallow default bitwise copy construct
00142         multiDirRefinement(const multiDirRefinement&);
00143 
00144         //- Disallow default bitwise assignment
00145         void operator=(const multiDirRefinement&);
00146 
00147 
00148 public:
00149 
00150     //- Runtime type information
00151     ClassName("multiDirRefinement");
00152 
00153 
00154     // Constructors
00155 
00156         //- Construct from dictionary. After construction all refinement will
00157         //  have been done (and runTime will have increased a few time steps if
00158         //  writeMesh = true)
00159         multiDirRefinement
00160         (
00161             polyMesh& mesh,
00162             const labelList& cellLabels,    // cells to refine
00163             const dictionary& dict
00164         );
00165 
00166         //- Explicitly provided directions to split in.
00167         multiDirRefinement
00168         (
00169             polyMesh& mesh,
00170             const labelList& cellLabels,    // cells to refine
00171             const List<vectorField>&,       // Explicitly provided directions
00172             const dictionary& dict
00173         );
00174 
00175         //- Construct from components. Only this one would allow undo actions.
00176         multiDirRefinement
00177         (
00178             polyMesh& mesh,
00179             undoableMeshCutter& cutter,     // actual mesh modifier
00180             const cellLooper& cellCutter,   // how to cut a single cell with
00181                                             // a plane
00182             const labelList& cellLabels,    // list of cells to refine
00183             const List<vectorField>& directions,
00184             const bool writeMesh = false    // write intermediate meshes
00185         );
00186 
00187 
00188     // Member Functions
00189 
00190         //- Access to addedCells (on the original mesh; see above)
00191         const labelListList& addedCells() const
00192         {
00193             return addedCells_;
00194         }
00195 };
00196 
00197 
00198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00199 
00200 } // End namespace Foam
00201 
00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00203 
00204 #endif
00205 
00206 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines