CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   GroovyBC (http://www.cfd-online.com/Forums/openfoam/86476-groovybc.html)

 longamon March 23, 2011 14:36

GroovyBC

Hi

I'm trying to use groovybc to specify an inflow condition, however i'm kinda stuck with it. my c++ knowledge is very limited.

the velocity profile i'm trying to implement is

U=min(y,kln(y)+B) , 0 , 0

where k and B are constants, y is the y coordinate of the point. Velocity is only streamwise, the other 2 components at the inlet are 0.

I can create yp=y and kln=k*log(yp)+B, however I don't how to choose the minimum of these two.

I'm using OF 1.7

thanks for any help

 gschaider March 23, 2011 16:44

Quote:
 Originally Posted by longamon (Post 300763) Hi I'm trying to use groovybc to specify an inflow condition, however i'm kinda stuck with it. my c++ knowledge is very limited. the velocity profile i'm trying to implement is U=min(y,kln(y)+B) , 0 , 0 where k and B are constants, y is the y coordinate of the point. Velocity is only streamwise, the other 2 components at the inlet are 0. I can create yp=y and kln=k*log(yp)+B, however I don't how to choose the minimum of these two. I'm using OF 1.7 thanks for any help
The min-function in groovyBC takes the minimum of a field and therefore only takes one argument.

The minimum of two fields a and b can be taken with the ?:-notation: (a < b ? a : b)

 longamon March 24, 2011 08:13

thanks

:D
thanks gschaider, that worked like a charm. kudos on the groovyBC app, great tool.

 longamon August 10, 2011 07:08

Groovy BC

Hi, its me again. Upgraded to OF 2.0 and installed swak4foam, however the notations has changed a bit. This is the entry for the boundary "Entrada"

Code:

```  Entrada       {         type            groovyBC;         valueExpression "vector(ret*nu*v/1.5,0,0);";         variables      "ret{Entrada}=590;nu{Entrada}=0.000138217;y1{Entrada}=pos().y;ymax{Entrada}=max(y1);y2{Entrada}=ymax-pos().y;yi{Entrada}=(y1<y2?y1:y2);yp{Entrada}=ret*yi/1.5;klny=2.5*log(yp+0.000001)+5;v{Entrada}=(yp<klny?yp:klny);";         value          uniform (1 0 0);       }```
and it throws this error:

Code:

```--> FOAM FATAL ERROR:  Parser Error at "1.5-6" :"field y1 not existing or of wrong type" "max(y1)" "    ^^"```

David

 gschaider August 10, 2011 18:19

Quote:
 Originally Posted by longamon (Post 319606) Hi, its me again. Upgraded to OF 2.0 and installed swak4foam, however the notations has changed a bit. This is the entry for the boundary "Entrada" Code: ```  Entrada       {         type            groovyBC;         valueExpression "vector(ret*nu*v/1.5,0,0);";         variables      "ret{Entrada}=590;nu{Entrada}=0.000138217;y1{Entrada}=pos().y;ymax{Entrada}=max(y1);y2{Entrada}=ymax-pos().y;yi{Entrada}=(y1 FOAM FATAL ERROR:  Parser Error at "1.5-6" :"field y1 not existing or of wrong type" "max(y1)" "    ^^"``` Appreciate your help David
Hmm. At first: You're working on the patch Entrada anyway, so there's no need to write the variables like this "ret{Entrada}=590" ("ret=590" is sufficient).

In my opinion this should not be the cause of your problem, but could you try it anyway? BTW: Using the external-variables syntax might lead to strange results if used on the "same" patch as external variables always get only one value (which is used for all faces).

 longamon August 11, 2011 07:23

That was it, y1{Entrada}=pos().y was supposed to be a vector and it wasn't

thanks

 RygeltheXVI November 22, 2011 21:58

Elegance Help

Hail all,
My c++ skill is quite low. Much like the original post I wish to compare to vector fields and get the minimum.
Basically I want:
U=(min(1,pos()z),0,0)

I was wondering how I would go about generating a field of uniform values 1. At the moment my work around is to use field2=(pos().z/pos().z). And seeing as this produces the result I want I'm not exactly complaining as much as I wish to know the 'correct' way to do it in the future.

And so i use:
variables "d=pos().z/pos().z;e=pos().z;profile=(e < d ? e : d)*vector(1,0,0);";
valueExpression "profile";

Its probably something really obvious or implied that I'm not aware of,
Striving for elegance, and Cheers

 gschaider November 23, 2011 14:45

Quote:
 Originally Posted by RygeltheXVI (Post 333192) Hail all, My c++ skill is quite low. Much like the original post I wish to compare to vector fields and get the minimum. Basically I want: U=(min(1,pos()z),0,0) I was wondering how I would go about generating a field of uniform values 1. At the moment my work around is to use field2=(pos().z/pos().z). And seeing as this produces the result I want I'm not exactly complaining as much as I wish to know the 'correct' way to do it in the future. And so i use: variables "d=pos().z/pos().z;e=pos().z;profile=(e < d ? e : d)*vector(1,0,0);"; valueExpression "profile"; Its probably something really obvious or implied that I'm not aware of, Striving for elegance, and Cheers
Since the release that has the date 2011-07-26 (check the README) there is a binary min/max in the parser. So basically

vector(min(pos().z,1),0,0)

should work

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