BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / DimensionedFields / DimensionedField / DimensionedFieldIO.C
blobbe049a4be8a05656d97b6ba99cbe738f17b8734d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "DimensionedField.H"
27 #include "IOstreams.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 template<class Type, class GeoMesh>
33 void Foam::DimensionedField<Type, GeoMesh>::readField
35     const dictionary& fieldDict,
36     const word& fieldDictEntry
39     dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions")));
41     Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_));
42     this->transfer(f);
46 template<class Type, class GeoMesh>
47 void Foam::DimensionedField<Type, GeoMesh>::readIfPresent
49     const word& fieldDictEntry
52     if
53     (
54         (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
55      || this->readOpt() == IOobject::MUST_READ
56      || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
57     )
58     {
59         readField(dictionary(readStream(typeName)), fieldDictEntry);
60     }
64 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
66 template<class Type, class GeoMesh>
67 Foam::DimensionedField<Type, GeoMesh>::DimensionedField
69     const IOobject& io,
70     const Mesh& mesh,
71     const word& fieldDictEntry
74     regIOobject(io),
75     Field<Type>(0),
76     mesh_(mesh),
77     dimensions_(dimless)
79     readField(dictionary(readStream(typeName)), fieldDictEntry);
83 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
85 template<class Type, class GeoMesh>
86 bool Foam::DimensionedField<Type, GeoMesh>::writeData
88     Ostream& os,
89     const word& fieldDictEntry
90 ) const
92     os.writeKeyword("dimensions") << dimensions() << token::END_STATEMENT
93         << nl << nl;
95     Field<Type>::writeEntry(fieldDictEntry, os);
97     // Check state of Ostream
98     os.check
99     (
100         "bool DimensionedField<Type, GeoMesh>::writeData"
101         "(Ostream& os, const word& fieldDictEntry) const"
102     );
104     return (os.good());
108 template<class Type, class GeoMesh>
109 bool Foam::DimensionedField<Type, GeoMesh>::writeData(Ostream& os) const
111     return writeData(os, "value");
115 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
117 template<class Type, class GeoMesh>
118 Foam::Ostream& Foam::operator<<
120     Ostream& os,
121     const DimensionedField<Type, GeoMesh>& df
124     df.writeData(os);
126     return os;
130 template<class Type, class GeoMesh>
131 Foam::Ostream& Foam::operator<<
133     Ostream& os,
134     const tmp<DimensionedField<Type, GeoMesh> >& tdf
137     tdf().writeData(os);
138     tdf.clear();
140     return os;
144 // ************************************************************************* //