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. 请教在求解器中编译函数调用的问题

请教在求解器中编译函数调用的问题

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

    大家好、各位大佬好,咨询一个编译函数调用问题
    我在别的论坛找到了一个在求解器中定义函数编译调用的例子如下:

    //fun.H
    #ifndef fun_H
    #define fun_H
    
    #include "scalar.H"
    #include "vector.H"
    
    namespace Foam
    {
        vector TestMe(const vector& myvec);
    }
    #endif
    

    以及

    //fun.C
    #include "fun.H"
    
    Foam::vector Foam::TestMe(const vector& myvec)
    {
        Info<< "Hello from TestMe" << endl;
        Info<< "vector: " << myvec << endl;
    }
    

    然后在主函数里面调用 "fun.H"就行了。

    #include "fun.H"
    
    using namespace Foam;
    
    int main(int argc, char *argv[])
    {
        vector A(1,2,3);
        Info<< "Hello from the main()" << endl;
        return 0;
    }
    

    我的思路就是直接在fun.H中写我想调用的代码。比如在“KinematicCloudI.H”文件中定义的

    template<class CloudType>
    inline const Foam::tmp<Foam::volVectorField>
    Foam::KinematicCloud<CloudType>::UPar() const
    {
        tmp<volVectorField> tUPar
        (
            volVectorField::New
            (
                this->name() + ":UPar",
                mesh_,
                dimensionedVector(dimVelocity, vector(0,0,0)),
                extrapolatedCalculatedFvPatchVectorField::typeName
            )
        );
    
    
        volVectorField& UPar = tUPar.ref();
        forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
        {
            const parcelType& p = iter();
            const label celli = p.cell();
            UPar[celli] += (p.U())/(p.nParticle());
        }
        UPar.primitiveFieldRef() /= 1;//mesh_.V();
        UPar.correctBoundaryConditions();
    
        return tUPar;
    }
    

    我直接移植过来,编译出现了如下错误:

    fun.H:16:41: error: no ‘const Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> > Foam::KinematicCloud<CloudType>::UPar() const’ member function declared in class ‘Foam::KinematicCloud<CloudType>’
     Foam::KinematicCloud<CloudType>::UPar() const
    
    

    我尝试把“KinematicCloudI.H”里面的头文件粘上去也通过不了,应该怎么修改以及加一些什么内容呢?
    谢谢

    1 条回复 最后回复

  • 登录

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