1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Foam::multiDirRefinement
28 Does multiple pass refinement to refine cells in multiple directions.
30 Gets a list of cells to refine and vectorFields for the whole mesh.
31 It then tries to refine in one direction after the other the wanted cells.
32 After construction the mesh will have been refined in multiple directions.
34 Holds the list of cells to refine and the map from original to added for
35 every refinement level.
37 Gets constructed from a dictionary or from components.
38 Uses an undoableMeshCutter which does the actual cutting. Undo facility
39 is switched of unless constructed from external one which allows this.
41 The cut cells get stored in addedCells which is for every vectorField
42 to cut with the map from uncut to added cell (i.e. from master to slave).
43 Note: map is only valid for a given direction.
45 Parallel: should be ok. Uses 'reduce' whenever it needs to make a
51 \*---------------------------------------------------------------------------*/
53 #ifndef multiDirRefinement_H
54 #define multiDirRefinement_H
56 #include "refinementIterator.H"
57 #include "vectorField.H"
59 #include "className.H"
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 // Forward declaration of classes
67 class undoableMeshCutter;
71 /*---------------------------------------------------------------------------*\
72 Class multiDirRefinement Declaration
73 \*---------------------------------------------------------------------------*/
75 class multiDirRefinement
79 //- Current set of cells to refine. Extended with added cells.
80 labelList cellLabels_;
82 //- from original to added cells.
83 // Gives for every cell in the original mesh an empty list or the
84 // list of cells this one has been split into (note: will include
85 // itself so e.g. for hex will be 8 if 2x2x2 refinement)
86 labelListList addedCells_;
89 // Private Static Functions
91 //- Given map from original to added cell set the refineCell for
92 // the added cells to be equal to the one on the original cells.
93 static void addCells(const Map<label>&, List<refineCell>&);
95 //- Given map from original to added cell set the vectorField for
96 // the added cells to be equal to the one on the original cells.
97 static void update(const Map<label>&, vectorField&);
99 //- Given map from original to added cell add the added cell to the
101 static void addCells(const Map<label>&, labelList& labels);
104 // Private Member Functions
106 //- Add new cells from map to overall list (addedCells_).
107 void addCells(const primitiveMesh&, const Map<label>&);
109 //- Remove hexes from cellLabels_ and return these in a list.
110 labelList splitOffHex(const primitiveMesh& mesh);
113 //- Refine cells (hex only) in all 3 directions.
117 const labelList& hexCells,
121 //- Refine cells in cellLabels_ in directions mentioned.
125 List<vectorField>& cellDirections,
126 const cellLooper& cellWalker,
127 undoableMeshCutter& cutter,
131 //- Refine based on dictionary. Calls refineAllDirs.
135 List<vectorField>& cellDirections,
136 const dictionary& dict,
141 //- Disallow default bitwise copy construct
142 multiDirRefinement(const multiDirRefinement&);
144 //- Disallow default bitwise assignment
145 void operator=(const multiDirRefinement&);
150 //- Runtime type information
151 ClassName("multiDirRefinement");
156 //- Construct from dictionary. After construction all refinement will
157 // have been done (and runTime will have increased a few time steps if
162 const labelList& cellLabels, // cells to refine
163 const dictionary& dict
166 //- Explicitly provided directions to split in.
170 const labelList& cellLabels, // cells to refine
171 const List<vectorField>&, // Explicitly provided directions
172 const dictionary& dict
175 //- Construct from components. Only this one would allow undo actions.
179 undoableMeshCutter& cutter, // actual mesh modifier
180 const cellLooper& cellCutter, // how to cut a single cell with
182 const labelList& cellLabels, // list of cells to refine
183 const List<vectorField>& directions,
184 const bool writeMesh = false // write intermediate meshes
190 //- Access to addedCells (on the original mesh; see above)
191 const labelListList& addedCells() const
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 } // End namespace Foam
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 // ************************************************************************* //