1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
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
26 Foam::multiDirRefinement
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
52 \*---------------------------------------------------------------------------*/
54 #ifndef multiDirRefinement_H
55 #define multiDirRefinement_H
57 #include "refinementIterator.H"
58 #include "vectorField.H"
60 #include "className.H"
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 // Forward declaration of classes
68 class undoableMeshCutter;
72 /*---------------------------------------------------------------------------*\
73 Class multiDirRefinement Declaration
74 \*---------------------------------------------------------------------------*/
76 class multiDirRefinement
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>&);
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
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.
118 const labelList& hexCells,
122 //- Refine cells in cellLabels_ in directions mentioned.
126 List<vectorField>& cellDirections,
127 const cellLooper& cellWalker,
128 undoableMeshCutter& cutter,
132 //- Refine based on dictionary. Calls refineAllDirs.
136 List<vectorField>& cellDirections,
137 const dictionary& dict,
142 //- Disallow default bitwise copy construct
143 multiDirRefinement(const multiDirRefinement&);
145 //- Disallow default bitwise assignment
146 void operator=(const multiDirRefinement&);
151 //- Runtime type information
152 ClassName("multiDirRefinement");
157 //- Construct from dictionary. After construction all refinement will
158 // have been done (and runTime will have increased a few time steps if
163 const labelList& cellLabels, // cells to refine
164 const dictionary& dict
167 //- Explicitly provided directions to split in.
171 const labelList& cellLabels, // cells to refine
172 const List<vectorField>&, // Explicitly provided directions
173 const dictionary& dict
176 //- Construct from components. Only this one would allow undo actions.
180 undoableMeshCutter& cutter, // actual mesh modifier
181 const cellLooper& cellCutter, // how to cut a single cell with
183 const labelList& cellLabels, // list of cells to refine
184 const List<vectorField>& directions,
185 const bool writeMesh = false // write intermediate meshes
191 //- Access to addedCells (on the original mesh; see above)
192 const labelListList& addedCells() const
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 } // End namespace Foam
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 // ************************************************************************* //