1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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)
35 stateLabel_("(unknown)"),
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)
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);
57 forAllConstIter(IDLList<entry>, phaseInfo, iter)
59 names_[cmptI] = iter().keyword();
60 Y_[cmptI] = readScalar(phaseInfo.lookup(names_[cmptI]));
64 checkTotalMassFraction();
69 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
71 Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
75 "Foam::Istream& Foam::operator>>(Istream&, phaseProperties&)"
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)
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);
93 forAllConstIter(IDLList<entry>, phaseInfo, iter)
95 pp.names_[cmptI] = iter().keyword();
96 pp.Y_[cmptI] = readScalar(phaseInfo.lookup(pp.names_[cmptI]));
100 pp.checkTotalMassFraction();
107 Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp)
111 "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
114 os << pp.phaseTypeNames_[pp.phase_] << nl << token::BEGIN_BLOCK << nl
117 forAll(pp.names_, cmptI)
119 os.writeKeyword(pp.names_[cmptI]) << pp.Y_[cmptI]
120 << token::END_STATEMENT << nl;
123 os << decrIndent << token::END_BLOCK << nl;
127 "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
134 // ************************************************************************* //