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