CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Pre-Processing

Groovy BC - time dependend Inlet

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By gschaider

Reply
 
LinkBack Thread Tools Display Modes
Old   March 8, 2012, 08:01
Default Groovy BC - time dependend Inlet
  #1
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,100
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
hi all,

i am trying to make my first own BC with groovy. I made my own scalarIcoFoam where i implemented just one scalar-field to simulate color in water or sth. like that (without diffusion).

So i wanna build a pulsating inlet for the new scalar field.

The value should switch every 0.5 seconds from value 0 to 1 and after 0.5 from 1 to 0. I think its a very simple implementation with groovy but i need some help.


Thx in advance
Tobi
Tobi is offline   Reply With Quote

Old   March 8, 2012, 08:43
Default
  #2
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,100
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Further question:
is it possible to create a bc for the inlet that only a few faces use that inlet condition (compare the picture | red line).
I wanna set just a few fields with value 1 to the inlet that i get a little fiber, but i dont know how.
Attached Images
File Type: jpg scalar.jpg (19.6 KB, 111 views)
Tobi is offline   Reply With Quote

Old   March 8, 2012, 11:17
Default
  #3
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Tobi View Post
Further question:
is it possible to create a bc for the inlet that only a few faces use that inlet condition (compare the picture | red line).
I wanna set just a few fields with value 1 to the inlet that i get a little fiber, but i dont know how.
Conditional BCs can be specified using the ?:-notation (see a C/C++/Java-book for the meaning of that). For instance "pos().y<0 ? 1 : 0" would give you 1 in the lower half of the patch. If with "only a few faces use that condition" you mean "use a Dirichlet-condition the other a Neumann-Condition" then you'll have to modify the fractionExpression too
gschaider is offline   Reply With Quote

Old   March 9, 2012, 10:45
Default
  #4
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,100
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by gschaider View Post
For instance "pos().y<0 ? 1 : 0"

Hey Gschaider,
thx for your replay. I am programming with c++ but never used that kind of programming but now (after searching for that notation) i know what you mean.

so i can use sth. like that:


Code:
variableValue = pos().y>0.2 ? (pos().y < 0.8 ? 1 : 0) : 0
So i defined the value of variableValue between 0.2 to 0.8 to 1 and the other one to zero.
Is that correct?

And i use my own variable to set the valueExpressions:

Code:
valueExpressions "variableValue";
Thx for your help.
tobi
Tobi is offline   Reply With Quote

Old   March 12, 2012, 19:31
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Tobi View Post
Hey Gschaider,
thx for your replay. I am programming with c++ but never used that kind of programming but now (after searching for that notation) i know what you mean.

so i can use sth. like that:


Code:
variableValue = pos().y>0.2 ? (pos().y < 0.8 ? 1 : 0) : 0
So i defined the value of variableValue between 0.2 to 0.8 to 1 and the other one to zero.
Is that correct?

And i use my own variable to set the valueExpressions:

Code:
valueExpressions "variableValue";
Thx for your help.
tobi
I think you can do it simpler with

Code:
valueExpression "(pos().y>0.2 && pos().y<0.8) ? 1 : 0";
(I think the && makes it easier to read than the nested ?: )
Tushar@cfd likes this.
gschaider is offline   Reply With Quote

Old   March 12, 2012, 20:09
Default
  #6
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,100
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Oh yes, this seems better. THX!
Tobi is offline   Reply With Quote

Old   September 4, 2012, 08:29
Default Time dependent inlet pressure
  #7
New Member
 
Sibusiso Mavuso
Join Date: Jul 2010
Location: South Africa/Pretoria
Posts: 21
Rep Power: 7
semaviso is on a distinguished road
Hi Foamers,

I am trying to specify runTime dependent pressure inlet boundary conditions using a GroovyBC.

The expression for this inlet pressure is:
P_inlet = 2^(-runTime+5)+10;

I tried it as follows:

inlet
{
type groovyBC;
valueExpression "2^(-runTime()+5)+10";
value 1.0e6
}

and I get ant fatal error:

"field runTime not existing or of wrong type"

Is there a way to use the run time in the boundary condition without getting this error?

Can someone help me with this.


thank you in advance,
SBU
semaviso is offline   Reply With Quote

Old   September 4, 2012, 10:41
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by semaviso View Post
Hi Foamers,

I am trying to specify runTime dependent pressure inlet boundary conditions using a GroovyBC.

The expression for this inlet pressure is:
P_inlet = 2^(-runTime+5)+10;

I tried it as follows:

inlet
{
type groovyBC;
valueExpression "2^(-runTime()+5)+10";
value 1.0e6
}

and I get ant fatal error:

"field runTime not existing or of wrong type"

Is there a way to use the run time in the boundary condition without getting this error?

Can someone help me with this.


thank you in advance,
SBU
Two problems:
- time() gives you the current physical time
- ^ is the out product of vectors/tensors in OpenFOAM/swak4Foam. What you probably want is the function pow(a,b) (which gives a^b). The only problem is that the current *released* version only works with constant b. This has been fixed in the current development-version of swak4Foam (the one in the Mercurial-archive). If you don't want to install that the usual log/exp-trick will help you: "exp(log(2)*(-time()+5))+10"
gschaider is offline   Reply With Quote

Old   September 5, 2012, 04:24
Default
  #9
New Member
 
Sibusiso Mavuso
Join Date: Jul 2010
Location: South Africa/Pretoria
Posts: 21
Rep Power: 7
semaviso is on a distinguished road
Bernhard,


I have used "pow(x,y)" instead of "x^y" :

inlet
{
type groovyBC;
variables "p0=10.0e5;";
valueExpression "pow(2,-time()+5) + p0";
value uniform 40.0e5;
}

and get this error:

--> FOAM FATAL ERROR:
Parser Error at "1.8-11" :"syntax error, unexpected TOKEN_time, expecting value"
"pow(2,-time()+5) + p0"
" ^^^^ "

From function parsingValue
in file PatchValueExpressionDriver.C at line 192.

FOAM exiting

please help.

thanx,
SBU
semaviso is offline   Reply With Quote

Old   September 5, 2012, 04:53
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by semaviso View Post
Bernhard,


I have used "pow(x,y)" instead of "x^y" :

inlet
{
type groovyBC;
variables "p0=10.0e5;";
valueExpression "pow(2,-time()+5) + p0";
value uniform 40.0e5;
}

and get this error:

--> FOAM FATAL ERROR:
Parser Error at "1.8-11" :"syntax error, unexpected TOKEN_time, expecting value"
"pow(2,-time()+5) + p0"
" ^^^^ "

From function parsingValue
in file PatchValueExpressionDriver.C at line 192.

FOAM exiting

please help.

thanx,
SBU
That is EXACTLY what I said: "pow currently only works with constant b"
gschaider is offline   Reply With Quote

Old   September 5, 2012, 05:28
Default
  #11
New Member
 
Sibusiso Mavuso
Join Date: Jul 2010
Location: South Africa/Pretoria
Posts: 21
Rep Power: 7
semaviso is on a distinguished road
thanks Bernhard will try it and keep you updated.
semaviso is offline   Reply With Quote

Old   May 31, 2013, 06:34
Default
  #12
New Member
 
Join Date: Mar 2013
Posts: 10
Rep Power: 4
peter_t is on a distinguished road
Hi there,
I am doing a thesis involving flow over a bump. I am finding information on groovyBC difficult to come by. Additionally, the information I do find is somewhat complicated. I am an engineer after all not a programmer haha. If somebody could explain to me how the following code works and what each individual symbol means that would be greatly appreciated. The following is a velocity profile of a wind tunnel inlet patch.

boundaryField
{
inlet
{
type groovyBC;
variables "Umax=1.0;d=0.01;turb_profile=Umax*pow(pos().y,0.1 428571429)*pow((1/d),0.1428571429);";
valueExpression "(pos().y < d) ? vector (turb_profile, 0, 0) : vector (1, 0, 0)";
value uniform (1 0 0 );
}
peter_t is offline   Reply With Quote

Old   May 31, 2013, 07:08
Default
  #13
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,100
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi Peter,

you do not Need programmers knowledge to use the groovy BC. Just read it like a equation


In the following lines you can see the definitions of variables
Code:
variables "Umax=1.0;d=0.01;turb_profile=Umax*pow(pos().y,0.1 428571429)*pow((1/d),0.1428571429);";
There you set the following varialbes in math-format:

U_{max} = 1,0 \frac{m}{s}
d= 0.01 m
turb\_profile = U_{max}\cdot (pos().y)^{0.1428571429} \cdot \left[\frac{1}{d}\right]^{0.1428571429}

pos().y = Position of y (so it should be the length)


The Profil used in the BC is:
Code:
valueExpression "(pos().y < d) ? vector (turb_profile, 0, 0) : vector (1, 0, 0)";
There you can see that there is an if - else condition:

if pos().y < d then use the vector: (turb_profile 0 0) else use the vector (1 0 0)


So you have a dependend vector in x-direction !

from y=0 till y = d the x-component is calculated with pos().y and the function defined above and after that you have the vector U=(1 0 0)

Hope it s clear enough!

Tobi
Tobi is offline   Reply With Quote

Old   June 1, 2013, 04:32
Default
  #14
New Member
 
Join Date: Mar 2013
Posts: 10
Rep Power: 4
peter_t is on a distinguished road
thanks heaps tobi that is very helpful indeed
peter_t is offline   Reply With Quote

Old   October 18, 2013, 15:34
Post
  #15
New Member
 
Join Date: Apr 2013
Posts: 2
Rep Power: 0
elingfre is on a distinguished road
Hey Guys,

I am looking and changing the groovyBC values and expressions for so long now, but don't get an inch further.

I got a closed System (outside wall) with an "inlet" it is also a wall, where i want to put pressure on. In the real world it is a cylinder gliding in the system and due to that pressure occures (liquid filled system).

I am so far

inlet
{
type groovyBC;
variables "pressure=22e05; T1=1e-04;Athmos=1e05:";
valueExpression "(time() < T1)? pressure : Athmos";
}

.. when i execute this there comes an error message that the Athmos couldn't be read and that the pressure was put to 500...

I want that when the time is lower than T1 the pressure occures to the system (inlet face) and after that -> goes back to normal Pressure ( 1 Bar (1e05 Pa)).


Do I have to use the fractionExpression due to my simulation? I read that it toggles the BC from Neumann to Dierlich(wrong spelling?).

Thanks for your Support!
elingfre is offline   Reply With Quote

Old   October 19, 2013, 17:28
Default
  #16
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by elingfre View Post
Hey Guys,

I am looking and changing the groovyBC values and expressions for so long now, but don't get an inch further.

I got a closed System (outside wall) with an "inlet" it is also a wall, where i want to put pressure on. In the real world it is a cylinder gliding in the system and due to that pressure occures (liquid filled system).

I am so far

inlet
{
type groovyBC;
variables "pressure=22e05; T1=1e-04;Athmos=1e05:";
valueExpression "(time() < T1)? pressure : Athmos";
}

.. when i execute this there comes an error message that the Athmos couldn't be read and that the pressure was put to 500...
It's always better to copy/paste the exact error message than retelling it.
Quote:
Originally Posted by elingfre View Post
I want that when the time is lower than T1 the pressure occures to the system (inlet face) and after that -> goes back to normal Pressure ( 1 Bar (1e05 Pa)).


Do I have to use the fractionExpression due to my simulation? I read that it toggles the BC from Neumann to Dierlich(wrong spelling?).
The way you tell it you switch from one fixed value to another. Then your formulation should be find. Although I'd expect a "kick" to the system with the sudden jump you give
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 20, 2013, 16:54
Default
  #17
New Member
 
Join Date: Apr 2013
Posts: 2
Rep Power: 0
elingfre is on a distinguished road
Thanks for you support gschaider!,
I worked it out and want to post my Example here.

inlet
{
type groovyBC;
variables "Druckstoss=22e05;Athmos=1e05;T1=5e-4;";
valueExpression "(time()< T1)? Druckstoss :Athmos ";
value uniform 1e05;
}

You only have to put a default value for the face. E.g. here 1e05 Pa (equal 1 Bar).
It works fine and triggers the boundary from 1 bar to 22 bar and back to 1 bar
elingfre is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with FloatingObject Leech OpenFOAM Running, Solving & CFD 10 March 29, 2012 15:24
how to define two inlet boundary condition at the different time nuengao FLUENT 2 December 13, 2010 19:40
Variable inlet speed in function of time Pascal_doran OpenFOAM 2 August 24, 2009 05:03
can i set the velocity and pressure at the inlet at the same time by UDF minyang.cau FLUENT 0 July 14, 2009 23:14
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 15:09


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