湍流模型编译的问题
-
这是我在雷诺应力中加入非线性的部分 ,目前是用复制的kEpsilon.C文件中进行修改,这里面的g1到g10都是标量,是一个系数。S跟W都是向量
void kEpsilonNN::correctNonlinearStress(const volTensorField& gradU) { timeScale_=k_/epsilon_; // Linear (nut) nut_ = -g1_*k_*timeScale_; nut_.correctBoundaryConditions(); // Quadratic (tau_NL) volSymmTensorField S(timeScale_*symm(gradU)); volTensorField W(timeScale_*skew(gradU)); nonlinearStress_ = 2 * k_ *( g2_ * ((S&W)-(W&S)) + g3_ * dev(innerSqr(S)) + g4_ * dev(W&W) + g5_ * ((W&innerSqr(S))-(innerSqr(S)&W)) + g6_ * ((W&W&S)-(dev2(S&W&W))) + g7_ * ((W&S&W&W)-(W&W&S&W)) + g8_ * ((S&W&innerSqr(S))-(innerSqr(S)&W&S)) + g9_ * ((W&W&innerSqr(S))+(dev2(innerSqr(S)&W&W))) + g10_ * ((W&innerSqr(S)&W&W)-(W&W&innerSqr(S)&W)) ); }
但是在编译的时候出现了这个问题。
error: no match for 'operator=' (operand types are 'Foam::volSymmTensorField' {aka 'Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh>'} and 'Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >') 81 | ); | ^
这是在我nonlinearStress_最后一个括号出现的。这是说我的nonlinearStress_没申明成向量还是啥呢?有人知道的吗?
还有人知道
, 是表示为 还是其他的呢? -
nonlinearStress_ = 2 * k_ *( g2_ * ((S&W)-(W&S)) + g3_ * dev(innerSqr(S)) + g4_ * dev(W&W) + g5_ * ((W&innerSqr(S))-(innerSqr(S)&W)) + g6_ * ((W&W&S)-(dev2(S&W&W))) + g7_ * ((W&S&W&W)-(W&W&S&W)) + g8_ * ((S&W&innerSqr(S))-(innerSqr(S)&W&S)) + g9_ * ((W&W&innerSqr(S))+(dev2(innerSqr(S)&W&W))) + g10_ * ((W&innerSqr(S)&W&W)-(W&W&innerSqr(S)&W)) );
代码量太多了,你可以只保留一个,然后编译看看有没有问题,然后增加一个看看。直到发现有问题的那一行
-
@李东岳 李老师,我是照着LienCubicKE.C的模板来加雷诺应力非线性项的,我看它的代码里面也是一样的写法,但是为什么就它的编译成功了呢?
void LienCubicKE::correctNonlinearStress(const volTensorField& gradU) { volSymmTensorField S(symm(gradU)); volTensorField W(skew(gradU)); volScalarField sBar((k_/epsilon_)*sqrt(2.0)*mag(S)); volScalarField wBar((k_/epsilon_)*sqrt(2.0)*mag(W)); volScalarField Cmu((2.0/3.0)/(Cmu1_ + sBar + Cmu2_*wBar)); volScalarField fMu(this->fMu()); nut_ = Cmu*fMu*sqr(k_)/epsilon_; nut_.correctBoundaryConditions(); nonlinearStress_ = fMu*k_ *( // Quadratic terms sqr(k_/epsilon_)/(Cbeta_ + pow3(sBar)) *( Cbeta1_*dev(innerSqr(S)) + Cbeta2_*twoSymm(S&W) + Cbeta3_*dev(symm(W&W)) ) // Cubic terms - pow3(Cmu*k_/epsilon_) *( (Cgamma1_*magSqr(S) - Cgamma2_*magSqr(W))*S + Cgamma4_*twoSymm((innerSqr(S)&W)) ) ); }
目前参考其他贴子[链接文本](https://www.cfd-china.com/topic/4128/修改湍流模型-定义表达式的问题?_=1705911573991) 里面的改,
volTensorField T2((S&W)-(W&S)); volSymmTensorField T3(dev(innerSqr(S))); volTensorField T4(dev(W & W)); volTensorField T5((W & innerSqr(S)) - (innerSqr(S) & W)); volTensorField T6((W & W & S) - (dev2(S & W & W))); volTensorField T7((W & S & W & W) - (W & W & S & W)); volTensorField T8((S & W & innerSqr(S)) - (innerSqr(S) & W & S)); volTensorField T9((W & W & innerSqr(S)) + (dev2(innerSqr(S) & W & W))); volTensorField T10((W & innerSqr(S) & W & W) - (W & W & innerSqr(S) & W)); volTensorField::Internal nonlinearStress_(2*k_*(g2_ * T2+ g3_ * T3+ g4_ * T4+ g5_ * T5+ g6_ * T6+ g7_ * T7+ g8_ * T8+ g9_ * T9+ g10_ * T10 ));
是编译成功了,但是有个问题,这个内部场的写法是有问题吗?我求的是全流场的
-
@李东岳 李老师,我试了按您那个CFD张量公式的介绍来写,能编译成功,但是按LienCubicKE.C里面的epsilon方程和k方程来写,运算时候直接发散了。于是,我按标准的kEpsilon的公式来写时,发现v2206和OF9的方程不一样,这是有什么说法吗?第一个是v2206的,第二个是of9的,两者差异在GbyNu的位置,一个跟Cmu,一个跟epsilon。我看蛮多文章里面的公式都跟of9一样的。
tmp<fvScalarMatrix> epsEqn ( fvm::ddt(alpha, rho, epsilon_) + fvm::div(alphaRhoPhi, epsilon_) - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_) == C1_*alpha()*rho()*GbyNu*Cmu_*k_() //Cmu? - fvm::SuSp(((2.0/3.0)*C1_ - C3_)*alpha()*rho()*divU, epsilon_) - fvm::Sp(C2_*alpha()*rho()*epsilon_()/k_(), epsilon_) + epsilonSource() + fvOptions(alpha, rho, epsilon_) );
tmp<fvScalarMatrix> epsEqn ( fvm::ddt(alpha, rho, epsilon_) + fvm::div(alphaRhoPhi, epsilon_) - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_) == C1_*alpha()*rho()*G*epsilon_()/k_() //epsilon? - fvm::SuSp(((2.0/3.0)*C1_ - C3_)*alpha()*rho()*divU, epsilon_) - fvm::Sp(C2_*alpha()*rho()*epsilon_()/k_(), epsilon_) + epsilonSource() + fvModels.source(alpha, rho, epsilon_) );
-
@李东岳 李老师,我看了应该是一样的,第一个是v2206,第二个是of9
const volScalarField::Internal divU ( fvc::div(fvc::absolute(this->phi(), U))().v() ); tmp<volTensorField> tgradU = fvc::grad(U); const volScalarField::Internal GbyNu ( this->type() + ":GbyNu", tgradU().v() && dev(twoSymm(tgradU().v())) ); const volScalarField::Internal G(this->GName(), nut()*GbyNu); tgradU.clear()
eddyViscosity<RASModel<BasicMomentumTransportModel>>::correct(); volScalarField::Internal divU ( fvc::div(fvc::absolute(this->phi(), U))() ); tmp<volTensorField> tgradU = fvc::grad(U); volScalarField::Internal G ( this->GName(), nut()*(dev(twoSymm(tgradU().v())) && tgradU().v()) ); tgradU.clear();