编译求解器时遇到:assignment of read-only location,求各位老师解答!
-
编译求解器时遇到这样一个问题:
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)’
提示有问题的代码是这样的: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上编译报错的。。。。
-
李老师您好!您的意思是internalField()用ref()代替吗?
-
@strive_DUT 是的,你试试
-
@东岳 是的,李老师,感谢李老师!两个版本的定义不一样!OpenFOAM-4中GeometricField字典中是这样定义的:
而foam-extend-4.0中是这样定义的: