1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 \*---------------------------------------------------------------------------*/
26 #include "ensightFile.H"
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 bool Foam::ensightFile::allowUndef_ = false;
32 Foam::scalar Foam::ensightFile::undefValue_ = Foam::floatScalarVGREAT;
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 Foam::ensightFile::ensightFile
38 const fileName& pathname,
39 IOstream::streamFormat format
42 OFstream(pathname, format)
44 // ascii formatting specs
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 Foam::ensightFile::~ensightFile()
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 bool Foam::ensightFile::allowUndef()
68 bool Foam::ensightFile::allowUndef(bool value)
70 bool old = allowUndef_;
76 Foam::scalar Foam::ensightFile::undefValue(const scalar value)
81 scalar old = undefValue_;
87 Foam::Ostream& Foam::ensightFile::write
93 stdStream().write(buf, count);
98 Foam::Ostream& Foam::ensightFile::write(const string& value)
102 for (string::size_type i = 0; i < 80; ++i)
107 string::size_type n = value.size();
113 for (string::size_type i = 0; i < n; ++i)
118 if (format() == IOstream::BINARY)
122 reinterpret_cast<char const *>(buf),
135 Foam::Ostream& Foam::ensightFile::write(const label value)
137 if (format() == IOstream::BINARY)
139 unsigned int ivalue(value);
143 reinterpret_cast<char const *>(&ivalue),
149 stdStream().width(10);
150 stdStream() << value;
157 Foam::Ostream& Foam::ensightFile::write
160 const label fieldWidth
163 if (format() == IOstream::BINARY)
165 unsigned int ivalue(value);
169 reinterpret_cast<char const *>(&ivalue),
175 stdStream().width(fieldWidth);
176 stdStream() << value;
183 Foam::Ostream& Foam::ensightFile::write(const scalar value)
185 if (format() == IOstream::BINARY)
191 reinterpret_cast<char const *>(&fvalue),
197 stdStream().width(12);
198 stdStream() << value;
205 void Foam::ensightFile::newline()
207 if (format() == IOstream::ASCII)
214 Foam::Ostream& Foam::ensightFile::writeUndef()
221 Foam::Ostream& Foam::ensightFile::writeKeyword(const string& key)
225 write(key + " undef");
239 Foam::Ostream& Foam::ensightFile::writeBinaryHeader()
241 if (format() == IOstream::BINARY)
250 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
252 Foam::string Foam::ensightFile::mask()
254 char buf[16] = "********";
259 Foam::string Foam::ensightFile::subDir(const label n)
263 sprintf(buf, "%08d", n);
268 // ************************************************************************* //