Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToEnsight / ensightMesh.H
blobda43cb5322f210171153446a72b7eeda03e5eec6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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 "fvMesh.H"
42 #include "OFstream.H"
43 #include <fstream>
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 class fvMesh;
51 class argList;
53 /*---------------------------------------------------------------------------*\
54                            Class ensightMesh Declaration
55 \*---------------------------------------------------------------------------*/
57 class ensightMesh
59 public:
60         class nFacePrimitives
61         {
62         public:
64             label nPoints;
65             label nTris;
66             label nQuads;
67             label nPolys;
69             nFacePrimitives()
70             :
71                 nPoints(0),
72                 nTris(0),
73                 nQuads(0),
74                 nPolys(0)
75             {}
76         };
78 private:
80     // Private data
82         //- Reference to the FOAM mesh
83         const fvMesh& mesh_;
85         //- Set binary file output
86         bool binary_;
88         //- The ensight part id for the first patch
89         label patchPartOffset_;
91         cellSets meshCellSets_;
93         List<faceSets> boundaryFaceSets_;
95         wordList allPatchNames_;
97         List<labelList> allPatchProcs_;
99         wordHashSet patchNames_;
101         HashTable<nFacePrimitives> nPatchPrims_;
104     // Private Member Functions
106         //- Disallow default bitwise copy construct
107         ensightMesh(const ensightMesh&);
109         //- Disallow default bitwise assignment
110         void operator=(const ensightMesh&);
112         void writePoints
113         (
114             const scalarField& pointsComponent,
115             OFstream& ensightGeometryFile
116         ) const;
118         cellShapeList ensMap
119         (
120             const cellShapeList& cellShapes,
121             const labelList& prims
122         ) const;
124         cellShapeList ensMap
125         (
126             const cellShapeList& cellShapes,
127             const labelList& hexes,
128             const labelList& wedges
129         ) const;
131         void writePrims
132         (
133             const cellShapeList& cellShapes,
134             const label pointOffset,
135             OFstream& ensightGeometryFile
136         ) const;
138         void writePolysNFaces
139         (
140             const labelList& polys,
141             const cellList& cellFaces,
142             OFstream& ensightGeometryFile
143         ) const;
145         void writePolysNPointsPerFace
146         (
147             const labelList& polys,
148             const cellList& cellFaces,
149             const faceList& faces,
150             OFstream& ensightGeometryFile
151         ) const;
153         void writePolysPoints
154         (
155             const labelList& polys,
156             const cellList& cellFaces,
157             const faceList& faces,
158             const label pointOffset,
159             OFstream& ensightGeometryFile
160         ) const;
162         void writeAllPolys
163         (
164             const labelList& pointOffsets,
165             OFstream& ensightGeometryFile
166         ) const;
168         void writeAllPrims
169         (
170             const char* key,
171             const label nPrims,
172             const cellShapeList& cellShapes,
173             const labelList& pointOffsets,
174             OFstream& ensightGeometryFile
175         ) const;
177         void writeFacePrims
178         (
179             const faceList& patchFaces,
180             const label pointOffset,
181             OFstream& ensightGeometryFile
182         ) const;
184         faceList ensMap
185         (
186             const faceList& patchFaces,
187             const labelList& prims
188         ) const;
190         void writeAllFacePrims
191         (
192             const char* key,
193             const labelList& prims,
194             const label nPrims,
195             const faceList& patchFaces,
196             const labelList& pointOffsets,
197             const labelList& patchProcessors,
198             OFstream& ensightGeometryFile
199         ) const;
201         void writeNSidedNPointsPerFace
202         (
203             const faceList& patchFaces,
204             OFstream& ensightGeometryFile
205         ) const;
207         void writeNSidedPoints
208         (
209             const faceList& patchFaces,
210             const label pointOffset,
211             OFstream& ensightGeometryFile
212         ) const;
214         void writeAllNSided
215         (
216             const labelList& prims,
217             const label nPrims,
218             const faceList& patchFaces,
219             const labelList& pointOffsets,
220             const labelList& patchProcessors,
221             OFstream& ensightGeometryFile
222         ) const;
224         void writeAscii
225         (
226             const fileName& postProcPath,
227             const word& prepend,
228             const label timeIndex,
229             Ostream& ensightCaseFile
230         ) const;
232         void writeBinary
233         (
234             const fileName& postProcPath,
235             const word& prepend,
236             const label timeIndex,
237             Ostream& ensightCaseFile
238         ) const;
240         void writePrimsBinary
241         (
242             const cellShapeList& cellShapes,
243             const label pointOffset,
244             std::ofstream& ensightGeometryFile
245         ) const;
247         void writeAllPrimsBinary
248         (
249             const char* key,
250             const label nPrims,
251             const cellShapeList& cellShapes,
252             const labelList& pointOffsets,
253             std::ofstream& ensightGeometryFile
254         ) const;
256         void writePolysNFacesBinary
257         (
258             const labelList& polys,
259             const cellList& cellFaces,
260             std::ofstream& ensightGeometryFile
261         ) const;
263         void writePolysNPointsPerFaceBinary
264         (
265             const labelList& polys,
266             const cellList& cellFaces,
267             const faceList& faces,
268             std::ofstream& ensightGeometryFile
269         ) const;
271         void writePolysPointsBinary
272         (
273             const labelList& polys,
274             const cellList& cellFaces,
275             const faceList& faces,
276             const label pointOffset,
277             std::ofstream& ensightGeometryFile
278         ) const;
280         void writeAllPolysBinary
281         (
282             const labelList& pointOffsets,
283             std::ofstream& ensightGeometryFile
284         ) const;
286         void writeAllFacePrimsBinary
287         (
288             const char* key,
289             const labelList& prims,
290             const label nPrims,
291             const faceList& patchFaces,
292             const labelList& pointOffsets,
293             const labelList& patchProcessors,
294             std::ofstream& ensightGeometryFile
295         ) const;
297         void writeFacePrimsBinary
298         (
299             const faceList& patchFaces,
300             const label pointOffset,
301             std::ofstream& ensightGeometryFile
302         ) const;
304         void writeNSidedPointsBinary
305         (
306             const faceList& patchFaces,
307             const label pointOffset,
308             std::ofstream& ensightGeometryFile
309         ) const;
311         void writeNSidedNPointsPerFaceBinary
312         (
313             const faceList& patchFaces,
314             std::ofstream& ensightGeometryFile
315         ) const;
317         void writeAllNSidedBinary
318         (
319             const labelList& prims,
320             const label nPrims,
321             const faceList& patchFaces,
322             const labelList& pointOffsets,
323             const labelList& patchProcessors,
324             std::ofstream& ensightGeometryFile
325         ) const;
327 public:
329     // Constructors
331         //- Construct from fvMesh
332         ensightMesh(const fvMesh&, const argList& args, const bool binary);
335     //- Destructor
336     ~ensightMesh();
339     // Member Functions
341         // Access
343             const fvMesh& mesh() const
344             {
345                 return mesh_;
346             }
348             const cellSets& meshCellSets() const
349             {
350                 return meshCellSets_;
351             }
353             const List<faceSets>& boundaryFaceSets() const
354             {
355                 return boundaryFaceSets_;
356             }
358             const wordList& allPatchNames() const
359             {
360                 return allPatchNames_;
361             }
363             const List<labelList>& allPatchProcs() const
364             {
365                 return allPatchProcs_;
366             }
368             const wordHashSet& patchNames() const
369             {
370                 return patchNames_;
371             }
373             const HashTable<nFacePrimitives>& nPatchPrims() const
374             {
375                 return nPatchPrims_;
376             }
378             //- The ensight part id for the first patch
379             label patchPartOffset() const
380             {
381                 return patchPartOffset_;
382             }
385     // I-O
387         void write
388         (
389             const fileName& postProcPath,
390             const word& prepend,
391             const label timeIndex,
392             Ostream& ensightCaseFile
393         ) const;
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
399 } // End namespace Foam
401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
403 #endif
405 // ************************************************************************* //