initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / meshCut / meshModifiers / multiDirRefinement / multiDirRefinement.H
blobf4bf854bbae7812a7a56df247049f01a5806ae26
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::multiDirRefinement
28 Description
29     Does multiple pass refinement to refine cells in multiple directions.
31     Gets a list of cells to refine and vectorFields for the whole mesh.
32     It then tries to refine in one direction after the other the wanted cells.
33     After construction the mesh will have been refined in multiple directions.
35     Holds the list of cells to refine and the map from original to added for
36     every refinement level.
38     Gets constructed from a dictionary or from components.
39     Uses an undoableMeshCutter which does the actual cutting. Undo facility
40     is switched of unless constructed from external one which allows this.
42     The cut cells get stored in addedCells which is for every vectorField
43     to cut with the map from uncut to added cell (i.e. from master to slave).
44     Note: map is only valid for a given direction.
46     Parallel: should be ok. Uses 'reduce' whenever it needs to make a
47     local decision.
49 SourceFiles
50     multiDirRefinement.C
52 \*---------------------------------------------------------------------------*/
54 #ifndef multiDirRefinement_H
55 #define multiDirRefinement_H
57 #include "refinementIterator.H"
58 #include "vectorField.H"
59 #include "Map.H"
60 #include "className.H"
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 namespace Foam
67 // Forward declaration of classes
68 class undoableMeshCutter;
69 class cellLooper;
70 class topoSet;
72 /*---------------------------------------------------------------------------*\
73                            Class multiDirRefinement Declaration
74 \*---------------------------------------------------------------------------*/
76 class multiDirRefinement
78     // Private data
80         //- Current set of cells to refine. Extended with added cells.
81         labelList cellLabels_;
83         //- from original to added cells.
84         //  Gives for every cell in the original mesh an empty list or the
85         //  list of cells this one has been split into (note: will include
86         //  itself so e.g. for hex will be 8 if 2x2x2 refinement)
87         labelListList addedCells_;
90     // Private Static Functions
92         //- Given map from original to added cell set the refineCell for
93         //  the added cells to be equal to the one on the original cells.
94         static void addCells(const Map<label>&, List<refineCell>&);
95         
96         //- Given map from original to added cell set the vectorField for
97         //  the added cells to be equal to the one on the original cells.
98         static void update(const Map<label>&, vectorField&);
100         //- Given map from original to added cell add the added cell to the
101         //  list of labels
102         static void addCells(const Map<label>&, labelList& labels);
105     // Private Member Functions
107         //- Add new cells from map to overall list (addedCells_).
108         void addCells(const primitiveMesh&, const Map<label>&);
110         //- Remove hexes from cellLabels_ and return these in a list.
111         labelList splitOffHex(const primitiveMesh& mesh);
114         //- Refine cells (hex only) in all 3 directions.
115         void refineHex8
116         (
117             polyMesh& mesh,
118             const labelList& hexCells,
119             const bool writeMesh
120         );
122         //- Refine cells in cellLabels_ in directions mentioned.
123         void refineAllDirs
124         (
125             polyMesh& mesh,
126             List<vectorField>& cellDirections,
127             const cellLooper& cellWalker,
128             undoableMeshCutter& cutter,
129             const bool writeMesh
130         );
132         //- Refine based on dictionary. Calls refineAllDirs.
133         void refineFromDict
134         (
135             polyMesh& mesh,
136             List<vectorField>& cellDirections,
137             const dictionary& dict,
138             const bool writeMesh
139         );
142         //- Disallow default bitwise copy construct
143         multiDirRefinement(const multiDirRefinement&);
145         //- Disallow default bitwise assignment
146         void operator=(const multiDirRefinement&);
149 public:
151     //- Runtime type information
152     ClassName("multiDirRefinement");
155     // Constructors
157         //- Construct from dictionary. After construction all refinement will
158         //  have been done (and runTime will have increased a few time steps if
159         //  writeMesh = true)
160         multiDirRefinement
161         (
162             polyMesh& mesh,
163             const labelList& cellLabels,    // cells to refine
164             const dictionary& dict
165         );
167         //- Explicitly provided directions to split in.
168         multiDirRefinement
169         (
170             polyMesh& mesh,
171             const labelList& cellLabels,    // cells to refine
172             const List<vectorField>&,       // Explicitly provided directions
173             const dictionary& dict
174         );
176         //- Construct from components. Only this one would allow undo actions.
177         multiDirRefinement
178         (
179             polyMesh& mesh,
180             undoableMeshCutter& cutter,     // actual mesh modifier
181             const cellLooper& cellCutter,   // how to cut a single cell with
182                                             // a plane
183             const labelList& cellLabels,    // list of cells to refine
184             const List<vectorField>& directions,
185             const bool writeMesh = false    // write intermediate meshes
186         );
189     // Member Functions
191         //- Access to addedCells (on the original mesh; see above)
192         const labelListList& addedCells() const
193         {
194             return addedCells_;
195         }
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 } // End namespace Foam
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 #endif
207 // ************************************************************************* //