CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   groovyBC - k-profile (http://www.cfd-online.com/Forums/openfoam-solving/71495-groovybc-k-profile.html)

heavy_user January 5, 2010 07:46

groovyBC - k-profile
 
Hi Folks,

I am using groovyBC to implement a profile for different variables.

I successfully implemented a profile for velocity and for epsilon on different two different inlets.

But when I try do do the same for k (using k-epsilon-model) it crashes right away...i tryed to brake it down to find the problem and I am stuck right now...

When I do :

inlet-gas
{
type fixedValue;
value uniform 0.000138;
}

it works fine.

when I do:

inlet-gas
{
type groovyBC;
value uniform 0.000138;
}

it crashes..

it says:
Courant Number mean: 2.78199e-12 max: 8.8507e-11
DILUPBiCG: Solving for Uy, Initial residual = 0.429436, Final residual = 4.56534e-17, No Iterations 1
DILUPBiCG: Solving for Uz, Initial residual = 0.999302, Final residual = 3.52628e-16, No Iterations 1
DILUPBiCG: Solving for T, Initial residual = 7.09251e-10, Final residual = 7.09251e-10, No Iterations 0
GAMG: Solving for p, Initial residual = 0.00208143, Final residual = 2.05939e-05, No Iterations 122
time step continuity errors : sum local = 1.5495e-15, global = -9.94268e-17, cumulative = 2.50625e-17
GAMG: Solving for p, Initial residual = 0.216801, Final residual = 0.0020369, No Iterations 20
time step continuity errors : sum local = 7.73954e-16, global = -2.65297e-17, cumulative = -1.4672e-18
#0 Foam::error::printStack(Foam::Ostream&) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 ?? in "/lib64/libc.so.6"
#3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so"
#4 void Foam::divide<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libfiniteVolume.so"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<doub le, Foam::fvPatchField, Foam::volMesh> > const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so"
#6 Foam::incompressible::RASModels::kEpsilon::correct () in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so"
#7 main in "/home/itvns/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantBoussinesqPisoFoam"
#8 __libc_start_main in "/lib64/libc.so.6"
#9 _start at /usr/src/packages/BUILD/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:116
Floating exception





is this a bug or am I doing something wrong??

thx for your help!

regards

gschaider January 5, 2010 10:52

Quote:

Originally Posted by heavy_user (Post 241516)

when I do:

inlet-gas
{
type groovyBC;
value uniform 0.000138;
}

it crashes..

<snip>

is this a bug or am I doing something wrong??

Depends on how you see it ;)

What happens is that it implicitly gets expanded to

Code:

inlet-gas
    {   
    type            groovyBC;
    value          uniform 0.000138;
valueExpression "0";
fractionExpression "1";
    }

and value is only used as a first guess from then on it becomes 0 which is somthing that should not happen to k.

So you should write
Code:

inlet-gas
    {   
    type            groovyBC;
    value          uniform 0.000138;
valueExpression "0.000138";
    }

to get what you want

Bernhard

heavy_user January 5, 2010 11:22

Hi Bernhard,

thx a lot for the answer...this way it works...BUT i am still confused...

The wiki says:

"valueExpression String with the value to be used if a Dirichlet-condition is needed. Defaults to zero"

Which i associated with assigning a "value". Since Dirichlet- gives the value at the boundary(!?).

--Whats the diference between "value" and "valueExpression"??

Somehow in the files for U and epsilon it works only defining:
"type, variables and valueExpression"

-- why is k different??

I ran into that problem since i am trying to have a profile matching experimental data.
I fittet spline to the data and used groovyBC to bring it on..

it should look like this:

type groovyBC;
variables

"MEAN2=0.92;r=sqrt(pos().x*pos().x+pos().y*pos().y );fact2=(-5.9481+21.679*r-33.885*r*r+30.097*r*r*r-16.745*r*r*r*r+6.0916*r*r*r*r*r-1.4707*r*r*r*r*r*r+0.23356*r*r*r*r*r*r*r-0.023442*r*r*r*r*r*r*r*r+0.001348*r*r*r*r*r*r*r*r* r-3.3838e-05*r*r*r*r*r*r*r*r*r*r);vel2=MEAN2*(-30.547+94.958*r-126.17*r*r+96.051*r*r*r-46.331*r*r*r*r+14.823*r*r*r*r*r-3.1929*r*r*r*r*r*r+0.45829*r*r*r*r*r*r*r-0.042037*r*r*r*r*r*r*r*r+0.0022294*r*r*r*r*r*r*r*r *r-5.2003e-05*r*r*r*r*r*r*r*r*r*r);";

valueExpression "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";

(at least this works for epsilon and U)...

How can i make it run?
I cant use:

value "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";//doesnt like it!
valueExpression "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";

If I do

value 0.12345;
valueExpression "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";

it is running fine, but i dont know what is goin on(which boundary is used)...


thx again!

regards!

gschaider January 5, 2010 15:19

Quote:

Originally Posted by heavy_user (Post 241546)
Hi Bernhard,

thx a lot for the answer...this way it works...BUT i am still confused...

The wiki says:

That's always the problem with documentation: it is clear to the documenter, but not to everyone else .....
In other words: I don't blame anybody if he feels like improving that Wiki-page, but I won't do it, because I understand it ;)

Quote:

Originally Posted by heavy_user (Post 241546)
"valueExpression String with the value to be used if a Dirichlet-condition is needed. Defaults to zero"

Which i associated with assigning a "value". Since Dirichlet- gives the value at the boundary(!?).

--Whats the diference between "value" and "valueExpression"??

In one sentence: valueExpression is used to calculate value.
value is always there. valueExpression is defined by groovyBC

Quote:

Originally Posted by heavy_user (Post 241546)
Somehow in the files for U and epsilon it works only defining:
"type, variables and valueExpression"

-- why is k different??

Because you defined value there if I remember it correctly

Quote:

Originally Posted by heavy_user (Post 241546)
I ran into that problem since i am trying to have a profile matching experimental data.
I fittet spline to the data and used groovyBC to bring it on..

it should look like this:

type groovyBC;
variables

"MEAN2=0.92;r=sqrt(pos().x*pos().x+pos().y*pos().y );fact2=(-5.9481+21.679*r-33.885*r*r+30.097*r*r*r-16.745*r*r*r*r+6.0916*r*r*r*r*r-1.4707*r*r*r*r*r*r+0.23356*r*r*r*r*r*r*r-0.023442*r*r*r*r*r*r*r*r+0.001348*r*r*r*r*r*r*r*r* r-3.3838e-05*r*r*r*r*r*r*r*r*r*r);vel2=MEAN2*(-30.547+94.958*r-126.17*r*r+96.051*r*r*r-46.331*r*r*r*r+14.823*r*r*r*r*r-3.1929*r*r*r*r*r*r+0.45829*r*r*r*r*r*r*r-0.042037*r*r*r*r*r*r*r*r+0.0022294*r*r*r*r*r*r*r*r *r-5.2003e-05*r*r*r*r*r*r*r*r*r*r);";

valueExpression "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";

(at least this works for epsilon and U)...

How can i make it run?
I cant use:

value "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";//doesnt like it!
valueExpression "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";

If I do

value 0.12345;
valueExpression "r>1 ? (3/2)*(fact2*fact2*vel2*vel2) : 0.00002";

it is running fine, but i dont know what is goin on(which boundary is used)...


thx again!

regards!

a) Impressive. Would be less impressive if you used pow(r,3) etc
b) "value 0.12345;" is only there as a placeholder before valueExpression is computed for the first time (which should be before any equation is solved). Basically it is only there to keep paraFoam happy (because that usually doesn't know about grovvy)

Bernhard

heavy_user January 7, 2010 05:46

Quote:

Originally Posted by gschaider (Post 241567)


a) Impressive. Would be less impressive if you used pow(r,3) etc
b) "value 0.12345;" is only there as a placeholder before valueExpression is computed for the first time (which should be before any equation is solved). Basically it is only there to keep paraFoam happy (because that usually doesn't know about grovvy)

Bernhard



a) -> I will do so, thx!
b) -> thats the information I have been looking for, thank you soo much!!!!!

I might add this information to the wiki, if you dont mind...
But thats a thing I dont understand..since you have been able to create groovyBC, i suppose you dont need it.
So mostly other people will benefit from it. But without a more detailed documentation it is not as usefull as it could be..but it should be measure up the efford you put in it..

best regards

heavy_user January 7, 2010 13:33

tracing errors...(call me alice)
 
1 Attachment(s)
Hi Folks (and special greetings to Bernhard ;)),

i have spend a lovely day with OF and groovyBC tracing errors..and now I am kind of stuck...again...

I am dealing with an error that tells me that groovyBC doesnt like negative expressions like sqrt(-value), which i can understand, i dont like them either..

#4 Foam::sqrt(Foam::UList<double> const&) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so"

I use:

type groovyBC;
variables "MEAN2=9.2;R=0.0026;r=(sqrt(pos().x*pos().x+pos(). y*pos().y))/R;vel2=MEAN2*(-29.547 + 94.958 * r - 126.17 * pow(r,2) + 96.051 * pow(r,3) - 46.331 * pow(r,4) + 14.823 * pow(r,5) - 3.1929 * pow(r,6) + 0.45829 * pow(r,7) - 0.042037 * pow(r,8) + 0.0022294 * pow(r,9) - 5.2003e-05 * pow(r,10));";

value uniform 0.053;
valueExpression " r>2 && r<3 ? sqrt(vel2*vel2*vel2)/(2*R*0.1) : 35663 ";

I fittet a spline to experimental Data (which is used for vel2).
Since there seesm to be negative expression where it should not be i finally checked the spline i fitted with xmgrace and xmgrace came up with a different curve. (see attachment, I am saving this fun for tomorrow)

But if I specify a region "r>2 && r<3 "in which the spline should give certainly positive values I still end up with a negativ value.

At the moment I can see only three possebilities for that:
1. xmgrace (or its user) messed up worse than it shows on graphs
2. funkyBC does strange things solving the equation for r
3. "r>2 && r<3 " doesn not work limiting the range where it uses the
equation

either way i am screwed...any ideas how to unscrew me??

regards

heavy_user January 7, 2010 13:48

...one more question, just curious about it..

Is it possible that groovyBC doesnt like "z" ???

When I did (for testing things):

type groovyBC;
variables "z=0.053;";
value uniform 0.053;
valueExpression " z";

he says :
Parser Error at "1.1" :"syntax error, unexpected 'z'"


but when I do:

type groovyBC;
variables "g=0.053;";
value uniform 0.053;
valueExpression " g";

it works...(yes we had a looot of fun today :D )...

gschaider January 11, 2010 06:01

Quote:

Originally Posted by heavy_user (Post 241746)
a) -> I will do so, thx!
b) -> thats the information I have been looking for, thank you soo much!!!!!

I might add this information to the wiki, if you dont mind...
But thats a thing I dont understand..since you have been able to create groovyBC, i suppose you dont need it.
So mostly other people will benefit from it. But without a more detailed documentation it is not as usefull as it could be..but it should be measure up the efford you put in it..

Would I mind? Au contraire. That is the idea behind the Wiki. Every improvement of that page is welcome

gschaider January 11, 2010 06:12

Quote:

Originally Posted by heavy_user (Post 241810)
...one more question, just curious about it..

Is it possible that groovyBC doesnt like "z" ???

I'm afraid the answer is: yes (and x and y as well)

Quote:

Originally Posted by heavy_user (Post 241810)
When I did (for testing things):

type groovyBC;
variables "z=0.053;";
value uniform 0.053;
valueExpression " z";

he says :
Parser Error at "1.1" :"syntax error, unexpected 'z'"


but when I do:

type groovyBC;
variables "g=0.053;";
value uniform 0.053;
valueExpression " g";

it works...(yes we had a looot of fun today :D )...

The problem is that z is used for getting the z-component of a vector (for instance U.z) and therefor is a "special" symbol for the parser (this is a shortcoming of the grammar that was inherited from funkySetFields)

I'll have a look at it when I find time and should I then remember it (the process of remembering would be aided by a report at https://sourceforge.net/apps/mantisb...e_status_id=90)

Bernhard

gschaider January 11, 2010 06:29

Quote:

Originally Posted by heavy_user (Post 241809)
Hi Folks (and special greetings to Bernhard ;)),

i have spend a lovely day with OF and groovyBC tracing errors..and now I am kind of stuck...again...

I am dealing with an error that tells me that groovyBC doesnt like negative expressions like sqrt(-value), which i can understand, i dont like them either..

#4 Foam::sqrt(Foam::UList<double> const&) in "/home/itvns/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so"

I use:

type groovyBC;
variables "MEAN2=9.2;R=0.0026;r=(sqrt(pos().x*pos().x+pos(). y*pos().y))/R;vel2=MEAN2*(-29.547 + 94.958 * r - 126.17 * pow(r,2) + 96.051 * pow(r,3) - 46.331 * pow(r,4) + 14.823 * pow(r,5) - 3.1929 * pow(r,6) + 0.45829 * pow(r,7) - 0.042037 * pow(r,8) + 0.0022294 * pow(r,9) - 5.2003e-05 * pow(r,10));";

value uniform 0.053;
valueExpression " r>2 && r<3 ? sqrt(vel2*vel2*vel2)/(2*R*0.1) : 35663 ";

I fittet a spline to experimental Data (which is used for vel2).
Since there seesm to be negative expression where it should not be i finally checked the spline i fitted with xmgrace and xmgrace came up with a different curve. (see attachment, I am saving this fun for tomorrow)

But if I specify a region "r>2 && r<3 "in which the spline should give certainly positive values I still end up with a negativ value.

At the moment I can see only three possebilities for that:
1. xmgrace (or its user) messed up worse than it shows on graphs
2. funkyBC does strange things solving the equation for r
3. "r>2 && r<3 " doesn not work limiting the range where it uses the
equation

either way i am screwed...any ideas how to unscrew me??

OK. That's a tricky one. The problem is that when groovy evaluates (a ? b : c) it evaluates the whole b and c. Then it evaluates a and according to that picks values from b or c. The problem with that approach is that it is

a) inefficient
b) leads to that kind of unexpected error

The only way to work around that would be to rewrite groovy so that it does some kind of lazy-evaluation on a per-face basis and that would be a major rewrite (which would make cases that don't use conditionals inefficient). So it is quite unlikely to happen
The other possibility would be to issue a warning and "fix" negative values before feeding them into sqrt (and similar functions).

As a quick fix I would suggest in your case ANOTHER variable (sorry) vel2pos which you set to 0 if vel2 is negative.

Bernhard

heavy_user January 11, 2010 12:00

Quote:

Originally Posted by gschaider (Post 242126)

OK. That's a tricky one.

Bernhard

:D , i knew it ...

Quote:

Originally Posted by gschaider (Post 242126)

As a quick fix I would suggest in your case ANOTHER variable (sorry) vel2pos which you set to 0 if vel2 is negative.

Bernhard

no prob, I love your tool and will use the little "workarround" with the extra variable...

I added some things to wiki, plz check if you like it that way...

regards

tamsilian May 26, 2010 10:41

help about groovyBC
 
Hi sir/madam
i simulated polymer in extruder(screw mill) by ViscoElastic fluidFoam,Jovani. According to my geometry, velocity vectors in boundary condition are changed .As result i should code variables condition in 0File>> U>> movingWalls.do you know that GroovyBC was compiled to OpenFoam as defualt or i have to compile it?and how to compile groovyBC to OpenFoam v.1.6?if you coded one geometry by groovyBC this is thanksful to sent it me by tamsilian@gmail.com. Could u help me?if you need more information about my geometry please request me.
Thanks in advanced your help

heavy_user May 26, 2010 10:56

Quote:

Originally Posted by tamsilian (Post 260358)
Hi sir/madam
i simulated polymer in extruder(screw mill) by ViscoElastic fluidFoam,Jovani. According to my geometry, velocity vectors in boundary condition are changed .As result i should code variables condition in 0File>> U>> movingWalls.do you know that GroovyBC was compiled to OpenFoam as defualt or i have to compile it?and how to compile groovyBC to OpenFoam v.1.6?if you coded one geometry by groovyBC this is thanksful to sent it me by tamsilian@gmail.com. Could u help me?if you need more information about my geometry please request me.
Thanks in advanced your help

Hi Tamsilian,

the answer to most of your questions is here:

http://openfoamwiki.net/index.php/Contrib_groovyBC

if you have any further questions...I will try to help...

regards


All times are GMT -4. The time now is 03:24.