FreeFOAM The Cross-Platform CFD Toolkit
hConstThermoI.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 cp,
33  const scalar hf
34 )
35 :
36  equationOfState(st),
37  Cp_(cp),
38  Hf_(hf)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 template<class equationOfState>
46 (
47  const word& name,
48  const hConstThermo& ct
49 )
50 :
51  equationOfState(name, ct),
52  Cp_(ct.Cp_),
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 Cp_*this->W();
88 }
89 
90 
91 template<class equationOfState>
93 (
94  const scalar T
95 ) const
96 {
97  return (Cp_*T + Hf_)*this->W();
98 }
99 
100 
101 template<class equationOfState>
102 inline Foam::scalar Foam::hConstThermo<equationOfState>::hs
103 (
104  const scalar T
105 ) const
106 {
107  return Cp_*T*this->W();
108 }
109 
110 
111 template<class equationOfState>
112 inline Foam::scalar Foam::hConstThermo<equationOfState>::hc() const
113 {
114  return Hf_*this->W();
115 }
116 
117 
118 template<class equationOfState>
119 inline Foam::scalar Foam::hConstThermo<equationOfState>::s
120 (
121  const scalar T
122 ) const
123 {
125  (
126  "scalar hConstThermo<equationOfState>::s(const scalar T) const"
127  );
128  return T;
129 }
130 
131 
132 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
133 
134 template<class equationOfState>
136 (
138 )
139 {
140  scalar molr1 = this->nMoles();
141 
142  equationOfState::operator+=(ct);
143 
144  molr1 /= this->nMoles();
145  scalar molr2 = ct.nMoles()/this->nMoles();
146 
147  Cp_ = molr1*Cp_ + molr2*ct.Cp_;
148  Hf_ = molr1*Hf_ + molr2*ct.Hf_;
149 }
150 
151 
152 template<class equationOfState>
153 inline void Foam::hConstThermo<equationOfState>::operator-=
154 (
156 )
157 {
158  scalar molr1 = this->nMoles();
159 
160  equationOfState::operator-=(ct);
161 
162  molr1 /= this->nMoles();
163  scalar molr2 = ct.nMoles()/this->nMoles();
164 
165  Cp_ = molr1*Cp_ - molr2*ct.Cp_;
166  Hf_ = molr1*Hf_ - molr2*ct.Hf_;
167 }
168 
169 
170 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
171 
172 template<class equationOfState>
173 inline Foam::hConstThermo<equationOfState> Foam::operator+
174 (
177 )
178 {
179  equationOfState eofs
180  (
181  static_cast<const equationOfState&>(ct1)
182  + static_cast<const equationOfState&>(ct2)
183  );
184 
186  (
187  eofs,
188  ct1.nMoles()/eofs.nMoles()*ct1.Cp_
189  + ct2.nMoles()/eofs.nMoles()*ct2.Cp_,
190  ct1.nMoles()/eofs.nMoles()*ct1.Hf_
191  + ct2.nMoles()/eofs.nMoles()*ct2.Hf_
192  );
193 }
194 
195 
196 template<class equationOfState>
197 inline Foam::hConstThermo<equationOfState> Foam::operator-
198 (
201 )
202 {
203  equationOfState eofs
204  (
205  static_cast<const equationOfState&>(ct1)
206  - static_cast<const equationOfState&>(ct2)
207  );
208 
210  (
211  eofs,
212  ct1.nMoles()/eofs.nMoles()*ct1.Cp_
213  - ct2.nMoles()/eofs.nMoles()*ct2.Cp_,
214  ct1.nMoles()/eofs.nMoles()*ct1.Hf_
215  - ct2.nMoles()/eofs.nMoles()*ct2.Hf_
216  );
217 }
218 
219 
220 template<class equationOfState>
221 inline Foam::hConstThermo<equationOfState> Foam::operator*
222 (
223  const scalar s,
225 )
226 {
228  (
229  s*static_cast<const equationOfState&>(ct),
230  ct.Cp_,
231  ct.Hf_
232  );
233 }
234 
235 
236 template<class equationOfState>
237 inline Foam::hConstThermo<equationOfState> Foam::operator==
238 (
241 )
242 {
243  return ct2 - ct1;
244 }
245 
246 
247 // ************************ vim: set sw=4 sts=4 et: ************************ //