Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / fieldAverage / fieldAverageItem / fieldAverageItemIO.C
blob30f4d87027ead8a00cc8af349ddc6cb5c399b0bc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2011 OpenCFD Ltd.
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 "fieldAverageItem.H"
27 #include "IOstreams.H"
28 #include "dictionaryEntry.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 Foam::fieldAverageItem::fieldAverageItem(Istream& is)
34     fieldName_("unknown"),
35     mean_(0),
36     prime2Mean_(0)
38     is.check("Foam::fieldAverageItem::fieldAverageItem(Foam::Istream&)");
40     const dictionaryEntry entry(dictionary::null, is);
42     fieldName_ = entry.keyword();
43     entry.lookup("mean") >> mean_;
44     entry.lookup("prime2Mean") >> prime2Mean_;
45     base_ = baseTypeNames_[entry.lookup("base")];
49 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
51 Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem)
53     is.check
54     (
55         "Foam::Istream& Foam::operator>>"
56         "(Foam::Istream&, Foam::fieldAverageItem&)"
57     );
59     const dictionaryEntry entry(dictionary::null, is);
61     faItem.fieldName_ = entry.keyword();
62     entry.lookup("mean") >> faItem.mean_;
63     entry.lookup("prime2Mean") >> faItem.prime2Mean_;
64     faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
66     return is;
70 Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
72     os.check
73     (
74         "Foam::Ostream& Foam::operator<<"
75         "(Foam::Ostream&, const Foam::fieldAverageItem&)"
76     );
78     os  << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl;
79     os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl;
80     os.writeKeyword("prime2Mean") << faItem.mean_
81         << token::END_STATEMENT << nl;
82     os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_]
83         << token::END_STATEMENT << nl << token::END_BLOCK << nl;
85     os.check
86     (
87         "Foam::Ostream& Foam::operator<<"
88         "(Foam::Ostream&, const Foam::fieldAverageItem&)"
89     );
91     return os;
95 // ************************************************************************* //