1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 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
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 \*---------------------------------------------------------------------------*/
27 #include "ensightFile.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 bool Foam::ensightFile::allowUndef_ = false;
33 Foam::scalar Foam::ensightFile::undefValue_ = Foam::floatScalarVGREAT;
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 Foam::ensightFile::ensightFile
39 const fileName& pathname,
40 IOstream::streamFormat format
43 OFstream(pathname, format)
45 // ascii formatting specs
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 Foam::ensightFile::~ensightFile()
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 bool Foam::ensightFile::allowUndef()
69 bool Foam::ensightFile::allowUndef(bool value)
71 bool old = allowUndef_;
77 Foam::scalar Foam::ensightFile::undefValue(const scalar& value)
82 scalar old = undefValue_;
88 Foam::Ostream& Foam::ensightFile::write
94 stream().write(buf, count);
99 Foam::Ostream& Foam::ensightFile::write(const string& value)
103 for (string::size_type i = 0; i < 80; ++i)
108 string::size_type n = value.size();
114 for (string::size_type i = 0; i < n; ++i)
119 if (format() == IOstream::BINARY)
123 reinterpret_cast<char const *>(buf),
136 Foam::Ostream& Foam::ensightFile::write(const label& value)
138 if (format() == IOstream::BINARY)
140 unsigned int ivalue(value);
144 reinterpret_cast<char const *>(&ivalue),
158 Foam::Ostream& Foam::ensightFile::write
161 const label fieldWidth
164 if (format() == IOstream::BINARY)
166 unsigned int ivalue(value);
170 reinterpret_cast<char const *>(&ivalue),
176 stream().width(fieldWidth);
184 Foam::Ostream& Foam::ensightFile::write(const scalar& value)
186 if (format() == IOstream::BINARY)
192 reinterpret_cast<char const *>(&fvalue),
206 void Foam::ensightFile::newline()
208 if (format() == IOstream::ASCII)
215 Foam::Ostream& Foam::ensightFile::writeUndef()
222 Foam::Ostream& Foam::ensightFile::writeKeyword(const string& key)
226 write(key + " undef");
240 Foam::Ostream& Foam::ensightFile::writeBinaryHeader()
242 if (format() == IOstream::BINARY)
251 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
253 Foam::string Foam::ensightFile::mask()
255 char buf[16] = "********";
260 Foam::string Foam::ensightFile::subDir(const label n)
264 sprintf(buf, "%08d", n);
269 // ************************************************************************* //