OpenFOAM 可压缩湍流库深度解析

分析可压缩湍流部分的继承关系

继承关系:

OpenFOAM 可压缩湍流库深度解析

solver 中:

Info << "Creating turbulence model.n" << nl;
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo
)
);

其中 Foam::compressible::turbulenceModelFoam::compressible::ThermalDiffusivity<CompressibleTurbulenceModel<fluidThermo>>typedef

所以这里首先调用的是 ThermalDiffusivity 中的 New

template<class BasicTurbulenceModel>
Foam::autoPtr<Foam::ThermalDiffusivity<BasicTurbulenceModel>>
Foam::ThermalDiffusivity<BasicTurbulenceModel>::New
(
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
{
return autoPtr<ThermalDiffusivity>
(
static_cast<ThermalDiffusivity*>(
BasicTurbulenceModel::New
(
rho,
U,
phi,
transport,
propertiesName
).ptr())
);
}

CompressibleTurbulenceModel<class TransportModel>BasicTurbulenceModel 的实例化,
因此接下来来到了 CompressibleTurbulenceModel
声明:

template<class TransportModel>
class CompressibleTurbulenceModel
:
public TurbulenceModel
<
geometricOneField,
volScalarField,
compressibleTurbulenceModel,
TransportModel
>

New 函数:

template<class TransportModel>
Foam::autoPtr<Foam::CompressibleTurbulenceModel<TransportModel>>
Foam::CompressibleTurbulenceModel<TransportModel>::New
(
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
{
return autoPtr<CompressibleTurbulenceModel>
(
static_cast<CompressibleTurbulenceModel*>(
TurbulenceModel
<
geometricOneField,
volScalarField,
compressibleTurbulenceModel,
transportModel
>::New
(
geometricOneField(),
rho,
U,
phi,
phi,
transport,
propertiesName
).ptr())
);
}

接着来到 TurbulenceModel 这里用到了 RTS
New 函数:

static autoPtr<TurbulenceModel> New
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName = turbulenceModel::propertiesName
);

构造函数:

Foam::TurbulenceModel<Alpha, Rho, BasicTurbulenceModel, TransportModel>::
TurbulenceModel
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
:
BasicTurbulenceModel
(
rho,
U,
alphaRhoPhi,
phi,
propertiesName
),
alpha_(alpha),
transport_(transport)
{}

它的模板基类 BasicTurbulenceModel 的实例化是 compressibleTurbulenceModel

Foam::compressibleTurbulenceModel::compressibleTurbulenceModel
(
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const word& propertiesName
)
:
turbulenceModel
(
U,
alphaRhoPhi,
phi,
propertiesName
),
rho_(rho)
{}

最后终于来到了幕后大 Boss:turbulenceModel 面前:

Foam::turbulenceModel::turbulenceModel
(
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const word& propertiesName
)

初始化列表中:alphaRhoPhi_(alphaRhoPhi)
另有函数:

inline const surfaceScalarField& alphaRhoPhi() const
{
return alphaRhoPhi_;
}

combustionModel.H 中:

inline Foam::tmp<Foam::surfaceScalarField> Foam::combustionModel::phi() const
{
return turbulence().alphaRhoPhi();
}

就是说,solver#include "compressibleCreatePhi.H" 创建的 phi 逐级传到了湍流模型中,我可以使用 Foam::combustionModel::phi() 来调用它!!!这是合理的!!!

原文:大专栏  OpenFOAM 可压缩湍流库深度解析


上一篇:【模板】Pollard-Rho算法


下一篇:浅谈质因数分解