initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / conversion / ensight / file / ensightFile.H
blob86979dfd4e55a39aec73f258284c4708061bd776
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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::ensightFile
28 Description
29     Ensight output with specialized write() for strings, integers and floats.
30     Correctly handles binary write as well.
32 \*---------------------------------------------------------------------------*/
34 #ifndef ensightFile_H
35 #define ensightFile_H
37 #include "OFstream.H"
38 #include "IOstream.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 /*---------------------------------------------------------------------------*\
46                         Class ensightFile Declaration
47 \*---------------------------------------------------------------------------*/
49 class ensightFile
51     public OFstream
53     // Private data
55         //- allow undef in results
56         static bool allowUndef_;
58         //- value to represent undef in results
59         static scalar undefValue_;
62     // Private member functions
64         //- Disallow default bitwise assignment
65         void operator=(const ensightFile&);
67         //- Disallow default copy constructor
68         ensightFile(const ensightFile&);
71 public:
73     // Constructors
75         //- Construct from pathname
76         ensightFile
77         (
78             const fileName& pathname,
79             IOstream::streamFormat format=IOstream::BINARY
80         );
83     // Destructor
84     ~ensightFile();
87     // Access
89         //- Return setting for whether 'undef' values are allowed in results
90         static bool allowUndef();
92         //- '*' mask appropriate for subDir
93         static string mask();
95         //- consistent zero-padded numbers for subdirectories
96         static string subDir(const label);
99     // Edit
101         static bool allowUndef(bool);
103         //- Assign the value to represent undef in the results
104         //  Returns the previous value
105         //  NB: do not use values larger than floatScalarVGREAT
106         static scalar undefValue(const scalar&);
109     // Output
111         //- binary write
112         virtual Ostream& write(const char* buf, std::streamsize count);
114         //- write element keyword with trailing newline, optionally with undef
115         virtual Ostream& writeKeyword(const string& key);
117         //- write "C Binary" for binary files (eg, geometry/measured)
118         Ostream& writeBinaryHeader();
120         //- write undef value
121         Ostream& writeUndef();
123         //- write string as "%80s" or as binary
124         Ostream& write(const string& value);
126         //- write integer as "%10d" or as binary
127         Ostream& write(const label& value);
129         //- write integer with specified width or as binary
130         Ostream& write(const label& value, const label fieldWidth);
132         //- write float as "%12.5e" or as binary
133         Ostream& write(const scalar& value);
135         //- Add carriage return to ascii stream
136         void newline();
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 } // End namespace Foam
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 #endif
148 // ************************************************************************* //