BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToEnsight / ensightMesh.H
blob1349d34c30231e660eb5cd5c6032415604396b6f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::ensightMesh
28 Description
30 SourceFiles
31     ensightMesh.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef ensightMesh_H
36 #define ensightMesh_H
38 #include "cellSets.H"
39 #include "faceSets.H"
40 #include "HashTable.H"
41 #include "HashSet.H"
42 #include "fvMesh.H"
43 #include "OFstream.H"
44 #include <fstream>
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 class fvMesh;
52 class argList;
54 /*---------------------------------------------------------------------------*\
55                            Class ensightMesh Declaration
56 \*---------------------------------------------------------------------------*/
58 class ensightMesh
60 public:
61         class nFacePrimitives
62         {
63         public:
65             label nPoints;
66             label nTris;
67             label nQuads;
68             label nPolys;
70             nFacePrimitives()
71             :
72                 nPoints(0),
73                 nTris(0),
74                 nQuads(0),
75                 nPolys(0)
76             {}
77         };
79 private:
81     // Private data
83         //- Reference to the OpenFOAM mesh
84         const fvMesh& mesh_;
86         //- Set binary file output
87         bool binary_;
89         //- The ensight part id for the first patch
90         label patchPartOffset_;
92         cellSets meshCellSets_;
94         List<faceSets> boundaryFaceSets_;
96         wordList allPatchNames_;
98         List<labelList> allPatchProcs_;
100         wordHashSet patchNames_;
102         HashTable<nFacePrimitives> nPatchPrims_;
105     // Private Member Functions
107         //- Disallow default bitwise copy construct
108         ensightMesh(const ensightMesh&);
110         //- Disallow default bitwise assignment
111         void operator=(const ensightMesh&);
113         void writePoints
114         (
115             const scalarField& pointsComponent,
116             OFstream& ensightGeometryFile
117         ) const;
119         cellShapeList map
120         (
121             const cellShapeList& cellShapes,
122             const labelList& prims
123         ) const;
125         cellShapeList map
126         (
127             const cellShapeList& cellShapes,
128             const labelList& hexes,
129             const labelList& wedges
130         ) const;
132         void writePrims
133         (
134             const cellShapeList& cellShapes,
135             const label pointOffset,
136             OFstream& ensightGeometryFile
137         ) const;
139         void writePolysNFaces
140         (
141             const labelList& polys,
142             const cellList& cellFaces,
143             OFstream& ensightGeometryFile
144         ) const;
146         void writePolysNPointsPerFace
147         (
148             const labelList& polys,
149             const cellList& cellFaces,
150             const faceList& faces,
151             OFstream& ensightGeometryFile
152         ) const;
154         void writePolysPoints
155         (
156             const labelList& polys,
157             const cellList& cellFaces,
158             const faceList& faces,
159             const label pointOffset,
160             OFstream& ensightGeometryFile
161         ) const;
163         void writeAllPolys
164         (
165             const labelList& pointOffsets,
166             OFstream& ensightGeometryFile
167         ) const;
169         void writeAllPrims
170         (
171             const char* key,
172             const label nPrims,
173             const cellShapeList& cellShapes,
174             const labelList& pointOffsets,
175             OFstream& ensightGeometryFile
176         ) const;
178         void writeFacePrims
179         (
180             const faceList& patchFaces,
181             const label pointOffset,
182             OFstream& ensightGeometryFile
183         ) const;
185         faceList map
186         (
187             const faceList& patchFaces,
188             const labelList& prims
189         ) const;
191         void writeAllFacePrims
192         (
193             const char* key,
194             const labelList& prims,
195             const label nPrims,
196             const faceList& patchFaces,
197             const labelList& pointOffsets,
198             const labelList& patchProcessors,
199             OFstream& ensightGeometryFile
200         ) const;
202         void writeNSidedNPointsPerFace
203         (
204             const faceList& patchFaces,
205             OFstream& ensightGeometryFile
206         ) const;
208         void writeNSidedPoints
209         (
210             const faceList& patchFaces,
211             const label pointOffset,
212             OFstream& ensightGeometryFile
213         ) const;
215         void writeAllNSided
216         (
217             const labelList& prims,
218             const label nPrims,
219             const faceList& patchFaces,
220             const labelList& pointOffsets,
221             const labelList& patchProcessors,
222             OFstream& ensightGeometryFile
223         ) const;
225         void writeAscii
226         (
227             const fileName& postProcPath,
228             const word& prepend,
229             const label timeIndex,
230             Ostream& ensightCaseFile
231         ) const;
233         void writeBinary
234         (
235             const fileName& postProcPath,
236             const word& prepend,
237             const label timeIndex,
238             Ostream& ensightCaseFile
239         ) const;
241         void writePrimsBinary
242         (
243             const cellShapeList& cellShapes,
244             const label pointOffset,
245             std::ofstream& ensightGeometryFile
246         ) const;
248         void writeAllPrimsBinary
249         (
250             const char* key,
251             const label nPrims,
252             const cellShapeList& cellShapes,
253             const labelList& pointOffsets,
254             std::ofstream& ensightGeometryFile
255         ) const;
257         void writePolysNFacesBinary
258         (
259             const labelList& polys,
260             const cellList& cellFaces,
261             std::ofstream& ensightGeometryFile
262         ) const;
264         void writePolysNPointsPerFaceBinary
265         (
266             const labelList& polys,
267             const cellList& cellFaces,
268             const faceList& faces,
269             std::ofstream& ensightGeometryFile
270         ) const;
272         void writePolysPointsBinary
273         (
274             const labelList& polys,
275             const cellList& cellFaces,
276             const faceList& faces,
277             const label pointOffset,
278             std::ofstream& ensightGeometryFile
279         ) const;
281         void writeAllPolysBinary
282         (
283             const labelList& pointOffsets,
284             std::ofstream& ensightGeometryFile
285         ) const;
287         void writeAllFacePrimsBinary
288         (
289             const char* key,
290             const labelList& prims,
291             const label nPrims,
292             const faceList& patchFaces,
293             const labelList& pointOffsets,
294             const labelList& patchProcessors,
295             std::ofstream& ensightGeometryFile
296         ) const;
298         void writeFacePrimsBinary
299         (
300             const faceList& patchFaces,
301             const label pointOffset,
302             std::ofstream& ensightGeometryFile
303         ) const;
305         void writeNSidedPointsBinary
306         (
307             const faceList& patchFaces,
308             const label pointOffset,
309             std::ofstream& ensightGeometryFile
310         ) const;
312         void writeNSidedNPointsPerFaceBinary
313         (
314             const faceList& patchFaces,
315             std::ofstream& ensightGeometryFile
316         ) const;
318         void writeAllNSidedBinary
319         (
320             const labelList& prims,
321             const label nPrims,
322             const faceList& patchFaces,
323             const labelList& pointOffsets,
324             const labelList& patchProcessors,
325             std::ofstream& ensightGeometryFile
326         ) const;
328 public:
330     // Constructors
332         //- Construct from fvMesh
333         ensightMesh(const fvMesh&, const argList& args, const bool binary);
336     //- Destructor
337     ~ensightMesh();
340     // Member Functions
342         // Access
344             const fvMesh& mesh() const
345             {
346                 return mesh_;
347             }
349             const cellSets& meshCellSets() const
350             {
351                 return meshCellSets_;
352             }
354             const List<faceSets>& boundaryFaceSets() const
355             {
356                 return boundaryFaceSets_;
357             }
359             const wordList& allPatchNames() const
360             {
361                 return allPatchNames_;
362             }
364             const List<labelList>& allPatchProcs() const
365             {
366                 return allPatchProcs_;
367             }
369             const wordHashSet& patchNames() const
370             {
371                 return patchNames_;
372             }
374             const HashTable<nFacePrimitives>& nPatchPrims() const
375             {
376                 return nPatchPrims_;
377             }
379             //- The ensight part id for the first patch
380             label patchPartOffset() const
381             {
382                 return patchPartOffset_;
383             }
386     // I-O
388         void write
389         (
390             const fileName& postProcPath,
391             const word& prepend,
392             const label timeIndex,
393             Ostream& ensightCaseFile
394         ) const;
398 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
400 } // End namespace Foam
402 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
404 #endif
406 // ************************************************************************* //