Forward compatibility: flex
[foam-extend-3.2.git] / src / thermophysicalModels / specie / thermo / eConst / eConstThermoI.H
blobd17acfed5272d41e8e34cc6cae3c1a73402c27fe
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 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
28 template<class equationOfState>
29 inline Foam::eConstThermo<equationOfState>::eConstThermo
31     const equationOfState& st,
32     const scalar cv,
33     const scalar hf
36     equationOfState(st),
37     Cv_(cv),
38     Hf_(hf)
42 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
44 template<class equationOfState>
45 inline Foam::eConstThermo<equationOfState>::eConstThermo
47     const word& name,
48     const eConstThermo<equationOfState>& ct
51     equationOfState(name, ct),
52     Cv_(ct.Cv_),
53     Hf_(ct.Hf_)
57 template<class equationOfState>
58 inline Foam::autoPtr<Foam::eConstThermo<equationOfState> >
59 Foam::eConstThermo<equationOfState>::clone() const
61     return autoPtr<eConstThermo<equationOfState> >
62     (
63         new eConstThermo<equationOfState>(*this)
64     );
68 template<class equationOfState>
69 inline Foam::autoPtr<Foam::eConstThermo<equationOfState> >
70 Foam::eConstThermo<equationOfState>::New(Istream& is)
72     return autoPtr<eConstThermo<equationOfState> >
73     (
74         new eConstThermo<equationOfState>(is)
75     );
79 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
81 template<class equationOfState>
82 inline Foam::scalar Foam::eConstThermo<equationOfState>::cp
84     const scalar
85 ) const
87     return Cv_*this->W() + specie::RR();
91 template<class equationOfState>
92 inline Foam::scalar Foam::eConstThermo<equationOfState>::h
94     const scalar T
95 ) const
97     return cp(T)*T + Hf_*this->W();
101 template<class equationOfState>
102 inline Foam::scalar Foam::eConstThermo<equationOfState>::hs
104     const scalar T
105 ) const
107     return cp(T)*T;
111 template<class equationOfState>
112 inline Foam::scalar Foam::eConstThermo<equationOfState>::hc() const
114     return Hf_*this->W();
118 template<class equationOfState>
119 inline Foam::scalar Foam::eConstThermo<equationOfState>::s
121     const scalar T
122 ) const
124     notImplemented("scalar eConstThermo::s(const scalar T) const");
125     return T;
129 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
131 template<class equationOfState>
132 inline void Foam::eConstThermo<equationOfState>::operator+=
134     const eConstThermo<equationOfState>& ct
137     scalar molr1 = this->nMoles();
139     equationOfState::operator+=(ct);
141     molr1 /= this->nMoles();
142     scalar molr2 = ct.nMoles()/this->nMoles();
144     Cv_ = molr1*Cv_ + molr2*ct.Cv_;
145     Hf_ = molr1*Hf_ + molr2*ct.Hf_;
149 template<class equationOfState>
150 inline void Foam::eConstThermo<equationOfState>::operator-=
152     const eConstThermo<equationOfState>& ct
155     scalar molr1 = this->nMoles();
157     equationOfState::operator-=(ct);
159     molr1 /= this->nMoles();
160     scalar molr2 = ct.nMoles()/this->nMoles();
162     Cv_ = molr1*Cv_ - molr2*ct.Cv_;
163     Hf_ = molr1*Hf_ - molr2*ct.Hf_;
167 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
169 template<class equationOfState>
170 inline Foam::eConstThermo<equationOfState> Foam::operator+
172     const eConstThermo<equationOfState>& ct1,
173     const eConstThermo<equationOfState>& ct2
176     equationOfState eofs
177     (
178         static_cast<const equationOfState&>(ct1)
179       + static_cast<const equationOfState&>(ct2)
180     );
182     return eConstThermo<equationOfState>
183     (
184         eofs,
185         ct1.nMoles()/eofs.nMoles()*ct1.Cv_
186       + ct2.nMoles()/eofs.nMoles()*ct2.Cv_,
187         ct1.nMoles()/eofs.nMoles()*ct1.Hf_
188       + ct2.nMoles()/eofs.nMoles()*ct2.Hf_
189     );
193 template<class equationOfState>
194 inline Foam::eConstThermo<equationOfState> Foam::operator-
196     const eConstThermo<equationOfState>& ct1,
197     const eConstThermo<equationOfState>& ct2
200     equationOfState eofs
201     (
202         static_cast<const equationOfState&>(ct1)
203       - static_cast<const equationOfState&>(ct2)
204     );
206     return eConstThermo<equationOfState>
207     (
208         eofs,
209         ct1.nMoles()/eofs.nMoles()*ct1.Cv_
210       - ct2.nMoles()/eofs.nMoles()*ct2.Cv_,
211         ct1.nMoles()/eofs.nMoles()*ct1.Hf_
212       - ct2.nMoles()/eofs.nMoles()*ct2.Hf_
213     );
217 template<class equationOfState>
218 inline Foam::eConstThermo<equationOfState> Foam::operator*
220     const scalar s,
221     const eConstThermo<equationOfState>& ct
224     return eConstThermo<equationOfState>
225     (
226         s*static_cast<const equationOfState&>(ct),
227         ct.Cv_,
228         ct.Hf_
229     );
233 template<class equationOfState>
234 inline Foam::eConstThermo<equationOfState> Foam::operator==
236     const eConstThermo<equationOfState>& ct1,
237     const eConstThermo<equationOfState>& ct2
240     return ct2 - ct1;
244 // ************************************************************************* //