Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / specie / thermo / hPolynomial / hPolynomialThermo.C
blob10d1a280b3c422013443cdbfdfb0fa357b6737cc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2011 OpenCFD Ltd.
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 "hPolynomialThermo.H"
27 #include "IOstreams.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template<class EquationOfState, int PolySize>
32 Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
34     Istream& is
37     EquationOfState(is),
38     Hf_(readScalar(is)),
39     Sf_(readScalar(is)),
40     CpCoeffs_("CpCoeffs<" + Foam::name(PolySize) + '>', is),
41     hCoeffs_(),
42     sCoeffs_()
44     Hf_ *= this->W();
45     Sf_ *= this->W();
46     CpCoeffs_ *= this->W();
48     hCoeffs_ = CpCoeffs_.integral();
49     sCoeffs_ = CpCoeffs_.integralMinus1();
51     // Offset h poly so that it is relative to the enthalpy at Tstd
52     hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd);
54     // Offset s poly so that it is relative to the entropy at Tstd
55     sCoeffs_[0] += Sf_ - sCoeffs_.value(specie::Tstd);
59 template<class EquationOfState, int PolySize>
60 Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
62     const dictionary& dict
65     EquationOfState(dict),
66     Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf"))),
67     Sf_(readScalar(dict.subDict("thermodynamics").lookup("Sf"))),
68     CpCoeffs_
69     (
70         dict.subDict("thermodynamics").lookup
71         (
72             "CpCoeffs<" + Foam::name(PolySize) + '>'
73         )
74     ),
75     hCoeffs_(),
76     sCoeffs_()
78     Hf_ *= this->W();
79     Sf_ *= this->W();
80     CpCoeffs_ *= this->W();
82     hCoeffs_ = CpCoeffs_.integral();
83     sCoeffs_ = CpCoeffs_.integralMinus1();
85     // Offset h poly so that it is relative to the enthalpy at Tstd
86     hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd);
88     // Offset s poly so that it is relative to the entropy at Tstd
89     sCoeffs_[0] += Sf_ - sCoeffs_.value(specie::Tstd);
93 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
95 template<class EquationOfState, int PolySize>
96 void Foam::hPolynomialThermo<EquationOfState, PolySize>::write
98     Ostream& os
99 ) const
101     EquationOfState::write(os);
103     dictionary dict("thermodynamics");
104     dict.add("Hf", Hf_);
105     dict.add("Sf", Sf_);
106     dict.add
107     (
108         word("CpCoeffs<" + Foam::name(PolySize) + '>'),
109         CpCoeffs_/this->W()
110     );
111     os  << dict;
115 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
117 template<class EquationOfState, int PolySize>
118 Foam::Ostream& Foam::operator<<
120     Ostream& os,
121     const hPolynomialThermo<EquationOfState, PolySize>& pt
124     os  << static_cast<const EquationOfState&>(pt) << tab
125         << pt.Hf_/pt.W() << tab
126         << pt.Sf_/pt.W() << tab
127         << "CpCoeffs<" << Foam::name(PolySize) << '>' << tab
128         << pt.CpCoeffs_/pt.W();
130     os.check
131     (
132         "operator<<"
133         "("
134             "Ostream&, "
135             "const hPolynomialThermo<EquationOfState, PolySize>&"
136         ")"
137     );
139     return os;
143 // ************************************************************************* //