ensightMesh.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 | Copyright (C) 2011-2013 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_;
95 
96  //- Output selected faceZones
97  const bool faceZones_;
99 
100  //- Set binary file output
101  const bool binary_;
102 
103  //- The ensight part id for the first patch
105 
107 
109 
111 
113 
115 
116  // faceZone - related variables
118 
120 
122 
123  //- Per boundary face whether to include or not
125 
126 
127  // Parallel merged points
128 
129  //- Global numbering for merged points
131 
132  //- From mesh point to global merged point
134 
135  //- Local points that are unique
137 
138 
139 
140  // Private Member Functions
141 
142  //- Disallow default bitwise copy construct
143  ensightMesh(const ensightMesh&);
144 
145  //- Disallow default bitwise assignment
146  void operator=(const ensightMesh&);
147 
148  void writePoints
149  (
150  const scalarField& pointsComponent,
151  ensightStream& ensightGeometryFile
152  ) const;
153 
155  (
156  const cellShapeList& cellShapes,
157  const labelList& prims,
158  const labelList& pointToGlobal
159  ) const;
160 
162  (
163  const cellShapeList& cellShapes,
164  const labelList& hexes,
165  const labelList& wedges,
166  const labelList& pointToGlobal
167  ) const;
168 
169  void writePrims
170  (
171  const cellShapeList& cellShapes,
172  ensightStream& ensightGeometryFile
173  ) const;
174 
175  void writePolysNFaces
176  (
177  const labelList& polys,
178  const cellList& cellFaces,
179  ensightStream& ensightGeometryFile
180  ) const;
181 
183  (
184  const labelList& polys,
185  const cellList& cellFaces,
186  const faceList& faces,
187  ensightStream& ensightGeometryFile
188  ) const;
189 
190  void writePolysPoints
191  (
192  const labelList& polys,
193  const cellList& cellFaces,
194  const faceList& faces,
195  const labelList& faceOwner,
196  ensightStream& ensightGeometryFile
197  ) const;
198 
199  void writeAllPolys
200  (
201  const labelList& pointToGlobal,
202  ensightStream& ensightGeometryFile
203  ) const;
204 
205  void writeAllPrims
206  (
207  const char* key,
208  const label nPrims,
209  const cellShapeList& cellShapes,
210  ensightStream& ensightGeometryFile
211  ) const;
212 
213  void writeFacePrims
214  (
215  const faceList& patchFaces,
216  ensightStream& ensightGeometryFile
217  ) const;
218 
219  void writeAllFacePrims
220  (
221  const char* key,
222  const labelList& prims,
223  const label nPrims,
224  const faceList& patchFaces,
225  ensightStream& ensightGeometryFile
226  ) const;
227 
229  (
230  const faceList& patchFaces,
231  ensightStream& ensightGeometryFile
232  ) const;
233 
234  void writeNSidedPoints
235  (
236  const faceList& patchFaces,
237  ensightStream& ensightGeometryFile
238  ) const;
239 
240  void writeAllNSided
241  (
242  const labelList& prims,
243  const label nPrims,
244  const faceList& patchFaces,
245  ensightStream& ensightGeometryFile
246  ) const;
247 
248  void writeAllPoints
249  (
250  const label ensightPartI,
251  const word& ensightPartName,
252  const pointField& uniquePoints,
253  const label nPoints,
254  ensightStream& ensightGeometryFile
255  ) const;
256 
257 public:
258 
259  // Constructors
260 
261  //- Construct from fvMesh
263  (
264  const fvMesh& mesh,
265  const bool noPatches,
266  const bool patches,
267  const wordReList& patchPatterns,
268  const bool faceZones,
269  const wordReList& faceZonePatterns,
270  const bool binary
271  );
272 
273 
274  //- Destructor
275  ~ensightMesh();
276 
277 
278  // Member Functions
279 
280  // Access
281 
282  const fvMesh& mesh() const
283  {
284  return mesh_;
285  }
286 
287  const cellSets& meshCellSets() const
288  {
289  return meshCellSets_;
290  }
291 
292  const List<faceSets>& boundaryFaceSets() const
293  {
294  return boundaryFaceSets_;
295  }
296 
297  const wordList& allPatchNames() const
298  {
299  return allPatchNames_;
300  }
301 
302  const wordHashSet& patchNames() const
303  {
304  return patchNames_;
305  }
306 
308  {
309  return nPatchPrims_;
310  }
311 
312  const List<faceSets>& faceZoneFaceSets() const
313  {
314  return faceZoneFaceSets_;
315  }
316 
317  const wordHashSet& faceZoneNames() const
318  {
319  return faceZoneNames_;
320  }
321 
323  {
324  return nFaceZonePrims_;
325  }
326 
327  //- The ensight part id for the first patch
328  label patchPartOffset() const
329  {
330  return patchPartOffset_;
331  }
332 
333 
334  // Parallel point merging
335 
336  //- Global numbering for merged points
337  const globalIndex& globalPoints() const
338  {
339  return globalPointsPtr_();
340  }
341 
342  //- From mesh point to global merged point
343  const labelList& pointToGlobal() const
344  {
345  return pointToGlobal_;
346  }
347 
348  //- Local points that are unique
349  const labelList& uniquePointMap() const
350  {
351  return uniquePointMap_;
352  }
353 
354 
355 
356 
357  // Other
358 
359  //- Update for new mesh
360  void correct();
361 
362  //- When exporting faceZones, check if a given face has to be included
363  // or not (i.e. faces on processor boundaries)
364  bool faceToBeIncluded(const label faceI) const;
365 
366  //- Helper to cause barrier. Necessary on Quadrics.
367  static void barrier();
368 
369 
370  // I-O
371 
372  void write
373  (
374  const fileName& postProcPath,
375  const word& prepend,
376  const label timeIndex,
377  const bool meshMoving,
378  Ostream& ensightCaseFile
379  ) const;
380 
381 };
382 
383 
384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385 
386 } // End namespace Foam
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 #endif
391 
392 // ************************************************************************* //
cellShapes
const cellShapeList & cellShapes
Definition: getFieldScalar.H:35
Foam::ensightMesh::writeAllNSided
void writeAllNSided(const labelList &prims, const label nPrims, const faceList &patchFaces, ensightStream &ensightGeometryFile) const
Foam::ensightStream
Abstract base class for writing Ensight data.
Definition: ensightStream.H:50
Foam::ensightMesh
Definition: ensightMesh.H:62
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
Foam::ensightMesh::writeAllPoints
void writeAllPoints(const label ensightPartI, const word &ensightPartName, const pointField &uniquePoints, const label nPoints, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::faceZoneNames
const wordHashSet & faceZoneNames() const
Definition: ensightMesh.H:316
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::ensightMesh::meshCellSets_
cellSets meshCellSets_
Definition: ensightMesh.H:105
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
HashTable.H
Foam::ensightMesh::write
void write(const fileName &postProcPath, const word &prepend, const label timeIndex, const bool meshMoving, Ostream &ensightCaseFile) const
scalarField.H
Foam::ensightMesh::pointToGlobal
const labelList & pointToGlobal() const
From mesh point to global merged point.
Definition: ensightMesh.H:342
Foam::ensightMesh::correct
void correct()
Update for new mesh.
cellShapeList.H
Foam::ensightMesh::mesh_
const fvMesh & mesh_
Reference to the OpenFOAM mesh.
Definition: ensightMesh.H:86
Foam::ensightMesh::faceZoneFaceSets
const List< faceSets > & faceZoneFaceSets() const
Definition: ensightMesh.H:311
Foam::ensightMesh::nFacePrimitives::nQuads
label nQuads
Definition: ensightMesh.H:70
Foam::ensightMesh::writeNSidedPoints
void writeNSidedPoints(const faceList &patchFaces, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::mesh
const fvMesh & mesh() const
Definition: ensightMesh.H:281
Foam::ensightMesh::faceToBeIncluded
bool faceToBeIncluded(const label faceI) const
When exporting faceZones, check if a given face has to be included.
patchFaces
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
Definition: extrudeMesh.C:148
Foam::HashSet
A HashTable with keys but without contents.
Definition: HashSet.H:59
Foam::ensightMesh::patches_
const bool patches_
Output selected patches only.
Definition: ensightMesh.H:92
Foam::ensightMesh::uniquePointMap_
labelList uniquePointMap_
Local points that are unique.
Definition: ensightMesh.H:135
Foam::ensightMesh::nFaceZonePrims
const HashTable< nFacePrimitives > & nFaceZonePrims() const
Definition: ensightMesh.H:321
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::ensightMesh::~ensightMesh
~ensightMesh()
Destructor.
Foam::ensightMesh::operator=
void operator=(const ensightMesh &)
Disallow default bitwise assignment.
Foam::ensightMesh::patchNames
const wordHashSet & patchNames() const
Definition: ensightMesh.H:301
Foam::ensightMesh::writeAllPrims
void writeAllPrims(const char *key, const label nPrims, const cellShapeList &cellShapes, ensightStream &ensightGeometryFile) const
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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::ensightMesh::nFacePrimitives
Definition: ensightMesh.H:65
Foam::ensightMesh::nFacePrimitives::nPolys
label nPolys
Definition: ensightMesh.H:71
PackedBoolList.H
Foam::ensightMesh::map
cellShapeList map(const cellShapeList &cellShapes, const labelList &prims, const labelList &pointToGlobal) const
Foam::ensightMesh::writePoints
void writePoints(const scalarField &pointsComponent, ensightStream &ensightGeometryFile) const
faceSets.H
Foam::ensightMesh::writePolysPoints
void writePolysPoints(const labelList &polys, const cellList &cellFaces, const faceList &faces, const labelList &faceOwner, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::writePrims
void writePrims(const cellShapeList &cellShapes, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::writeAllFacePrims
void writeAllFacePrims(const char *key, const labelList &prims, const label nPrims, const faceList &patchFaces, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::writeNSidedNPointsPerFace
void writeNSidedNPointsPerFace(const faceList &patchFaces, ensightStream &ensightGeometryFile) const
cellList.H
Foam::ensightMesh::boundaryFaceSets
const List< faceSets > & boundaryFaceSets() const
Definition: ensightMesh.H:291
Foam::ensightMesh::nPatchPrims_
HashTable< nFacePrimitives > nPatchPrims_
Definition: ensightMesh.H:113
Foam::cellSets
Definition: cellSets.H:44
Foam::ensightMesh::nFacePrimitives::nFacePrimitives
nFacePrimitives()
Definition: ensightMesh.H:73
timeIndex
label timeIndex
Definition: getTimeIndex.H:4
HashSet.H
Foam::ensightMesh::patchPartOffset
label patchPartOffset() const
The ensight part id for the first patch.
Definition: ensightMesh.H:327
Foam::ensightMesh::writeFacePrims
void writeFacePrims(const faceList &patchFaces, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::binary_
const bool binary_
Set binary file output.
Definition: ensightMesh.H:100
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::ensightMesh::pointToGlobal_
labelList pointToGlobal_
From mesh point to global merged point.
Definition: ensightMesh.H:132
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
meshMoving
bool meshMoving
Definition: checkMeshMoving.H:3
Foam::ensightMesh::boundaryFaceToBeIncluded_
PackedBoolList boundaryFaceToBeIncluded_
Per boundary face whether to include or not.
Definition: ensightMesh.H:123
Foam::ensightMesh::boundaryFaceSets_
List< faceSets > boundaryFaceSets_
Definition: ensightMesh.H:107
Foam::ensightMesh::ensightMesh
ensightMesh(const ensightMesh &)
Disallow default bitwise copy construct.
Foam::HashTable
An STL-conforming hash table.
Definition: HashTable.H:61
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::ensightMesh::meshCellSets
const cellSets & meshCellSets() const
Definition: ensightMesh.H:286
Foam::ensightMesh::allPatchNames_
wordList allPatchNames_
Definition: ensightMesh.H:109
Foam::ensightMesh::patchNames_
wordHashSet patchNames_
Definition: ensightMesh.H:111
wordReList.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::ensightMesh::allPatchNames
const wordList & allPatchNames() const
Definition: ensightMesh.H:296
Foam::ensightMesh::patchPartOffset_
label patchPartOffset_
The ensight part id for the first patch.
Definition: ensightMesh.H:103
Foam::ensightMesh::faceZoneNames_
wordHashSet faceZoneNames_
Definition: ensightMesh.H:118
Foam::ensightMesh::patchPatterns_
const wordReList patchPatterns_
Definition: ensightMesh.H:93
Foam::ensightMesh::nFacePrimitives::nTris
label nTris
Definition: ensightMesh.H:69
Foam::ensightMesh::faceZonePatterns_
const wordReList faceZonePatterns_
Definition: ensightMesh.H:97
Foam::ensightMesh::writePolysNFaces
void writePolysNFaces(const labelList &polys, const cellList &cellFaces, ensightStream &ensightGeometryFile) const
Foam::ensightMesh::faceZoneFaceSets_
List< faceSets > faceZoneFaceSets_
Definition: ensightMesh.H:116
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::ensightMesh::writeAllPolys
void writeAllPolys(const labelList &pointToGlobal, ensightStream &ensightGeometryFile) const
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::ensightMesh::writePolysNPointsPerFace
void writePolysNPointsPerFace(const labelList &polys, const cellList &cellFaces, const faceList &faces, ensightStream &ensightGeometryFile) const
cellSets.H
Foam::ensightMesh::nPatchPrims
const HashTable< nFacePrimitives > & nPatchPrims() const
Definition: ensightMesh.H:306
Foam::ensightMesh::globalPointsPtr_
autoPtr< globalIndex > globalPointsPtr_
Global numbering for merged points.
Definition: ensightMesh.H:129
Foam::ensightMesh::globalPoints
const globalIndex & globalPoints() const
Global numbering for merged points.
Definition: ensightMesh.H:336
Foam::ensightMesh::faceZones_
const bool faceZones_
Output selected faceZones.
Definition: ensightMesh.H:96
Foam::ensightMesh::nFaceZonePrims_
HashTable< nFacePrimitives > nFaceZonePrims_
Definition: ensightMesh.H:120
Foam::ensightMesh::barrier
static void barrier()
Helper to cause barrier. Necessary on Quadrics.
Foam::ensightMesh::uniquePointMap
const labelList & uniquePointMap() const
Local points that are unique.
Definition: ensightMesh.H:348
Foam::ensightMesh::noPatches_
const bool noPatches_
Suppress patches.
Definition: ensightMesh.H:89