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

Any hints for user-defined BCs without using groovyBC/Swak4Foam?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 21, 2013, 09:22
Question Any hints for user-defined BCs without using groovyBC/Swak4Foam?
  #1
Member
 
David Long
Join Date: May 2012
Location: Germany
Posts: 54
Rep Power: 5
keepfit is on a distinguished road
Hi Foamers,

as I am not very clear about the idea/principle behind Swak4Foam/groovyBC, so I was wondering, is there some easy way to define some customized boundary conditions?

For instance: assuming inlet z coordinates is from z = 0 m to z = 4 m, I want to define an "alpha 1" source from z =0 to z =2 m at the inlet with a velocity 2 m/s at x-axis, while the pressure of outlet is fixed to 0.

Or more complex, I want the source velocity varying from: Vx = | 2*sin(t* 2*Pi/T) | (absolute value) , where T is the period.

So how to implement these BCs without using predefine Swak4Foam?

Any recommendations or hints will be highly appreciated.
keepfit is offline   Reply With Quote

Old   March 21, 2013, 10:02
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by keepfit View Post
Hi Foamers,

as I am not very clear about the idea/principle behind Swak4Foam/groovyBC, so I was wondering, is there some easy way to define some customized boundary conditions?

For instance: assuming inlet z coordinates is from z = 0 m to z = 4 m, I want to define an "alpha 1" source from z =0 to z =2 m at the inlet with a velocity 2 m/s at x-axis, while the pressure of outlet is fixed to 0.

Or more complex, I want the source velocity varying from: Vx = | 2*sin(t* 2*Pi/T) | (absolute value) , where T is the period.

So how to implement these BCs without using predefine Swak4Foam?

Any recommendations or hints will be highly appreciated.
There is the coded-BC (since OF 2.0) that allows you to include little C++-programs that calculate your BC. If you're fluent in C++ and know the OF-API well then you might be as fast writing your BC with it as you might be with groovyBC.

The expressions you mention would be "pos().z<2 ? 1 : 0" for alpha1 (if I understand your description correctly) and "2*sin(time()*2*pi/42)" (with a period 42) in groovyBC which I think (but I'm biased) is pretty straightforward. It's a bit more typing (but not exactly rocket-science) in coded/C++
__________________
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   March 21, 2013, 10:13
Default Implement your own Boundary Condition
  #3
Senior Member
 
JR22's Avatar
 
Jose Rey
Join Date: Oct 2012
Posts: 122
Rep Power: 8
JR22 will become famous soon enough
There is a tutorial by Hakan Nilsson from Chalmers University on how to implement your own boundary condition. You can find it here:
http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/implementBoundaryCondition.pdf

The tutorial seems to be current as of version 2.0.x.
JR22 is offline   Reply With Quote

Old   March 21, 2013, 14:54
Default
  #4
Member
 
David Long
Join Date: May 2012
Location: Germany
Posts: 54
Rep Power: 5
keepfit is on a distinguished road
Quote:
Originally Posted by JR22 View Post
There is a tutorial by Hakan Nilsson from Chalmers University on how to implement your own boundary condition. You can find it here:
http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/implementBoundaryCondition.pdf

The tutorial seems to be current as of version 2.0.x.
Quote:
Originally Posted by gschaider View Post
There is the coded-BC (since OF 2.0) that allows you to include little C++-programs that calculate your BC. If you're fluent in C++ and know the OF-API well then you might be as fast writing your BC with it as you might be with groovyBC.

The expressions you mention would be "pos().z<2 ? 1 : 0" for alpha1 (if I understand your description correctly) and "2*sin(time()*2*pi/42)" (with a period 42) in groovyBC which I think (but I'm biased) is pretty straightforward. It's a bit more typing (but not exactly rocket-science) in coded/C++
thanks, it's great help.

What I want is to code a small fraction of C++ and make it usable for calculating the specified BCs. The difficult part is the OF-API that operates on the mesh properties like cell faces, coordinates and so on.

In this way I might be able to make a wave-generation BCs with varying the "alpha1" position according to the wave period T and other parameters.
keepfit is offline   Reply With Quote

Old   October 29, 2013, 10:10
Default
  #5
New Member
 
Join Date: Mar 2013
Posts: 5
Rep Power: 4
brocco is on a distinguished road
Hi bernard!
Yesterday I started to have a look on swak and in particular the capabilities of groovybc,but in truth i've not understood a lot !(my brain after thesis is cooked!). I was interested to know how to produce the input speed with only conditions of geometric type as you suggested to keepfit for alpha1 but obviously for me is a velocity vector.
The idea is to produce sub-areas without having to change each time the mesh. For example on a square produce strips with input speed not anything. How could I do?
for example
1<x<3, 0<y<1, & 4<x<6, 2<y<3 ecc....

suggestions?
Attached Images
File Type: png example.png (6.4 KB, 6 views)
brocco is offline   Reply With Quote

Old   October 29, 2013, 12:41
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by brocco View Post
Hi bernard!
Yesterday I started to have a look on swak and in particular the capabilities of groovybc,but in truth i've not understood a lot !(my brain after thesis is cooked!). I was interested to know how to produce the input speed with only conditions of geometric type as you suggested to keepfit for alpha1 but obviously for me is a velocity vector.
The idea is to produce sub-areas without having to change each time the mesh. For example on a square produce strips with input speed not anything. How could I do?
for example
1<x<3, 0<y<1, & 4<x<6, 2<y<3 ecc....

suggestions?
That'd be with the ?: operator. For the two rectangles in you example (I guess your & was meant to be a | ) it should be something like

"((1<pos().x && pos().x<3 && 0<pos().y && pos().y<1) || (4<pos().x && pos().x<6 && 2<pos().y && pos().y<3)) ? 1 : 0"

would give the value 1 on these two rectangles and 0 elsewhere
__________________
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 30, 2013, 06:56
Default
  #7
New Member
 
Join Date: Mar 2013
Posts: 5
Rep Power: 4
brocco is on a distinguished road
thanks a lot!works perfectly...

caldaiasemplificata_ingresso_ariaprimaria
{
type groovyBCFixedValue;
valueExpression "((1<pos().x && pos().x<2 && -22<pos().y && pos().y<-21) || (3<pos().x && pos().x<4 && -28<pos().y && pos().y<-26)) ? vector(0,0,0.6) : vector(0,0,0)";

}

thanks again
brocco is offline   Reply With Quote

Reply

Tags
boundary condition, user defined function

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
[ICEM] How can I define different zones in ICEM? llrr ANSYS Meshing & Geometry 13 August 4, 2014 20:04
UDF link fortran source yorelchr Fluent UDF and Scheme Programming 0 February 7, 2013 04:44
using METIS functions in fortran dokeun Main CFD Forum 7 January 29, 2013 05:06
Dealing with BC's in OF 1.6 vkrastev OpenFOAM Running, Solving & CFD 5 September 4, 2012 11:58
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21


All times are GMT -4. The time now is 18:56.