CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Non-normal inflow with groovyBC (http://www.cfd-online.com/Forums/openfoam/74372-non-normal-inflow-groovybc.html)

bjr March 30, 2010 22:12

Non-normal inflow with groovyBC
 
Anybody have any general guidance on this? I am trying to work my way up to 45 degree flow... but starting with this 80/10 ratio. I've got it working without groovyBC, but does anybody know how the formulation would need to be changed if using Groovy... my current attempt looks like this...


/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (80 10 0);

boundaryField
{

front
{
type groovyBC;
variables "zp=pts().z;minZ=min(zp);maxZ=max(zp);para=-pow(pos().z/0.390667,0.13)*normal();";
valueExpression "(1+0.00005*sin(500*time()))*para";
value uniform (80 10 0);
}

inlet
{
type groovyBC;
variables "zp=pts().z;minZ=min(zp);maxZ=max(zp);para=-pow(pos().z/0.390667,0.13)*normal();";
valueExpression "(1+0.00005*sin(500*time()))*para";
value uniform (80 10 0);
}

back
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (80 10 0);
}

outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (80 10 0);
}

lowerWall
{
type fixedValue;
value uniform (0 0 0);
}

OBJECT_patch0
{
type fixedValue;
value uniform (0 0 0);
}

upperWall
{
type slip;
}
}


// ************************************************** *********************** //

bjr March 31, 2010 15:24

Getting there... this works
 
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (63.63 63.63 0);

boundaryField
{

/*
inlet
{
type fixedValue;
value $internalField;
}
*/

inlet
{
type groovyBC;
//variables "zp=pts().z;minZ=min(zp);maxZ=max(zp);para=-pow(pos().z/0.390667,0.13)*normal();";
//valueExpression "vector(63.63*para, 63.63*para, 0)";
valueExpression "vector(63.63, 63.63, 0)";
value uniform (63.63 63.63 0);
}

/*
front
{
//type slip;
type fixedValue;
value $internalField;
}
*/

front
{
type groovyBC;
//variables "zp=pts().z;minZ=min(zp);maxZ=max(zp);para=-pow(pos().z/0.390667,0.13)*normal();";
//valueExpression "90*para";
//valueExpression "vector(63.63*para, 63.63*para, 0)";
valueExpression "vector(63.63, 63.63, 0)";
value uniform (63.63 63.63 0);
}

/*
back
{
//type slip;
type inletOutlet;
inletValue uniform (0 0 0);
//value uniform (90 0 0);
value $internalField;
}
*/

back
{
type groovyBC;
valueExpression "vector(0,0,0)";
//valueExpression "vector(63.63,63.63,0)";
gradientExpression "vector(0,0,0)";
fractionExpression "(phi > 0) ? 0 : 1";
//value uniform (0 0 0);
value $internalField;
}


/*
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
//value uniform (90 0 0);
value $internalField;
}
*/

outlet
{
type groovyBC;
valueExpression "vector(0,0,0)";
//valueExpression "vector(63.63,63.63,0)";
gradientExpression "vector(0,0,0)";
fractionExpression "(phi > 0) ? 0 : 1";
//value uniform (0 0 0);
value $internalField;
}

lowerWall
{
type slip;
//type fixedValue;
//value uniform (0 0 0);
}

OBJECT_patch0
{
type fixedValue;
value uniform (0 0 0);
}

upperWall
{
type slip;
}
}


// ************************************************** *********************** //

bjr March 31, 2010 17:26

But, if I switch the commented lines from

//valueExpression "vector(63.63*para, 63.63*para, 0)";
valueExpression "vector(63.63, 63.63, 0)";

to

valueExpression "vector(63.63*para, 63.63*para, 0)";
//valueExpression "vector(63.63, 63.63, 0)";

it gives the error...

Starting time loop

Time = 1



Parser Error at "1.18" :"syntax error, unexpected ','"
"vector(63.63*para, 63.63*para, 0)"
" ^ "


Any ideas?

gschaider March 31, 2010 18:21

Quote:

Originally Posted by bjr (Post 252599)
But, if I switch the commented lines from

//valueExpression "vector(63.63*para, 63.63*para, 0)";
valueExpression "vector(63.63, 63.63, 0)";

to

valueExpression "vector(63.63*para, 63.63*para, 0)";
//valueExpression "vector(63.63, 63.63, 0)";

it gives the error...

Starting time loop

Time = 1



Parser Error at "1.18" :"syntax error, unexpected ','"
"vector(63.63*para, 63.63*para, 0)"
" ^ "


Any ideas?

Looks like a bug in the parser. Could you report a bug at http://sourceforge.net/apps/mantisbt...e_status_id=-2

Bernhard

bjr March 31, 2010 18:30

I don't get it because there seems to be a successful case here... he thinks he has a pow(x,y) error, but seems to have gotten the above syntax to work.

http://www.cfd-online.com/Forums/ope...-groovybc.html

"""
I managed to get a parabolic profile with

variables "w=0.00005;m=3;n=2;Umax=1*(m+1)*(n+1)/m/n;c=pos().y-w;d=pos().z-w;a=pow((c/w),2);b=pow((d/w),2);speed=Umax*(1-a)*(1-b);";
valueExpression "vector (speed, 0, 0)";

in my starting file for U but i have two problems.
pow() does not accecpt non integer values for the exponent like pow(a,1.5) is this a "normal" behaviour?
and
i need some function to get the distance from a point like
distance = pos().z-w now this will result in an negative value if pos().z <w which "should" be positive, i tried abs() but it seems its not implemented and i tried something like sqr(pow(pos().z-w,2)) which doesnt work either.
"""

bjr March 31, 2010 18:46

Found the problem as far as syntax is concerned...
 
I've at least made the syntax happy... I believe the normal and the negative sign do not combine with the vector function. I suppose this makes sense, to be explicit about the vector components in this way. As for making sure it's physically correct... that's my problem. Thanks for entertaining my thoughts out loud though Bernhard! Once again it's us and not groovyBC!

inlet
{
type groovyBC;
valueExpression "vector(pow(pos().z/0.390667,0.13)*63.63,pow(pos().z/0.390667,0.13)*63.63,0)";
value uniform (63.63 63.63 0);
}

bunni January 14, 2011 20:42

help with inflow to groovybc
 
Sorry for the newbie questions, but clearly I'm misunderstanding something. I'd like to use groovyBC to vary the inlet velocity both in time and space. I've been playing with the examples circulatingsplash.

I'll use that example, from the 0/U file:

atmosphere
{
type groovyBC;
valueExpression "-(alpha1+internalField(alpha1))*0.5*normal()";
value uniform (0 0 0);
}


So, my questions:

(1) why do you need
value uniform(0,0,0) ?

From what I understand valueExpression is going to assign a value to each cell face, what role is the uniform playing?

(2) how is
{
type groovyBC
valueExpression " vector(0,2,0)";
}

different from
{
type groovyBC
valueExpression "2*normal()";
}

different from:
{
type fixedValue
value uniform(0,2,0)
}

?
(in this case, atmosphere is on the y=1 plane)

Cheers

gschaider January 15, 2011 12:27

Quote:

Originally Posted by bunni (Post 290508)
Sorry for the newbie questions, but clearly I'm misunderstanding something. I'd like to use groovyBC to vary the inlet velocity both in time and space. I've been playing with the examples circulatingsplash.

I'll use that example, from the 0/U file:

atmosphere
{
type groovyBC;
valueExpression "-(alpha1+internalField(alpha1))*0.5*normal()";
value uniform (0 0 0);
}


So, my questions:

(1) why do you need
value uniform(0,0,0) ?

From what I understand valueExpression is going to assign a value to each cell face, what role is the uniform playing?

value is only needed by programs that "don't understand" the groovyBC (usual reason is that they are not OpenFOAM-programs - therefor they can't load the libs - that understand the OF-Fileformat. Usually postprocessors like Paraview and Visit) and want some information about the value on the border (although for the IC the value is probably inconsistent with the groovyBC)

Quote:

Originally Posted by bunni (Post 290508)
(2) how is
{
type groovyBC
valueExpression " vector(0,2,0)";
}

different from
{
type groovyBC
valueExpression "2*normal()";
}

different from:
{
type fixedValue
value uniform(0,2,0)
}

?
(in this case, atmosphere is on the y=1 plane)

They are all equivalent. The middle one is the most flexible because it makes no assumption about the orientation of the boundary. So if you got to 3D and your atmosphere is z=1 you can reuse the files from the IC and they will still work.

bunni January 15, 2011 22:32

thanks
 
Ok, thanks for that. It's good to know I have some idea. So, the

value uniform (0,2,0) is for postprocessing - I do use paraview. Now,
I haven't noticed any difference from the following BC's:

(1)
type groovybc;
valueExpression 2*normal;

(2)
type groovybc;
valueExpression 2*cos(time())*normal;

The latter should give me a periodic wave, but as I run the case, and post-processes using paraview I see no difference as a function of time. This could then be a paraview problem? can you suggest a different way of processing the data to see what's going on?

Thanks so much for your help, it's good to know I'm somewhat on the right track.

gschaider January 17, 2011 11:35

Quote:

Originally Posted by bunni (Post 290595)
Ok, thanks for that. It's good to know I have some idea. So, the

value uniform (0,2,0) is for postprocessing - I do use paraview. Now,
I haven't noticed any difference from the following BC's:

(1)
type groovybc;
valueExpression 2*normal;

(2)
type groovybc;
valueExpression 2*cos(time())*normal;

The latter should give me a periodic wave, but as I run the case, and post-processes using paraview I see no difference as a function of time. This could then be a paraview problem? can you suggest a different way of processing the data to see what's going on?

Thanks so much for your help, it's good to know I'm somewhat on the right track.

Could you please copy the relevant expressions here so that we're not chasing ghosts? The entries you copied won't work (wrong case of BC, no " around expression, no () after normal)

Bernhard


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