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

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

 March 21, 2013, 09:22 Any hints for user-defined BCs without using groovyBC/Swak4Foam? #1 Member   David Long Join Date: May 2012 Location: Germany Posts: 55 Rep Power: 5 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.

March 21, 2013, 10:02
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by keepfit 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

 March 21, 2013, 10:13 Implement your own Boundary Condition #3 Senior Member     Jose Rey Join Date: Oct 2012 Posts: 127 Rep Power: 9 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.

March 21, 2013, 14:54
#4
Member

David Long
Join Date: May 2012
Location: Germany
Posts: 55
Rep Power: 5
Quote:
 Originally Posted by JR22 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 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.

October 29, 2013, 10:10
#5
New Member

Join Date: Mar 2013
Posts: 9
Rep Power: 4
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
 example.png (6.4 KB, 6 views)

October 29, 2013, 12:41
#6
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by brocco 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
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

 October 30, 2013, 06:56 #7 New Member   Join Date: Mar 2013 Posts: 9 Rep Power: 4 thanks a lot!works perfectly... caldaiasemplificata_ingresso_ariaprimaria { type groovyBCFixedValue; valueExpression "((1

 Tags boundary condition, user defined function

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post llrr ANSYS Meshing & Geometry 13 August 4, 2014 20:04 yorelchr Fluent UDF and Scheme Programming 0 February 7, 2013 04:44 dokeun Main CFD Forum 7 January 29, 2013 05:06 vkrastev OpenFOAM Running, Solving & CFD 5 September 4, 2012 11:58 asaijo OpenFOAM Installation 9 April 6, 2011 12:21

All times are GMT -4. The time now is 14:38.