编译失败求助



  • 想实现更改每个单元的粘度的功能,于是在laminarTransport的类singlePhaseTransportModel.H中加入了

    virtual void crtMyNu(const labelUList& myList,scalar myNu);
    

    目的是为了在simpleFoam里面可以调用laminarTransport.crtMyNu(),输入单元编号的List,和想改成的数值myNu;
    然后在Newtonian.H 里加入

            void crtMyNu(const labelUList& myList,scalar myNu)
            {                                                 
                           forAll(myList,i)                                                                                              
                         {                                                                 
                               label cellI=myList[i];                                                                                        
                                 this->nu_[cellI]=myNu;
                       }                                                                                                         
         } 
    

    实现对nu_的具体修改。
    编译libincompressibleTransportModels时没有错误
    但是在simpleFOAM.C中加入

    laminarTransport.crtMyNu(solidCells,scalar(10000));
    

    后,编译simpleFOAM时报错

    -lm -o /home/samuel/OpenFOAM/samuel-v1806/platforms/linux64GccDPInt64Opt/bin/GCSimpleFoam
    Make/linux64GccDPInt64Opt/GCSimpleFoam.o: In function `main':
    GCSimpleFoam.C:(.text.startup+0x3748): undefined reference to `Foam::singlePhaseTransportModel::crtMyNu(Foam::UList<long> const&, double)'
    collect2: error: ld returned 1 exit status
    /home/samuel/OpenFOAM/OpenFOAM-v1806/wmake/makefiles/general:136: recipe for target '/home/samuel/OpenFOAM/samuel-v1806/platforms/linux64GccDPInt64Opt/bin/GCSimpleFoam' failed
    make: *** [/home/samuel/OpenFOAM/samuel-v1806/platforms/linux64GccDPInt64Opt/bin/GCSimpleFoam] Error 1
    

    编译错误的原因是什么呢?搞不懂。。


  • 教授

    @Samuel-Tu编译失败求助 中说:

    void crtMyNu(const labelUList& myList,scalar myNu)

    这句改成 void singlePhaseTransportModel::crtMyNu(const labelUList& myList,scalar myNu) 试试?



  • @wwzhao 在Newtonian.H里加吗,singlePhaseTransportModel类编译不通过了。

    In file included from viscosityModels/Newtonian/Newtonian.C:26:0:
    viscosityModels/Newtonian/Newtonian.H:110:14: error: ‘singlePhaseTransportModel’ has not been declared
             void singlePhaseTransportModel::crtMyNu(const labelUList& myList,scalar myNu)
                  ^~~~~~~~~~~~~~~~~~~~~~~~~
    /home/samuel/OpenFOAM/OpenFOAM-v1806/wmake/rules/General/transform:34: recipe for target '/home/samuel/OpenFOAM/OpenFOAM-v1806/build/linux64GccDPInt64Opt/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.o' failed
    make: *** [/home/samuel/OpenFOAM/OpenFOAM-v1806/build/linux64GccDPInt64Opt/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.o] Error 1
    


  • 好像发现原因了,Newtonian没有从singlePhaseTransportMode继承,因此如果在singlePhaseTransportMode中定义虚函数是不行的


Log in to reply
 


CFD中文网 | 东岳流体学术 | 东岳流体商业 | 吉ICP备20003622号-1