BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / specie / thermo / janaf / janafThermo.C
blob1ef5bec98e033444d568611b0bd7adf2a6b2c520
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "janafThermo.H"
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
31 template<class EquationOfState>
32 void Foam::janafThermo<EquationOfState>::checkInputData() const
34     if (Tlow_ >= Thigh_)
35     {
36         FatalErrorIn("janafThermo<EquationOfState>::check()")
37             << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
38             << exit(FatalIOError);
39     }
41     if (Tcommon_ <= Tlow_)
42     {
43         FatalErrorIn("janafThermo<EquationOfState>::check()")
44             << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
45             << exit(FatalIOError);
46     }
48     if (Tcommon_ > Thigh_)
49     {
50         FatalErrorIn("janafThermo<EquationOfState>::check()")
51             << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
52             << exit(FatalIOError);
53     }
57 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
59 template<class EquationOfState>
60 Foam::janafThermo<EquationOfState>::janafThermo(Istream& is)
62     EquationOfState(is),
63     Tlow_(readScalar(is)),
64     Thigh_(readScalar(is)),
65     Tcommon_(readScalar(is))
67     checkInputData();
69     forAll(highCpCoeffs_, i)
70     {
71         is >> highCpCoeffs_[i];
72     }
74     forAll(lowCpCoeffs_, i)
75     {
76         is >> lowCpCoeffs_[i];
77     }
79     // Check state of Istream
80     is.check("janafThermo::janafThermo(Istream& is)");
84 template<class EquationOfState>
85 Foam::janafThermo<EquationOfState>::janafThermo(const dictionary& dict)
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"))
94     checkInputData();
98 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
100 template<class EquationOfState>
101 void Foam::janafThermo<EquationOfState>::write(Ostream& os) const
103     EquationOfState::write(os);
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;
115 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
117 template<class EquationOfState>
118 Foam::Ostream& Foam::operator<<
120     Ostream& os,
121     const janafThermo<EquationOfState>& jt
124     os  << static_cast<const EquationOfState&>(jt) << nl
125         << "    " << jt.Tlow_
126         << tab << jt.Thigh_
127         << tab << jt.Tcommon_;
129     os << nl << "    ";
131     forAll(jt.highCpCoeffs_, i)
132     {
133         os << jt.highCpCoeffs_[i] << ' ';
134     }
136     os << nl << "    ";
138     forAll(jt.lowCpCoeffs_, i)
139     {
140         os << jt.lowCpCoeffs_[i] << ' ';
141     }
143     os << endl;
145     os.check
146     (
147         "operator<<(Ostream& os, const janafThermo<EquationOfState>& jt)"
148     );
150     return os;
154 // ************************************************************************* //