【转载】OpenFOAM可变边界条件codedFixedValue

原文链接:OpenFOAM可变边界条件codedFixedValue - 简书 (jianshu.com)

OpenFOAM中可以通过codedFixedValue边界条件来实现空间及时间分部的边界条件
举个栗子,在射流外设置一个线性分布的速度场

 1 AirInlet
 2     {
 3         //type            fixedValue;
 4         //value           uniform (0 0 0.61);
 5         type        codedFixedValue;
 6         value       uniform (0 0 6.10);
 7     
 8         name    linearVelocity;
 9         code
10         #{
11             const vectorField& Cf = patch().Cf();   //center of the patch
12             vectorField& field = *this;             //the target velocity field
13 
14             const scalar Umax = 6.1;
15             const scalar r1 = 0.02;                 //radius of the hot coflow
16             const scalar r2 = 0.06;                 //radius of the domain
17         
18             forAll(Cf, faceI)
19             {
20                 const scalar x = Cf[faceI][0];
21                 const scalar y = Cf[faceI][1];
22                 const scalar R = sqrt(x*x+y*y);
23                 
24                 if(R>r1){
25                     field[faceI] = vector(0,0,Umax*(r2-R)/(r2-r1));
26                 }
27             }
28         #};
29     }

如需要设置随时间变化的边界条件,可采用如下方法得到OF运行时间

1 this->db().time().value();

 

posted @ 2021-12-15 10:30  Lagomgom  阅读(790)  评论(1)    收藏  举报