No matching function for call
-
在向DPMFoam求解器collision model中添加一个随机函数时出现下面错误,各位老老师帮忙看看:
添加的代码:label seed; Random randomNumber;//.H文件下的定义
volumeFactor_(1.0), seed(1), randomNumber(seed),//Constructors
Info<< randomNumber.scalar01() << endl;//在一个函数里输出随机数
错误提示:
error: no matching function for call to 'Foam::Random::scalar01() const' Info<< randomNumber.scalar01() << endl;
-
@星星星星晴 在 No matching function for call 中说:
cachedRandom& rndGen = this->owner().rndGen();
还是不行,一直在改,感觉调用一个很简单的函数,实现起来好难呀,昨天的方法和今天都编译不了,我把文件传上来pairCollision.zip ,哪位大佬帮忙看看
-
@upc_ngh
晕 他俩都不在一个class里 怎么能互相调用呢。。
不确定能不能过,你试试看template<class CloudType> void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair ( typename CloudType::parcelType& pA, typename CloudType::parcelType& pB ) const { cachedRandom& rndGen = this->owner().rndGen(); 。 。 。 。 scalar YY = rndGen.sample01<scalar>() * 2.0 - 1.0 + ROOTVSMALL;// I want to INfo the randomnumber everytime when I call this //evaluatePair function. Info<< "Random number = " << YY << endl }
-
@星星星星晴
好吧还是不太对,报错是下面的样子,我再试试看吧,这和课本上的C++是不太一样,多谢多谢In file included from ./submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.T.H:186:0, from ./parcels/include/makeParcelCollisionModels.H:34, from parcels/derived/basicKinematicCollidingParcel/makeBasicKinematicCollidingParcelSubmodels.C:34: ./submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.T.C: In instantiation of 'void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair(typename CloudType::parcelType&, typename CloudType::parcelType&) const [with CloudType = Foam::CollidingCloud<Foam::KinematicCloud<Foam::Cloud<Foam::CollidingParcel<Foam::KinematicParcel<Foam::particle> > > > >; typename CloudType::parcelType = Foam::CollidingParcel<Foam::KinematicParcel<Foam::particle> >]': parcels/derived/basicKinematicCollidingParcel/makeBasicKinematicCollidingParcelSubmodels.C:50:58: required from here ./submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.T.C:301:45: error: passing 'const Foam::CollidingCloud<Foam::KinematicCloud<Foam::Cloud<Foam::CollidingParcel<Foam::KinematicParcel<Foam::particle> > > > >' as 'this' argument discards qualifiers [-fpermissive] cachedRandom& rndGen = this->owner().rndGen(); ^ In file included from ./clouds/Templates/KinematicCloud/KinematicCloud.T.H:621:0, from ./clouds/derived/basicKinematicCollidingCloud/basicKinematicCollidingCloud.H:36, from parcels/derived/basicKinematicCollidingParcel/makeBasicKinematicCollidingParcelSubmodels.C:26: ./clouds/Templates/KinematicCloud/KinematicCloudI.T.H:359:28: note: in call to 'Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen() [with CloudType = Foam::Cloud<Foam::CollidingParcel<Foam::KinematicParcel<Foam::particle> > >]' inline Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen() ^ /home/ofuser/blueCFD/OpenFOAM-4.x/wmake/makefiles/general:251: recipe for target '/home/ofuser/blueCFD/OpenFOAM-4.x/platforms/mingw_w64GccDPInt32Opt/src/lagrangian/intermediate/makeBasicKinematicCollidingParcelSubmodels.o' failed make: *** [/home/ofuser/blueCFD/OpenFOAM-4.x/platforms/mingw_w64GccDPInt32Opt/src/lagrangian/intermediate/makeBasicKinematicCollidingParcelSubmodels.o] Error 1