BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / utilities / postProcessing / dataConversion / foamToEnsight / ensightMesh.H
blob6d860dfc9176b741a2bab844db5bb375cc046953
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::ensightMesh
27 Description
29 SourceFiles
30     ensightMesh.C
32 \*---------------------------------------------------------------------------*/
34 #ifndef ensightMesh_H
35 #define ensightMesh_H
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"
47 #include <fstream>
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
54 class fvMesh;
55 class argList;
56 class globalIndex;
57 class ensightStream;
59 /*---------------------------------------------------------------------------*\
60                            Class ensightMesh Declaration
61 \*---------------------------------------------------------------------------*/
63 class ensightMesh
65 public:
66         class nFacePrimitives
67         {
68         public:
70             label nTris;
71             label nQuads;
72             label nPolys;
74             nFacePrimitives()
75             :
76                 nTris(0),
77                 nQuads(0),
78                 nPolys(0)
79             {}
80         };
82 private:
84     // Private data
86         //- Reference to the OpenFOAM mesh
87         const fvMesh& mesh_;
89         //- Suppress patches
90         const bool noPatches_;
92         //- Output selected patches only
93         const bool patches_;
94         const wordReList patchPatterns_;
96         //- Output selected faceZones
97         const bool faceZones_;
98         const wordReList faceZonePatterns_;
100         //- Set binary file output
101         const bool binary_;
103         //- The ensight part id for the first patch
104         label patchPartOffset_;
106         cellSets meshCellSets_;
108         List<faceSets> boundaryFaceSets_;
110         wordList allPatchNames_;
112         wordHashSet patchNames_;
114         HashTable<nFacePrimitives> nPatchPrims_;
116         // faceZone - related variables
117         List<faceSets> faceZoneFaceSets_;
119         wordHashSet faceZoneNames_;
121         HashTable<nFacePrimitives> nFaceZonePrims_;
123         //- Per boundary face whether to include or not
124         PackedBoolList boundaryFaceToBeIncluded_;
127         // Parallel merged points
129             //- Global numbering for merged points
130             autoPtr<globalIndex> globalPointsPtr_;
132             //- From mesh point to global merged point
133             labelList pointToGlobal_;
135             //- Local points that are unique
136             labelList uniquePointMap_;
140     // Private Member Functions
142         //- Disallow default bitwise copy construct
143         ensightMesh(const ensightMesh&);
145         //- Disallow default bitwise assignment
146         void operator=(const ensightMesh&);
148         void writePoints
149         (
150             const scalarField& pointsComponent,
151             ensightStream& ensightGeometryFile
152         ) const;
154         cellShapeList map
155         (
156             const cellShapeList& cellShapes,
157             const labelList& prims,
158             const labelList& pointToGlobal
159         ) const;
161         cellShapeList map
162         (
163             const cellShapeList& cellShapes,
164             const labelList& hexes,
165             const labelList& wedges,
166             const labelList& pointToGlobal
167         ) const;
169         void writePrims
170         (
171             const cellShapeList& cellShapes,
172             ensightStream& ensightGeometryFile
173         ) const;
175         void writePolysNFaces
176         (
177             const labelList& polys,
178             const cellList& cellFaces,
179             ensightStream& ensightGeometryFile
180         ) const;
182         void writePolysNPointsPerFace
183         (
184             const labelList& polys,
185             const cellList& cellFaces,
186             const faceList& faces,
187             ensightStream& ensightGeometryFile
188         ) const;
190         void writePolysPoints
191         (
192             const labelList& polys,
193             const cellList& cellFaces,
194             const faceList& faces,
195             ensightStream& ensightGeometryFile
196         ) const;
198         void writeAllPolys
199         (
200             const labelList& pointToGlobal,
201             ensightStream& ensightGeometryFile
202         ) const;
204         void writeAllPrims
205         (
206             const char* key,
207             const label nPrims,
208             const cellShapeList& cellShapes,
209             ensightStream& ensightGeometryFile
210         ) const;
212         void writeFacePrims
213         (
214             const faceList& patchFaces,
215             ensightStream& ensightGeometryFile
216         ) const;
218         void writeAllFacePrims
219         (
220             const char* key,
221             const labelList& prims,
222             const label nPrims,
223             const faceList& patchFaces,
224             ensightStream& ensightGeometryFile
225         ) const;
227         void writeNSidedNPointsPerFace
228         (
229             const faceList& patchFaces,
230             ensightStream& ensightGeometryFile
231         ) const;
233         void writeNSidedPoints
234         (
235             const faceList& patchFaces,
236             ensightStream& ensightGeometryFile
237         ) const;
239         void writeAllNSided
240         (
241             const labelList& prims,
242             const label nPrims,
243             const faceList& patchFaces,
244             ensightStream& ensightGeometryFile
245         ) const;
247         void writeAllInternalPoints
248         (
249             const pointField& uniquePoints,
250             const label nPoints,
251             ensightStream& ensightGeometryFile
252         ) const;
254         void writeAllPatchPoints
255         (
256             label ensightPatchI,
257             const word& patchName,
258             const pointField& uniquePoints,
259             const label nPoints,
260             ensightStream& ensightGeometryFile
261         ) const;
263 public:
265     // Constructors
267         //- Construct from fvMesh
268         ensightMesh
269         (
270             const fvMesh& mesh,
271             const bool noPatches,
272             const bool patches,
273             const wordReList& patchPatterns,
274             const bool faceZones,
275             const wordReList& faceZonePatterns,
276             const bool binary
277         );
280     //- Destructor
281     ~ensightMesh();
284     // Member Functions
286         // Access
288             const fvMesh& mesh() const
289             {
290                 return mesh_;
291             }
293             const cellSets& meshCellSets() const
294             {
295                 return meshCellSets_;
296             }
298             const List<faceSets>& boundaryFaceSets() const
299             {
300                 return boundaryFaceSets_;
301             }
303             const wordList& allPatchNames() const
304             {
305                 return allPatchNames_;
306             }
308             const wordHashSet& patchNames() const
309             {
310                 return patchNames_;
311             }
313             const HashTable<nFacePrimitives>& nPatchPrims() const
314             {
315                 return nPatchPrims_;
316             }
318             const List<faceSets>& faceZoneFaceSets() const
319             {
320                 return faceZoneFaceSets_;
321             }
323             const wordHashSet& faceZoneNames() const
324             {
325                 return faceZoneNames_;
326             }
328             const HashTable<nFacePrimitives>& nFaceZonePrims() const
329             {
330                 return nFaceZonePrims_;
331             }
333             //- The ensight part id for the first patch
334             label patchPartOffset() const
335             {
336                 return patchPartOffset_;
337             }
340         // Parallel point merging
342             //- Global numbering for merged points
343             const globalIndex& globalPoints() const
344             {
345                 return globalPointsPtr_();
346             }
348             //- From mesh point to global merged point
349             const labelList& pointToGlobal() const
350             {
351                 return pointToGlobal_;
352             }
354             //- Local points that are unique
355             const labelList& uniquePointMap() const
356             {
357                 return uniquePointMap_;
358             }
363     // Other
365         //- Update for new mesh
366         void correct();
368         //- When exporting faceZones, check if a given face has to be included
369         //  or not (i.e. faces on processor boundaries)
370         bool faceToBeIncluded(const label faceI) const;
372         //- Helper to cause barrier. Necessary on Quadrics.
373         static void barrier();
376     // I-O
378         void write
379         (
380             const fileName& postProcPath,
381             const word& prepend,
382             const label timeIndex,
383             Ostream& ensightCaseFile
384         ) const;
389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 } // End namespace Foam
393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 #endif
397 // ************************************************************************* //