1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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
36 FatalErrorIn("janafThermo<EquationOfState>::check()")
37 << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
38 << exit(FatalIOError);
41 if (Tcommon_ <= Tlow_)
43 FatalErrorIn("janafThermo<EquationOfState>::check()")
44 << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
45 << exit(FatalIOError);
48 if (Tcommon_ > Thigh_)
50 FatalErrorIn("janafThermo<EquationOfState>::check()")
51 << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
52 << exit(FatalIOError);
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 template<class EquationOfState>
60 Foam::janafThermo<EquationOfState>::janafThermo(Istream& is)
63 Tlow_(readScalar(is)),
64 Thigh_(readScalar(is)),
65 Tcommon_(readScalar(is))
69 forAll(highCpCoeffs_, i)
71 is >> highCpCoeffs_[i];
74 forAll(lowCpCoeffs_, i)
76 is >> lowCpCoeffs_[i];
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"))
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<<
121 const janafThermo<EquationOfState>& jt
124 os << static_cast<const EquationOfState&>(jt) << nl
127 << tab << jt.Tcommon_;
131 forAll(jt.highCpCoeffs_, i)
133 os << jt.highCpCoeffs_[i] << ' ';
138 forAll(jt.lowCpCoeffs_, i)
140 os << jt.lowCpCoeffs_[i] << ' ';
147 "operator<<(Ostream& os, const janafThermo<EquationOfState>& jt)"
154 // ************************************************************************* //