OpenFOAM中的时间步
-
谢谢东岳大神。但是我现在有个算法,按照这个植入好像算的结果不对,能算一个周期的时间步只算了不到一个周期。
具体算法如下:
代码如下```
code_text{ const dimensionedScalar DeltaT = runTime.deltaT(); dimensionedScalar r = 1.5; volScalarField alpha10("alpha10", 2*alpha1-alpha1.oldTime()); volScalarField alpha11("alpha11", 2*alpha1-0.5*alpha1.oldTime()); volVectorField U10("U10",2*U-U.oldTime()); phi10 = fvc::interpolate(U10)& mesh.Sf(); H = twoPhaseProperties.calcuH(alpha10); H.correctBoundaryConditions(); dimensionedScalar beta_ = sqrt(1.5/(thicknesss_*thicknesss_*Mu_*DeltaT)); fvScalarMatrix midEqn ( fvm::laplacian(mid) -fvm::Sp((c-sqrt(c*c-1))*beta_,mid) ); solve ( midEqn == (-fvc::div(phi10,alpha10)+alpha11/DeltaT)/(thicknesss_*thicknesss_*Mu_) +fvc::laplacian(H/(thicknesss_*thicknesss_)-2*c*beta_*alpha10) ); mid.correctBoundaryConditions(); fvScalarMatrix alpha1Eqn ( fvm::laplacian(alpha1) -fvm::Sp((c+sqrt(c*c-1))*beta_,alpha1) ); solve ( alpha1Eqn ==mid ); alpha1.correctBoundaryConditions(); alpha1 = max(min(alpha1,1.0),-1.0); alpha1.correctBoundaryConditions(); }
这是计算一个周期的结果
如果我将代码更改为code_text ```{ const dimensionedScalar DeltaT = runTime.deltaT(); dimensionedScalar r = 1.5; volScalarField alpha10("alpha10", 2*alpha1.oldTime()-alpha1.oldTime().oldTime()); volScalarField alpha11("alpha11", 2*alpha1.oldTime()-0.5*alpha1.oldTime().oldTime()); volVectorField U10("U10",2*U.oldTime()-U.oldTime().oldTime()); phi10 = fvc::interpolate(U10)& mesh.Sf(); H = twoPhaseProperties.calcuH(alpha10); H.correctBoundaryConditions(); dimensionedScalar beta_ = sqrt(1.5/(thicknesss_*thicknesss_*Mu_*DeltaT)); fvScalarMatrix midEqn ( fvm::laplacian(mid) -fvm::Sp((c-sqrt(c*c-1))*beta_,mid) ); solve ( midEqn == (-fvc::div(phi10,alpha10)+alpha11/DeltaT)/(thicknesss_*thicknesss_*Mu_) +fvc::laplacian(H/(thicknesss_*thicknesss_)-2*c*beta_*alpha10) ); mid.correctBoundaryConditions(); fvScalarMatrix alpha1Eqn ( fvm::laplacian(alpha1) -fvm::Sp((c+sqrt(c*c-1))*beta_,alpha1) ); solve ( alpha1Eqn ==mid ); alpha1.correctBoundaryConditions(); alpha1 = max(min(alpha1,1.0),-1.0); alpha1.correctBoundaryConditions(); }
这是这段代码的计算结果
这才是一个周期,我实在是弄不清楚问题在哪希望大佬可以解答一下 -
while (runTime.loop()) { Info<< "Time = " << runTime.userTimeName() << nl << endl; #include "CourantNo.H" // Pressure-velocity PISO corrector { fvModels.correct(); #include "UEqn.H" 如果不进行动量预测 U都是当前时间步 // --- PISO loop while (piso.correct()) { #include "pEqn.H" } 在这面之后U是下一个时间步的 } viscosity->correct(); turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; }
你那个我看不太懂,用上面的代码举例是这样
-
按照上述算法来执行,也就是第一二步写成如下形成:volScalarField alpha10("alpha10", 2*alpha1-alpha1.oldTime()); volScalarField alpha11("alpha11", 2*alpha1-0.5*alpha1.oldTime());
是不对的,如果写成
volScalarField alpha10("alpha10", 2*alpha1.oldTime()-alpha1.oldTime().oldTime()); volScalarField alpha11("alpha11", 2*alpha1.oldTime()-0.5*alpha1.oldTime().oldTime());
算法就变成了就可以求解,只是求解精度比matlab上写的精度差一点,应该是第一二步有点问题。图片中的算法在matlab中实施起来是没问题的