Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    编译求解器时遇到:assignment of read-only location,求各位老师解答!

    OpenFOAM
    2
    5
    844
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • strive_DUT
      strive_DUT last edited by 李东岳

      编译求解器时遇到这样一个问题:

      assignment of read-only location ‘(& rho.Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::internalField())->Foam::DimensionedField<double, Foam::volMesh>::<anonymous>.Foam::Field<double>::<anonymous>.Foam::List<double>::<anonymous>.Foam::UList<double>::operator[](celli)’
      

      TIM图片20191122091402.jpg
      提示有问题的代码是这样的:

      rho.internalField()[celli] = rho0 - ((rho0*Ru*TCells[celli])/(Mw - b*rho0) - (a*aa*rho0*rho0)/(Mw*Mw + 2.0*b*Mw*rho0 - b*b*rho0*rho0) - pCells[celli])/((Ru*TCells[celli])/(Mw - b*rho0) - (2.0*a*aa*rho0)/(Mw*Mw + 2.0*b*rho0*Mw - b*b*rho0*rho0) + (Ru*TCells[celli]*b*rho0)/Foam::pow(Mw - b*rho0,2) + (a*aa*rho0*rho0*(2.0*Mw*b - 2.0*b*b*rho0))/Foam::pow(Mw*Mw + 2.0*b*rho0*Mw - b*b*rho0*rho0,2));
      

      这段代码之前是在foam-extend版本编译成功的,现在在OpenFOAM-7上编译报错的。。。。

      1 Reply Last reply Reply Quote
      • 李东岳
        李东岳 管理员 last edited by

        rho.ref().[celli]
        

        CFD高性能服务器 http://dyfluid.com/servers.html

        1 Reply Last reply Reply Quote
        • strive_DUT
          strive_DUT last edited by

          李老师您好!您的意思是internalField()用ref()代替吗?

          李东岳 1 Reply Last reply Reply Quote
          • 李东岳
            李东岳 管理员 @strive_DUT last edited by

            @strive_DUT 是的,你试试

            CFD高性能服务器 http://dyfluid.com/servers.html

            strive_DUT 1 Reply Last reply Reply Quote
            • strive_DUT
              strive_DUT @李东岳 last edited by

              @东岳 是的,李老师,感谢李老师!两个版本的定义不一样!OpenFOAM-4中GeometricField字典中是这样定义的:TIM截图20191122141846.png
              而foam-extend-4.0中是这样定义的:TIM截图20191122141934.png

              1 Reply Last reply Reply Quote
              • First post
                Last post

              CFD中文网 | 东岳流体 | 京ICP备15017992号-2
              论坛登录问题反馈可联系 li.dy@dyfluid.com