Skip to content
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
CFD中文网

CFD中文网

GarethG

Gareth

@Gareth
关于
帖子
4
主题
2
群组
0
粉丝
0
关注
0

帖子

最新

  • 200万网格并行算力测试(OpenFOAM版本)
    GarethG Gareth
    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
    

  • 模型报错: `request for surfaceScalarField phi...failed`
    GarethG Gareth

    各位老师好,我最近在尝试定义一个新的边界条件,结合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的源代码,可能犯了一些愚蠢的错误。希望各位大佬能对该问题给出一些建议。 谢谢!


  • 编译新边界时报错
    GarethG Gareth

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


  • 编译新边界时报错
    GarethG 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部分造成的,但我弄不清楚为什么?

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

  • 登录

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]