MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
twoPhaseMixtureThermo.C
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
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 #include "twoPhaseMixtureThermo.H"
27 #include "gradientEnergyFvPatchScalarField.H"
28 #include "mixedEnergyFvPatchScalarField.H"
29 
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(twoPhaseMixtureThermo, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
41 Foam::twoPhaseMixtureThermo::twoPhaseMixtureThermo
42 (
43  const fvMesh& mesh
44 )
45 :
46  psiThermo(mesh, word::null),
47  twoPhaseMixture(mesh, *this),
48  thermo1_(NULL),
49  thermo2_(NULL)
50 {
51  {
52  volScalarField T1(IOobject::groupName("T", phase1Name()), T_);
53  T1.write();
54  }
55 
56  {
57  volScalarField T2(IOobject::groupName("T", phase2Name()), T_);
58  T2.write();
59  }
60 
61  thermo1_ = rhoThermo::New(mesh, phase1Name());
62  thermo2_ = rhoThermo::New(mesh, phase2Name());
63 
64  thermo1_->validate(phase1Name(), "e");
65  thermo2_->validate(phase2Name(), "e");
66 
67  correct();
68 }
69 
70 
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 
73 Foam::twoPhaseMixtureThermo::~twoPhaseMixtureThermo()
74 {}
75 
76 
77 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
78 
79 void Foam::twoPhaseMixtureThermo::correct()
80 {
81  thermo1_->he() = thermo1_->he(p_, T_);
82  thermo1_->correct();
83 
84  thermo2_->he() = thermo2_->he(p_, T_);
85  thermo2_->correct();
86 
87  psi_ = alpha1()*thermo1_->psi() + alpha2()*thermo2_->psi();
88  mu_ = alpha1()*thermo1_->mu() + alpha2()*thermo2_->mu();
89  alpha_ = alpha1()*thermo1_->alpha() + alpha2()*thermo2_->alpha();
90 }
91 
92 
93 bool Foam::twoPhaseMixtureThermo::incompressible() const
94 {
95  return thermo1_->incompressible() && thermo2_->incompressible();
96 }
97 
98 
99 bool Foam::twoPhaseMixtureThermo::isochoric() const
100 {
101  return thermo1_->isochoric() && thermo2_->isochoric();
102 }
103 
104 
105 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::he
106 (
107  const volScalarField& p,
108  const volScalarField& T
109 ) const
110 {
111  return alpha1()*thermo1_->he(p, T) + alpha2()*thermo2_->he(p, T);
112 }
113 
114 
115 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::he
116 (
117  const scalarField& p,
118  const scalarField& T,
119  const labelList& cells
120 ) const
121 {
122  return
123  scalarField(alpha1(), cells)*thermo1_->he(p, T, cells)
124  + scalarField(alpha2(), cells)*thermo2_->he(p, T, cells);
125 }
126 
127 
128 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::he
129 (
130  const scalarField& p,
131  const scalarField& T,
132  const label patchi
133 ) const
134 {
135  return
136  alpha1().boundaryField()[patchi]*thermo1_->he(p, T, patchi)
137  + alpha2().boundaryField()[patchi]*thermo2_->he(p, T, patchi);
138 }
139 
140 
141 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::hc() const
142 {
143  return alpha1()*thermo1_->hc() + alpha2()*thermo2_->hc();
144 }
145 
146 
147 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::THE
148 (
149  const scalarField& h,
150  const scalarField& p,
151  const scalarField& T0,
152  const labelList& cells
153 ) const
154 {
155  notImplemented("twoPhaseMixtureThermo::THE(...)");
156  return T0;
157 }
158 
159 
160 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::THE
161 (
162  const scalarField& h,
163  const scalarField& p,
164  const scalarField& T0,
165  const label patchi
166 ) const
167 {
168  notImplemented("twoPhaseMixtureThermo::THE(...)");
169  return T0;
170 }
171 
172 
173 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::Cp() const
174 {
175  return alpha1()*thermo1_->Cp() + alpha2()*thermo2_->Cp();
176 }
177 
178 
179 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::Cp
180 (
181  const scalarField& p,
182  const scalarField& T,
183  const label patchi
184 ) const
185 {
186  return
187  alpha1().boundaryField()[patchi]*thermo1_->Cp(p, T, patchi)
188  + alpha2().boundaryField()[patchi]*thermo2_->Cp(p, T, patchi);
189 }
190 
191 
192 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::Cv() const
193 {
194  return alpha1()*thermo1_->Cv() + alpha2()*thermo2_->Cv();
195 }
196 
197 
198 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::Cv
199 (
200  const scalarField& p,
201  const scalarField& T,
202  const label patchi
203 ) const
204 {
205  return
206  alpha1().boundaryField()[patchi]*thermo1_->Cv(p, T, patchi)
207  + alpha2().boundaryField()[patchi]*thermo2_->Cv(p, T, patchi);
208 }
209 
210 
211 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::gamma() const
212 {
213  return alpha1()*thermo1_->gamma() + alpha2()*thermo2_->gamma();
214 }
215 
216 
217 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::gamma
218 (
219  const scalarField& p,
220  const scalarField& T,
221  const label patchi
222 ) const
223 {
224  return
225  alpha1().boundaryField()[patchi]*thermo1_->gamma(p, T, patchi)
226  + alpha2().boundaryField()[patchi]*thermo2_->gamma(p, T, patchi);
227 }
228 
229 
230 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::Cpv() const
231 {
232  return alpha1()*thermo1_->Cpv() + alpha2()*thermo2_->Cpv();
233 }
234 
235 
236 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::Cpv
237 (
238  const scalarField& p,
239  const scalarField& T,
240  const label patchi
241 ) const
242 {
243  return
244  alpha1().boundaryField()[patchi]*thermo1_->Cpv(p, T, patchi)
245  + alpha2().boundaryField()[patchi]*thermo2_->Cpv(p, T, patchi);
246 }
247 
248 
249 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::CpByCpv() const
250 {
251  return
252  alpha1()*thermo1_->CpByCpv()
253  + alpha2()*thermo2_->CpByCpv();
254 }
255 
256 
257 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::CpByCpv
258 (
259  const scalarField& p,
260  const scalarField& T,
261  const label patchi
262 ) const
263 {
264  return
265  alpha1().boundaryField()[patchi]*thermo1_->CpByCpv(p, T, patchi)
266  + alpha2().boundaryField()[patchi]*thermo2_->CpByCpv(p, T, patchi);
267 }
268 
269 
270 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::kappa() const
271 {
272  return alpha1()*thermo1_->kappa() + alpha2()*thermo2_->kappa();
273 }
274 
275 
276 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::kappa
277 (
278  const label patchi
279 ) const
280 {
281  return
282  alpha1().boundaryField()[patchi]*thermo1_->kappa(patchi)
283  + alpha2().boundaryField()[patchi]*thermo2_->kappa(patchi);
284 }
285 
286 
287 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::kappaEff
288 (
289  const volScalarField& alphat
290 ) const
291 {
292  return
293  alpha1()*thermo1_->kappaEff(alphat)
294  + alpha2()*thermo2_->kappaEff(alphat);
295 }
296 
297 
298 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::kappaEff
299 (
300  const scalarField& alphat,
301  const label patchi
302 ) const
303 {
304  return
305  alpha1().boundaryField()[patchi]*thermo1_->kappaEff(alphat, patchi)
306  + alpha2().boundaryField()[patchi]*thermo2_->kappaEff(alphat, patchi)
307  ;
308 }
309 
310 
311 Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::alphaEff
312 (
313  const volScalarField& alphat
314 ) const
315 {
316  return
317  alpha1()*thermo1_->alphaEff(alphat)
318  + alpha2()*thermo2_->alphaEff(alphat);
319 }
320 
321 
322 Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::alphaEff
323 (
324  const scalarField& alphat,
325  const label patchi
326 ) const
327 {
328  return
329  alpha1().boundaryField()[patchi]*thermo1_->alphaEff(alphat, patchi)
330  + alpha2().boundaryField()[patchi]*thermo2_->alphaEff(alphat, patchi)
331  ;
332 }
333 
334 
335 // ************************************************************************* //