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-------------------------------------------------------------------------------
10License
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{
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// ************************************************************************* //
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:105
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:87
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A keyword and a list of tokens is a 'dictionaryEntry'.
virtual const dictionary & dict() const noexcept
Return dictionary (ie, this)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
wordList toc() const
Return the table of contents.
Definition: dictionary.C:602
const keyType & keyword() const noexcept
Return keyword.
Definition: entry.H:195
Helper class to manage multi-specie phase properties.
static const Enum< phaseType > phaseTypeNames
Corresponding word representations for phase type enumerations.
phaseProperties()
Default construct, as 'UNKNOWN' state.
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333