00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "hPsiThermo.H"
00028
00029
00030
00031 template<class MixtureType>
00032 void Foam::hPsiThermo<MixtureType>::calculate()
00033 {
00034 const scalarField& hCells = h_.internalField();
00035 const scalarField& pCells = this->p_.internalField();
00036
00037 scalarField& TCells = this->T_.internalField();
00038 scalarField& psiCells = this->psi_.internalField();
00039 scalarField& muCells = this->mu_.internalField();
00040 scalarField& alphaCells = this->alpha_.internalField();
00041
00042 forAll(TCells, celli)
00043 {
00044 const typename MixtureType::thermoType& mixture_ =
00045 this->cellMixture(celli);
00046
00047 TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
00048 psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
00049
00050 muCells[celli] = mixture_.mu(TCells[celli]);
00051 alphaCells[celli] = mixture_.alpha(TCells[celli]);
00052 }
00053
00054 forAll(T_.boundaryField(), patchi)
00055 {
00056 fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
00057 fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
00058 fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
00059
00060 fvPatchScalarField& ph = h_.boundaryField()[patchi];
00061
00062 fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
00063 fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
00064
00065 if (pT.fixesValue())
00066 {
00067 forAll(pT, facei)
00068 {
00069 const typename MixtureType::thermoType& mixture_ =
00070 this->patchFaceMixture(patchi, facei);
00071
00072 ph[facei] = mixture_.H(pT[facei]);
00073
00074 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00075 pmu[facei] = mixture_.mu(pT[facei]);
00076 palpha[facei] = mixture_.alpha(pT[facei]);
00077 }
00078 }
00079 else
00080 {
00081 forAll(pT, facei)
00082 {
00083 const typename MixtureType::thermoType& mixture_ =
00084 this->patchFaceMixture(patchi, facei);
00085
00086 pT[facei] = mixture_.TH(ph[facei], pT[facei]);
00087
00088 ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
00089 pmu[facei] = mixture_.mu(pT[facei]);
00090 palpha[facei] = mixture_.alpha(pT[facei]);
00091 }
00092 }
00093 }
00094 }
00095
00096
00097
00098
00099 template<class MixtureType>
00100 Foam::hPsiThermo<MixtureType>::hPsiThermo(const fvMesh& mesh)
00101 :
00102 basicPsiThermo(mesh),
00103 MixtureType(*this, mesh),
00104
00105 h_
00106 (
00107 IOobject
00108 (
00109 "h",
00110 mesh.time().timeName(),
00111 mesh,
00112 IOobject::NO_READ,
00113 IOobject::NO_WRITE
00114 ),
00115 mesh,
00116 dimensionSet(0, 2, -2, 0, 0),
00117 this->hBoundaryTypes()
00118 )
00119 {
00120 scalarField& hCells = h_.internalField();
00121 const scalarField& TCells = this->T_.internalField();
00122
00123 forAll(hCells, celli)
00124 {
00125 hCells[celli] = this->cellMixture(celli).H(TCells[celli]);
00126 }
00127
00128 forAll(h_.boundaryField(), patchi)
00129 {
00130 h_.boundaryField()[patchi] ==
00131 h(this->T_.boundaryField()[patchi], patchi);
00132 }
00133
00134 hBoundaryCorrection(h_);
00135
00136 calculate();
00137
00138
00139 this->psi_.oldTime();
00140 }
00141
00142
00143
00144
00145 template<class MixtureType>
00146 Foam::hPsiThermo<MixtureType>::~hPsiThermo()
00147 {}
00148
00149
00150
00151
00152 template<class MixtureType>
00153 void Foam::hPsiThermo<MixtureType>::correct()
00154 {
00155 if (debug)
00156 {
00157 Info<< "entering hPsiThermo<MixtureType>::correct()" << endl;
00158 }
00159
00160
00161 this->psi_.oldTime();
00162
00163 calculate();
00164
00165 if (debug)
00166 {
00167 Info<< "exiting hPsiThermo<MixtureType>::correct()" << endl;
00168 }
00169 }
00170
00171
00172 template<class MixtureType>
00173 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::h
00174 (
00175 const scalarField& T,
00176 const labelList& cells
00177 ) const
00178 {
00179 tmp<scalarField> th(new scalarField(T.size()));
00180 scalarField& h = th();
00181
00182 forAll(T, celli)
00183 {
00184 h[celli] = this->cellMixture(cells[celli]).H(T[celli]);
00185 }
00186
00187 return th;
00188 }
00189
00190
00191 template<class MixtureType>
00192 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::h
00193 (
00194 const scalarField& T,
00195 const label patchi
00196 ) const
00197 {
00198 tmp<scalarField> th(new scalarField(T.size()));
00199 scalarField& h = th();
00200
00201 forAll(T, facei)
00202 {
00203 h[facei] = this->patchFaceMixture(patchi, facei).H(T[facei]);
00204 }
00205
00206 return th;
00207 }
00208
00209
00210 template<class MixtureType>
00211 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::Cp
00212 (
00213 const scalarField& T,
00214 const label patchi
00215 ) const
00216 {
00217 tmp<scalarField> tCp(new scalarField(T.size()));
00218 scalarField& cp = tCp();
00219
00220 forAll(T, facei)
00221 {
00222 cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
00223 }
00224
00225 return tCp;
00226 }
00227
00228
00229 template<class MixtureType>
00230 Foam::tmp<Foam::volScalarField> Foam::hPsiThermo<MixtureType>::Cp() const
00231 {
00232 const fvMesh& mesh = this->T_.mesh();
00233
00234 tmp<volScalarField> tCp
00235 (
00236 new volScalarField
00237 (
00238 IOobject
00239 (
00240 "Cp",
00241 mesh.time().timeName(),
00242 mesh,
00243 IOobject::NO_READ,
00244 IOobject::NO_WRITE
00245 ),
00246 mesh,
00247 dimensionSet(0, 2, -2, -1, 0),
00248 this->T_.boundaryField().types()
00249 )
00250 );
00251
00252 volScalarField& cp = tCp();
00253
00254 forAll(this->T_, celli)
00255 {
00256 cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
00257 }
00258
00259 forAll(this->T_.boundaryField(), patchi)
00260 {
00261 const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
00262 fvPatchScalarField& pCp = cp.boundaryField()[patchi];
00263
00264 forAll(pT, facei)
00265 {
00266 pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
00267 }
00268 }
00269
00270 return tCp;
00271 }
00272
00273
00274 template<class MixtureType>
00275 Foam::tmp<Foam::scalarField> Foam::hPsiThermo<MixtureType>::Cv
00276 (
00277 const scalarField& T,
00278 const label patchi
00279 ) const
00280 {
00281 tmp<scalarField> tCv(new scalarField(T.size()));
00282 scalarField& cv = tCv();
00283
00284 forAll(T, facei)
00285 {
00286 cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
00287 }
00288
00289 return tCv;
00290 }
00291
00292
00293 template<class MixtureType>
00294 Foam::tmp<Foam::volScalarField> Foam::hPsiThermo<MixtureType>::Cv() const
00295 {
00296 const fvMesh& mesh = this->T_.mesh();
00297
00298 tmp<volScalarField> tCv
00299 (
00300 new volScalarField
00301 (
00302 IOobject
00303 (
00304 "Cv",
00305 mesh.time().timeName(),
00306 mesh,
00307 IOobject::NO_READ,
00308 IOobject::NO_WRITE
00309 ),
00310 mesh,
00311 dimensionSet(0, 2, -2, -1, 0)
00312 )
00313 );
00314
00315 volScalarField& cv = tCv();
00316
00317 forAll(this->T_, celli)
00318 {
00319 cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
00320 }
00321
00322 forAll(this->T_.boundaryField(), patchi)
00323 {
00324 cv.boundaryField()[patchi] =
00325 Cv(this->T_.boundaryField()[patchi], patchi);
00326 }
00327
00328 return tCv;
00329 }
00330
00331
00332 template<class MixtureType>
00333 bool Foam::hPsiThermo<MixtureType>::read()
00334 {
00335 if (basicPsiThermo::read())
00336 {
00337 MixtureType::read(*this);
00338 return true;
00339 }
00340 else
00341 {
00342 return false;
00343 }
00344 }
00345
00346
00347