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 "blockList.H"
67 #include "searchableSurfaces.H"
68 #include "polyMesh.H"
69 #include "IOdictionary.H"
70 #include "blockVertexList.H"
71 #include "blockEdgeList.H"
72 #include "blockFaceList.H"
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
76 namespace Foam
77 {
78 
79 /*---------------------------------------------------------------------------*\
80  Class blockMesh Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 class blockMesh
84 :
85  public blockList
86 {
87 public:
88 
89  // Data Types
90 
91  //- The block merging strategy
92  enum mergeStrategy
93  {
97  };
98 
99 
100 private:
101 
102  // Static Data
103 
104  //- Names corresponding to the mergeStrategy
105  static const Enum<mergeStrategy> strategyNames_;
106 
107 
108  // Private Data
109 
110  //- Reference to mesh dictionary
111  const IOdictionary& meshDict_;
112 
113  //- Switch for verbose output
114  bool verboseOutput;
115 
116  //- Switch checking face consistency (defaults to true)
117  bool checkFaceCorrespondence_;
118 
119  //- Optional searchable geometry to project face-points to
120  searchableSurfaces geometry_;
121 
122  //- The scaling factor to convert to metres
123  scalar scaleFactor_;
124 
125  //- The list of block vertices
126  blockVertexList blockVertices_;
127 
128  //- The list of block vertex positions
129  pointField vertices_;
130 
131  //- The list of curved edges
132  blockEdgeList edges_;
133 
134  //- The list of curved faces
135  blockFaceList faces_;
136 
137  //- The blocks themselves (the topology) as a polyMesh
138  autoPtr<polyMesh> topologyPtr_;
139 
140  //- The sum of all cells in each block
141  label nPoints_;
142 
143  //- The sum of all cells in each block
144  label nCells_;
145 
146  //- The point offset added to each block
147  labelList blockOffsets_;
148 
149  //- The merge points information
150  labelList mergeList_;
151 
152  mutable pointField points_;
153 
154  mutable cellShapeList cells_;
155 
156  mutable faceListList patches_;
157 
158 
159  // Private Member Functions
160 
161  template<class Source>
162  void checkPatchLabels
163  (
164  const Source& source,
165  const word& patchName,
166  const pointField& points,
167  faceList& patchShapes
168  ) const;
169 
170  void readPatches
171  (
172  const dictionary& meshDescription,
173  faceListList& tmpBlocksPatches,
176  wordList& nbrPatchNames
177  );
178 
179  void readBoundary
180  (
181  const dictionary& meshDescription,
183  faceListList& tmpBlocksPatches,
185  );
186 
187  void createCellShapes(cellShapeList& tmpBlockCells);
188 
189  autoPtr<polyMesh> createTopology
190  (
191  const IOdictionary& dict,
192  const word& regionName
193  );
194 
195  void check(const polyMesh& bm, const dictionary& dict) const;
196 
197  //- Determine merge info and final number of cells/points
198  //- based on point distances
199  void calcGeometricalMerge();
200 
201  //- Determine merge info and final number of cells/points
202  //- based on block topology
203  void calcTopologicalMerge();
204 
205  faceList createPatchFaces(const polyPatch& patchTopologyFaces) const;
206 
207  void createPoints() const;
208  void createCells() const;
209  void createPatches() const;
210 
211 
212  //- No copy construct
213  blockMesh(const blockMesh&) = delete;
214 
215  //- No copy assignment
216  void operator=(const blockMesh&) = delete;
217 
218 
219 public:
220 
221  //- Runtime type information
222  ClassName("blockMesh");
223 
224 
225  // Constructors
226 
227  //- Construct from IOdictionary for given region
228  // Default is topological merging.
229  blockMesh
230  (
231  const IOdictionary& dict,
232  const word& regionName,
233  mergeStrategy strategy = mergeStrategy::DEFAULT_MERGE
234  );
235 
236 
237  //- Destructor
238  ~blockMesh() = default;
239 
240 
241  // Member Functions
242 
243  // Access
244 
245  //- Access to input dictionary
246  const dictionary& meshDict() const
247  {
248  return meshDict_;
249  }
250 
251  //- Optional searchable geometry to project face-points to
252  const searchableSurfaces& geometry() const
253  {
254  return geometry_;
255  }
256 
257  //- True if the blockMesh topology exists
258  bool valid() const;
259 
260  //- Reference to point field defining the blockMesh
261  // these points have not been scaled by scaleFactor
262  const pointField& vertices() const;
263 
264  //- Return the blockMesh topology as a polyMesh
265  const polyMesh& topology() const;
266 
267  //- Return the curved edges
268  const blockEdgeList& edges() const
269  {
270  return edges_;
271  }
272 
273  //- Return the curved faces
274  const blockFaceList& faces() const
275  {
276  return faces_;
277  }
278 
279  //- The scaling factor used to convert to metres
280  scalar scaleFactor() const;
281 
282  //- The points for the entire mesh
283  // these points have been scaled by scaleFactor
284  const pointField& points() const;
285 
286  //- Return cell shapes list
287  const cellShapeList& cells() const;
288 
289  //- Return the patch face lists
290  const faceListList& patches() const;
291 
292  //- Get patch information from the topology mesh
293  PtrList<dictionary> patchDicts() const;
294 
295  //- Return patch names
296  wordList patchNames() const;
297 
298  //- Number of blocks with specified zones
299  label numZonedBlocks() const;
300 
301 
302  // Edit
303 
304  //- Enable/disable verbose information about the progress
305  void verbose(const bool on=true);
306 
307 
308  // Write
309 
310  //- Writes edges of blockMesh in OBJ format.
311  void writeTopology(Ostream&) const;
312 };
313 
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 } // End namespace Foam
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 #endif
322 
323 // ************************************************************************* //
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:143
Foam::Enum< mergeStrategy >
Foam::blockMesh::meshDict
const dictionary & meshDict() const
Access to input dictionary.
Definition: blockMesh.H:310
Foam::blockMesh::patches
const faceListList & patches() const
Return the patch face lists.
Definition: blockMesh.C:188
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:158
Foam::blockMesh::ClassName
ClassName("blockMesh")
Runtime type information.
Foam::blockMesh::mergeStrategy
mergeStrategy
The block merging strategy.
Definition: blockMesh.H:156
Foam::blockVertexList
PtrList< blockVertex > blockVertexList
A PtrList of blockVertex.
Definition: blockVertexList.H:47
Foam::cellShapeList
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Definition: cellShapeList.H:45
Foam::blockMesh::geometry
const searchableSurfaces & geometry() const
Optional searchable geometry to project face-points to.
Definition: blockMesh.H:316
Foam::blockMesh::MERGE_TOPOLOGY
"topology" merge by block topology (default)
Definition: blockMesh.H:159
polyMesh.H
Foam::blockMesh::faces
const blockFaceList & faces() const
Return the curved faces.
Definition: blockMesh.H:338
Foam::blockMesh::topology
const polyMesh & topology() const
Return the blockMesh topology as a polyMesh.
Definition: blockMesh.C:130
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::blockMesh::verbose
void verbose(const bool on=true)
Enable/disable verbose information about the progress.
Definition: blockMesh.C:118
patchTypes
wordList patchTypes(nPatches)
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::blockEdgeList
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
Definition: blockEdgeList.H:47
Foam::blockMesh::writeTopology
void writeTopology(Ostream &) const
Writes edges of blockMesh in OBJ format.
Definition: blockMesh.C:235
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:67
blockEdgeList.H
Foam::blockMesh::vertices
const pointField & vertices() const
Reference to point field defining the blockMesh.
Definition: blockMesh.C:124
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:160
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::blockMesh::valid
bool valid() const
True if the blockMesh topology exists.
Definition: blockMesh.C:112
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:160
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
blockVertexList.H
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:217
Foam::faceListList
List< faceList > faceListList
A List of faceList.
Definition: faceListFwd.H:49
Foam::blockMesh::points
const pointField & points() const
The points for the entire mesh.
Definition: blockMesh.C:166
Foam::List< label >
Foam::blockMesh::patchNames
wordList patchNames() const
Return patch names.
Definition: blockMesh.C:199
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:332
Foam::blockList
PtrList< block > blockList
A PtrList of blocks.
Definition: blockList.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::blockMesh::cells
const cellShapeList & cells() const
Return cell shapes list.
Definition: blockMesh.C:177
blockList.H
Enum.H
Foam::blockMesh
A multi-block mesh generator.
Definition: blockMesh.H:147