Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / thermophysicalModels / specie / thermo / janaf / janafThermo.C
blob719a3444925e809dbeae6d2e66fdf9b7f6fa0135
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Description
25     JANAF tables based thermodynamics package templated ito the equationOfState.
27 \*---------------------------------------------------------------------------*/
29 #include "janafThermo.H"
30 #include "IOstreams.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 template<class equationOfState>
35 Foam::janafThermo<equationOfState>::janafThermo(Istream& is)
37     equationOfState(is),
38     Tlow_(readScalar(is)),
39     Thigh_(readScalar(is)),
40     Tcommon_(readScalar(is))
42     if (Tlow_ >= Thigh_)
43     {
44         FatalIOErrorIn
45         (
46             "janafThermo<equationOfState>::janafThermo(Istream& is)",
47             is
48         )   << "Tlow(" << Tlow_ << ") >= Thigh(" << Thigh_ << ')'
49             << exit(FatalIOError);
50     }
52     if (Tcommon_ <= Tlow_)
53     {
54         FatalIOErrorIn
55         (
56             "janafThermo<equationOfState>::janafThermo(Istream& is)",
57             is
58         )   << "Tcommon(" << Tcommon_ << ") <= Tlow(" << Tlow_ << ')'
59             << exit(FatalIOError);
60     }
62     if (Tcommon_ > Thigh_)
63     {
64         FatalIOErrorIn
65         (
66             "janafThermo<equationOfState>::janafThermo(Istream& is)",
67             is
68         )   << "Tcommon(" << Tcommon_ << ") > Thigh(" << Thigh_ << ')'
69             << exit(FatalIOError);
70     }
72     for
73     (
74         register label coefLabel=0;
75         coefLabel<janafThermo<equationOfState>::nCoeffs_;
76         coefLabel++
77     )
78     {
79         is >> highCpCoeffs_[coefLabel];
80     }
82     for
83     (
84         register label coefLabel=0;
85         coefLabel<janafThermo<equationOfState>::nCoeffs_;
86         coefLabel++
87     )
88     {
89         is >> lowCpCoeffs_[coefLabel];
90     }
92     // Check state of Istream
93     is.check("janafThermo::janafThermo(Istream& is)");
97 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
99 template<class equationOfState>
100 Foam::Ostream& Foam::operator<<
102     Ostream& os,
103     const janafThermo<equationOfState>& jt
106     os  << static_cast<const equationOfState&>(jt) << nl
107         << "    " << jt.Tlow_
108         << tab << jt.Thigh_
109         << tab << jt.Tcommon_;
111     os << nl << "    ";
113     for
114     (
115         register label coefLabel=0;
116         coefLabel<janafThermo<equationOfState>::nCoeffs_;
117         coefLabel++
118     )
119     {
120         os << jt.highCpCoeffs_[coefLabel] << ' ';
121     }
123     os << nl << "    ";
125     for
126     (
127         register label coefLabel=0;
128         coefLabel<janafThermo<equationOfState>::nCoeffs_;
129         coefLabel++
130     )
131     {
132         os << jt.lowCpCoeffs_[coefLabel] << ' ';
133     }
135     os << endl;
137     os.check
138     (
139         "operator<<(Ostream& os, const janafThermo<equationOfState>& jt)"
140     );
142     return os;
146 // ************************************************************************* //