multiDirRefinement.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::multiDirRefinement
26 
27 Description
28  Does multiple pass refinement to refine cells in multiple directions.
29 
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.
33 
34  Holds the list of cells to refine and the map from original to added for
35  every refinement level.
36 
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.
40 
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.
44 
45  Parallel: should be ok. Uses 'reduce' whenever it needs to make a
46  local decision.
47 
48 SourceFiles
49  multiDirRefinement.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef multiDirRefinement_H
54 #define multiDirRefinement_H
55 
56 #include "refinementIterator.H"
57 #include "vectorField.H"
58 #include "Map.H"
59 #include "className.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 // Forward declaration of classes
67 class undoableMeshCutter;
68 class cellLooper;
69 class topoSet;
70 
71 /*---------------------------------------------------------------------------*\
72  Class multiDirRefinement Declaration
73 \*---------------------------------------------------------------------------*/
74 
76 {
77  // Private data
78 
79  //- Current set of cells to refine. Extended with added cells.
80  labelList cellLabels_;
81 
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_;
87 
88 
89  // Private Static Functions
90 
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>&);
94 
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&);
98 
99  //- Given map from original to added cell add the added cell to the
100  // list of labels
101  static void addCells(const Map<label>&, labelList& labels);
102 
103 
104  // Private Member Functions
105 
106  //- Add new cells from map to overall list (addedCells_).
107  void addCells(const primitiveMesh&, const Map<label>&);
108 
109  //- Remove hexes from cellLabels_ and return these in a list.
110  labelList splitOffHex(const primitiveMesh& mesh);
111 
112 
113  //- Refine cells (hex only) in all 3 directions.
114  void refineHex8
115  (
116  polyMesh& mesh,
117  const labelList& hexCells,
118  const bool writeMesh
119  );
120 
121  //- Refine cells in cellLabels_ in directions mentioned.
122  void refineAllDirs
123  (
124  polyMesh& mesh,
125  List<vectorField>& cellDirections,
126  const cellLooper& cellWalker,
127  undoableMeshCutter& cutter,
128  const bool writeMesh
129  );
130 
131  //- Refine based on dictionary. Calls refineAllDirs.
132  void refineFromDict
133  (
134  polyMesh& mesh,
135  List<vectorField>& cellDirections,
136  const dictionary& dict,
137  const bool writeMesh
138  );
139 
140 
141  //- Disallow default bitwise copy construct
143 
144  //- Disallow default bitwise assignment
145  void operator=(const multiDirRefinement&);
146 
147 
148 public:
149 
150  //- Runtime type information
151  ClassName("multiDirRefinement");
152 
153 
154  // Constructors
155 
156  //- Construct from dictionary. After construction all refinement will
157  // have been done (and runTime will have increased a few time steps if
158  // writeMesh = true)
160  (
161  polyMesh& mesh,
162  const labelList& cellLabels, // cells to refine
163  const dictionary& dict
164  );
165 
166  //- Explicitly provided directions to split in.
168  (
169  polyMesh& mesh,
170  const labelList& cellLabels, // cells to refine
171  const List<vectorField>&, // Explicitly provided directions
172  const dictionary& dict
173  );
174 
175  //- Construct from components. Only this one would allow undo actions.
177  (
178  polyMesh& mesh,
179  undoableMeshCutter& cutter, // actual mesh modifier
180  const cellLooper& cellCutter, // how to cut a single cell with
181  // a plane
182  const labelList& cellLabels, // list of cells to refine
184  const bool writeMesh = false // write intermediate meshes
185  );
186 
187 
188  // Member Functions
189 
190  //- Access to addedCells (on the original mesh; see above)
191  const labelListList& addedCells() const
192  {
193  return addedCells_;
194  }
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #endif
205 
206 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
Does multiple pass refinement to refine cells in multiple directions.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Definition: directions.H:64
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Definition: cellLooper.H:69
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
const labelListList & addedCells() const
Access to addedCells (on the original mesh; see above)
dynamicFvMesh & mesh
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
ClassName("multiDirRefinement")
Runtime type information.