CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] groovyBC - k-profile

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 5, 2010, 07:46
Question groovyBC - k-profile
  #1
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
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:rintStack(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:perator/<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
heavy_user is offline   Reply With Quote

Old   January 5, 2010, 10:52
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by heavy_user View Post

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
gschaider is offline   Reply With Quote

Old   January 5, 2010, 11:22
Default
  #3
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
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!
heavy_user is offline   Reply With Quote

Old   January 5, 2010, 15:19
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by heavy_user View Post
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 View Post
"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 View Post
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 View Post
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
gschaider is offline   Reply With Quote

Old   January 7, 2010, 05:46
Lightbulb
  #5
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
Quote:
Originally Posted by gschaider View Post


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 is offline   Reply With Quote

Old   January 7, 2010, 13:33
Default tracing errors...(call me alice)
  #6
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
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
Attached Images
File Type: jpg why.jpg (32.7 KB, 14 views)
heavy_user is offline   Reply With Quote

Old   January 7, 2010, 13:48
Default
  #7
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
...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 )...
heavy_user is offline   Reply With Quote

Old   January 11, 2010, 06:01
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by heavy_user View Post
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 is offline   Reply With Quote

Old   January 11, 2010, 06:12
Default
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by heavy_user View Post
...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 View Post
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 )...
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 is offline   Reply With Quote

Old   January 11, 2010, 06:29
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by heavy_user View Post
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
gschaider is offline   Reply With Quote

Old   January 11, 2010, 12:00
Default
  #11
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
Quote:
Originally Posted by gschaider View Post

OK. That's a tricky one.

Bernhard
, i knew it ...

Quote:
Originally Posted by gschaider View Post

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
heavy_user is offline   Reply With Quote

Old   May 26, 2010, 11:41
Default help about groovyBC
  #12
New Member
 
Joseph
Join Date: Mar 2010
Posts: 14
Rep Power: 15
tamsilian is an unknown quantity at this point
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
tamsilian is offline   Reply With Quote

Old   May 26, 2010, 11:56
Default
  #13
Senior Member
 
Join Date: Dec 2009
Posts: 112
Rep Power: 17
heavy_user is on a distinguished road
Quote:
Originally Posted by tamsilian View Post
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
heavy_user is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] groovyBC - inlet profile at complex terrain potac OpenFOAM Community Contributions 2 January 3, 2017 20:18
[swak4Foam] Problem with fully developed velocity profile groovyBC in 2D axi-sym mesh harshad88 OpenFOAM Community Contributions 7 July 24, 2014 15:28
[swak4Foam] groovyBC error: velocity profile (2D) >> what's wrong? vitorspadeto OpenFOAM Community Contributions 4 June 19, 2014 16:31
[swak4Foam] parabolic velocity profile with fluctuations (groovyBC?) newOFuser OpenFOAM Community Contributions 17 July 15, 2013 18:27
[swak4Foam] Scale discrete inlet velocity profile with groovyBC cboss OpenFOAM Community Contributions 1 June 20, 2010 14:02


All times are GMT -4. The time now is 08:55.