CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Swirl input using groovyBC (http://www.cfd-online.com/Forums/openfoam/84996-swirl-input-using-groovybc.html)

usergk February 14, 2011 19:59

Swirl input using groovyBC
 
Hello Foamers,

I am trying to implement swirl input in a cylindrical tube (axis along z dir). I came across the groovyBC code to implement swirl input:

inlet
{
type groovyBC;
variables "rpm=8000.0;Un=55.8;c=sum(pos()*mag(Sf()))/sum(mag(Sf()));n=sum(normal())/mag(sum(normal()));p=pos()-c;r=mag(p)+1.0e-10;R=max(r);
xt=vector(0,n.z,-n.y);xT=xt/mag(xt);yt=vector(n.y*n.y+n.z*n.z,-n.x*n.y,-n.x*n.z);yT=yt/mag(yt);";
valueExpression "-Un*normal() + (rpm*pi/30)*((p & yT)*xT - (p & xT)*yT)";
}

Can someone explain what xt, yt, and (p & yT)*xT - (p & xT)*yT refer to?

Thanks so much,

Regards,
gk

usergk February 15, 2011 12:43

Hello,

Can anyone provide some hints here?

Many thanks,
gk

Bernhard February 16, 2011 03:08

They are defined in variables. If you don't understand the formulation, make a sketch, using the known vectors (pos and normal), in a random orientation. In your sketch you will understand each term immediately. (With the assumption that this is a correct implementation of course ;))

tuominen February 16, 2011 03:16

Quote:

Originally Posted by usergk (Post 295258)
Hello Foamers,

I am trying to implement swirl input in a cylindrical tube (axis along z dir). I came across the groovyBC code to implement swirl input:

inlet
{
type groovyBC;
variables "rpm=8000.0;Un=55.8;c=sum(pos()*mag(Sf()))/sum(mag(Sf()));n=sum(normal())/mag(sum(normal()));p=pos()-c;r=mag(p)+1.0e-10;R=max(r);
xt=vector(0,n.z,-n.y);xT=xt/mag(xt);yt=vector(n.y*n.y+n.z*n.z,-n.x*n.y,-n.x*n.z);yT=yt/mag(yt);";
valueExpression "-Un*normal() + (rpm*pi/30)*((p & yT)*xT - (p & xT)*yT)";
}

Can someone explain what xt, yt, and (p & yT)*xT - (p & xT)*yT refer to?

Thanks so much,

Regards,
gk

Hi

I have used following code:
Code:

type        groovyBC;
variables
(
    "yp=pos().y;"
    "xp=pos().x;"
    "r=sqrt(pow(xp,2)+pow(yp,2));"

    "U_ax=31.35;"
    "U_t=20.97;"
    "theta=asin(xp/r);"
    "U_tx=sqrt(pow(U_t*cos(theta),2));"
    "U_ty=-U_t*sin(theta);"
);
valueExpression "vector ( U_tx, U_ty, U_ax )";

U_ax is axial velocity along z-axis and U_t is tangential velocity. U_tx and U_ty are tangential velocity's x- and y-components. Sqrt and pow in U_tx only make sure that x component is always positive (I have modelled only sector, not full cylinder).

Lasse

usergk February 16, 2011 11:43

Thanks a lot for the inputs! Really appreciate it! :)

I was able to get it running using Lasse's code.

gk

FedericaF July 25, 2013 08:02

Hello,

I used funkySetBoundary in openfoam 1.7 to generate a swirl in the inlet patch for a sector of a cylinder and it works. I have attached below the file funkySetBoundaryDict used.


Code:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

velocityswirl {
 field U;
  expressions
  (
      {   
            target value;
            patchName inlet;
                     
            variables      "rpm=1000.0;Un=10;c=sum(pos()*mag(Sf()))/sum(mag(Sf()));n=sum(normal())/mag(sum(normal()));n=sum(normal())/mag(sum(normal()));p=pos()-c;r=mag(pos()-vector(0,0,1))+1.0e-10;R=max(r);xt=vector(0,n.z,-n.y);xT=xt/mag(xt);yt=vector(n.y*n.y+n.z*n.z,-n.x*n.y,-n.x*n.z);yT=yt/mag(yt);";
                 
                          expression "-Un*normal() + (rpm*pi/30)*(((pos()-c) & yT)*xT-((pos()-c) & xT)*yT)";
      }
);


//!!! in "variables" do not leave any space between the definitions of two variables and in "espression" try to replace the name of few variables with their definitions !!!

//!!! c=sum(pos()*mag(Sf()))/sum(mag(Sf())) works just for full patches; for other cases you have to set manually !!!



All times are GMT -4. The time now is 01:38.