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-2020 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  scale | Point scaling | no | 1.0
37  vertices | | yes |
38  blocks | | yes |
39  edges | | no |
40  faces | | no |
41  boundary | Boundary definition | no |
42  patches | Alternate version for "boundary" | no |
43  namedBlocks | | no |
44  namedVertices | | no |
45  mergeType | Merging "points" or "topology" | no | topology
46  checkFaceCorrespondence | | no | true
47  verbose | | no | true
48  \endtable
49 
50 Note
51  The vertices, cells and patches for filling the blocks are demand-driven.
52 
53 SourceFiles
54  blockMesh.C
55  blockMeshCheck.C
56  blockMeshCreate.C
57  blockMeshMerge.C
58  blockMeshTopology.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef blockMesh_H
63 #define blockMesh_H
64 
65 #include "Enum.H"
66 #include "block.H"
67 #include "PtrList.H"
68 #include "searchableSurfaces.H"
69 #include "polyMesh.H"
70 #include "IOdictionary.H"
71 #include "blockVertexList.H"
72 #include "blockEdgeList.H"
73 #include "blockFaceList.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class blockMesh Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class blockMesh
85 :
86  public PtrList<block>
87 {
88 public:
89 
90  // Typedefs
91 
92  //- The list of blocks is stored as a PtrList
93  typedef PtrList<block> blockList;
94 
95 
96  // Data Types
97 
98  //- The block merging strategy
99  enum mergeStrategy
100  {
101  DEFAULT_MERGE,
103  MERGE_POINTS
104  };
105 
106 
107 private:
108 
109  // Static Data
110 
111  //- Names corresponding to the mergeStrategy
112  static const Enum<mergeStrategy> strategyNames_;
113 
114 
115  // Private Data
116 
117  //- Reference to mesh dictionary
118  const IOdictionary& meshDict_;
119 
120  //- Output verbosity
121  bool verbose_;
122 
123  //- Switch checking face consistency (defaults to true)
124  bool checkFaceCorrespondence_;
125 
126  //- Optional searchable geometry to project face-points to
127  searchableSurfaces geometry_;
128 
129  //- The scaling factor to convert to metres
130  scalar scaleFactor_;
131 
132  //- The list of block vertices
133  blockVertexList blockVertices_;
134 
135  //- The list of block vertex positions
136  pointField vertices_;
137 
138  //- The list of curved edges
139  blockEdgeList edges_;
140 
141  //- The list of curved faces
142  blockFaceList faces_;
143 
144  //- The blocks themselves (the topology) as a polyMesh
145  autoPtr<polyMesh> topologyPtr_;
146 
147  //- The sum of all cells in each block
148  label nPoints_;
149 
150  //- The sum of all cells in each block
151  label nCells_;
152 
153  //- The point offset added to each block
154  labelList blockOffsets_;
155 
156  //- The merge points information
157  labelList mergeList_;
158 
159  mutable pointField points_;
160 
161  mutable cellShapeList cells_;
162 
163  mutable faceListList patches_;
164 
165 
166  // Private Member Functions
167 
168  template<class Source>
169  void checkPatchLabels
170  (
171  const Source& source,
172  const word& patchName,
173  const pointField& points,
174  faceList& patchShapes
175  ) const;
176 
177  void readPatches
178  (
179  const dictionary& meshDescription,
180  faceListList& tmpBlocksPatches,
183  wordList& nbrPatchNames
184  );
185 
186  void readBoundary
187  (
188  const dictionary& meshDescription,
190  faceListList& tmpBlocksPatches,
192  );
193 
194  void createCellShapes(cellShapeList& tmpBlockCells);
195 
196  autoPtr<polyMesh> createTopology
197  (
198  const IOdictionary& dict,
199  const word& regionName
200  );
201 
202  void check(const polyMesh& bm, const dictionary& dict) const;
203 
204  //- Determine merge info and final number of cells/points
205  //- based on point distances
206  void calcGeometricalMerge();
207 
208  //- Determine merge info and final number of cells/points
209  //- based on block topology
210  void calcTopologicalMerge();
211 
212  faceList createPatchFaces(const polyPatch& patchTopologyFaces) const;
213 
214  void createPoints() const;
215  void createCells() const;
216  void createPatches() const;
217 
218 
219  //- No copy construct
220  blockMesh(const blockMesh&) = delete;
221 
222  //- No copy assignment
223  void operator=(const blockMesh&) = delete;
224 
225 
226 public:
227 
228  // Static Data
229 
230  //- The default verbosity (true)
231  static bool verboseOutput;
232 
233 
234  //- Runtime type information
235  ClassName("blockMesh");
236 
237 
238  // Constructors
239 
240  //- Construct from IOdictionary for given region
241  // Default is topological merging.
242  explicit blockMesh
243  (
244  const IOdictionary& dict,
246  mergeStrategy strategy = mergeStrategy::DEFAULT_MERGE
247  );
248 
249 
250  //- Destructor
251  ~blockMesh() = default;
252 
253 
254  // Member Functions
255 
256  // Access
257 
258  //- Access to input dictionary
259  const dictionary& meshDict() const
260  {
261  return meshDict_;
262  }
263 
264  //- Optional searchable geometry to project face-points to
265  const searchableSurfaces& geometry() const
266  {
267  return geometry_;
268  }
269 
270  //- True if the blockMesh topology exists
271  bool valid() const noexcept;
272 
273  //- Reference to point field defining the blockMesh.
274  // These points are \b not scaled by scaleFactor
275  const pointField& vertices() const;
276 
277  //- Return the blockMesh topology as a polyMesh
278  const polyMesh& topology() const;
279 
280  //- Return the curved edges
281  const blockEdgeList& edges() const
282  {
283  return edges_;
284  }
285 
286  //- Return the curved faces
287  const blockFaceList& faces() const
288  {
289  return faces_;
290  }
291 
292  //- The scaling factor used to convert to metres
293  scalar scaleFactor() const;
294 
295  //- The points for the entire mesh.
296  // These points \b are scaled by scaleFactor
297  const pointField& points() const;
298 
299  //- Return cell shapes list
300  const cellShapeList& cells() const;
301 
302  //- Return the patch face lists
303  const faceListList& patches() const;
304 
305  //- Get patch information from the topology mesh
307 
308  //- Return patch names
309  wordList patchNames() const;
310 
311  //- Number of blocks with specified zones
312  label numZonedBlocks() const;
313 
314 
315  // Verbosity
316 
317  //- Verbose output
318  bool verbose() const noexcept;
319 
320  //- Enable/disable verbose output
321  // \return old value
322  bool verbose(const bool on) noexcept;
323 
324 
325  // Mesh Generation
326 
327  //- Create polyMesh, with cell zones
328  autoPtr<polyMesh> mesh(const IOobject& io) const;
329 };
330 
331 
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333 
334 } // End namespace Foam
335 
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 
338 #endif
339 
340 // ************************************************************************* //
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
Get patch information from the topology mesh.
Definition: blockMesh.C:153
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::blockMesh::valid
bool valid() const noexcept
True if the blockMesh topology exists.
Definition: blockMesh.C:114
Foam::Enum< mergeStrategy >
Foam::blockMesh::meshDict
const dictionary & meshDict() const
Access to input dictionary.
Definition: blockMesh.H:323
Foam::blockMesh::mesh
autoPtr< polyMesh > mesh(const IOobject &io) const
Create polyMesh, with cell zones.
Definition: blockMeshCreate.C:277
Foam::blockMesh::patches
const faceListList & patches() const
Return the patch face lists.
Definition: blockMesh.C:198
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::blockMesh::DEFAULT_MERGE
Default (TOPOLOGY), not selectable.
Definition: blockMesh.H:165
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::mergeStrategy
mergeStrategy
The block merging strategy.
Definition: blockMesh.H:163
Foam::blockVertexList
PtrList< blockVertex > blockVertexList
A PtrList of blockVertex.
Definition: blockVertexList.H:47
Foam::blockMesh::geometry
const searchableSurfaces & geometry() const
Optional searchable geometry to project face-points to.
Definition: blockMesh.H:329
Foam::blockMesh::MERGE_TOPOLOGY
"topology" merge by block topology (default)
Definition: blockMesh.H:166
polyMesh.H
Foam::blockMesh::faces
const blockFaceList & faces() const
Return the curved faces.
Definition: blockMesh.H:351
Foam::blockMesh::topology
const polyMesh & topology() const
Return the blockMesh topology as a polyMesh.
Definition: blockMesh.C:140
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
patchTypes
wordList patchTypes(nPatches)
Foam::blockEdgeList
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
Definition: blockEdgeList.H:47
searchableSurfaces.H
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::blockMesh::verbose
bool verbose() const noexcept
Verbose output.
Definition: blockMesh.C:120
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::vertices
const pointField & vertices() const
Reference to point field defining the blockMesh.
Definition: blockMesh.C:134
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
blockFaceList.H
Foam::blockMesh::scaleFactor
scalar scaleFactor() const
The scaling factor used to convert to metres.
Definition: blockMesh.C:170
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:121
Foam::blockMesh::MERGE_POINTS
"points" merge by point geometry
Definition: blockMesh.H:167
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
blockVertexList.H
Foam::blockMesh::blockList
PtrList< block > blockList
The list of blocks is stored as a PtrList.
Definition: blockMesh.H:157
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:227
Foam::blockMesh::points
const pointField & points() const
The points for the entire mesh.
Definition: blockMesh.C:176
Foam::List< label >
Foam::blockMesh::patchNames
wordList patchNames() const
Return patch names.
Definition: blockMesh.C:209
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::blockMesh::~blockMesh
~blockMesh()=default
Destructor.
Foam::blockMesh::edges
const blockEdgeList & edges() const
Return the curved edges.
Definition: blockMesh.H:345
PtrList.H
Foam::blockMesh::cells
const cellShapeList & cells() const
Return cell shapes list.
Definition: blockMesh.C:187
block.H
Foam::blockMesh::verboseOutput
static bool verboseOutput
The default verbosity (true)
Definition: blockMesh.H:295
Enum.H
Foam::blockMesh
A multi-block mesh generator.
Definition: blockMesh.H:148