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