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