blockMesh.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-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::blockMesh
29
30Description
31 A multi-block mesh generator
32
33 Dictionary controls
34 \table
35 Property | Description | Required | Default
36 prescale | Point scaling before transform | no | 1.0
37 scale | Point scaling after transform | no | 1.0
38 transform | Point transform (origin, rotation) | no |
39 vertices | | yes |
40 blocks | | yes |
41 edges | | no |
42 faces | | no |
43 boundary | Boundary definition | no |
44 patches | Alternate version for "boundary" | no |
45 namedBlocks | | no |
46 namedVertices | | no |
47 mergeType | Merging "points" or "topology" | no | topology
48 checkFaceCorrespondence | | no | true
49 verbose | | no | true
50 \endtable
51
52Note
53 The \c prescale and \c scale can be a single scalar or a vector of
54 values.
55
56 The vertices, cells and patches for filling the blocks are demand-driven.
57
58SourceFiles
59 blockMesh.C
60 blockMeshCheck.C
61 blockMeshCreate.C
62 blockMeshMerge.C
63 blockMeshTopology.C
64
65\*---------------------------------------------------------------------------*/
66
67#ifndef blockMesh_H
68#define blockMesh_H
69
70#include "Enum.H"
71#include "Switch.H"
72#include "block.H"
73#include "PtrList.H"
74#include "cartesianCS.H"
75#include "searchableSurfaces.H"
76#include "polyMesh.H"
77#include "IOdictionary.H"
78#include "blockVertexList.H"
79#include "blockEdgeList.H"
80#include "blockFaceList.H"
81
82// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83
84namespace Foam
85{
86
87/*---------------------------------------------------------------------------*\
88 Class blockMesh Declaration
89\*---------------------------------------------------------------------------*/
90
91class blockMesh
92:
93 public PtrList<block>
94{
95public:
96
97 // Typedefs
98
99 //- The list of blocks is stored as a PtrList
100 typedef PtrList<block> blockList;
101
102
103 // Data Types
104
105 //- The block merging strategy
106 enum mergeStrategy
107 {
111 };
112
113
114private:
115
116 // Static Data
117
118 //- Names corresponding to the mergeStrategy
119 static const Enum<mergeStrategy> strategyNames_;
120
121
122 // Data Types
123
124 //- Point transformations. Internal usage
125 enum transformTypes : unsigned
126 {
127 NO_TRANSFORM = 0,
128 ROTATION = 0x1,
129 TRANSLATION = 0x2,
130 PRESCALING = 0x4,
131 PRESCALING3 = 0x8,
132 SCALING = 0x10,
133 SCALING3 = 0x20
134 };
135
136
137 // Private Data
138
139 //- Reference to mesh dictionary
140 const IOdictionary& meshDict_;
141
142 //- Output verbosity level
143 int verbose_;
144
145 //- Check face consistency (defaults to true)
146 bool checkFaceCorrespondence_;
147
148 //- The mesh merging strategy
149 mergeStrategy mergeStrategy_;
150
151 //- Types of point transformations requested
152 unsigned transformType_;
153
154 //- Optional searchable geometry to project face-points to
155 searchableSurfaces geometry_;
156
157 //- The list of block vertices
158 blockVertexList blockVertices_;
159
160 //- The list of block vertex positions
161 pointField vertices_;
162
163 //- The list of curved edges
164 blockEdgeList edges_;
166 //- The list of curved faces
167 blockFaceList faces_;
168
169 //- The scaling factor before rotate/translate
170 vector prescaling_;
171
172 //- The scaling factor after rotate/translate
173 vector scaling_;
175 //- Local coordinate system transformation
176 coordSystem::cartesian transform_;
177
178 //- The blocks themselves (the topology) as a polyMesh
179 autoPtr<polyMesh> topologyPtr_;
181 //- The sum of all cells in each block
182 label nPoints_;
184 //- The sum of all cells in each block
185 label nCells_;
186
187 //- The merge points information
188 labelList mergeList_;
189
190 //- The point offset added to each block. Offsets into mergeList_
191 labelList blockOffsets_;
192
193 mutable pointField points_;
194
195 mutable cellShapeList cells_;
196
197 mutable faceListList patches_;
198
199
200 // Private Member Functions
201
202 //- Get scaling and/or coordinate transforms
203 // \return True if scaling and/or transformations are needed
204 bool readPointTransforms(const dictionary& dict);
205
206 void readPatches
207 (
208 const dictionary& meshDescription,
209 faceListList& tmpBlocksPatches,
212 wordList& nbrPatchNames
213 );
214
215 void readBoundary
216 (
217 const dictionary& meshDescription,
219 faceListList& tmpBlocksPatches,
221 );
222
223 //- Topology blocks as cell shapes
224 cellShapeList getBlockShapes() const;
225
226 autoPtr<polyMesh> createTopology
227 (
228 const IOdictionary& dict,
229 const word& regionName
230 );
231
232
233 //- Simple checks for collapsed hex cells
234 bool checkDegenerate() const;
235
236 void check(const polyMesh& bm, const dictionary& dict) const;
237
238 //- Determine merge info and final number of cells/points
239 //- based on point distances
240 void calcGeometricalMerge();
241
242 //- Determine merge info and final number of cells/points
243 //- based on block topology
244 void calcTopologicalMerge();
245
246 faceList createPatchFaces(const polyPatch& patchTopologyFaces) const;
247
248 void createPoints() const;
249 void createCells() const;
250 void createPatches() const;
251
252
253 //- No copy construct
254 blockMesh(const blockMesh&) = delete;
255
256 //- No copy assignment
257 void operator=(const blockMesh&) = delete;
258
259
260public:
261
262 // Static Data
263
264 //- The default verbosity (true)
265 static bool verboseOutput;
266
267
268 //- Runtime type information
269 ClassName("blockMesh");
270
271
272 // Constructors
273
274 //- Construct from IOdictionary for given region
275 // Default is topological merging.
276 explicit blockMesh
277 (
278 const IOdictionary& dict,
281 int verbosity = 0 // 0: use static or dictionary value
282 );
283
284
285 //- Destructor
286 ~blockMesh() = default;
287
288
289 // Member Functions
290
291 // General Access, Description
292
293 //- Access to input dictionary
294 const dictionary& meshDict() const noexcept
295 {
296 return meshDict_;
297 }
298
299 //- Optional searchable geometry to project face-points to
301 {
302 return geometry_;
303 }
304
305 //- The curved edges
306 const blockEdgeList& edges() const noexcept
307 {
308 return edges_;
309 }
310
311 //- The curved faces
312 const blockFaceList& faces() const noexcept
313 {
314 return faces_;
315 }
316
317 //- True if the blockMesh topology exists
318 bool valid() const noexcept;
319
320 //- Return the patch names
321 wordList patchNames() const;
322
323 //- Number of blocks with specified zones
324 label numZonedBlocks() const;
325
326
327 // Point Transformations
328
329 //- True if scaling and/or transformations are needed
330 bool hasPointTransforms() const noexcept;
331
332 //- Apply coordinate transforms and scaling
333 bool inplacePointTransforms(pointField& pts) const;
334
335 //- Apply coordinate transforms and scaling
336 tmp<pointField> globalPosition(const pointField& localPoints) const;
337
338
339 // Block Topology
340
341 //- Reference to point field defining the blocks,
342 //- these points are \b unscaled and \b non-transformed
344
345 //- Point field defining the blocks,
346 //- optionally transformed and scaled
347 tmp<pointField> vertices(bool applyTransform) const;
348
349 //- The blockMesh topology as a polyMesh
350 //- \b unscaled and \b non-transformed
351 const polyMesh& topology() const;
352
353 //- The blockMesh topology as a polyMesh
354 //- optionally transformed and scaled
355 refPtr<polyMesh> topology(bool applyTransform) const;
356
357
358 // Detailed Mesh
359
360 //- The points for the entire mesh.
361 //- These points \b are scaled and transformed
362 const pointField& points() const;
363
364 //- Return cell shapes list
365 const cellShapeList& cells() const;
366
367 //- Return the patch face lists
368 const faceListList& patches() const;
369
370 //- Patch information from the topology mesh
372
373
374 // Verbosity
375
376 //- Output verbosity level
377 int verbose() const noexcept;
378
379 //- Change the output verbosity level.
380 // \return old level
381 int verbose(const int level) noexcept;
382
383
384 // Mesh Generation
385
386 //- Create polyMesh, with cell zones
387 autoPtr<polyMesh> mesh(const IOobject& io) const;
388
389
390 // Housekeeping
391
392 //- Old (v2106 and earlier) uniform scaling factor
393 // \deprecated use inplacePointTransforms or globalPosition instead
394 scalar scaleFactor() const
395 {
396 return scaling_.x();
397 }
398};
399
400
401// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402
403} // End namespace Foam
404
405// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
406
407#endif
408
409// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A multi-block mesh generator.
Definition: blockMesh.H:168
ClassName("blockMesh")
Runtime type information.
const faceListList & patches() const
Return the patch face lists.
Definition: blockMesh.C:388
bool hasPointTransforms() const noexcept
True if scaling and/or transformations are needed.
Definition: blockMesh.C:435
const pointField & vertices() const noexcept
Definition: blockMesh.C:327
static bool verboseOutput
The default verbosity (true)
Definition: blockMesh.H:339
wordList patchNames() const
Return the patch names.
Definition: blockMesh.C:399
int verbose() const noexcept
Output verbosity level.
Definition: blockMesh.C:313
const blockEdgeList & edges() const noexcept
The curved edges.
Definition: blockMesh.H:380
~blockMesh()=default
Destructor.
tmp< pointField > globalPosition(const pointField &localPoints) const
Apply coordinate transforms and scaling.
Definition: blockMesh.C:514
mergeStrategy
The block merging strategy.
Definition: blockMesh.H:181
@ DEFAULT_MERGE
Default (TOPOLOGY), not selectable.
Definition: blockMesh.H:182
@ MERGE_TOPOLOGY
"topology" merge by block topology (default)
Definition: blockMesh.H:183
@ MERGE_POINTS
"points" merge by point geometry
Definition: blockMesh.H:184
label numZonedBlocks() const
Number of blocks with specified zones.
Definition: blockMesh.C:417
scalar scaleFactor() const
Old (v2106 and earlier) uniform scaling factor.
Definition: blockMesh.H:468
bool valid() const noexcept
True if the blockMesh topology exists.
Definition: blockMesh.C:307
bool inplacePointTransforms(pointField &pts) const
Apply coordinate transforms and scaling.
Definition: blockMesh.C:441
const blockFaceList & faces() const noexcept
The curved faces.
Definition: blockMesh.H:386
const cellShapeList & cells() const
Return cell shapes list.
Definition: blockMesh.C:377
const pointField & points() const
Definition: blockMesh.C:366
const searchableSurfaces & geometry() const noexcept
Optional searchable geometry to project face-points to.
Definition: blockMesh.H:374
PtrList< dictionary > patchDicts() const
Patch information from the topology mesh.
Definition: blockMesh.C:349
const polyMesh & topology() const
PtrList< block > blockList
The list of blocks is stored as a PtrList.
Definition: blockMesh.H:174
const dictionary & meshDict() const noexcept
Access to input dictionary.
Definition: blockMesh.H:368
A Cartesian coordinate system.
Definition: cartesianCS.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:321
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
A class for managing references or pointers (no reference counting)
Definition: refPtr.H:58
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
A class for managing temporary objects.
Definition: tmp.H:65
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
dynamicFvMesh & mesh
Foam::word regionName(Foam::polyMesh::defaultRegion)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Definition: cellShapeList.H:45
List< word > wordList
A List of words.
Definition: fileName.H:63
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
Definition: blockFaceList.H:47
List< label > labelList
A List of labels.
Definition: List.H:66
PtrList< blockVertex > blockVertexList
A PtrList of blockVertex.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
Definition: blockEdgeList.H:47
const direction noexcept
Definition: Scalar.H:223
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
List< faceList > faceListList
A List of faceList.
Definition: faceListFwd.H:49
wordList patchTypes(nPatches)
dictionary dict