multiDirRefinement.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 public:
142 
143  //- Runtime type information
144  ClassName("multiDirRefinement");
145 
146 
147  // Constructors
148 
149  //- Construct from dictionary. After construction all refinement will
150  // have been done (and runTime will have increased a few time steps if
151  // writeMesh = true)
153  (
154  polyMesh& mesh,
155  const labelList& cellLabels, // cells to refine
156  const dictionary& dict
157  );
158 
159  //- Explicitly provided directions to split in.
161  (
162  polyMesh& mesh,
163  const labelList& cellLabels, // cells to refine
164  const List<vectorField>&, // Explicitly provided directions
165  const dictionary& dict
166  );
167 
168  //- Construct from components. Only this one would allow undo actions.
170  (
171  polyMesh& mesh,
172  undoableMeshCutter& cutter, // actual mesh modifier
173  const cellLooper& cellCutter, // how to cut a single cell with
174  // a plane
175  const labelList& cellLabels, // list of cells to refine
177  const bool writeMesh = false // write intermediate meshes
178  );
179 
180  //- Disallow default bitwise copy construction
181  multiDirRefinement(const multiDirRefinement&) = delete;
182 
183 
184  // Member Functions
185 
186  //- Access to addedCells (on the original mesh; see above)
187  const labelListList& addedCells() const
188  {
189  return addedCells_;
190  }
191 
192 
193  // Member Operators
194 
195  //- Disallow default bitwise assignment
196  void operator=(const multiDirRefinement&) = delete;
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 #endif
207 
208 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
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...
void operator=(const multiDirRefinement &)=delete
Disallow default bitwise assignment.
dynamicFvMesh & mesh
const labelListList & addedCells() const
Access to addedCells (on the original mesh; see above)
multiDirRefinement(polyMesh &mesh, const labelList &cellLabels, const dictionary &dict)
Construct from dictionary. After construction all refinement will.
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.