initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / phaseProperties / phaseProperties / phasePropertiesIO.C
blobf738cf2683683f5a8aaded5500f7b511772db846
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "phaseProperties.H"
28 #include "dictionaryEntry.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 Foam::phaseProperties::phaseProperties(Istream& is)
34     phase_(UNKNOWN),
35     stateLabel_("(unknown)"),
36     names_(0),
37     Y_(0),
38     globalIds_(0),
39     globalCarrierIds_(0)
41     is.check("Foam::phaseProperties::phaseProperties(Istream& is)");
43     dictionaryEntry phaseInfo(dictionary::null, is);
45     phase_ = phaseTypeNames_[phaseInfo.keyword()];
46     stateLabel_ = phaseToStateLabel(phase_);
48     if (phaseInfo.size() > 0)
49     {
50         label nComponents = phaseInfo.size();
51         names_.setSize(nComponents, "unknownSpecie");
52         Y_.setSize(nComponents, 0.0);
53         globalIds_.setSize(nComponents, -1);
54         globalCarrierIds_.setSize(nComponents, -1);
56         label cmptI = 0;
57         forAllConstIter(IDLList<entry>, phaseInfo, iter)
58         {
59             names_[cmptI] = iter().keyword();
60             Y_[cmptI] = readScalar(phaseInfo.lookup(names_[cmptI]));
61             cmptI++;
62         }
64         checkTotalMassFraction();
65     }
69 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
71 Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
73     is.check
74     (
75         "Foam::Istream& Foam::operator>>(Istream&, phaseProperties&)"
76     );
78     dictionaryEntry phaseInfo(dictionary::null, is);
80     pp.phase_ = pp.phaseTypeNames_[phaseInfo.keyword()];
81     pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_);
83     if (phaseInfo.size() > 0)
84     {
85         label nComponents = phaseInfo.size();
87         pp.names_.setSize(nComponents, "unknownSpecie");
88         pp.Y_.setSize(nComponents, 0.0);
89         pp.globalIds_.setSize(nComponents, -1);
90         pp.globalCarrierIds_.setSize(nComponents, -1);
92         label cmptI = 0;
93         forAllConstIter(IDLList<entry>, phaseInfo, iter)
94         {
95             pp.names_[cmptI] = iter().keyword();
96             pp.Y_[cmptI] = readScalar(phaseInfo.lookup(pp.names_[cmptI]));
97             cmptI++;
98         }
100         pp.checkTotalMassFraction();
101     }
103     return is;
107 Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp)
109     os.check
110     (
111         "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
112     );
114     os  << pp.phaseTypeNames_[pp.phase_] << nl << token::BEGIN_BLOCK << nl
115         << incrIndent;
117     forAll(pp.names_, cmptI)
118     {
119         os.writeKeyword(pp.names_[cmptI]) << pp.Y_[cmptI]
120             << token::END_STATEMENT << nl;
121     }
123     os  << decrIndent << token::END_BLOCK << nl;
125     os.check
126     (
127         "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
128     );
130     return os;
134 // ************************************************************************* //