ensightMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::ensightMesh
26 
27 Description
28 
29 SourceFiles
30  ensightMesh.C
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef ensightMesh_H
35 #define ensightMesh_H
36 
37 #include "cellSets.H"
38 #include "faceSets.H"
39 #include "HashTable.H"
40 #include "HashSet.H"
41 #include "PackedBoolList.H"
42 #include "wordReList.H"
43 #include "scalarField.H"
44 #include "cellShapeList.H"
45 #include "cellList.H"
46 
47 #include <fstream>
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 class fvMesh;
55 class argList;
56 class globalIndex;
57 class ensightStream;
58 
59 /*---------------------------------------------------------------------------*\
60  Class ensightMesh Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class ensightMesh
64 {
65 public:
66  class nFacePrimitives
67  {
68  public:
69 
72  label nPolys;
73 
75  :
76  nTris(0),
77  nQuads(0),
78  nPolys(0)
79  {}
80  };
81 
82 private:
83 
84  // Private Data
85 
86  //- Reference to the OpenFOAM mesh
87  const fvMesh& mesh_;
88 
89  //- Suppress patches
90  const bool noPatches_;
91 
92  //- Output selected patches only
93  const bool patches_;
94  const wordReList patchPatterns_;
95 
96  //- Output selected faceZones
97  const bool faceZones_;
98  const wordReList faceZonePatterns_;
99 
100  //- Set binary file output
101  const bool binary_;
102 
103  //- The ensight part id for the first patch
104  label patchPartOffset_;
105 
106  cellSets meshCellSets_;
107 
108  List<faceSets> boundaryFaceSets_;
109 
110  wordList allPatchNames_;
111 
112  wordHashSet patchNames_;
113 
114  HashTable<nFacePrimitives> nPatchPrims_;
115 
116  // faceZone - related variables
117  List<faceSets> faceZoneFaceSets_;
118 
119  wordHashSet faceZoneNames_;
120 
121  HashTable<nFacePrimitives> nFaceZonePrims_;
122 
123  //- Per boundary face whether to include or not
124  PackedBoolList boundaryFaceToBeIncluded_;
125 
126 
127  // Parallel merged points
128 
129  //- Global numbering for merged points
130  autoPtr<globalIndex> globalPointsPtr_;
131 
132  //- From mesh point to global merged point
133  labelList pointToGlobal_;
134 
135  //- Local points that are unique
136  labelList uniquePointMap_;
137 
138 
139 
140  // Private Member Functions
141 
142  void writePoints
143  (
144  const scalarField& pointsComponent,
145  ensightStream& ensightGeometryFile
146  ) const;
147 
148  cellShapeList map
149  (
150  const cellShapeList& cellShapes,
151  const labelList& prims,
152  const labelList& pointToGlobal
153  ) const;
154 
155  cellShapeList map
156  (
157  const cellShapeList& cellShapes,
158  const labelList& hexes,
159  const labelList& wedges,
160  const labelList& pointToGlobal
161  ) const;
162 
163  void writePrims
164  (
165  const cellShapeList& cellShapes,
166  ensightStream& ensightGeometryFile
167  ) const;
168 
169  void writePolysNFaces
170  (
171  const labelList& polys,
172  const cellList& cellFaces,
173  ensightStream& ensightGeometryFile
174  ) const;
175 
176  void writePolysNPointsPerFace
177  (
178  const labelList& polys,
179  const cellList& cellFaces,
180  const faceList& faces,
181  ensightStream& ensightGeometryFile
182  ) const;
183 
184  void writePolysPoints
185  (
186  const labelList& polys,
187  const cellList& cellFaces,
188  const faceList& faces,
189  const labelList& faceOwner,
190  ensightStream& ensightGeometryFile
191  ) const;
192 
193  void writeAllPolys
194  (
195  const labelList& pointToGlobal,
196  ensightStream& ensightGeometryFile
197  ) const;
198 
199  void writeAllPrims
200  (
201  const char* key,
202  const label nPrims,
203  const cellShapeList& cellShapes,
204  ensightStream& ensightGeometryFile
205  ) const;
206 
207  void writeFacePrims
208  (
209  const faceList& patchFaces,
210  ensightStream& ensightGeometryFile
211  ) const;
212 
213  void writeAllFacePrims
214  (
215  const char* key,
216  const labelList& prims,
217  const label nPrims,
218  const faceList& patchFaces,
219  ensightStream& ensightGeometryFile
220  ) const;
221 
222  void writeNSidedNPointsPerFace
223  (
224  const faceList& patchFaces,
225  ensightStream& ensightGeometryFile
226  ) const;
227 
228  void writeNSidedPoints
229  (
230  const faceList& patchFaces,
231  ensightStream& ensightGeometryFile
232  ) const;
233 
234  void writeAllNSided
235  (
236  const labelList& prims,
237  const label nPrims,
238  const faceList& patchFaces,
239  ensightStream& ensightGeometryFile
240  ) const;
241 
242  void writeAllPoints
243  (
244  const label ensightPartI,
245  const word& ensightPartName,
246  const pointField& uniquePoints,
247  const label nPoints,
248  ensightStream& ensightGeometryFile
249  ) const;
250 
251 public:
252 
253  // Constructors
254 
255  //- Construct from fvMesh
257  (
258  const fvMesh& mesh,
259  const bool noPatches,
260  const bool patches,
261  const wordReList& patchPatterns,
262  const bool faceZones,
263  const wordReList& faceZonePatterns,
264  const bool binary
265  );
266 
267  //- Disallow default bitwise copy construction
268  ensightMesh(const ensightMesh&) = delete;
269 
270 
271  //- Destructor
272  ~ensightMesh();
273 
274 
275  // Member Functions
276 
277  // Access
279  const fvMesh& mesh() const
280  {
281  return mesh_;
282  }
284  const cellSets& meshCellSets() const
285  {
286  return meshCellSets_;
287  }
289  const List<faceSets>& boundaryFaceSets() const
290  {
291  return boundaryFaceSets_;
292  }
294  const wordList& allPatchNames() const
295  {
296  return allPatchNames_;
297  }
299  const wordHashSet& patchNames() const
300  {
301  return patchNames_;
302  }
305  {
306  return nPatchPrims_;
307  }
309  const List<faceSets>& faceZoneFaceSets() const
310  {
311  return faceZoneFaceSets_;
312  }
314  const wordHashSet& faceZoneNames() const
315  {
316  return faceZoneNames_;
317  }
320  {
321  return nFaceZonePrims_;
322  }
323 
324  //- The ensight part id for the first patch
325  label patchPartOffset() const
326  {
327  return patchPartOffset_;
328  }
329 
330 
331  // Parallel point merging
332 
333  //- Global numbering for merged points
334  const globalIndex& globalPoints() const
335  {
336  return globalPointsPtr_();
337  }
338 
339  //- From mesh point to global merged point
340  const labelList& pointToGlobal() const
341  {
342  return pointToGlobal_;
343  }
344 
345  //- Local points that are unique
346  const labelList& uniquePointMap() const
347  {
348  return uniquePointMap_;
349  }
350 
351 
352 
353 
354  // Other
355 
356  //- Update for new mesh
357  void correct();
358 
359  //- When exporting faceZones, check if a given face has to be included
360  // or not (i.e. faces on processor boundaries)
361  bool faceToBeIncluded(const label facei) const;
362 
363  //- Helper to cause barrier. Necessary on Quadrics.
364  static void barrier();
365 
366 
367  // I-O
368 
369  void write
370  (
371  const fileName& postProcPath,
372  const word& prepend,
373  const label timeIndex,
374  const bool meshMoving,
375  Ostream& ensightCaseFile
376  ) const;
377 
378 
379  // Member Operators
380 
381  //- Disallow default bitwise assignment
382  void operator=(const ensightMesh&) = delete;
383 };
384 
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 } // End namespace Foam
389 
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 
392 #endif
393 
394 // ************************************************************************* //
const HashTable< nFacePrimitives > & nPatchPrims() const
Definition: ensightMesh.H:303
A HashTable with keys but without contents.
Definition: HashSet.H:59
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:59
A class for handling file names.
Definition: fileName.H:79
const wordHashSet & faceZoneNames() const
Definition: ensightMesh.H:313
label patchPartOffset() const
The ensight part id for the first patch.
Definition: ensightMesh.H:324
const labelList & uniquePointMap() const
Local points that are unique.
Definition: ensightMesh.H:345
~ensightMesh()
Destructor.
Abstract base class for writing Ensight data.
Definition: ensightStream.H:50
patches[0]
ensightMesh(const fvMesh &mesh, const bool noPatches, const bool patches, const wordReList &patchPatterns, const bool faceZones, const wordReList &faceZonePatterns, const bool binary)
Construct from fvMesh.
const cellSets & meshCellSets() const
Definition: ensightMesh.H:283
void correct()
Update for new mesh.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
const List< faceSets > & boundaryFaceSets() const
Definition: ensightMesh.H:288
A class for handling words, derived from string.
Definition: word.H:59
label nPoints
const cellShapeList & cellShapes
const wordHashSet & patchNames() const
Definition: ensightMesh.H:298
const fvMesh & mesh() const
Definition: ensightMesh.H:278
void operator=(const ensightMesh &)=delete
Disallow default bitwise assignment.
An STL-conforming hash table.
Definition: HashTable.H:61
const HashTable< nFacePrimitives > & nFaceZonePrims() const
Definition: ensightMesh.H:318
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const wordList & allPatchNames() const
Definition: ensightMesh.H:293
static void barrier()
Helper to cause barrier. Necessary on Quadrics.
A bit-packed bool list.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label timeIndex
Definition: getTimeIndex.H:4
const List< faceSets > & faceZoneFaceSets() const
Definition: ensightMesh.H:308
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const labelList & pointToGlobal() const
From mesh point to global merged point.
Definition: ensightMesh.H:339
const globalIndex & globalPoints() const
Global numbering for merged points.
Definition: ensightMesh.H:333
bool faceToBeIncluded(const label facei) const
When exporting faceZones, check if a given face has to be included.
Namespace for OpenFOAM.
void write(const fileName &postProcPath, const word &prepend, const label timeIndex, const bool meshMoving, Ostream &ensightCaseFile) const
bool meshMoving