forAll boundary



  • 自定义了Sb,防止越界,对边界的值进行修正:

    forAll(Sb.boundaryField(), patchI)
        {
                 forAll (Sb.boundaryField()[patchI],facei) 
                  {
            	if(Sb.boundaryField()[patchI][facei] < 0.001) 
                       { 
                         Sb.boundaryField()[patchI][facei] = 0.001; 
                       }
                  }
        }
    

    wmake失败:

    error: assignment of read-only location ‘(&(& Sb.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField<double, Foam::fvPatchField, Foam::volMesh>())->Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary::<anonymous>.Foam::FieldField<Foam::fvPatchField, double>::<anonymous>.Foam::PtrList<Foam::fvPatchField<double> >::<anonymous>.Foam::UPtrList<T>::operator[]<Foam::fvPatchField<double> >(patchI))->Foam::fvPatchField<double>::<anonymous>.Foam::Field<double>::<anonymous>.Foam::List<double>::<anonymous>.Foam::UList<T>::operator[]<double>(facei)’
                          Sb.boundaryField()[patchI][facei] = 0.001;
    

    错在哪里啊?:zoule:



  • @danaoforAll boundary 中说:

    Sb.boundaryField()[patchI][facei] = 0.001;

    Sb.boundaryField().ref()[patchI][facei] = 0.001; 
    


  • 应该是Sb.boundaryField() 返回const reference
    Sb.boundaryField().ref() 返回 reference
    根据我的经验是这样,如果错误的话把编译错误贴上来
    认真看看代码很简单的,编译器的错误已经告诉你所有信息了!


Log in to reply