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 :
36 {
37  is >> *this;
38 }
39 
40 
41 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
42 
44 {
45  is.check(FUNCTION_NAME);
46 
47  const dictionaryEntry phaseInfo(dictionary::null, is);
48  const dictionary& dict = phaseInfo.dict();
49 
50  pp.phase_ = pp.phaseTypeNames[phaseInfo.keyword()];
51  pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_);
52 
53  // The names in the dictionary order of appearance
54  pp.names_ = dict.toc();
55 
56  const label nComponents = pp.names_.size();
57 
58  pp.Y_.resize(nComponents, Zero);
59  pp.carrierIds_.resize(nComponents, -1);
60 
61  for (label cmpti = 0; cmpti < nComponents; ++cmpti)
62  {
63  pp.Y_[cmpti] = dict.get<scalar>(pp.names_[cmpti]);
64  }
65  pp.checkTotalMassFraction();
66 
67  return is;
68 }
69 
70 
72 {
74 
75  os.beginBlock(pp.phaseTypeNames[pp.phase_]);
76 
77  forAll(pp.names_, cmpti)
78  {
79  os.writeEntry(pp.names_[cmpti], pp.Y_[cmpti]);
80  }
81 
82  os.endBlock();
83 
85  return os;
86 }
87 
88 
89 // ************************************************************************* //
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:76
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dictionaryEntry::dict
virtual const dictionary & dict() const noexcept
Return dictionary (ie, this)
Definition: dictionaryEntry.C:102
Foam::phaseProperties
Helper class to manage multi-specie phase properties.
Definition: phaseProperties.H:60
Foam::entry::keyword
const keyType & keyword() const noexcept
Return keyword.
Definition: entry.H:195
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
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:107
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::dictionary::null
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:392
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
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:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
phaseProperties.H
dictionaryEntry.H
Foam::phaseProperties::phaseProperties
phaseProperties()
Default construct, as 'UNKNOWN' state.
Definition: phaseProperties.C:182
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::dictionary::toc
wordList toc() const
Return the table of contents.
Definition: dictionary.C:602
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56