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

phasePropertiesIO.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) 2008-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 "phaseProperties.H"
00028 #include "dictionaryEntry.H"
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 Foam::phaseProperties::phaseProperties(Istream& is)
00033 :
00034     phase_(UNKNOWN),
00035     stateLabel_("(unknown)"),
00036     names_(0),
00037     Y_(0),
00038     globalIds_(0),
00039     globalCarrierIds_(0)
00040 {
00041     is.check("Foam::phaseProperties::phaseProperties(Istream& is)");
00042 
00043     dictionaryEntry phaseInfo(dictionary::null, is);
00044 
00045     phase_ = phaseTypeNames_[phaseInfo.keyword()];
00046     stateLabel_ = phaseToStateLabel(phase_);
00047 
00048     if (phaseInfo.size() > 0)
00049     {
00050         label nComponents = phaseInfo.size();
00051         names_.setSize(nComponents, "unknownSpecie");
00052         Y_.setSize(nComponents, 0.0);
00053         globalIds_.setSize(nComponents, -1);
00054         globalCarrierIds_.setSize(nComponents, -1);
00055 
00056         label cmptI = 0;
00057         forAllConstIter(IDLList<entry>, phaseInfo, iter)
00058         {
00059             names_[cmptI] = iter().keyword();
00060             Y_[cmptI] = readScalar(phaseInfo.lookup(names_[cmptI]));
00061             cmptI++;
00062         }
00063 
00064         checkTotalMassFraction();
00065     }
00066 }
00067 
00068 
00069 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00070 
00071 Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
00072 {
00073     is.check
00074     (
00075         "Foam::Istream& Foam::operator>>(Istream&, phaseProperties&)"
00076     );
00077 
00078     dictionaryEntry phaseInfo(dictionary::null, is);
00079 
00080     pp.phase_ = pp.phaseTypeNames_[phaseInfo.keyword()];
00081     pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_);
00082 
00083     if (phaseInfo.size() > 0)
00084     {
00085         label nComponents = phaseInfo.size();
00086 
00087         pp.names_.setSize(nComponents, "unknownSpecie");
00088         pp.Y_.setSize(nComponents, 0.0);
00089         pp.globalIds_.setSize(nComponents, -1);
00090         pp.globalCarrierIds_.setSize(nComponents, -1);
00091 
00092         label cmptI = 0;
00093         forAllConstIter(IDLList<entry>, phaseInfo, iter)
00094         {
00095             pp.names_[cmptI] = iter().keyword();
00096             pp.Y_[cmptI] = readScalar(phaseInfo.lookup(pp.names_[cmptI]));
00097             cmptI++;
00098         }
00099 
00100         pp.checkTotalMassFraction();
00101     }
00102 
00103     return is;
00104 }
00105 
00106 
00107 Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp)
00108 {
00109     os.check
00110     (
00111         "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
00112     );
00113 
00114     os  << pp.phaseTypeNames_[pp.phase_] << nl << token::BEGIN_BLOCK << nl
00115         << incrIndent;
00116 
00117     forAll(pp.names_, cmptI)
00118     {
00119         os.writeKeyword(pp.names_[cmptI]) << pp.Y_[cmptI]
00120             << token::END_STATEMENT << nl;
00121     }
00122 
00123     os  << decrIndent << token::END_BLOCK << nl;
00124 
00125     os.check
00126     (
00127         "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
00128     );
00129 
00130     return os;
00131 }
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd