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 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 Note
34  The vertices, cells and patches for filling the blocks are demand-driven.
35 
36 SourceFiles
37  blockMesh.C
38  blockMeshCheck.C
39  blockMeshCreate.C
40  blockMeshMerge.C
41  blockMeshTopology.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef blockMesh_H
46 #define blockMesh_H
47 
48 #include "blockList.H"
49 #include "searchableSurfaces.H"
50 #include "polyMesh.H"
51 #include "IOdictionary.H"
52 #include "blockVertexList.H"
53 #include "blockEdgeList.H"
54 #include "blockFaceList.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class blockMesh Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class blockMesh
66 :
67  public blockList
68 {
69  // Private data
70 
71  //- Reference to mesh dictionary
72  const IOdictionary& meshDict_;
73 
74  //- Switch for verbose output
75  bool verboseOutput;
76 
77  //- Switch checking face consistency (defaults to true)
78  bool checkFaceCorrespondence_;
79 
80  //- Optional searchable geometry to project face-points to
81  searchableSurfaces geometry_;
82 
83  //- The scaling factor to convert to metres
84  scalar scaleFactor_;
85 
86  //- The list of block vertices
87  blockVertexList blockVertices_;
88 
89  //- The list of block vertex positions
90  pointField vertices_;
91 
92  //- The list of curved edges
93  blockEdgeList edges_;
94 
95  //- The list of curved faces
96  blockFaceList faces_;
97 
98  //- The blocks themselves (the topology) as a polyMesh
99  autoPtr<polyMesh> topologyPtr_;
100 
101  //- The sum of all cells in each block
102  label nPoints_;
103 
104  //- The sum of all cells in each block
105  label nCells_;
106 
107  //- The point offset added to each block
108  labelList blockOffsets_;
109 
110  //- The merge points information
111  labelList mergeList_;
112 
113  mutable pointField points_;
114 
115  mutable cellShapeList cells_;
116 
117  mutable faceListList patches_;
118 
119 
120  // Private Member Functions
121 
122  template<class Source>
123  void checkPatchLabels
124  (
125  const Source& source,
126  const word& patchName,
127  const pointField& points,
128  faceList& patchShapes
129  ) const;
130 
131  void readPatches
132  (
133  const dictionary& meshDescription,
134  faceListList& tmpBlocksPatches,
137  wordList& nbrPatchNames
138  );
139 
140  void readBoundary
141  (
142  const dictionary& meshDescription,
144  faceListList& tmpBlocksPatches,
146  );
147 
148  void createCellShapes(cellShapeList& tmpBlockCells);
149 
150  autoPtr<polyMesh> createTopology
151  (
152  const IOdictionary& dict,
153  const word& regionName
154  );
155 
156  void check(const polyMesh& bm, const dictionary& dict) const;
157 
158  //- Determine the merge info and the final number of cells/points
159  void calcMergeInfo();
160 
161  //- Determine the merge info and the final number of cells/points
162  void calcMergeInfoFast();
163 
164  faceList createPatchFaces(const polyPatch& patchTopologyFaces) const;
165 
166  void createPoints() const;
167  void createCells() const;
168  void createPatches() const;
169 
170 
171  //- No copy construct
172  blockMesh(const blockMesh&) = delete;
173 
174  //- No copy assignment
175  void operator=(const blockMesh&) = delete;
176 
177 
178 public:
179 
180  // Static data members
181 
182  ClassName("blockMesh");
183 
184 
185  // Constructors
186 
187  //- Construct from IOdictionary
188  blockMesh(const IOdictionary& dict, const word& regionName);
189 
190 
191  //- Destructor
192  ~blockMesh() = default;
193 
194 
195  // Member Functions
196 
197  // Access
198 
199  //- Access to input dictionary
200  const dictionary& meshDict() const
201  {
202  return meshDict_;
203  }
204 
205  //- Optional searchable geometry to project face-points to
206  const searchableSurfaces& geometry() const
207  {
208  return geometry_;
209  }
210 
211  //- True if the blockMesh topology exists
212  bool valid() const;
213 
214  //- Reference to point field defining the blockMesh
215  // these points have not been scaled by scaleFactor
216  const pointField& vertices() const;
217 
218  //- Return the blockMesh topology as a polyMesh
219  const polyMesh& topology() const;
220 
221  //- Return the curved edges
222  const blockEdgeList& edges() const
223  {
224  return edges_;
225  }
226 
227  //- Return the curved faces
228  const blockFaceList& faces() const
229  {
230  return faces_;
231  }
232 
233  //- The scaling factor used to convert to metres
234  scalar scaleFactor() const;
235 
236  //- The points for the entire mesh
237  // these points have been scaled by scaleFactor
238  const pointField& points() const;
239 
240  //- Return cell shapes list
241  const cellShapeList& cells() const;
242 
243  //- Return the patch face lists
244  const faceListList& patches() const;
245 
246  //- Get patch information from the topology mesh
248 
249  //- Return patch names
250  wordList patchNames() const;
251 
252  //- Number of blocks with specified zones
253  label numZonedBlocks() const;
254 
255 
256  // Edit
257 
258  //- Enable/disable verbose information about the progress
259  void verbose(const bool on=true);
260 
261 
262  // Write
263 
264  //- Writes edges of blockMesh in OBJ format.
265  void writeTopology(Ostream&) const;
266 };
267 
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 } // End namespace Foam
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #endif
276 
277 // ************************************************************************* //
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:119
Foam::blockMesh::meshDict
const dictionary & meshDict() const
Access to input dictionary.
Definition: blockMesh.H:199
Foam::blockMesh::patches
const faceListList & patches() const
Return the patch face lists.
Definition: blockMesh.C:164
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::blockMesh::ClassName
ClassName("blockMesh")
Foam::blockMesh::geometry
const searchableSurfaces & geometry() const
Optional searchable geometry to project face-points to.
Definition: blockMesh.H:205
polyMesh.H
Foam::blockMesh::faces
const blockFaceList & faces() const
Return the curved faces.
Definition: blockMesh.H:227
Foam::blockMesh::topology
const polyMesh & topology() const
Return the blockMesh topology as a polyMesh.
Definition: blockMesh.C:106
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:94
patchTypes
wordList patchTypes(nPatches)
Foam::blockMesh::writeTopology
void writeTopology(Ostream &) const
Writes edges of blockMesh in OBJ format.
Definition: blockMesh.C:211
searchableSurfaces.H
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field< vector >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
blockEdgeList.H
Foam::blockMesh::vertices
const pointField & vertices() const
Reference to point field defining the blockMesh.
Definition: blockMesh.C:100
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
blockFaceList.H
Foam::blockMesh::scaleFactor
scalar scaleFactor() const
The scaling factor used to convert to metres.
Definition: blockMesh.C:136
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::blockMesh::valid
bool valid() const
True if the blockMesh topology exists.
Definition: blockMesh.C:88
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
blockVertexList.H
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:193
Foam::blockMesh::points
const pointField & points() const
The points for the entire mesh.
Definition: blockMesh.C:142
Foam::List< label >
Foam::blockMesh::patchNames
wordList patchNames() const
Return patch names.
Definition: blockMesh.C:175
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:221
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:153
blockList.H
Foam::blockMesh
A multi-block mesh generator.
Definition: blockMesh.H:64