编译体积力时遇到的小报错
-
在学习用openfoam做自航的时候想尝试用体积力模型替代桨模型产生的推力,这需要引入体积力模型。
在编译时有遇到一点小问题,关于未定义引用,请问要怎么正确引用,解决这个报错提示使得编译成功?
首先这是wmake出现的提示:/usr/bin/ld.bfd: /home/dyfluid/OpenFOAM/OpenFOAM-7/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/waveProp/waveProp.o: in function `main.cold': waveProp.C:(.text.unlikely+0x49d): undefined reference to `Foam::functionObjects::forces::~forces()' /usr/bin/ld.bfd: /home/dyfluid/OpenFOAM/OpenFOAM-7/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/waveProp/waveProp.o: in function `main': waveProp.C:(.text.startup+0x8bc9): undefined reference to `Foam::functionObjects::forces::forces(Foam::word const&, Foam::objectRegistry const&, Foam::dictionary const&)' /usr/bin/ld.bfd: waveProp.C:(.text.startup+0x8bed): undefined reference to `Foam::functionObjects::forces::calcForcesMoment()' /usr/bin/ld.bfd: waveProp.C:(.text.startup+0x8bfc): undefined reference to `Foam::functionObjects::forces::forceEff() const' /usr/bin/ld.bfd: waveProp.C:(.text.startup+0xa444): undefined reference to `Foam::functionObjects::forces::~forces()' collect2: error: ld returned 1 exit status make: *** [/home/dyfluid/OpenFOAM/OpenFOAM-7/wmake/makefiles/general:142: /home/dyfluid/OpenFOAM/OpenFOAM-7/platforms/linux64GccDPInt32Opt/bin/waveProp] Error 1
对应文件bodyForce.H中定义体积力的部分:
// Define the (cylindrical) region for the body force from dictionary values const scalar yProp (readScalar(bodyForceDict.lookup("yProp"))); const scalar zProp (readScalar(bodyForceDict.lookup("zProp"))); const scalar xPropmin (readScalar(bodyForceDict.lookup("xPropmin"))); const scalar xPropmax (readScalar(bodyForceDict.lookup("xPropmax"))); const scalar tipRadius (readScalar(bodyForceDict.lookup("tipRadius"))); const scalar hubRadius (readScalar(bodyForceDict.lookup("hubRadius"))); Foam::functionObjects::forces F ( "forces", mesh, dragForceDict ); F.calcForcesMoment();//这里未定义引用,该如何修改? vector force =F.forceEff();//这里未定义引用,该如何修改? scalar drag = force.x();//这里未定义,该如何修改? Info << "Thrust = " << drag << endl; scalar thrust = 1.1*drag; //Considering 10% more