LHS and RHS of + have different dimensions



  • 0_1461484152803_QQ截图20160424155317.png



  • 这种错误出在什么地方呢



  • 对于带量纲的量,在做加法或减法的时候会检查量纲,只有相同量纲的量才会做加减,量纲不同的量是不行的,比如速度+时间=?,所以这个问题肯定是你哪个量的量纲弄错了。不同量纲的量可以做乘除运算



  • 0_1461500609852_1461243530932-qq截图20160421205531.png



  • rho2() 为0, VSMALL没有单位? 该怎样解决呢?



  • 你这个是为了避免分母除0是吧,VSMALL=1.0e-37,是一个scalar的量,从代码上看rho1(),rho2()应该是两个volScalarField类型,有一种办法就是构造一个同样的volScalarField场,比如

    volScalarField zeroField
    (
         IOobject
         (
              "ZERO",
              runTime.timeName(),
              mesh
         ),
         mesh,
         dimesionedScalar("vsmall", dimensionSet(1,-3,0,0,0,0,0), VSMALL)
    )
    

    名字嘛,如果不lookup的话,随便起吧。



  • 很感谢!



  • @Aeronastro @administrators 试了一下,好像不行哦



  • @mark 什么错误?可以附图吗?



  • Create time
    
    Create mesh for time = 0
    
    
    Reading g
    
    PIMPLE: Operating solver in PISO mode
    
    Reading field p_rgh
    
    Reading field U
    
    Reading/calculating face flux field phi
    
    Constructing twoPhaseMixtureThermo
    
    Selecting thermodynamics package 
    {
        type            heRhoThermo;
        mixture         pureMixture;
        transport       sutherland;
        thermo          hConst;
        equationOfState PengRobinsonGas;
        specie          specie;
        energy          sensibleEnthalpy;
    }
    
    Selecting thermodynamics package 
    {
        type            heRhoThermo;
        mixture         pureMixture;
        transport       sutherland;
        thermo          hConst;
        equationOfState PengRobinsonGas;
        specie          specie;
        energy          sensibleEnthalpy;
    }
    
    Reading thermophysical properties
    
    --> FOAM Warning : 
        From function GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
        in file /opt/openfoam240/src/OpenFOAM/lnInclude/GeometricField.C at line 108
        read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED suggests that a read constructor for field rho1 would be more appropriate.
    --> FOAM Warning : 
        From function GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
        in file /opt/openfoam240/src/OpenFOAM/lnInclude/GeometricField.C at line 108
        read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED suggests that a read constructor for field rho2 would be more appropriate.
    Creating phaseChangeTwoPhaseMixture
    
    Selecting phaseChange model SchnerrSauer
    Calculating field g.h
    
    Selecting turbulence model type LESModel
    Selecting LES turbulence model oneEqEddy
    Selecting LES delta type smooth
    Selecting LES delta type cubeRootVol
    oneEqEddyCoeffs
    {
        ce              1.048;
        Prt             1;
        ck              0.094;
    }
    
    Creating field kinetic energy K
    
    No finite volume options present
    
    Courant Number mean: 4.9504176e-07 max: 1.9500023e-05
    
    Starting time loop
    
    Courant Number mean: 4.9014036e-07 max: 1.9306953e-05
    deltaT = 9.9009901e-09
    Time = 9.90099e-09
    
    PIMPLE: iteration 1
    
    
    --> FOAM FATAL ERROR: 
    LHS and RHS of + have different dimensions
         dimensions : [1 -3 0 0 0 0 0] + [0 0 0 0 0 0 0]
    
    
        From function operator+(const dimensionSet&, const dimensionSet&)
        in file dimensionSet/dimensionSet.C at line 478.
    
    FOAM aborting
    
    #0  Foam::error::printStack(Foam::Ostream&) at ??:?
    #1  Foam::error::abort() at ??:?
    #2  Foam::operator+(Foam::dimensionSet const&, Foam::dimensionSet const&) at ??:?
    #3  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator+<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensioned<double> const&) at ??:?
    #4  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator+<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, double const&) at ??:?
    #5  Foam::phaseChangeTwoPhaseMixture::vDotAlphal() const at ??:?
    #6  ? at ??:?
    #7  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
    #8  ? at ??:?
    已放弃 (核心已转储)
    zhubin@zhubin-System-Product-Name:~/OpenFOAM/zhubin-2.4.0/run/tutorials/myFoam$
    


  • @mark 还是dimension不匹配,你在代码里把rho2()+VSMALL改成rho2()+zeroField了吗?



  • @Aeronastro
    防止分母为0 ,我设置一个dimensionedScalar small_ ,
    small = 1.0e-36 这样一个非常小的数可以吗?
    volScalarField alphalCoeff(1.0/rho1() - alpha1_*(1.0/rho1() - 1.0/(rho2() + small())));
    这样就可以算了:sunglasses: 请指教..



  • @mark 嗯嗯,只要给定量纲就可以了,dimensionedScalar设置了量纲,而且operator+可以使volscalarField和dimensionedScalar可以相加就没问题了

    我不明白,为什么设置新的volScalarField这样的场不行呢?你试过不行是吗?



  • @Aeronastro 应该也可以的,刚才我忘记wmake那个库文件,直接wmake求解器了,先这样算着,我改天再试一下



  • @Aeronastro dimesionedScalar拼写错了,是dimensionedScalar;结尾还有分号“;”。



  • @Foamer24

    你回贴的这俩位我还有点印象,2016年的时候他们俩研究的还很深刻,后来就没怎么来过。不知道最近怎么样了,有没有在CFD。我有种预感他俩是不是转行了...


Log in to reply