@huangyuhui723 以of10为例。
对的,he是通过heThermo.C里这个函数构造的。
he_
(
IOobject
(
BasicThermo::phasePropertyName
(
MixtureType::thermoType::heName(),
phaseName
),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
volScalarFieldProperty //这个函数确定cell和patch的值
(
"he",
dimEnergy/dimMass,
&MixtureType::cellThermoMixture, //cell
&MixtureType::patchFaceThermoMixture, //patch
&MixtureType::thermoMixtureType::HE,
this->p_,
this->T_
),
this->heBoundaryTypes(),
this->heBoundaryBaseTypes()
),
能看到he的边界是通过这个函数确定的:
template<class BasicThermo, class MixtureType>
template<class PatchFaceMixture, class Method, class ... Args>
Foam::tmp<Foam::scalarField>
Foam::heThermo<BasicThermo, MixtureType>::patchFieldProperty
(
PatchFaceMixture patchFaceMixture,
Method psiMethod,
const label patchi,
const Args& ... args
) const
{
tmp<scalarField> tPsi
(
new scalarField(this->T_.boundaryField()[patchi].size())
);
scalarField& psi = tPsi.ref();
forAll(this->T_.boundaryField()[patchi], facei)
{
psi[facei] =
((this->*patchFaceMixture)(patchi, facei).*psiMethod)
(
args[facei] ...
); //计算he边界上的值
}
return tPsi;
}
关键是这个patchFaceMixture函数,调用的是coefficientMultiComponentMixture.C里的:
template<class ThermoType>
const typename
Foam::coefficientMultiComponentMixture<ThermoType>::thermoMixtureType&
Foam::coefficientMultiComponentMixture<ThermoType>::patchFaceThermoMixture
(
const label patchi,
const label facei
) const
{
mixture_ =
this->Y()[0].boundaryField()[patchi][facei]
*this->specieThermos()[0];
for (label i=1; i<this->Y().size(); i++)
{
mixture_ +=
this->Y()[i].boundaryField()[patchi][facei]
*this->specieThermos()[i];
}
return mixture_;
}
可以看出混合物的he的边界值是通过上面这个函数更新的,即各个组分的质量分数加权求得的。如果需要更改边界值,修改这个函数。但是注意,直接修改这个函数会改变所有特性的值包括he。
speciesThermos()[i]指的是组分i的特性,OpenFOAM源代码中每个组分的焓值调用的是thermoI.H里的:
template<class Thermo, template<class> class Type>
inline Foam::scalar
Foam::species::thermo<Thermo, Type>::HE(const scalar p, const scalar T) const
{
return Type<thermo<Thermo, Type>>::HE(*this, p, T);
}
调用的是sensibleEnthalpy.H里的:
scalar HE
(
const Thermo& thermo,
const scalar p,
const scalar T
) const
{
return thermo.Hs(p, T);
}
调用的是janafThermoI.H里的:
template<class EquationOfState>
inline Foam::scalar Foam::janafThermo<EquationOfState>::Hs //显焓
(
const scalar p,
const scalar T
) const
{
return Ha(p, T) - Hf();
}
template<class EquationOfState>
inline Foam::scalar Foam::janafThermo<EquationOfState>::Ha //总焓
(
const scalar p,
const scalar T
) const
{
const coeffArray& a = coeffs(T);
return
(
((((a[4]/5.0*T + a[3]/4.0)*T + a[2]/3.0)*T + a[1]/2.0)*T + a[0])*T
+ a[5]
) + EquationOfState::H(p, T);
}
template<class EquationOfState>
inline Foam::scalar Foam::janafThermo<EquationOfState>::Hf() const //生成焓
{
const coeffArray& a = lowCpCoeffs_;
return
(
(
(((a[4]/5.0*Tstd + a[3]/4.0)*Tstd + a[2]/3.0)*Tstd + a[1]/2.0)*Tstd
+ a[0]
)*Tstd + a[5]
);
}
也就是说,如果要更改每个组分的特性,需要改变不同的janaf系数,这一般是不可能这么做的。当然,可以使用不同的thermo模型。
上面仅以coefficientMultiComponentMixture和janaf为例说明这些函数的调用关系。OpenFOAM0-10中很多调用关系,比如&MixtureType::thermoMixtureType::HE,理解会有点难。
如果觉得OpenFOAM0-10中这些关系难以理解,建议看看ESI版本的OpenFOAM(比如OpenFOAM-v2012)和基金会以前的版本(比如OpenFOAM-6和OpenFOAM-7),这些版本的代码直接很多,但意思是一样的,会容易理解很多。
供参考。