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 "writeFunctions.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 // C++ version of fwrite_str80 from FieldView/uns/write_binary_uns.c
31 // Write padded string of 80 char.
32 bool writeStr80(std::ostream& os, const string& str)
36 memset(cBuf, '\0', 80);
40 strncpy(cBuf, str.c_str(), (len < 80 ? len : 80));
42 os.write(cBuf, 80*sizeof(char));
48 // Write single integer
49 bool writeInt(std::ostream& os, int val1)
51 os.write(reinterpret_cast<char*>(&val1), sizeof(int));
58 bool writeFloat(std::ostream& os, scalar val1)
60 float floatVal = val1;
62 os.write(reinterpret_cast<char*>(&floatVal), sizeof(float));
68 // Debug: write raw bytes
69 void writeBytes(char* start, int nBytes)
71 cout.setf(std::ios::hex, std::ios::basefield);
73 cout<< start << " : ";
75 for (int i = 0; i < nBytes; i++)
77 cout<< " " << start[i];
81 cout.setf(std::ios::dec);
85 // Debug: write wall flags data
86 void writeWallFlags(Ostream& os, label cellI, const labelList& wallFlags)
88 os << "cell " << cellI << " wallsFlags:";
89 forAll(wallFlags, wallFaceI)
91 os << wallFlags[wallFaceI] << ' ';
97 // ************************************************************************* //