Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    如何在求解器编程中编写获取某个网格的速度?

    OpenFOAM
    3
    14
    6117
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 飞
      飞火流星jyj last edited by

      例如U(i,j,k),请老师指点一下

      十分感谢

      1 Reply Last reply Reply Quote
      • X
        xpqiu 教授 last edited by

                forAll(U, cellI)
                {
                    scalar Ux = U[cellI].component(0);
                    scalar Uy = U[cellI].y();
                    scalar Uz = U[cellI].component(2);
                }
        

        .component(0) 或者 .x() 两种方式任君选择。

        飞 2 Replies Last reply Reply Quote
        • 飞
          飞火流星jyj @xpqiu last edited by

          @xpqiu版主, 我定义了一个变量然后赋值
          U2=U[celli]
          计算报错:
          Different dimensions for =
          dimensions : [0 1 -1 0 0 0 0] = [0 0 0 0 0 0 0]

          From function dimensionSet::operator=(const dimensionSet&) const
          in file dimensionSet/dimensionSet.C at line 171.
          

          怎么U[celli]成无单位的量了,不是应该是单位网格的速度

          十分感谢

          1 Reply Last reply Reply Quote
          • 飞
            飞火流星jyj @xpqiu last edited by

            @xpqiu 解决了:happy:

            十分感谢

            1 Reply Last reply Reply Quote
            • 飞
              飞火流星jyj last edited by

              对于单个网格如何写速度方程,想更新单个网格的速度,UEqn好像是求解了所有的

              十分感谢

              1 Reply Last reply Reply Quote
              • 李东岳
                李东岳 管理员 last edited by

                对于单个网格如何写速度方程

                在什么情况下需要对单个网格求解速度方程?

                CFD高性能服务器 http://dyfluid.com/servers.html

                飞 1 Reply Last reply Reply Quote
                • 飞
                  飞火流星jyj @李东岳 last edited by 飞火流星jyj

                  @李东岳 李老师,就是添加源项的速度方程只想对于某种网格求解以此来更新这个网格内的速度

                  十分感谢

                  李东岳 1 Reply Last reply Reply Quote
                  • 李东岳
                    李东岳 管理员 @飞火流星jyj last edited by

                    @飞火流星jyj

                    那你只在某个网格应用原乡就可以了。

                    CFD高性能服务器 http://dyfluid.com/servers.html

                    飞 1 Reply Last reply Reply Quote
                    • 飞
                      飞火流星jyj @李东岳 last edited by

                      @李东岳 那要怎么写呢,李老师能请简单指点一下:happy:

                      十分感谢

                      1 Reply Last reply Reply Quote
                      • 李东岳
                        李东岳 管理员 last edited by

                        比如你某个区域要应用源项,你可以写:

                        forAll(mesh.C(), celli)
                        {
                            if (mesh.C().component(0) < 5 && mesh.C().component(0) > 0)
                            {
                                Source[celli] = 1.0;
                            }
                        }
                        

                        就表示你网格区域如果网格单元x方向的位置大于0并且小于5,就存在S=1的源项。

                        CFD高性能服务器 http://dyfluid.com/servers.html

                        飞 1 Reply Last reply Reply Quote
                        • 飞
                          飞火流星jyj @李东岳 last edited by

                          @李东岳 李老师我的是3.0.X版本的,
                          提示:
                          UEqn.H:68:6: error: ‘Source’ was not declared in this scope
                          Source 没有指定,这个要怎么创建啊

                          十分感谢

                          1 Reply Last reply Reply Quote
                          • 李东岳
                            李东岳 管理员 last edited by

                            首先你得声明Source场如:

                            volScalarField Source
                            (
                                IOobject
                                (
                                随便找一段复制进来
                                )
                            )
                            

                            CFD高性能服务器 http://dyfluid.com/servers.html

                            飞 1 Reply Last reply Reply Quote
                            • 飞
                              飞火流星jyj @李东岳 last edited by 李东岳

                              @李东岳
                              1.

                              volScalarField Source
                              (
                                  IOobject
                                  (
                                              "Source",
                              		runTime.timeName(),
                              		mesh,
                              		IOobject::NO_READ,
                              		IOobject::AUTO_WRITE
                                  ),
                                  mesh
                              );
                              

                              加了,mesh才能通过编译,
                              2. Source[celli]是double类型的,是不是类似于对应网格的Source.value(),
                              3. volScalarField又是定义单位的呢,是不是在速度方程后添加==Source;并且保证量纲统一就可以达到更新速度的目的
                              4. 我还不是很理解volScalarField和scalarField的区别

                              李老师我问题比较多,看您方便回答哪个,十分感谢

                              十分感谢

                              1 Reply Last reply Reply Quote
                              • 李东岳
                                李东岳 管理员 last edited by

                                其他你的理解大体正确,·volScalarField和scalarField的区别仅仅在于volScalarField附加了边界的信息,scalarField`只是网格点的信息不包含边界。

                                CFD高性能服务器 http://dyfluid.com/servers.html

                                1 Reply Last reply Reply Quote
                                • First post
                                  Last post

                                CFD中文网 | 东岳流体 | 京ICP备15017992号-2
                                论坛登录问题反馈可联系 li.dy@dyfluid.com