FreeFOAM The Cross-Platform CFD Toolkit
ensightFile.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::ensightFile
26 
27 Description
28  Ensight output with specialized write() for strings, integers and floats.
29  Correctly handles binary write as well.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef ensightFile_H
34 #define ensightFile_H
35 
36 #include <OpenFOAM/OFstream.H>
37 #include <OpenFOAM/IOstream.H>
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 /*---------------------------------------------------------------------------*\
45  Class ensightFile Declaration
46 \*---------------------------------------------------------------------------*/
47 
49 :
50  public OFstream
51 {
52  // Private data
53 
54  //- allow undef in results
55  static bool allowUndef_;
56 
57  //- value to represent undef in results
58  static scalar undefValue_;
59 
60 
61  // Private member functions
62 
63  //- Disallow default bitwise assignment
64  void operator=(const ensightFile&);
65 
66  //- Disallow default copy constructor
67  ensightFile(const ensightFile&);
68 
69 
70 public:
71 
72  // Constructors
73 
74  //- Construct from pathname
76  (
77  const fileName& pathname,
79  );
80 
81 
82  // Destructor
83  ~ensightFile();
84 
85 
86  // Access
87 
88  //- Return setting for whether 'undef' values are allowed in results
89  static bool allowUndef();
90 
91  //- '*' mask appropriate for subDir
92  static string mask();
93 
94  //- consistent zero-padded numbers for subdirectories
95  static string subDir(const label);
96 
97 
98  // Edit
99 
100  static bool allowUndef(bool);
101 
102  //- Assign the value to represent undef in the results
103  // Returns the previous value
104  // NB: do not use values larger than floatScalarVGREAT
105  static scalar undefValue(const scalar&);
106 
107 
108  // Output
109 
110  //- binary write
111  virtual Ostream& write(const char* buf, std::streamsize count);
112 
113  //- write element keyword with trailing newline, optionally with undef
114  virtual Ostream& writeKeyword(const string& key);
115 
116  //- write "C Binary" for binary files (eg, geometry/measured)
118 
119  //- write undef value
120  Ostream& writeUndef();
121 
122  //- write string as "%80s" or as binary
123  Ostream& write(const string& value);
124 
125  //- write integer as "%10d" or as binary
126  Ostream& write(const label& value);
127 
128  //- write integer with specified width or as binary
129  Ostream& write(const label& value, const label fieldWidth);
130 
131  //- write float as "%12.5e" or as binary
132  Ostream& write(const scalar& value);
133 
134  //- Add carriage return to ascii stream
135  void newline();
136 };
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 } // End namespace Foam
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #endif
146 
147 // ************************ vim: set sw=4 sts=4 et: ************************ //