CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Wall BC varying with tube radius (https://www.cfd-online.com/Forums/openfoam-pre-processing/178420-wall-bc-varying-tube-radius.html)

k.giannoko August 26, 2016 04:49

Wall BC varying with tube radius
 
Hello Everyone,

If i have a pipe flow and I want to impose a slip condition at the wall varying with local tube radius, cause the tube is not straight but it's radius is different from point to point. How can I insert R in this expression :

Wall
{
type codedFixedValue;
value uniform (0 0 0);
redirectType rampedFixedValue;
code
#{
vector (0, 0 , f(R)*DUz/Dy);
#};
}



Thank you very much

babakflame October 2, 2016 13:50

Hey Giannokostas

Look at these two samples. Hope you find the idea:)
Before defining your vector, you need to define your function correctly.

Code:

inlet    {       
type            codedFixedValue;
        value          uniform (0 0 0);
        redirectType    velocitySquareInlet;
            code        #{
            const fvPatch& boundaryPatch = patch();
              const vectorField& Cf = boundaryPatch.Cf();
              vectorField& field = *this;
              scalar min = 0.501;
              scalar max = 0.751;   
          forAll(Cf, faceI)            {
                if (
                    (Cf[faceI].z() > min) &&
                    (Cf[faceI].z() < max) &&
                    (Cf[faceI].y() > min) &&
                    (Cf[faceI].y() < max)
                  )
                {
                    field[faceI] = vector(0.1, 0, 0);
                }
            }
        #};
    }

Code:

right
    {
        type codedFixedValue;
    value uniform 0;
    redirectType rampedFixedValue;
    code
    #{

        (*this)==scalar(1.1*log(1.0));
//      (*this)==vector(0.5*sin(3.141592)*this->db().time().value())/2,0,0);

    #};

You can roughly do anything with codedFixedValue boundary Type.

Hope this helps.

smodh October 6, 2016 03:52

I am using codedFixedValue bc for implementing ΔV=0 ;where V=x2+y2+z2
my boundarycondition at 0/phi is:
inlet
{
type codedFixedValue;
value uniform 0;
redirectType velocitySquareInlet;

code
#{
const fvPatch& boundaryPatch = patch();
const vectorField& Cf = boundaryPatch.Cf();

scalarField& field = *this;

forAll(Cf, faceI)
{
(
(Cf[faceI].x()=0) &&
(Cf[faceI].y()=0) &&
(Cf[faceI].z()=0)
)
{
field[faceI] = ((Cf[faceI].x()*Cf[faceI].x())
+(Cf[faceI].y()*Cf[faceI].y())
+(Cf[faceI].z()*Cf[faceI].z()));
}
}
#};


But in terminal I have error in BC
does anyone have idea where I am wrong?
thanks

babakflame October 6, 2016 16:34

Hey Sachin

Can u post the error and describing your boundary a little more? Is it a scalar or vector??

You are trying to define a gradient. Isn't gradient a vector?

smodh October 7, 2016 03:43

Good morning Bobi,

I solved problem. actually it is a scalar and the solution is

FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [1 2 -3 0 0 -1 0];

internalField uniform 0;

boundaryField
{
inlet
{
type codedFixedValue;
value uniform 0;
redirectType velocitySquareInlet;

code
#{
const fvPatch& boundaryPatch = patch();
const vectorField& Cf[/B] = boundaryPatch.Cf();

scalarField& field = *this;

forAll(Cf, faceI)
{
{
field[faceI] = ((Cf[faceI].x()*Cf[faceI].x())
+(Cf[faceI].y()*Cf[faceI].y())
+(Cf[faceI].z()*Cf[faceI].z()));
}
}

#};
}

I don't under one thing in the code is, my class is scalar.
but in the code beginning, I have to write "const vectorField& CF"
why? My field is scalar.
now code is work perfectly....but still dont understand this function meaning.

babakflame October 7, 2016 10:36

Hey Sachin

Good thing that u posted the final code for others.

It would be even nicer if u use the link for code so as your posted code becomes distinguishable from other lines.

cf() member function returns the location of the face center as a vector. So, when u want to use it to as a member function for an object (boundaryPatch) of class fvPatch, the result is a vectorField.

I tried to describe it clearly. Hope this helped you.

k.giannoko October 14, 2016 06:09

Navier Slip condition
 
Hello everyone ,

Thanks for your replies i found them very useful. But still wonder , how can I insert a velocity component derivative (i.e. dUz/dy) to impose a Navier-Slip condition at the wall using the codeFixed utility..


Thank you

K.G


All times are GMT -4. The time now is 14:54.