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