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