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中文网

  1. CFD中文网
  2. OpenFOAM
  3. 湍流模型跨版本(2.1.1与2.3.1)编译问题-已解决

湍流模型跨版本(2.1.1与2.3.1)编译问题-已解决

已定时 已固定 已锁定 已移动 OpenFOAM
3 帖子 3 发布者 2.3k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 一 离线
    一 离线
    一颗鸭蛋
    写于 最后由 编辑
    #1

    最近需要将2.1.1版本下开发的湍流KOmegaMDH 模型添加到2.3.1中,直接在如下根目录下新建文件夹KOmegaMDH将KOmegaMDH.C和KOmegaMDH.H放进去,

    2.3.1/src/turbulenceModels/incompressible/RAS
    

    在Make/files 中添加’KOmegaMDH/KOmegaMDH.C’并保存,在RAS下运行wclean和wmake libso 自动将库模型全部更新一遍,但编译到KOmegaMDH模型时便会报如下错误:

        error:invalid new-expression of abstruct class type 'FOAM::incompressible::RASModels::KOmegaMDH'   //出现这个错误原因是new 了一个抽象类出错,说明父类(接口)中有纯虚函数没有实现。接口里的纯虚函数全部需要实现,这样才能new 子类。https://www.cnblogs.com/laizhenghong2012/p/11302657.html(参考此文档解释)
        
            return auto<basseType>(new baseType##Type parlist); 
                                                             ^
    /home/kdd/OpenFOAM/OpenFOAM-2.3.1/src/turbulenceModels/incompressible/RAS/lnInclude/RASModel.H:125:9: note: in expansion of macro 鈥榙eclareRunTimeSelectionTable鈥?         declareRunTimeSelectionTable
                   ^
    In file included from kOmegaMHD.C:26:0:
    kOmegaMHD.H:77:7: note:   because the following virtual functions are pure within 'Foam::incompressible::RASModels::kOmegaMHD':
                    class kOmegaMHD
                          ^
    In file included from /home/kdd/OpenFOAM/OpenFOAM-2.3.1/src/turbulenceModels/incompressible/RAS/lnInclude/RASModel.H:47:0,
                 from kOmegaMHD.H:62,
                 from kOmegaMHD.C:26:
    /home/kdd/OpenFOAM%(#804e4e)[/OpenFOAM-2.3.1/src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H:217:37]: note: 	virtual Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::incompressible::turbulenceModel::divDevRhoReff(const volScalarField&, Foam::volVectorField&) const  //这里才是最关键,显示这个H文件里217行有个虚函数const=0没有实现
         virtual tmp<fvVectorMatrix> divDevRhoReff
                                     ^
    

    找到/OpenFOAM-2.3.1/src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H 并将这个H文件打开找到217行如下:

      213  //- Return the source term for the momentum equation
      214 virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const = 0;
      215 
      216 //- Return the source term for the momentum equation
      217  virtual tmp<fvVectorMatrix> divDevRhoReff
           (
                const volScalarField& rho,
                volVectorField& U
            ) const = 0;
        //- Solve the turbulence equations and correct the turbulence viscosity
        virtual void correct() = 0;
    

    发现在2.3.1版本下的湍流模型的H文件中有两个同样的//- Return the source term for the momentum equation (213行和217行)
    再找到/OpenFOAM-2.1.1/src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H 发现只有一个//- Return the source term for the momentum equation ,如下:

       //- Return the source term for the momentum equation
        virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const;          
       //- Solve the turbulence equations and correct the turbulence viscosity
        virtual void correct();
    

    所以正确的做法是在KOmegaMDH.H文档中再添加一个与2.3.1相同的//- Return the source term for the momentum equation 函数,添加如下内容:

       //- Return the source term for the momentum equation
        virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const;
    
        //- Return the source term for the momentum equation
        virtual tmp<fvVectorMatrix> divDevRhoReff
        (
            const volScalarField& rho,
            volVectorField& U
        ) const;    //添加这个函数,你也可以在查看2.3.1中其他模型下的H文档与2.2.1的进行对比,就能发现其中差异。
    
        //- Solve the turbulence equations and correct the turbulence viscosity
        virtual void correct();
    

    然后点击保存,再运行wclean和wmake libso 就可以了,希望可以帮到其他小伙伴~

    1 条回复 最后回复
  • S 离线
    S 离线
    Samuel-Tu
    写于 最后由 编辑
    #2

    感谢楼主分享

    1 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 编辑
    #3

    感谢楼主分享

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复

  • 登录

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