janafThermo.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-2015 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 "janafThermo.H"
27 #include "IOstreams.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class EquationOfState>
33 {
34  if (Tlow_ >= Thigh_)
35  {
37  << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
38  << exit(FatalError);
39  }
40 
41  if (Tcommon_ <= Tlow_)
42  {
44  << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
45  << exit(FatalError);
46  }
47 
48  if (Tcommon_ > Thigh_)
49  {
51  << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
52  << exit(FatalError);
53  }
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
59 template<class EquationOfState>
61 :
62  EquationOfState(is),
63  Tlow_(readScalar(is)),
64  Thigh_(readScalar(is)),
65  Tcommon_(readScalar(is))
66 {
68 
70  {
71  is >> highCpCoeffs_[i];
72  }
73 
75  {
76  is >> lowCpCoeffs_[i];
77  }
78 
79  // Check state of Istream
80  is.check("janafThermo::janafThermo(Istream& is)");
81 }
82 
83 
84 template<class EquationOfState>
86 :
87  EquationOfState(dict),
88  Tlow_(readScalar(dict.subDict("thermodynamics").lookup("Tlow"))),
89  Thigh_(readScalar(dict.subDict("thermodynamics").lookup("Thigh"))),
90  Tcommon_(readScalar(dict.subDict("thermodynamics").lookup("Tcommon"))),
91  highCpCoeffs_(dict.subDict("thermodynamics").lookup("highCpCoeffs")),
92  lowCpCoeffs_(dict.subDict("thermodynamics").lookup("lowCpCoeffs"))
93 {
95 }
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
100 template<class EquationOfState>
102 {
104 
105  dictionary dict("thermodynamics");
106  dict.add("Tlow", Tlow_);
107  dict.add("Thigh", Thigh_);
108  dict.add("Tcommon", Tcommon_);
109  dict.add("highCpCoeffs", highCpCoeffs_);
110  dict.add("lowCpCoeffs", lowCpCoeffs_);
111  os << indent << dict.dictName() << dict;
112 }
113 
114 
115 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
116 
117 template<class EquationOfState>
118 Foam::Ostream& Foam::operator<<
119 (
120  Ostream& os,
122 )
123 {
124  os << static_cast<const EquationOfState&>(jt) << nl
125  << " " << jt.Tlow_
126  << tab << jt.Thigh_
127  << tab << jt.Tcommon_;
128 
129  os << nl << " ";
130 
131  forAll(jt.highCpCoeffs_, i)
132  {
133  os << jt.highCpCoeffs_[i] << ' ';
134  }
135 
136  os << nl << " ";
137 
138  forAll(jt.lowCpCoeffs_, i)
139  {
140  os << jt.lowCpCoeffs_[i] << ' ';
141  }
142 
143  os << endl;
144 
145  os.check
146  (
147  "operator<<(Ostream& os, const janafThermo<EquationOfState>& jt)"
148  );
149 
150  return os;
151 }
152 
153 
154 // ************************************************************************* //
Foam::dictionaryName::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::janafThermo::janafThermo
janafThermo(const EquationOfState &st, const scalar Tlow, const scalar Thigh, const scalar Tcommon, const coeffArray &highCpCoeffs, const coeffArray &lowCpCoeffs)
Construct from components.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::janafThermo
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:49
Foam::janafThermo::lowCpCoeffs_
coeffArray lowCpCoeffs_
Definition: janafThermo.H:113
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
janafThermo.H
Foam::janafThermo::highCpCoeffs_
coeffArray highCpCoeffs_
Definition: janafThermo.H:112
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Foam::janafThermo::checkInputData
void checkInputData() const
Check that input data is valid.
Definition: janafThermo.C:32
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
readScalar
#define readScalar
Definition: doubleScalar.C:38
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::tab
static const char tab
Definition: Ostream.H:259
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::janafThermo::write
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:101
write
Tcoeff write()
Foam::dictionary::add
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:729
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress