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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::multiDirRefinement
28
29Description
30 Does multiple pass refinement to refine cells in multiple directions.
31
32 Gets a list of cells to refine and vectorFields for the whole mesh.
33 It then tries to refine in one direction after the other the wanted cells.
34 After construction the mesh will have been refined in multiple directions.
35
36 Holds the list of cells to refine and the map from original to added for
37 every refinement level.
38
39 Gets constructed from a dictionary or from components.
40 Uses an undoableMeshCutter which does the actual cutting. Undo facility
41 is switched of unless constructed from external one which allows this.
42
43 The cut cells get stored in addedCells which is for every vectorField
44 to cut with the map from uncut to added cell (i.e. from master to slave).
45 Note: map is only valid for a given direction.
46
47 Parallel: should be ok. Uses 'reduce' whenever it needs to make a
48 local decision.
49
50SourceFiles
51 multiDirRefinement.C
52
53\*---------------------------------------------------------------------------*/
54
55#ifndef multiDirRefinement_H
56#define multiDirRefinement_H
57
58#include "refinementIterator.H"
59#include "vectorField.H"
60#include "Map.H"
61#include "className.H"
62
63// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64
65namespace Foam
66{
67
68// Forward Declarations
69class undoableMeshCutter;
70class cellLooper;
71class topoSet;
72
73/*---------------------------------------------------------------------------*\
74 Class multiDirRefinement Declaration
75\*---------------------------------------------------------------------------*/
78{
79 // Private data
80
81 //- Current set of cells to refine. Extended with added cells.
82 labelList cellLabels_;
83
84 //- From original to added cells.
85 // Gives for every cell in the original mesh an empty list or the
86 // list of cells this one has been split into (note: will include
87 // itself so e.g. for hex will be 8 if 2x2x2 refinement)
88 labelListList addedCells_;
89
90
91 // Private Static Functions
92
93 //- Given map from original to added cell set the refineCell for
94 // the added cells to be equal to the one on the original cells.
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 //- No copy construct
144 multiDirRefinement(const multiDirRefinement&) = delete;
145
146 //- No copy assignment
147 void operator=(const multiDirRefinement&) = delete;
148
149
150public:
151
152 //- Runtime type information
153 ClassName("multiDirRefinement");
154
155
156 // Constructors
157
158 //- Construct from dictionary. After construction all refinement will
159 // have been done (and runTime will have increased a few time steps if
160 // writeMesh = true)
162 (
163 polyMesh& mesh,
164 const labelList& cellLabels, // cells to refine
165 const dictionary& dict
166 );
167
168 //- Explicitly provided directions to split in.
170 (
171 polyMesh& mesh,
172 const labelList& cellLabels, // cells to refine
173 const List<vectorField>&, // Explicitly provided directions
174 const dictionary& dict
175 );
176
177 //- Construct from components. Only this one would allow undo actions.
179 (
180 polyMesh& mesh,
181 undoableMeshCutter& cutter, // actual mesh modifier
182 const cellLooper& cellCutter, // how to cut a single cell with
183 // a plane
184 const labelList& cellLabels, // list of cells to refine
186 const bool writeMesh = false // write intermediate meshes
187 );
188
189
190 // Member Functions
191
192 //- Access to addedCells (on the original mesh; see above)
193 const labelListList& addedCells() const
194 {
195 return addedCells_;
196 }
197};
198
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202} // End namespace Foam
203
204// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206#endif
207
208// ************************************************************************* //
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Definition: cellLooper.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Definition: directions.H:70
Does multiple pass refinement to refine cells in multiple directions.
ClassName("multiDirRefinement")
Runtime type information.
const labelListList & addedCells() const
Access to addedCells (on the original mesh; see above)
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
mesh update()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
dictionary dict