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

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