CFD中文网

    CFD中文网

    • 登录
    • 搜索
    • 最新
    1. 主页
    2. Gareth
    • 资料
    • 关注 0
    • 粉丝 0
    • 主题 2
    • 帖子 4
    • 群组 0

    Gareth

    @Gareth

    1
    资料浏览
    4
    帖子
    0
    粉丝
    0
    关注
    注册时间 最后登录
    位置 南京 年龄 29

    Gareth 取消关注 关注

    Gareth 发布的最新帖子

    • RE: 200万网格并行算力测试(OpenFOAM版本)
      CPU型号:AMD EPYC 7542 32-Core 双路
      系统:Ubuntu 18.04  内存128G
      OpenFOAM版本:OpenFOAM-8
      64 77.7
      32 79.7
      16 ·107.4
      8 136.58
      4 272.46
      2 760.95
      1 1128.93
      
      发布在 OpenFOAM
      Gareth
      Gareth
    • 模型报错: `request for surfaceScalarField phi...failed`

      各位老师好,我最近在尝试定义一个新的边界条件,结合timeVaryingMappedFixedValue和inletOutelt边界。在每个时间步对边界插值赋值之后,再根据边界上的通量判断入流/出流,将出流的区域设置zeroGradient,而入流区域仍采用插值结果。

      下面是我参考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();
      }
      

      新的边界条件能够成功编译。但在进行测试case(pimpleFoam)时,会在decomposePar分解并行区域步骤报错(直接进行单核计算也会出现相同错误):

      --> FOAM FATAL ERROR:
          request for surfaceScalarField phi from objectRegistry region0 failed
          available objects of type surfaceScalarField are 0()
          
          From function const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>] in file /home/gareth/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 211.
      

      以下是objectRegistryTemplates.C文件的对应内容:

              FatalErrorInFunction
                  << nl
                  << "    request for " << Type::typeName
                  << " " << name << " from objectRegistry " << this->name()
                  << " failed\n    available objects of type " << Type::typeName
                  << " are" << nl
                  << names<Type>();
      
              if (cacheTemporaryObject(name))
              {
                  FatalErrorInFunction
                      << nl
                      << "    request for " << name << " from objectRegistry "
                      << this->name() << " to be cached failed" << nl
                      << "    available temporary objects are" << nl
                      << temporaryObjects_;
              }
              FatalErrorInFunction                 // line 211
                  << abort(FatalError);            // line 212
          }
          return NullObjectRef<Type>();
      

      根据错误信息,似乎是没有找到surfaceScalarField类型的对象phi,但我只是结合inletOutlet边界,对原始的timeVaryingMappedFixedValue边界代码进行修改,并未改变其他源代码部分。并且我检查了求解器createFields.H,包含对通量phi的创建。所以我很困惑这个问题是如何产生的?

      我是刚开始接触OpenFOAM的源代码,可能犯了一些愚蠢的错误。希望各位大佬能对该问题给出一些建议。 谢谢!

      发布在 OpenFOAM
      Gareth
      Gareth
    • RE: 编译新边界时报错

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

      发布在 OpenFOAM
      Gareth
      Gareth
    • 编译新边界时报错

      各位老师好,我最近在尝试定义一个新的边界条件,目的是在每个时间步对边界赋值之后,再根据速度方向判断入流/出流,对出流的区域设置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部分造成的,但我弄不清楚为什么?

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

      发布在 OpenFOAM
      Gareth
      Gareth