OpenFOAM 可压缩湍流库深度解析

天涯浪子 提交于 2019-11-30 14:31:25

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

继承关系:

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 可压缩湍流库深度解析


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!