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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::blockMesh
29 
30 Description
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 
52 Note
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 
58 SourceFiles
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 
84 namespace Foam
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class blockMesh Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class blockMesh
92 :
93  public PtrList<block>
94 {
95 public:
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  {
108  DEFAULT_MERGE,
110  MERGE_POINTS
111  };
112 
113 
114 private:
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_;
165 
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_;
174 
175  //- Local coordinate system transformation
176  coordSystem::cartesian transform_;
177 
178  //- The blocks themselves (the topology) as a polyMesh
179  autoPtr<polyMesh> topologyPtr_;
180 
181  //- The sum of all cells in each block
182  label nPoints_;
183 
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 
260 public:
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,
280  mergeStrategy strategy = mergeStrategy::DEFAULT_MERGE,
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
300  const searchableSurfaces& geometry() const noexcept
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
343  const pointField& vertices() const noexcept;
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
371  PtrList<dictionary> patchDicts() const;
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 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::blockMesh::patchDicts
PtrList< dictionary > patchDicts() const
Patch information from the topology mesh.
Definition: blockMesh.C:369
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Foam::blockMesh::valid
bool valid() const noexcept
True if the blockMesh topology exists.
Definition: blockMesh.C:327
Foam::Enum< mergeStrategy >
Foam::blockMesh::mesh
autoPtr< polyMesh > mesh(const IOobject &io) const
Create polyMesh, with cell zones.
Definition: blockMeshCreate.C:355
Foam::blockMesh::patches
const faceListList & patches() const
Return the patch face lists.
Definition: blockMesh.C:408
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::blockMesh::DEFAULT_MERGE
Default (TOPOLOGY), not selectable.
Definition: blockMesh.H:182
Foam::blockMesh::ClassName
ClassName("blockMesh")
Runtime type information.
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:318
Foam::blockMesh::verbose
int verbose() const noexcept
Output verbosity level.
Definition: blockMesh.C:333
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::blockMesh::mergeStrategy
mergeStrategy
The block merging strategy.
Definition: blockMesh.H:180
Foam::blockVertexList
PtrList< blockVertex > blockVertexList
A PtrList of blockVertex.
Definition: blockVertexList.H:47
Foam::blockMesh::geometry
const searchableSurfaces & geometry() const noexcept
Optional searchable geometry to project face-points to.
Definition: blockMesh.H:374
Foam::cellShapeList
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Definition: cellShapeList.H:45
Foam::blockMesh::vertices
const pointField & vertices() const noexcept
Definition: blockMesh.C:347
Foam::blockMesh::MERGE_TOPOLOGY
"topology" merge by block topology (default)
Definition: blockMesh.H:183
Foam::blockMesh::faces
const blockFaceList & faces() const noexcept
The curved faces.
Definition: blockMesh.H:386
cartesianCS.H
polyMesh.H
Foam::blockMesh::topology
const polyMesh & topology() const
Definition: blockMeshCreate.C:294
Foam::blockMesh::edges
const blockEdgeList & edges() const noexcept
The curved edges.
Definition: blockMesh.H:380
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
patchTypes
wordList patchTypes(nPatches)
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::blockEdgeList
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
Definition: blockEdgeList.H:47
searchableSurfaces.H
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::Field< vector >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
blockEdgeList.H
Foam::blockMesh::scaleFactor
scalar scaleFactor() const
Old (v2106 and earlier) uniform scaling factor.
Definition: blockMesh.H:468
Switch.H
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
blockFaceList.H
Foam::blockMesh::inplacePointTransforms
bool inplacePointTransforms(pointField &pts) const
Apply coordinate transforms and scaling.
Definition: blockMesh.C:461
Foam::blockMesh::globalPosition
tmp< pointField > globalPosition(const pointField &localPoints) const
Apply coordinate transforms and scaling.
Definition: blockMesh.C:534
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::blockMesh::MERGE_POINTS
"points" merge by point geometry
Definition: blockMesh.H:184
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
blockVertexList.H
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::blockMesh::hasPointTransforms
bool hasPointTransforms() const noexcept
True if scaling and/or transformations are needed.
Definition: blockMesh.C:455
Foam::blockMesh::blockList
PtrList< block > blockList
The list of blocks is stored as a PtrList.
Definition: blockMesh.H:174
Foam::blockFaceList
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
Definition: blockFaceList.H:47
IOdictionary.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::blockMesh::numZonedBlocks
label numZonedBlocks() const
Number of blocks with specified zones.
Definition: blockMesh.C:437
Foam::faceListList
List< faceList > faceListList
A List of faceList.
Definition: faceListFwd.H:49
Foam::blockMesh::points
const pointField & points() const
Definition: blockMesh.C:386
Foam::coordSystem::cartesian
A Cartesian coordinate system.
Definition: cartesianCS.H:69
Foam::faceList
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
Foam::Vector< scalar >
Foam::List< word >
Foam::blockMesh::patchNames
wordList patchNames() const
Return the patch names.
Definition: blockMesh.C:419
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::blockMesh::~blockMesh
~blockMesh()=default
Destructor.
PtrList.H
Foam::blockMesh::cells
const cellShapeList & cells() const
Return cell shapes list.
Definition: blockMesh.C:397
block.H
Foam::blockMesh::meshDict
const dictionary & meshDict() const noexcept
Access to input dictionary.
Definition: blockMesh.H:368
Foam::blockMesh::verboseOutput
static bool verboseOutput
The default verbosity (true)
Definition: blockMesh.H:339
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition: PtrList.H:60
Enum.H
Foam::blockMesh
A multi-block mesh generator.
Definition: blockMesh.H:165