00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::ensightFile 00026 00027 Description 00028 Ensight output with specialized write() for strings, integers and floats. 00029 Correctly handles binary write as well. 00030 00031 \*---------------------------------------------------------------------------*/ 00032 00033 #ifndef ensightFile_H 00034 #define ensightFile_H 00035 00036 #include <OpenFOAM/OFstream.H> 00037 #include <OpenFOAM/IOstream.H> 00038 00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00040 00041 namespace Foam 00042 { 00043 00044 /*---------------------------------------------------------------------------*\ 00045 Class ensightFile Declaration 00046 \*---------------------------------------------------------------------------*/ 00047 00048 class ensightFile 00049 : 00050 public OFstream 00051 { 00052 // Private data 00053 00054 //- allow undef in results 00055 static bool allowUndef_; 00056 00057 //- value to represent undef in results 00058 static scalar undefValue_; 00059 00060 00061 // Private member functions 00062 00063 //- Disallow default bitwise assignment 00064 void operator=(const ensightFile&); 00065 00066 //- Disallow default copy constructor 00067 ensightFile(const ensightFile&); 00068 00069 00070 public: 00071 00072 // Constructors 00073 00074 //- Construct from pathname 00075 ensightFile 00076 ( 00077 const fileName& pathname, 00078 IOstream::streamFormat format=IOstream::BINARY 00079 ); 00080 00081 00082 // Destructor 00083 ~ensightFile(); 00084 00085 00086 // Access 00087 00088 //- Return setting for whether 'undef' values are allowed in results 00089 static bool allowUndef(); 00090 00091 //- '*' mask appropriate for subDir 00092 static string mask(); 00093 00094 //- consistent zero-padded numbers for subdirectories 00095 static string subDir(const label); 00096 00097 00098 // Edit 00099 00100 static bool allowUndef(bool); 00101 00102 //- Assign the value to represent undef in the results 00103 // Returns the previous value 00104 // NB: do not use values larger than floatScalarVGREAT 00105 static scalar undefValue(const scalar&); 00106 00107 00108 // Output 00109 00110 //- binary write 00111 virtual Ostream& write(const char* buf, std::streamsize count); 00112 00113 //- write element keyword with trailing newline, optionally with undef 00114 virtual Ostream& writeKeyword(const string& key); 00115 00116 //- write "C Binary" for binary files (eg, geometry/measured) 00117 Ostream& writeBinaryHeader(); 00118 00119 //- write undef value 00120 Ostream& writeUndef(); 00121 00122 //- write string as "%80s" or as binary 00123 Ostream& write(const string& value); 00124 00125 //- write integer as "%10d" or as binary 00126 Ostream& write(const label& value); 00127 00128 //- write integer with specified width or as binary 00129 Ostream& write(const label& value, const label fieldWidth); 00130 00131 //- write float as "%12.5e" or as binary 00132 Ostream& write(const scalar& value); 00133 00134 //- Add carriage return to ascii stream 00135 void newline(); 00136 }; 00137 00138 00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00140 00141 } // End namespace Foam 00142 00143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00144 00145 #endif 00146 00147 // ************************ vim: set sw=4 sts=4 et: ************************ //