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-2025 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  // Note refCells is current list of cells to refine
94  // (these should all have been refined)
95  static void addCells(const Map<label>&, List<refineCell>&);
96 
97  //- Given map from original to added cell set the vectorField for
98  // the added cells to be equal to the one on the original cells.
99  static void update(const Map<label>&, vectorField&);
100 
101  //- Given map from original to added cell add the added cell to the
102  // list of labels
103  static void addCells(const Map<label>&, labelList& labels);
104 
105 
106  // Private Member Functions
107 
108  //- Add new cells from map to overall list (addedCells_).
109  void addCells(const primitiveMesh&, const Map<label>&);
110 
111  //- Remove hexes from cellLabels_ and return these in a list.
112  labelList splitOffHex(const primitiveMesh& mesh);
113 
114 
115  //- Refine cells (hex only) in all 3 directions.
116  void refineHex8
117  (
118  polyMesh& mesh,
119  const labelList& hexCells,
120  const bool writeMesh
121  );
122 
123  //- Refine cells in cellLabels_ in directions mentioned.
124  void refineAllDirs
125  (
126  polyMesh& mesh,
127  List<vectorField>& cellDirections,
128  const cellLooper& cellWalker,
129  undoableMeshCutter& cutter,
130  const bool writeMesh
131  );
132 
133  //- Refine based on dictionary. Calls refineAllDirs.
134  void refineFromDict
135  (
136  polyMesh& mesh,
137  List<vectorField>& cellDirections,
138  const dictionary& dict,
139  const bool writeMesh
140  );
141 
142 
143 public:
144 
145  //- Runtime type information
146  ClassName("multiDirRefinement");
147 
148 
149  // Constructors
150 
151  //- Construct from dictionary. After construction all refinement will
152  // have been done (and runTime will have increased a few time steps if
153  // writeMesh = true)
155  (
156  polyMesh& mesh,
157  const labelList& cellLabels, // cells to refine
158  const dictionary& dict,
159  const dictionary& coordinatesDict
160  );
161 
162  //- Explicitly provided directions to split in.
164  (
165  polyMesh& mesh,
166  const labelList& cellLabels, // cells to refine
167  const List<vectorField>&, // Explicitly provided directions
168  const dictionary& dict,
169  const dictionary& coordinatesDict
170  );
171 
172  //- Construct from components. Only this one would allow undo actions.
174  (
175  polyMesh& mesh,
176  undoableMeshCutter& cutter, // actual mesh modifier
177  const cellLooper& cellCutter, // how to cut a single cell with
178  // a plane
179  const labelList& cellLabels, // list of cells to refine
181  const bool writeMesh = false // write intermediate meshes
182  );
183 
184  //- Disallow default bitwise copy construction
185  multiDirRefinement(const multiDirRefinement&) = delete;
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  // Member Operators
198 
199  //- Disallow default bitwise assignment
200  void operator=(const multiDirRefinement&) = delete;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Definition: cellLooper.H:72
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Definition: directions.H:67
Does multiple pass refinement to refine cells in multiple directions.
const labelListList & addedCells() const
Access to addedCells (on the original mesh; see above)
multiDirRefinement(polyMesh &mesh, const labelList &cellLabels, const dictionary &dict, const dictionary &coordinatesDict)
Construct from dictionary. After construction all refinement will.
ClassName("multiDirRefinement")
Runtime type information.
void operator=(const multiDirRefinement &)=delete
Disallow default bitwise assignment.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
dictionary dict