FreeFOAM The Cross-Platform CFD Toolkit
eConstThermoI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
27 
28 template<class equationOfState>
30 (
31  const equationOfState& st,
32  const scalar cv,
33  const scalar hf
34 )
35 :
36  equationOfState(st),
37  Cv_(cv),
38  Hf_(hf)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 template<class equationOfState>
46 (
47  const word& name,
48  const eConstThermo<equationOfState>& ct
49 )
50 :
51  equationOfState(name, ct),
52  Cv_(ct.Cv_),
53  Hf_(ct.Hf_)
54 {}
55 
56 
57 template<class equationOfState>
60 {
62  (
64  );
65 }
66 
67 
68 template<class equationOfState>
71 {
73  (
75  );
76 }
77 
78 
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 
81 template<class equationOfState>
83 (
84  const scalar
85 ) const
86 {
87  return Cv_*this->W() + specie::RR;
88 }
89 
90 
91 template<class equationOfState>
93 (
94  const scalar T
95 ) const
96 {
97  return cp(T)*T + Hf_*this->W();
98 }
99 
100 
101 template<class equationOfState>
102 inline Foam::scalar Foam::eConstThermo<equationOfState>::hs
103 (
104  const scalar T
105 ) const
106 {
107  return cp(T)*T;
108 }
109 
110 
111 template<class equationOfState>
112 inline Foam::scalar Foam::eConstThermo<equationOfState>::hc() const
113 {
114  return Hf_*this->W();
115 }
116 
117 
118 template<class equationOfState>
119 inline Foam::scalar Foam::eConstThermo<equationOfState>::s
120 (
121  const scalar T
122 ) const
123 {
124  notImplemented("scalar eConstThermo::s(const scalar T) const");
125  return T;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
130 
131 template<class equationOfState>
133 (
135 )
136 {
137  scalar molr1 = this->nMoles();
138 
139  equationOfState::operator+=(ct);
140 
141  molr1 /= this->nMoles();
142  scalar molr2 = ct.nMoles()/this->nMoles();
143 
144  Cv_ = molr1*Cv_ + molr2*ct.Cv_;
145  Hf_ = molr1*Hf_ + molr2*ct.Hf_;
146 }
147 
148 
149 template<class equationOfState>
150 inline void Foam::eConstThermo<equationOfState>::operator-=
151 (
153 )
154 {
155  scalar molr1 = this->nMoles();
156 
157  equationOfState::operator-=(ct);
158 
159  molr1 /= this->nMoles();
160  scalar molr2 = ct.nMoles()/this->nMoles();
161 
162  Cv_ = molr1*Cv_ - molr2*ct.Cv_;
163  Hf_ = molr1*Hf_ - molr2*ct.Hf_;
164 }
165 
166 
167 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
168 
169 template<class equationOfState>
170 inline Foam::eConstThermo<equationOfState> Foam::operator+
171 (
174 )
175 {
176  equationOfState eofs
177  (
178  static_cast<const equationOfState&>(ct1)
179  + static_cast<const equationOfState&>(ct2)
180  );
181 
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  );
190 }
191 
192 
193 template<class equationOfState>
194 inline Foam::eConstThermo<equationOfState> Foam::operator-
195 (
198 )
199 {
200  equationOfState eofs
201  (
202  static_cast<const equationOfState&>(ct1)
203  - static_cast<const equationOfState&>(ct2)
204  );
205 
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  );
214 }
215 
216 
217 template<class equationOfState>
218 inline Foam::eConstThermo<equationOfState> Foam::operator*
219 (
220  const scalar s,
222 )
223 {
225  (
226  s*static_cast<const equationOfState&>(ct),
227  ct.Cv_,
228  ct.Hf_
229  );
230 }
231 
232 
233 template<class equationOfState>
234 inline Foam::eConstThermo<equationOfState> Foam::operator==
235 (
238 )
239 {
240  return ct2 - ct1;
241 }
242 
243 
244 // ************************ vim: set sw=4 sts=4 et: ************************ //