eConstThermo.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 | Copyright (C) 2011-2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "eConstThermo.H"
27 #include "IOstreams.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class EquationOfState>
33 :
34  EquationOfState(is),
35  Cv_(readScalar(is)),
36  Hf_(readScalar(is))
37 {
38  is.check("eConstThermo<EquationOfState>::eConstThermo(Istream&)");
39 
40  Cv_ *= this->W();
41  Hf_ *= this->W();
42 }
43 
44 
45 template<class EquationOfState>
47 :
48  EquationOfState(dict),
49  Cv_(readScalar(dict.subDict("thermodynamics").lookup("Cv"))),
50  Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf")))
51 {
52  Cv_ *= this->W();
53  Hf_ *= this->W();
54 }
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
59 template<class EquationOfState>
61 {
63 
64  dictionary dict("thermodynamics");
65  dict.add("Cv", Cv_/this->W());
66  dict.add("Hf", Hf_/this->W());
67  os << indent << dict.dictName() << dict;
68 }
69 
70 
71 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
72 
73 template<class EquationOfState>
74 Foam::Ostream& Foam::operator<<
75 (
76  Ostream& os,
78 )
79 {
80  os << static_cast<const EquationOfState&>(ct) << tab
81  << ct.Cv_/ct.W() << tab << ct.Hf_/ct.W();
82 
83  os.check("Ostream& operator<<(Ostream&, const eConstThermo&)");
84  return os;
85 }
86 
87 
88 // ************************************************************************* //
#define readScalar
Definition: doubleScalar.C:38
Constant properties thermodynamics package templated on an equation of state.
Definition: eConstThermo.H:48
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
runTime write()
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
dictionary dict
stressControl lookup("compactNormalStress") >> compactNormalStress
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:739
static const char tab
Definition: Ostream.H:259
void write(Ostream &os) const
Write to Ostream.
Definition: eConstThermo.C:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115