Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    怎么获取边界上一点的压力值

    OpenFOAM
    3
    6
    2212
    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.
    • 陈
      陈琦 last edited by

      请教各位,在使用OpenFoam的codefixedvalue边界时,可以每一个时间步都输出该边界上某个坐标点(x0,y0,z0)附近的压力吗? 代码应该怎么写呢? C++小白求帮助

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

        可以,但是会比较乱七八糟。对于输出的功能,最好通过controlDict里面的function来调用,比如下面这些代码

        functions
        {
        	extraInfo
        	{
        		type				coded;
        
        		functionObjectLibs	("libutilityFunctionObjects.so");
        
        		name				dummy;
        
        		codeExecute
        		#{
        			const volVectorField& U = mesh().lookupObject<volVectorField>("U");
        
        			Info<< "max U = " << max(mag(U)).value() << nl;
        
        			const volScalarField& epsilon = mesh().lookupObject<volScalarField>("epsilon");
        
        			Info<< "min/max epslion = " << min(epsilon).value() << ", " << max(epsilon).value() << endl;
        
        			const volScalarField& k = mesh().lookupObject<volScalarField>("k");
        
        			Info<< "min/max k = " << min(k).value() << ", " << max(k).value() << endl;
        
        			const volScalarField& p = mesh().lookupObject<volScalarField>("p");
        
        			Info<< "min/max p = " << min(p).value() << ", " << max(p).value() << endl;
        		#};
        	}
        }
        

        CFD课程 改成线上了 http://dyfluid.com/class.html
        CFD高性能服务器 http://dyfluid.com/servers.html

        1 Reply Last reply Reply Quote
        • 陈
          陈琦 last edited by

          李老师,是这样的,我想做一个流动反馈控制的一个研究。在流场下游有个分离区,在分离点附近有喷口,通过喷流实现对流动的控制。现在的想法是在分离区选择一个点,测量该点的压力波动,以该物理量作为输入,实时调节喷口的速度。
          所以我希望能在计算中随时获取该点压力值,并根据该值计算出喷口边界上的速度,并不只是想输出压力。

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

            我希望能在计算中随时获取该点压力值

            那你应该知道该点的坐标,然后定位该点的网格ID,然后p[cellID]就是你的压力值

            CFD课程 改成线上了 http://dyfluid.com/class.html
            CFD高性能服务器 http://dyfluid.com/servers.html

            1 Reply Last reply Reply Quote
            • 陈
              陈琦 last edited by 李东岳

              这是我根据网上的模板修改的一个喷口边界条件(jet),喷口的速度随时间和空间位置变化,可以正常使用。请问一下,如果我想输出网格ID为faceI0的格心的压力,应该怎么实现呢? 再进一步,如果这个网格点不在jet边界上(比如在hump边界上),那么在这里可以获得该点的压力吗?

              /*--------------------------------*- C++ -*----------------------------------*\
              | =========                 |                                                 |
              | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
              |  \\    /   O peration     | Version:  5.0                                   |
              |   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
              |    \\/     M anipulation  |                                                 |
              \*---------------------------------------------------------------------------*/
              FoamFile
              {
                  version     2.0;
                  format      ascii;
                  class       volVectorField;
                  location    "11012";
                  object      U;
              }
              // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
              
              dimensions      [0 1 -1 0 0 0 0];
              
              internalField   uniform (0 0 0);
              
              boundaryField
              {
                  backfront
                  {
                      type            empty;
                  }
                  
                  hump
                  {
                      type            noSlip;
                  }
                 
                  inlet
                  {
                      type            timeVaryingMappedFixedValue;
                      offset          constant (0 0 0);
                      value           nonuniform List<vector> 
                      216
                       (..... )  ;
                  }
                  
                  jet
                  {
                      type            codedFixedValue;
                      name            nouse;
                      value           (0 0 0);
                      redirectType    jeton;
                      
                      codeOptions
                      #{
                          -I$(LIB_SRC)/finiteVolume/lnInclude \
                          -I$(LIB_SRC)/meshTools/lnInclude
                      #}; 
              
                      codeInclude
                      #{
                          #include "fvCFD.H"
                          #include <cmath>
                          #include <iostream>
                      #};         
              
                      code
                      #{
                          const fvPatch& boundaryPatch = patch();   
                          const vectorField& Cf = boundaryPatch.Cf();
                          vectorField& field = *this;
              
                          const scalar pi = constant::mathematical::pi;
                          scalar x0=0.654157, z0=0.115013, d=0.004554;
                          scalar umax=26.6,   fjet=138.5;
                          scalar theta = 18.31163/pi;
                         
                          forAll(Cf, faceI)
                          {
                              scalar x  = Cf[faceI].x();
                              scalar z  = Cf[faceI].z();
                              scalar t  = this->db().time().value();
              
                              scalar kesi  = pow( (x-x0)*(x-x0)+(z-z0)*(z-z0),0.5);
                              scalar ujmag = 6*umax*( (kesi/d)-pow(kesi/d,2) )*sin(2*pi*fjet*t);
                              scalar ujet  = ujmag*sin(theta);
                              scalar vjet  = ujmag*cos(theta);
                              
                              field[faceI] = vector(ujet,0,vjet);
                          }
                      #};    
                  }
              
                  lowWall
                  {
                      type            noSlip;
                  }
                  outlet
                  {
                      type            zeroGradient;
                  }
                  top
                  {
                      type            zeroGradient;
                  }
              }
              
              Z 1 Reply Last reply Reply Quote
              • Z
                zhengshu930 @陈琦 last edited by

                @陈琦 有没有模板上传一下?想要借鉴一下

                1 Reply Last reply Reply Quote
                • First post
                  Last post

                CFD中文网 | 东岳流体 | 京ICP备15017992号-2