FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "phaseProperties.H"
00027 #include <OpenFOAM/dictionaryEntry.H>
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 Foam::phaseProperties::phaseProperties(Istream& is)
00032 :
00033     phase_(UNKNOWN),
00034     stateLabel_("(unknown)"),
00035     names_(0),
00036     Y_(0),
00037     globalIds_(0),
00038     globalCarrierIds_(0)
00039 {
00040     is.check("Foam::phaseProperties::phaseProperties(Istream& is)");
00041 
00042     dictionaryEntry phaseInfo(dictionary::null, is);
00043 
00044     phase_ = phaseTypeNames_[phaseInfo.keyword()];
00045     stateLabel_ = phaseToStateLabel(phase_);
00046 
00047     if (phaseInfo.size() > 0)
00048     {
00049         label nComponents = phaseInfo.size();
00050         names_.setSize(nComponents, "unknownSpecie");
00051         Y_.setSize(nComponents, 0.0);
00052         globalIds_.setSize(nComponents, -1);
00053         globalCarrierIds_.setSize(nComponents, -1);
00054 
00055         label cmptI = 0;
00056         forAllConstIter(IDLList<entry>, phaseInfo, iter)
00057         {
00058             names_[cmptI] = iter().keyword();
00059             Y_[cmptI] = readScalar(phaseInfo.lookup(names_[cmptI]));
00060             cmptI++;
00061         }
00062 
00063         checkTotalMassFraction();
00064     }
00065 }
00066 
00067 
00068 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00069 
00070 Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
00071 {
00072     is.check
00073     (
00074         "Foam::Istream& Foam::operator>>(Istream&, phaseProperties&)"
00075     );
00076 
00077     dictionaryEntry phaseInfo(dictionary::null, is);
00078 
00079     pp.phase_ = pp.phaseTypeNames_[phaseInfo.keyword()];
00080     pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_);
00081 
00082     if (phaseInfo.size() > 0)
00083     {
00084         label nComponents = phaseInfo.size();
00085 
00086         pp.names_.setSize(nComponents, "unknownSpecie");
00087         pp.Y_.setSize(nComponents, 0.0);
00088         pp.globalIds_.setSize(nComponents, -1);
00089         pp.globalCarrierIds_.setSize(nComponents, -1);
00090 
00091         label cmptI = 0;
00092         forAllConstIter(IDLList<entry>, phaseInfo, iter)
00093         {
00094             pp.names_[cmptI] = iter().keyword();
00095             pp.Y_[cmptI] = readScalar(phaseInfo.lookup(pp.names_[cmptI]));
00096             cmptI++;
00097         }
00098 
00099         pp.checkTotalMassFraction();
00100     }
00101 
00102     return is;
00103 }
00104 
00105 
00106 Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp)
00107 {
00108     os.check
00109     (
00110         "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
00111     );
00112 
00113     os  << pp.phaseTypeNames_[pp.phase_] << nl << token::BEGIN_BLOCK << nl
00114         << incrIndent;
00115 
00116     forAll(pp.names_, cmptI)
00117     {
00118         os.writeKeyword(pp.names_[cmptI]) << pp.Y_[cmptI]
00119             << token::END_STATEMENT << nl;
00120     }
00121 
00122     os  << decrIndent << token::END_BLOCK << nl;
00123 
00124     os.check
00125     (
00126         "Foam::Ostream& Foam::operator<<(Ostream&, const phaseProperties&)"
00127     );
00128 
00129     return os;
00130 }
00131 
00132 
00133 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines