FreeFOAM The Cross-Platform CFD Toolkit
hRhoMixtureThermo.C
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) 2009-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 #include "hRhoMixtureThermo.H"
27 #include <finiteVolume/fvMesh.H>
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class MixtureType>
34 {
35  const scalarField& hCells = h_.internalField();
36  const scalarField& pCells = p_.internalField();
37 
38  scalarField& TCells = T_.internalField();
39  scalarField& psiCells = psi_.internalField();
40  scalarField& rhoCells = rho_.internalField();
41  scalarField& muCells = mu_.internalField();
42  scalarField& alphaCells = alpha_.internalField();
43 
44  forAll(TCells, celli)
45  {
46  const typename MixtureType::thermoType& mixture =
47  this->cellMixture(celli);
48 
49  TCells[celli] = mixture.TH(hCells[celli], TCells[celli]);
50  psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]);
51  rhoCells[celli] = mixture.rho(pCells[celli], TCells[celli]);
52 
53  muCells[celli] = mixture.mu(TCells[celli]);
54  alphaCells[celli] = mixture.alpha(TCells[celli]);
55  }
56 
57  forAll(T_.boundaryField(), patchi)
58  {
59  fvPatchScalarField& pp = p_.boundaryField()[patchi];
60  fvPatchScalarField& pT = T_.boundaryField()[patchi];
61  fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];
62  fvPatchScalarField& prho = rho_.boundaryField()[patchi];
63 
64  fvPatchScalarField& ph = h_.boundaryField()[patchi];
65 
66  fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi];
67  fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi];
68 
69  if (pT.fixesValue())
70  {
71  forAll(pT, facei)
72  {
73  const typename MixtureType::thermoType& mixture =
74  this->patchFaceMixture(patchi, facei);
75 
76  ph[facei] = mixture.H(pT[facei]);
77 
78  ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
79  prho[facei] = mixture.rho(pp[facei], pT[facei]);
80  pmu_[facei] = mixture.mu(pT[facei]);
81  palpha_[facei] = mixture.alpha(pT[facei]);
82  }
83  }
84  else
85  {
86  forAll(pT, facei)
87  {
88  const typename MixtureType::thermoType& mixture =
89  this->patchFaceMixture(patchi, facei);
90 
91  pT[facei] = mixture.TH(ph[facei], pT[facei]);
92 
93  ppsi[facei] = mixture.psi(pp[facei], pT[facei]);
94  prho[facei] = mixture.rho(pp[facei], pT[facei]);
95  pmu_[facei] = mixture.mu(pT[facei]);
96  palpha_[facei] = mixture.alpha(pT[facei]);
97  }
98  }
99  }
100 }
101 
102 
103 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
104 
105 template<class MixtureType>
107 :
108  hReactionThermo(mesh),
109  MixtureType(*this, mesh)
110 {
111  scalarField& hCells = h_.internalField();
112  const scalarField& TCells = T_.internalField();
113 
114  forAll(hCells, celli)
115  {
116  hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
117  }
118 
120  {
122  }
123 
125 
126  calculate();
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
132 template<class MixtureType>
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 
139 template<class MixtureType>
141 {
142  if (debug)
143  {
144  Info<< "entering hRhoMixtureThermo<MixtureType>::correct()" << endl;
145  }
146 
147  calculate();
148 
149  if (debug)
150  {
151  Info<< "exiting hRhoMixtureThermo<MixtureType>::correct()" << endl;
152  }
153 }
154 
155 
156 template<class MixtureType>
159 {
160  const fvMesh& mesh = T_.mesh();
161 
163  (
164  new volScalarField
165  (
166  IOobject
167  (
168  "hc",
169  mesh.time().timeName(),
170  mesh,
173  ),
174  mesh,
175  h_.dimensions()
176  )
177  );
178 
179  volScalarField& hcf = thc();
180  scalarField& hcCells = hcf.internalField();
181 
182  forAll(hcCells, celli)
183  {
184  hcCells[celli] = this->cellMixture(celli).Hc();
185  }
186 
187  forAll(hcf.boundaryField(), patchi)
188  {
189  scalarField& hcp = hcf.boundaryField()[patchi];
190 
191  forAll(hcp, facei)
192  {
193  hcp[facei] = this->patchFaceMixture(patchi, facei).Hc();
194  }
195  }
196 
197  return thc;
198 }
199 
200 
201 template<class MixtureType>
204 (
205  const scalarField& T,
206  const labelList& cells
207 ) const
208 {
209  tmp<scalarField> th(new scalarField(T.size()));
210  scalarField& h = th();
211 
212  forAll(T, celli)
213  {
214  h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
215  }
216 
217  return th;
218 }
219 
220 
221 template<class MixtureType>
224 (
225  const scalarField& T,
226  const label patchi
227 ) const
228 {
229  tmp<scalarField> th(new scalarField(T.size()));
230  scalarField& h = th();
231 
232  forAll(T, facei)
233  {
234  h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
235  }
236 
237  return th;
238 }
239 
240 
241 template<class MixtureType>
244 (
245  const scalarField& T,
246  const label patchi
247 ) const
248 {
249  tmp<scalarField> tCp(new scalarField(T.size()));
250 
251  scalarField& cp = tCp();
252 
253  forAll(T, facei)
254  {
255  cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
256  }
257 
258  return tCp;
259 }
260 
261 
262 template<class MixtureType>
265 {
266  const fvMesh& mesh = T_.mesh();
267 
269  (
270  new volScalarField
271  (
272  IOobject
273  (
274  "Cp",
275  mesh.time().timeName(),
276  mesh,
279  ),
280  mesh,
281  dimensionSet(0, 2, -2, -1, 0)
282  )
283  );
284 
285  volScalarField& cp = tCp();
286 
287  scalarField& cpCells = cp.internalField();
288  const scalarField& TCells = T_.internalField();
289 
290  forAll(TCells, celli)
291  {
292  cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]);
293  }
294 
295  forAll(T_.boundaryField(), patchi)
296  {
297  cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
298  }
299 
300  return tCp;
301 }
302 
303 
304 template<class MixtureType>
306 {
307  if (hReactionThermo::read())
308  {
309  MixtureType::read(*this);
310  return true;
311  }
312  else
313  {
314  return false;
315  }
316 }
317 
318 
319 // ************************ vim: set sw=4 sts=4 et: ************************ //