OpenFOAM可变边界条件codedFixedValue

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

AirInlet
    {
        //type            fixedValue;
        //value           uniform (0 0 0.61);
        type        codedFixedValue;
        value       uniform (0 0 6.10);
    
        name    linearVelocity;
        code
        #{
            const vectorField& Cf = patch().Cf();   //center of the patch
            vectorField& field = *this;             //the target velocity field

            const scalar Umax = 6.1;
            const scalar r1 = 0.02;                 //radius of the hot coflow
            const scalar r2 = 0.06;                 //radius of the domain
        
            forAll(Cf, faceI)
            {
                const scalar x = Cf[faceI][0];
                const scalar y = Cf[faceI][1];
                const scalar R = sqrt(x*x+y*y);
                
                if(R>r1){
                    field[faceI] = vector(0,0,Umax*(r2-R)/(r2-r1));
                }
            }
        #};
    }

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

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

你可能感兴趣的:(OpenFOAM可变边界条件codedFixedValue)