FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

DimensionedFieldIO.C

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-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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "DimensionedField.H"
00027 #include <OpenFOAM/IOstreams.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00035 
00036 template<class Type, class GeoMesh>
00037 void DimensionedField<Type, GeoMesh>::readField
00038 (
00039     const dictionary& fieldDict,
00040     const word& fieldDictEntry
00041 )
00042 {
00043     dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions")));
00044 
00045     Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_));
00046     this->transfer(f);
00047 }
00048 
00049 
00050 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00051 
00052 template<class Type, class GeoMesh>
00053 DimensionedField<Type, GeoMesh>::DimensionedField
00054 (
00055     const IOobject& io,
00056     const Mesh& mesh,
00057     const word& fieldDictEntry
00058 )
00059 :
00060     regIOobject(io),
00061     Field<Type>(0),
00062     mesh_(mesh),
00063     dimensions_(dimless)
00064 {
00065     readField(dictionary(readStream(typeName)), fieldDictEntry);
00066 }
00067 
00068 
00069 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00070 
00071 template<class Type, class GeoMesh>
00072 bool DimensionedField<Type, GeoMesh>::writeData
00073 (
00074     Ostream& os,
00075     const word& fieldDictEntry
00076 ) const
00077 {
00078     os.writeKeyword("dimensions") << dimensions() << token::END_STATEMENT
00079         << nl << nl;
00080 
00081     Field<Type>::writeEntry(fieldDictEntry, os);
00082 
00083     // Check state of Ostream
00084     os.check
00085     (
00086         "bool DimensionedField<Type, GeoMesh>::writeData"
00087         "(Ostream& os, const word& fieldDictEntry) const"
00088     );
00089 
00090     return (os.good());
00091 }
00092 
00093 
00094 template<class Type, class GeoMesh>
00095 bool DimensionedField<Type, GeoMesh>::writeData(Ostream& os) const
00096 {
00097     return writeData(os, "value");
00098 }
00099 
00100 
00101 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00102 
00103 template<class Type, class GeoMesh>
00104 Ostream& operator<<(Ostream& os, const DimensionedField<Type, GeoMesh>& df)
00105 {
00106     df.writeData(os);
00107 
00108     return os;
00109 }
00110 
00111 
00112 template<class Type, class GeoMesh>
00113 Ostream& operator<<
00114 (
00115     Ostream& os,
00116     const tmp<DimensionedField<Type, GeoMesh> >& tdf
00117 )
00118 {
00119     tdf().writeData(os);
00120     tdf.clear();
00121 
00122     return os;
00123 }
00124 
00125 
00126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00127 
00128 } // End namespace Foam
00129 
00130 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines