phasePropertiesIO.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "phaseProperties.H"
29 #include "dictionaryEntry.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  phase_(UNKNOWN),
36  stateLabel_("(unknown)"),
37  names_(),
38  Y_(),
39  carrierIds_()
40 {
41  is >> *this;
42 }
43 
44 
45 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
46 
48 {
49  is.check(FUNCTION_NAME);
50 
51  const dictionaryEntry phaseInfo(dictionary::null, is);
52  const dictionary& dict = phaseInfo.dict();
53 
54  pp.phase_ = pp.phaseTypeNames[phaseInfo.keyword()];
55  pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_);
56 
57  // The names in the dictionary order of appearance
58  pp.names_ = dict.toc();
59 
60  const label nComponents = pp.names_.size();
61 
62  pp.Y_.resize(nComponents, 0.0);
63  pp.carrierIds_.resize(nComponents, -1);
64 
65  for (label cmpti = 0; cmpti < nComponents; ++cmpti)
66  {
67  pp.Y_[cmpti] = dict.get<scalar>(pp.names_[cmpti]);
68  }
69  pp.checkTotalMassFraction();
70 
71  return is;
72 }
73 
74 
76 {
77  os.check(FUNCTION_NAME);
78 
79  os.beginBlock(pp.phaseTypeNames[pp.phase_]);
80 
81  forAll(pp.names_, cmpti)
82  {
83  os.writeEntry(pp.names_[cmpti], pp.Y_[cmpti]);
84  }
85 
86  os.endBlock();
87 
88  os.check(FUNCTION_NAME);
89  return os;
90 }
91 
92 
93 // ************************************************************************* //
Foam::dictionaryEntry
A keyword and a list of tokens is a 'dictionaryEntry'.
Definition: dictionaryEntry.H:65
Foam::phaseProperties::phaseTypeNames
static const Enum< phaseType > phaseTypeNames
Corresponding word representations for phase type enumerations.
Definition: phaseProperties.H:78
Foam::entry::keyword
const keyType & keyword() const
Return keyword.
Definition: entry.H:187
Foam::phaseProperties
Helper class to manage multi-specie phase properties.
Definition: phaseProperties.H:62
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:91
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::dictionary::null
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:385
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::List::resize
void resize(const label newSize)
Adjust allocated size of list.
Definition: ListI.H:139
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:109
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
phaseProperties.H
dictionaryEntry.H
Foam::phaseProperties::phaseProperties
phaseProperties()
Null constructor.
Definition: phaseProperties.C:181
Foam::dictionaryEntry::dict
virtual const dictionary & dict() const
Return dictionary.
Definition: dictionaryEntry.C:102
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::dictionary::toc
wordList toc() const
Return the table of contents.
Definition: dictionary.C:665
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102