FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/IOstreams.H>
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class equationOfState>
33 :
34  equationOfState(is),
35  Tlow_(readScalar(is)),
36  Thigh_(readScalar(is)),
37  Tcommon_(readScalar(is))
38 {
39  if (Tlow_ >= Thigh_)
40  {
42  (
43  "janafThermo<equationOfState>::janafThermo(Istream& is)",
44  is
45  ) << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
46  << exit(FatalIOError);
47  }
48 
49  if (Tcommon_ <= Tlow_)
50  {
52  (
53  "janafThermo<equationOfState>::janafThermo(Istream& is)",
54  is
55  ) << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
56  << exit(FatalIOError);
57  }
58 
59  if (Tcommon_ > Thigh_)
60  {
62  (
63  "janafThermo<equationOfState>::janafThermo(Istream& is)",
64  is
65  ) << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
66  << exit(FatalIOError);
67  }
68 
69  for
70  (
71  register label coefLabel=0;
72  coefLabel<janafThermo<equationOfState>::nCoeffs_;
73  coefLabel++
74  )
75  {
76  is >> highCpCoeffs_[coefLabel];
77  }
78 
79  for
80  (
81  register label coefLabel=0;
82  coefLabel<janafThermo<equationOfState>::nCoeffs_;
83  coefLabel++
84  )
85  {
86  is >> lowCpCoeffs_[coefLabel];
87  }
88 
89  // Check state of Istream
90  is.check("janafThermo::janafThermo(Istream& is)");
91 }
92 
93 
94 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
95 
96 template<class equationOfState>
97 Foam::Ostream& Foam::operator<<
98 (
99  Ostream& os,
101 )
102 {
103  os << static_cast<const equationOfState&>(jt) << nl
104  << " " << jt.Tlow_
105  << tab << jt.Thigh_
106  << tab << jt.Tcommon_;
107 
108  os << nl << " ";
109 
110  for
111  (
112  register label coefLabel=0;
113  coefLabel<janafThermo<equationOfState>::nCoeffs_;
114  coefLabel++
115  )
116  {
117  os << jt.highCpCoeffs_[coefLabel] << ' ';
118  }
119 
120  os << nl << " ";
121 
122  for
123  (
124  register label coefLabel=0;
125  coefLabel<janafThermo<equationOfState>::nCoeffs_;
126  coefLabel++
127  )
128  {
129  os << jt.lowCpCoeffs_[coefLabel] << ' ';
130  }
131 
132  os << endl;
133 
134  os.check
135  (
136  "operator<<(Ostream& os, const janafThermo<equationOfState>& jt)"
137  );
138 
139  return os;
140 }
141 
142 
143 // ************************ vim: set sw=4 sts=4 et: ************************ //