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-2016 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  //- 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 
154  cellShapeList map
155  (
156  const cellShapeList& cellShapes,
157  const labelList& prims,
158  const labelList& pointToGlobal
159  ) const;
160 
161  cellShapeList map
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 
182  void writePolysNPointsPerFace
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 
228  void writeNSidedNPointsPerFace
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
282  const fvMesh& mesh() const
283  {
284  return mesh_;
285  }
287  const cellSets& meshCellSets() const
288  {
289  return meshCellSets_;
290  }
292  const List<faceSets>& boundaryFaceSets() const
293  {
294  return boundaryFaceSets_;
295  }
297  const wordList& allPatchNames() const
298  {
299  return allPatchNames_;
300  }
302  const wordHashSet& patchNames() const
303  {
304  return patchNames_;
305  }
308  {
309  return nPatchPrims_;
310  }
312  const List<faceSets>& faceZoneFaceSets() const
313  {
314  return faceZoneFaceSets_;
315  }
317  const wordHashSet& faceZoneNames() const
318  {
319  return faceZoneNames_;
320  }
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 // ************************************************************************* //
void write(const fileName &postProcPath, const word &prepend, const label timeIndex, const bool meshMoving, Ostream &ensightCaseFile) const
A HashTable with keys but without contents.
Definition: HashSet.H:59
const List< faceSets > & faceZoneFaceSets() const
Definition: ensightMesh.H:311
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
const cellSets & meshCellSets() const
Definition: ensightMesh.H:286
A class for handling file names.
Definition: fileName.H:69
bool faceToBeIncluded(const label facei) const
When exporting faceZones, check if a given face has to be included.
const labelList & uniquePointMap() const
Local points that are unique.
Definition: ensightMesh.H:348
~ensightMesh()
Destructor.
Abstract base class for writing Ensight data.
Definition: ensightStream.H:50
patches[0]
const HashTable< nFacePrimitives > & nFaceZonePrims() const
Definition: ensightMesh.H:321
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
label patchPartOffset() const
The ensight part id for the first patch.
Definition: ensightMesh.H:327
const List< faceSets > & boundaryFaceSets() const
Definition: ensightMesh.H:291
A class for handling words, derived from string.
Definition: word.H:59
label nPoints
const cellShapeList & cellShapes
const HashTable< nFacePrimitives > & nPatchPrims() const
Definition: ensightMesh.H:306
const wordHashSet & faceZoneNames() const
Definition: ensightMesh.H:316
An STL-conforming hash table.
Definition: HashTable.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const fvMesh & mesh() const
Definition: ensightMesh.H:281
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
const wordHashSet & patchNames() const
Definition: ensightMesh.H:301
label timeIndex
Definition: getTimeIndex.H:4
const wordList & allPatchNames() const
Definition: ensightMesh.H:296
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
const labelList & pointToGlobal() const
From mesh point to global merged point.
Definition: ensightMesh.H:342
const globalIndex & globalPoints() const
Global numbering for merged points.
Definition: ensightMesh.H:336
Namespace for OpenFOAM.
bool meshMoving