Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    编译新边界时报错

    OpenFOAM
    1
    2
    188
    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.
    • Gareth
      Gareth last edited by

      各位老师好,我最近在尝试定义一个新的边界条件,目的是在每个时间步对边界赋值之后,再根据速度方向判断入流/出流,对出流的区域设置zeroGradient。相当于inletOutlet边界,只是不使用字典设置的inletValue,而使用对边界面赋值的结果。

      下面是我参考inletOutlet边界文件修改的updateCoeffs()函数:

      template<class Type>
      void Foam::timeVaryingInletOutletFvPatchField<Type>::updateCoeffs()
      {
          if (this->updated())
          {
              return;
          }
         
          this->operator==(fieldMapper_.map());
      //***************注释掉该部分后编译成功**********************************//
      // 拷贝于‘inletOutlet’边界源文件,用于判断方向并对系数赋值
          const Field<scalar>& phip =
              this->patch().template lookupPatchField<surfaceScalarField, scalar>
              (
                  phiName_
              );
          this->valueFraction() = 1.0 - pos0(phip);
      //**********************************************************************//
          fixedValueFvPatchField<Type>::updateCoeffs();
      }
      

      在编译时有如下的错误信息:

      // error 1
      /home/gareth/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/DimensionedField.H:83:40: 
      error: invalid use of incomplete type ‘class Foam::surfaceMesh’
               typedef typename GeoMesh::Mesh Mesh;
                                             ^~~~
      // 中间省略,基本上都是这两种错误.....
      // error 2
      /home/gareth/OpenFOAM/Custom-8/newBoundary/myCode/timeVaryingInletOutlet/timeVaryingInletOutletFvPatchField.C:321:26: 
      error: invalid initialization of reference of type ‘const Foam::Field<double>&’ from expression of type ‘const Patch {aka const Foam::fvsPatchField<double>}’
           const Field<scalar>& phip =
                                ^~~~
      

      感觉问题出在phip通量场的定义和方向判断部分,我将这部分代码注释掉之后,编译可以顺利完成(0 errors)。看起来这两种编译错误都是由phip部分造成的,但我弄不清楚为什么?

      麻烦各位老师帮忙解答下,谢谢!

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

        我已经解决了这个编译错误,主要是自己粗心大意导致的:135: :136: 。
        在***FvPatchFields.C文件中增加了#include surfaceFields.H即能编译通过

        1 Reply Last reply Reply Quote
        • First post
          Last post

        CFD中文网 | 东岳流体 | 京ICP备15017992号-2