Loading...
Searching...
No Matches
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:
37 is >> *this;
38}
39
40
41// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
42
43Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
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
71Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp)
72{
73 os.check(FUNCTION_NAME);
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
84 os.check(FUNCTION_NAME);
85 return os;
86}
87
88
89// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition IOstream.C:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:133
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
const keyType & keyword() const noexcept
Return keyword.
Definition entry.H:231
Helper class to manage multi-specie phase properties.
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).
Istream & operator>>(Istream &, directionInfo &)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299