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 
43 Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
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 
71 Foam::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 // ************************************************************************* //
dictionary dict
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
Helper class to manage multi-specie phase properties.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Definition: exprTraits.C:40
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Istream & operator>>(Istream &, directionInfo &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
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:77
phaseProperties()
Default construct, as &#39;UNKNOWN&#39; state.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127