量纲不匹配
-
求助各位大佬,我想要在interFoam求解器的动量方程加阻尼消波项,修改UEqn.H,编译可以通过,运行算咧的时候报错量纲不匹配,改了好多次一直都是这个问题,是我定义的有问题吗
dimensionedScalar nu1 ( "nu1", dimensionSet(0,2,-1,0,0,0,0), 1.48e-05 ); dimensionedScalar nu2 ( "nu2", dimensionSet(0,2,-1,0,0,0,0), 1.0e-6 ); // Need to store rho for ddt(rho, U) volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*rho1 + alpha2*rho2 ); volScalarField nu ( IOobject ( "nu", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*nu1+alpha2*nu2 ); volScalarField muf ( IOobject ( "muf", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), rho*nu ); ![3.png](/assets/uploads/files/1734663338888-3.png)
dimensionedScalar r0 ( "r0", dimensionSet(0,0,-1,0,0,0,0), 0 ); dimensionedScalar r1 ( "r1", dimensionSet(0,0,-1,0,0,0,0), 5 ); dimensionedScalar x1 = max(mesh.Cf().component(vector::X))-min(mesh.Cf().component(vector::X)); dimensionedScalar x0 ( "x0", 2.4 ); volScalarField rField ( "rField", max(r1*(mesh.C().component(vector::X)-x0)/(x1-x0),r0) ); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) - fvm::laplacian(muf,U) - rho*U*rField );
-
@学流体的小明 后来我看了一下运行日志发现量纲不匹配并不是动量方程的量纲不匹配,是我在定义阻尼区起点的时候没有定义量纲所以会一直报错,后来把阻尼区起点定义量纲之后就可以啦,整个代码是这样的。```
dimensionedScalar r0 ( "r0", dimensionSet(0,0,-1,0,0,0,0), 0 ); dimensionedScalar r1 ( "r1", dimensionSet(0,0,-1,0,0,0,0), 5 ); dimensionedScalar x1 = max(mesh.Cf().component(vector::X))-min(mesh.Cf().component(vector::X)); dimensionedScalar x0 ( "x0", dimensionSet(0,1,0,0,0,0,0), 12 ); volScalarField R ( "R", max(r1*(mesh.C().component(vector::X)-x0)/(x1-x0),r0) ); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) - fvm::laplacian(muf,U) - (fvc::grad(U)&fvc::grad(muf)) + rho*U*R );