SRF/MRF的使用问题?数值模拟中要定义旋转速度。



  • 0_1492160946446_upload-f6cf43d7-b9a3-44a7-a5df-c48a08c052aa
    如图所示的几何模型,入口为圆环的外侧,出口为圆环的内侧,有水流过,在圆环的上表面要有一个旋转速度,下表面是无滑移的,我应该怎么定义旋转速度,使用MRF可以实现吗?



  • @小龙 不,你只需要定义上表面的速度旋转就可以了,不需要别的参考系。



  • @cfd-china 那表面上的旋转速度怎么定义呢?可以给我详细的说一下吗?谢谢啦。



  • @cfd-china 您好,这个问题还在困扰着我,是用SRF定义上表面的旋转速度吗,还是其他的方法,您可以帮我解答一下吗?



  • @小龙
    你要做点数学运算,就是用网格点的位置表示出来速度的方向矢量,比如如果网格点在(1 1 1),你的速度是(2 2 2),那就就这样写:

        wallV
        {
            type            codedFixedValue;
    	value 		uniform (0 0 0);
    	redirectType	dummy; 
    	code
    	#{
    	const fvPatch& boundaryPatch = this->patch(); 
            const vectorField& Cf = boundaryPatch.Cf(); 
            vectorField& U = *this;
    	forAll(Cf,faceI)
    	{
    	    scalar x = Cf[faceI].x();
                scalar y = Cf[faceI].y();
                scalar z = Cf[faceI].z();
                v[faceI] = vector(2x, 2y, 2z);
    	}
            #};
    }
    


  • @李东岳 速度是指线速度吗?OF有类似的自带算例吗?



  • @小龙 OpenFOAM应该不存在相关现成的算例,你尝试过上面的代码了么?能否运行?:big_mouth:



  • @cfd-china 尝试过了,不能运行



  • @cfd-china 0_1485330951563_upload-2a6a3824-2ce9-4a18-9d5e-08a9ae5cfa12 麻烦您帮我看一下这样定义的旋转速度对吗,我对OpenFoam学习的还不够深入,感谢您对我的帮助。


  • 管理员

    你这个和壁面旋转速度还不一样,你的壁面旋转是那种平的旋转速度吧?像是顶盖驱动流那种平的速度?



  • @赵一铭 嗯对,就是那种类似于顶盖驱动流的平的旋转速度,


  • 管理员

    岳哥那个代码提示什么错误?



  • @赵一铭 提示了很多错误,我一会用电脑运行一下,截图您帮我看看,您先看看我在上面截图发的那个对吗,可以用吗?谢谢您了


  • 管理员

    @小龙
    好的,最好贴文本上来,代码高亮一下。



  • @赵一铭 嗯嗯,谢谢您了,我以前没发过,以后会注意的



  • @赵一铭 我一会发个文本上来



  • @赵一铭

    MOVINGWALL
    {
        type            codedFixedValue;
        name    swirl;
    
        code
        #{
            const vector axis(0, 0, 1);
    
            vectorField v(2.0*this->patch().Cf() ^ axis);
            v.replace(vector::Z, 0);
            operator==(v);
        #};
        value           $internalField;
    }
    

    ···



  • @赵一铭
    这个是李东岳老师给的代码运行的错误

    Create time
    
    Create mesh for time = 0
    
    
    SIMPLE: convergence criteria
        field p	 tolerance 0.01
        field U	 tolerance 0.001
        field "(k|epsilon)"	 tolerance 0.001
    
    Reading field p
    
    --> FOAM Warning : 
        From function Foam::Field<Type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = double; Foam::label = int]
        in file /home/ubuntu/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Field.C at line 317
        Reading "/home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/p.boundaryField.INLET" from line 27 to line 28
        expected keyword 'uniform' or 'nonuniform', assuming deprecated Field format from Foam version 2.0.
    --> FOAM Warning : 
        From function Foam::Field<Type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = double; Foam::label = int]
        in file /home/ubuntu/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Field.C at line 317
        Reading "/home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/p.boundaryField.OUTLET" from line 32 to line 33
        expected keyword 'uniform' or 'nonuniform', assuming deprecated Field format from Foam version 2.0.
    AMI: Creating addressing and weights between 1911 source faces and 1911 target faces
    AMI: Patch source sum(weights) min/max/average = 0.999994, 1, 1
    AMI: Patch target sum(weights) min/max/average = 0.924226, 1, 0.999254
    Reading field U
    
    Using dynamicCode for patch MOVINGWALL on field U at line 80 in "/home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL"
    Creating new library in "dynamicCode/dummy/platforms/linux64GccDPInt32Opt/lib/libdummy_998c505417ee368105406475ef07b1aa535fae1b.so"
    Invoking "wmake -s libso /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/dynamicCode/dummy"
    wmakeLnInclude: linking include files to ./lnInclude
    Making dependency list for source file fixedValueFvPatchFieldTemplate.C
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL: In member function ‘virtual void Foam::dummyFixedValueFvPatchVectorField::updateCoeffs()’:
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:13: error: ‘v’ was not declared in this scope
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:31: error: unable to find numeric literal operator ‘operator""x’
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:31: note: use -std=gnu++11 or -fext-numeric-literals to enable more built-in suffixes
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:35: error: unable to find numeric literal operator ‘operator""y’
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:35: note: use -std=gnu++11 or -fext-numeric-literals to enable more built-in suffixes
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:39: error: unable to find numeric literal operator ‘operator""z’
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:93:39: note: use -std=gnu++11 or -fext-numeric-literals to enable more built-in suffixes
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:90:13: warning: unused variable ‘x’ [-Wunused-variable]
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:91:20: warning: unused variable ‘y’ [-Wunused-variable]
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:92:20: warning: unused variable ‘z’ [-Wunused-variable]
    /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL:87:22: warning: unused variable ‘U’ [-Wunused-variable]
    /opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/fixedValueFvPatchFieldTemplate.o' failed
    make: *** [Make/linux64GccDPInt32Opt/fixedValueFvPatchFieldTemplate.o] Error 1
    
    
    --> FOAM FATAL IO ERROR: 
    Failed wmake "dynamicCode/dummy/platforms/linux64GccDPInt32Opt/lib/libdummy_998c505417ee368105406475ef07b1aa535fae1b.so"
    
    
    file: /home/xiaolong/OpenFOAM/xiaolong-4.1/run/xuanzhuan/0/U.boundaryField.MOVINGWALL from line 80 to line 84.
    
        From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
        in file db/dynamicLibrary/codedBase/codedBase.C at line 206.
    
    FOAM exiting
    

  • 管理员

    code
            #{
                // const vector axis(1, 0, 0);
                const fvPatch& boundaryPatch = this->patch();
                vectorField v = boundaryPatch.Cf();
                forAll(boundaryPatch, faceI)
                {
                    v[faceI] = vector(boundaryPatch.Cf()[faceI].x(),0,0);//修改这个
                }
    
                //vectorField v(1, 1, 1);
                //v.replace(vector::X, 1.0);
                operator==(v);
            #};
    

    试试这个,把速度初始化为网格边界面的x方向的值了即(value, 0, 0),参考这个定义你自己的函数。



  • @赵一铭
    感谢您,我还有两个问题:
    这个是定义了绕x轴的旋转速度吗?
    假如我的旋转速度是1500r/min,我该怎么换算呢,修改哪里呢?


登录后回复
 

与 CFD 中国 的连接断开,我们正在尝试重连,请耐心等待