FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/HashTable.H>
40 #include <OpenFOAM/HashSet.H>
41 #include <finiteVolume/fvMesh.H>
42 #include <OpenFOAM/OFstream.H>
43 #include <fstream>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 class fvMesh;
51 class argList;
52 
53 /*---------------------------------------------------------------------------*\
54  Class ensightMesh Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 {
59 public:
61  {
62  public:
63 
64  label nPoints;
65  label nTris;
66  label nQuads;
67  label nPolys;
68 
70  :
71  nPoints(0),
72  nTris(0),
73  nQuads(0),
74  nPolys(0)
75  {}
76  };
77 
78 private:
79 
80  // Private data
81 
82  //- Reference to the OpenFOAM mesh
83  const fvMesh& mesh_;
84 
85  //- Set binary file output
86  bool binary_;
87 
88  //- The ensight part id for the first patch
89  label patchPartOffset_;
90 
91  cellSets meshCellSets_;
92 
93  List<faceSets> boundaryFaceSets_;
94 
95  wordList allPatchNames_;
96 
97  List<labelList> allPatchProcs_;
98 
99  wordHashSet patchNames_;
100 
101  HashTable<nFacePrimitives> nPatchPrims_;
102 
103 
104  // Private Member Functions
105 
106  //- Disallow default bitwise copy construct
107  ensightMesh(const ensightMesh&);
108 
109  //- Disallow default bitwise assignment
110  void operator=(const ensightMesh&);
111 
112  void writePoints
113  (
114  const scalarField& pointsComponent,
115  OFstream& ensightGeometryFile
116  ) const;
117 
118  cellShapeList map
119  (
120  const cellShapeList& cellShapes,
121  const labelList& prims
122  ) const;
123 
124  cellShapeList map
125  (
126  const cellShapeList& cellShapes,
127  const labelList& hexes,
128  const labelList& wedges
129  ) const;
130 
131  void writePrims
132  (
133  const cellShapeList& cellShapes,
134  const label pointOffset,
135  OFstream& ensightGeometryFile
136  ) const;
137 
138  void writePolysNFaces
139  (
140  const labelList& polys,
141  const cellList& cellFaces,
142  OFstream& ensightGeometryFile
143  ) const;
144 
145  void writePolysNPointsPerFace
146  (
147  const labelList& polys,
148  const cellList& cellFaces,
149  const faceList& faces,
150  OFstream& ensightGeometryFile
151  ) const;
152 
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;
161 
162  void writeAllPolys
163  (
164  const labelList& pointOffsets,
165  OFstream& ensightGeometryFile
166  ) const;
167 
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;
176 
177  void writeFacePrims
178  (
179  const faceList& patchFaces,
180  const label pointOffset,
181  OFstream& ensightGeometryFile
182  ) const;
183 
184  faceList map
185  (
186  const faceList& patchFaces,
187  const labelList& prims
188  ) const;
189 
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;
200 
201  void writeNSidedNPointsPerFace
202  (
203  const faceList& patchFaces,
204  OFstream& ensightGeometryFile
205  ) const;
206 
207  void writeNSidedPoints
208  (
209  const faceList& patchFaces,
210  const label pointOffset,
211  OFstream& ensightGeometryFile
212  ) const;
213 
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;
223 
224  void writeAscii
225  (
226  const fileName& postProcPath,
227  const word& prepend,
228  const label timeIndex,
229  Ostream& ensightCaseFile
230  ) const;
231 
232  void writeBinary
233  (
234  const fileName& postProcPath,
235  const word& prepend,
236  const label timeIndex,
237  Ostream& ensightCaseFile
238  ) const;
239 
240  void writePrimsBinary
241  (
242  const cellShapeList& cellShapes,
243  const label pointOffset,
244  std::ofstream& ensightGeometryFile
245  ) const;
246 
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;
255 
256  void writePolysNFacesBinary
257  (
258  const labelList& polys,
259  const cellList& cellFaces,
260  std::ofstream& ensightGeometryFile
261  ) const;
262 
263  void writePolysNPointsPerFaceBinary
264  (
265  const labelList& polys,
266  const cellList& cellFaces,
267  const faceList& faces,
268  std::ofstream& ensightGeometryFile
269  ) const;
270 
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;
279 
280  void writeAllPolysBinary
281  (
282  const labelList& pointOffsets,
283  std::ofstream& ensightGeometryFile
284  ) const;
285 
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;
296 
297  void writeFacePrimsBinary
298  (
299  const faceList& patchFaces,
300  const label pointOffset,
301  std::ofstream& ensightGeometryFile
302  ) const;
303 
304  void writeNSidedPointsBinary
305  (
306  const faceList& patchFaces,
307  const label pointOffset,
308  std::ofstream& ensightGeometryFile
309  ) const;
310 
311  void writeNSidedNPointsPerFaceBinary
312  (
313  const faceList& patchFaces,
314  std::ofstream& ensightGeometryFile
315  ) const;
316 
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;
326 
327 public:
328 
329  // Constructors
330 
331  //- Construct from fvMesh
332  ensightMesh(const fvMesh&, const argList& args, const bool binary);
333 
334 
335  //- Destructor
336  ~ensightMesh();
337 
338 
339  // Member Functions
340 
341  // Access
342 
343  const fvMesh& mesh() const
344  {
345  return mesh_;
346  }
347 
348  const cellSets& meshCellSets() const
349  {
350  return meshCellSets_;
351  }
352 
354  {
355  return boundaryFaceSets_;
356  }
357 
358  const wordList& allPatchNames() const
359  {
360  return allPatchNames_;
361  }
362 
364  {
365  return allPatchProcs_;
366  }
367 
368  const wordHashSet& patchNames() const
369  {
370  return patchNames_;
371  }
372 
374  {
375  return nPatchPrims_;
376  }
377 
378  //- The ensight part id for the first patch
379  label patchPartOffset() const
380  {
381  return patchPartOffset_;
382  }
383 
384 
385  // I-O
386 
387  void write
388  (
389  const fileName& postProcPath,
390  const word& prepend,
391  const label timeIndex,
392  Ostream& ensightCaseFile
393  ) const;
394 };
395 
396 
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398 
399 } // End namespace Foam
400 
401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402 
403 #endif
404 
405 // ************************ vim: set sw=4 sts=4 et: ************************ //