OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ensightFile.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::ensightFile
00027 
00028 Description
00029     Ensight output with specialized write() for strings, integers and floats.
00030     Correctly handles binary write as well.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #ifndef ensightFile_H
00035 #define ensightFile_H
00036 
00037 #include "OFstream.H"
00038 #include "IOstream.H"
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 /*---------------------------------------------------------------------------*\
00046                         Class ensightFile Declaration
00047 \*---------------------------------------------------------------------------*/
00048 
00049 class ensightFile
00050 :
00051     public OFstream
00052 {
00053     // Private data
00054 
00055         //- allow undef in results
00056         static bool allowUndef_;
00057 
00058         //- value to represent undef in results
00059         static scalar undefValue_;
00060 
00061 
00062     // Private member functions
00063 
00064         //- Disallow default bitwise assignment
00065         void operator=(const ensightFile&);
00066 
00067         //- Disallow default copy constructor
00068         ensightFile(const ensightFile&);
00069 
00070 
00071 public:
00072 
00073     // Constructors
00074 
00075         //- Construct from pathname
00076         ensightFile
00077         (
00078             const fileName& pathname,
00079             IOstream::streamFormat format=IOstream::BINARY
00080         );
00081 
00082 
00083     // Destructor
00084     ~ensightFile();
00085 
00086 
00087     // Access
00088 
00089         //- Return setting for whether 'undef' values are allowed in results
00090         static bool allowUndef();
00091 
00092         //- '*' mask appropriate for subDir
00093         static string mask();
00094 
00095         //- consistent zero-padded numbers for subdirectories
00096         static string subDir(const label);
00097 
00098 
00099     // Edit
00100 
00101         static bool allowUndef(bool);
00102 
00103         //- Assign the value to represent undef in the results
00104         //  Returns the previous value
00105         //  NB: do not use values larger than floatScalarVGREAT
00106         static scalar undefValue(const scalar&);
00107 
00108 
00109     // Output
00110 
00111         //- binary write
00112         virtual Ostream& write(const char* buf, std::streamsize count);
00113 
00114         //- write element keyword with trailing newline, optionally with undef
00115         virtual Ostream& writeKeyword(const string& key);
00116 
00117         //- write "C Binary" for binary files (eg, geometry/measured)
00118         Ostream& writeBinaryHeader();
00119 
00120         //- write undef value
00121         Ostream& writeUndef();
00122 
00123         //- write string as "%80s" or as binary
00124         Ostream& write(const string& value);
00125 
00126         //- write integer as "%10d" or as binary
00127         Ostream& write(const label& value);
00128 
00129         //- write integer with specified width or as binary
00130         Ostream& write(const label& value, const label fieldWidth);
00131 
00132         //- write float as "%12.5e" or as binary
00133         Ostream& write(const scalar& value);
00134 
00135         //- Add carriage return to ascii stream
00136         void newline();
00137 };
00138 
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 } // End namespace Foam
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 #endif
00147 
00148 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd