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
26 帖子 3 发布者 9.4k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • C 离线
    C 离线
    coolhhh 神
    在 中回复了 yzxwh 最后由 编辑
    #21

    @yzxwh
    意思是赋值完,直接 Info << pointMotionU_ 也结果有误?
    你是把赋值pointMotionU_ 写在velocityMotionsolver.C文件中吗?还是写在这个函数外边?关注变量的作用域范围,可以把velocityMotionsolver理解为一个子函数,在子函数定义的pointMotionU_为局部变量,如果在这个函数外边重新定义变量赋值的话,并没有修改子函数中的值

    Y 1 条回复 最后回复
  • Y 离线
    Y 离线
    yzxwh
    在 中回复了 coolhhh 最后由 编辑
    #22

    @coolhhh 大佬,赋值之前与赋值之后的PointMotionU_输出是一样的。我是在velocityMotionSolver的类的public类型中添加了一个成员函数readPointmotionU();

    fd6e77fe-722f-4395-b61d-bef21c82d610-image.png
    并在其中进行了tempPointmotionU的读取与对PointmotionU_的赋值操作,如下:
    ee503d56-9d1e-4a8d-9752-72488bd4b8f4-image.png
    然后我在velocitylaplacianfvmotionsolver的c文件中调用了这个函数:
    802e872c-006d-4e91-b13b-a68c13d4dc9e-image.png
    我这样算是在子函数中定义的变量吗?

    C 1 条回复 最后回复
  • C 离线
    C 离线
    coolhhh 神
    在 中回复了 yzxwh 最后由 编辑
    #23

    @yzxwh

    1. 看起来没问题,我也按照你的问题写了个简单例子测试,输出结果是正确的。
    #include "fvCFD.H"
    
    class Parent {
    protected:
        int protectedVar = 5;
    
    public:
        void modifyVariable() {
            int tmp = 10;
            int tmp2 = tmp;
            Parent::protectedVar = tmp;
            Info << "tmp2 = " << tmp2 << nl << endl;
            Info << "Parent::protectedVar = " << Parent::protectedVar << nl << endl;
        }
    };
    
    class Child : public Parent {
    public:
        void accessParentFunction() {
            Parent::modifyVariable();
            Info << "Child::protectedVar = " << Parent::protectedVar << nl << endl;
        }
    };
    
    
    int main(int argc, char *argv[])
    {
    
        #include "setRootCase.H"
        Child child;
        child.accessParentFunction();
    
        Info<< "End\n" << endl;
    
        return 0;
    }
    
    

    04337ff2-6477-48e1-bca1-9486a8e80341-image.png


    1. 看到velocityMotionsolver.H函数中有个返回引用函数:pointVectorField& pointMotionu(),试试能不能创建一个引用,然后修改引用的值,看看结果会不会变化。
    pointVectorField& pointMotionURef = pointMotionU();
    pointMotionURef = tempPointMotionU;
    Info << "pointMotionURef = " << pointMotionURef << endl;
    Info << "pointMotionU = " << pointMotionU_ << endl;
    

    439b08e4-6271-455e-a1ca-6d9394b3879f-image.png

    Y 1 条回复 最后回复
  • Y 离线
    Y 离线
    yzxwh
    在 中回复了 coolhhh 最后由 编辑
    #24

    @coolhhh 大佬,我这边已经把问题解决了,如图所示,添加了一段delete代码删掉了旧对象,再重新分配,就可以进行赋值了。
    fd2d5404-3f75-411a-9a6c-d263cd456b9a-image.png
    大佬的悉心指点对我颇有助益,万分感谢大佬在这段时间的指导与帮助!!!

    C 1 条回复 最后回复
  • C 离线
    C 离线
    coolhhh 神
    在 中回复了 yzxwh 最后由 编辑
    #25

    @yzxwh 厉害厉害,我也学习了:146: :146:

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

    :146: :146: :146: :146:

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

    1 条回复 最后回复
  • C coolhhh 被引用 于这个主题

  • 登录

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