CFD中文网

    CFD中文网

    • 登录
    • 搜索
    • 最新

    interFoam 或 interDyMFoam 如何调用 sixDoFRigidBodyMotion 类?

    OpenFOAM
    3
    6
    431
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • P
      pcwang 最后由 编辑

      各位老师朋友们大家好,我的课题是关于漂浮式平台,目前需要将系泊线的外力和力矩耦合到浮体上,将浮体的位移和速度传递给系泊线作为边界条件,从而进行双向耦合。想请教一下各位在 interFoam 或 旧版本中的 interDyMFoam 中是如何调用 sixDoFRigidBodyMotion 的?

      1 条回复 最后回复 回复 引用
      • bestucan
        bestucan 版主 副教授 最后由 编辑

        https://www.cfd-online.com/Forums/openfoam-programming-development/155119-how-access-solid-body-motion-state-custom-interdymfoam-c.html

        https://precice.discourse.group/t/problems-with-building-an-adapter-between-sixdofmotion-solver-and-calculix/536/2

        https://develop.openfoam.com/Development/openfoam/-/issues/2182

        滚来滚去……~(~o ̄▽ ̄)~o 滚来滚去都不能让大家看出来我不是老师么 O_o

        异步沟通方式(《posting style》from wiki)(下载后打开):
        https://www.jianguoyun.com/p/Dc52X2sQsLv2BRiqnKYD
        提问的智慧(github在gitee的镜像):
        https://gitee.com/bestucan/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md

        P 1 条回复 最后回复 回复 引用
        • P
          pcwang @bestucan 最后由 编辑

          @bestucan 感谢您的回复。

          这几天我在知网找到了一篇硕士论文,其中在第二章第2.3节有对sixDoFRigidBodyMotion类的调用的介绍,以下是硕士论文的网址:
          WEC-防波堤集成系统能量捕获效率与消波性能研究

          [1]毛艳军. WEC-防波堤集成系统能量捕获效率与消波性能研究[D].大连理工大学,2019.DOI:10.26991/d.cnki.gdllu.2019.001609.

          我目前遇到的另一个困难是,我想把浮体的位移和速度通过sixDoFRigidBodyMotion下的restraint类传递给系泊线。希望通过一个新的约束模型,调用浮体的位移和速度矢量,作为系泊计算的边界条件。但是目前还没有找到相应的变量或者代码,不知道@bestucan 老师您有什么高见?

          bestucan 1 条回复 最后回复 回复 引用
          • bestucan
            bestucan 版主 副教授 @pcwang 最后由 编辑

            @pcwang

            https://www.openfoam.com/documentation/guides/v2112/api/classFoam_1_1sixDoFRigidBodyMotionRestraint.html

            这几个是并列关系,都是单独的类:
            Screenshot from 2022-05-09 16-51-13.png

            但会互相影响、调用,比如调用了solver,更新过的其他类才有意义什么的。

            这个类 sixDoFRigidBodyMotionRestraint 的 Public Member Functions 里没有返回速度的函数。
            这个类 sixDoFRigidBodyMotion 的 Public Member Functions 里有 vector & v () 和 const vector & v () const。

            从这里取速度,但是怎么把速度给系泊什么的,我第一次听这个词,不是很了解:143:

            滚来滚去……~(~o ̄▽ ̄)~o 滚来滚去都不能让大家看出来我不是老师么 O_o

            异步沟通方式(《posting style》from wiki)(下载后打开):
            https://www.jianguoyun.com/p/Dc52X2sQsLv2BRiqnKYD
            提问的智慧(github在gitee的镜像):
            https://gitee.com/bestucan/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md

            1 条回复 最后回复 回复 引用
            • P
              pcwang 最后由 编辑

              @bestucan
              非常感谢您的回复,对我的启发很大。

              之前提到的硕士论文中的流程图如下:

              sixDoFRigidBodyMotion模块代码实现流程.png

              我之前一直在研究interDyMFoam.C对sixDoFRigidBodyMotion类的调用流程,以及sixDoFSolver下的Newmark.C的源码结构,所以忽略了对于速度v这个变量定义的位置。我去看了一下sixDoFSolver和sixDoFRigidBodyMotion这两个类的头文件。

              六自由度运动求解器sixDoFSolver在sixDoFSolver.H62行处,声明了一个sixDoFRigidBodyMotion的类:

              sixDoFRigidBodyMotion& body_;
              

              而在sixDoFRigidBodyMotion类的头文件sixDoFRigidBodyMotion.H中,在第79到83行,有如下声明:

              //- Motion state data object
              sixDoFRigidBodyMotionState motionState_;
                
              //- Motion state data object for previous time-step
              sixDoFRigidBodyMotionState motionState0_;
              

              并且对于速度v、加速度a的声明,源码中将其声明为内联函数,在sixDoFRigidBodyMotionI.H中的第143到第152行:

               inline const Foam::vector& Foam::sixDoFRigidBodyMotion::v() const
               {
                   return motionState_.v();
               }
                
                
               inline const Foam::vector& Foam::sixDoFRigidBodyMotion::a() const
               {
                   return motionState_.a();
               }
              

              所以按照代码的思路和我的理解,应该是将所有的状态量如速度v、加速度a等,保存在sixDoFRigidBodyMotionState这个类中,并且除了当前时间步的运动状态,前一时间步的运动状态也能够访问。

              关于取速度的问题,我认为是可行的。在查阅源码时,见到了sixDoFRigidBodyMotionRestraint的子类linearDamper::restrain()调用了sixDoFRigidBodyMotion的v()。

              sixDoFRigidBodyMotion_v().png

              代码在linearDamper.C的第73到89行,如下

               void Foam::sixDoFRigidBodyMotionRestraints::linearDamper::restrain
               (
                   const sixDoFRigidBodyMotion& motion,
                   vector& restraintPosition,
                   vector& restraintForce,
                   vector& restraintMoment
               ) const
               {
                   restraintForce = -coeff_*motion.v();
                   restraintMoment = Zero;
                
                   if (motion.report())
                   {
                       Info<< " force " << restraintForce
                           << endl;
                   }
               }
              

              不难理解,阻尼与速度成正比,所以需要得到六自由度浮体的速度v,即公式中的motion.v()。而调用restrain函数需要把sixDoFRigidBodyMotion& motion传入,因此实现了对速度的调用。

              除此之外,类似的像是 sphericalAngularDamper、sphericalAngularSpring、linearAxialAngularSpring、tabulatedAxialAngularSpring这些约束模型,实现了对角速度omega()的调用,如下图所示

              sixDoFRigidBodyMotion_omega().png

              以上是我的一些拙见,有错误的地方还请多多指点。

              H 1 条回复 最后回复 回复 引用
              • H
                HITSC30 @pcwang 最后由 编辑

                @pcwang 楼主思路十分清晰,祝顺利毕业:146:

                1 条回复 最后回复 回复 引用
                • First post
                  Last post