在linearViscousStress中硬植入nonlinearStress非线性应力
-
@李东岳 在 关于修改湍流模型中非线性雷诺应力项的问题 中说:
我觉得你不用这么写。你动继承肯定会有一些问题,目前也看不出来,不是很strightworrd。比较简单的是:
kOmega.H头文件不用动,你先去把tau植入到你的kOmega.C里面
计算G
去devTau函数里面把tau的非线性部分加上第一种简单一些,但有一些硬植入。就是devTau函数这块
现在我尝试采用硬植入的方式更改divDevRhoReff,原定义nonlinearEddyViscosity.H中:
protected: // Fields volSymmTensorField nonlinearStress_;
nonlinearEddyViscosity.C中:
nonlinearStress_ ( IOobject ( IOobject::groupName("nonlinearStress", alphaRhoPhi.group()), this->runTime_.timeName(), this->mesh_ ), this->mesh_, dimensionedSymmTensor ( "nonlinearStress", sqr(dimVelocity), Zero ) )
仿照上面,我在linearViscousStress.C中:
/ * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // tensor I(1,0,0,0,1,0,0,0,1); volSymmTensorField S(twoSymm(fvc::grad(this->U_))); volTensorField W(twoSkew(fvc::grad(this->U_))); nonlinearStress_ ( IOobject ( IOobject::groupName("nonlinearStress", alphaRhoPhi.group()), this->runTime_.timeName(), this->mesh_ ), this->mesh_, dimensionedSymmTensor ( "nonlinearStress", sqr(dimVelocity), 1/omega_*(S&S - (1/3)*magSqr(W)*I + twoSymm(S&W) + (2.5)*(W&W - (1/3)*magSqr(W)*I)) ) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class BasicTurbulenceModel> Foam::tmp<Foam::fvVectorMatrix> Foam::linearViscousStress<BasicTurbulenceModel>::divDevRhoReff // ( const volScalarField& rho, volVectorField& U ) const { return ( - fvc::div((this->alpha_*rho*this->nuEff())*dev2(T(fvc::grad(U)))) -fvc::div((this->alpha_*rho*this->nuEff())* nonlinearStress_ ) //????? - fvm::laplacian(this->alpha_*rho*this->nuEff(), U) ); }
疑问:这样在Constructor给 nonlinearStress_ 赋值对不对?如果可以,最棘手的是nonlinearStress_中含有一个omega_,怎么声明引用?只在上面加一个相应湍流模型的H文件就可以吗?
没系统学过c++,对改写模棱两可,希望各位能直面迷津 -
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class BasicTurbulenceModel> Foam::linearViscousStress<BasicTurbulenceModel>::linearViscousStress ( const word& modelName, const alphaField& alpha, const rhoField& rho, const volVectorField& U, const surfaceScalarField& alphaRhoPhi, const surfaceScalarField& phi, const transportModel& transport, const word& propertiesName ) : BasicTurbulenceModel ( modelName, alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName ), nonlinearStress_ ( IOobject ( IOobject::groupName("nonlinearStress", alphaRhoPhi.group()), this->runTime_.timeName(), this->mesh_ ), this->mesh_, dimensionedSymmTensor ( "nonlinearStress", sqr(dimVelocity), Zero ) ) { tensor I(1,0,0,0,1,0,0,0,1); volSymmTensorField S(twoSymm(fvc::grad(this->U_))); volTensorField W(twoSkew(fvc::grad(this->U_))); nonlinearStress_ = 1/omega_ //omega_??? *( S&S - (1/3)*magSqr(W)*I + twoSymm(S&W) + (2.5)*(W&W - (1/3)*magSqr(W)*I)); }
类似这样吗?修正直接跟在后面,那对于omega_是直接在:inearViscousStress.H文件中定义:
volScalarField omega_; 然后使用就可以吗? 麻烦老师了~