|
[Sponsors] |
March 8, 2012, 08:01 |
Groovy BC - time dependend Inlet
|
#1 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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 |
|
March 8, 2012, 08:43 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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. |
|
March 8, 2012, 11:17 |
|
#3 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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
|
|
March 9, 2012, 10:45 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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 Is that correct? And i use my own variable to set the valueExpressions: Code:
valueExpressions "variableValue"; tobi |
|
March 12, 2012, 19:31 |
|
#5 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
valueExpression "(pos().y>0.2 && pos().y<0.8) ? 1 : 0"; |
||
September 4, 2012, 09:29 |
Time dependent inlet pressure
|
#7 |
New Member
Sibusiso Mavuso
Join Date: Jul 2010
Location: South Africa/Pretoria
Posts: 22
Rep Power: 16 |
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 |
|
September 4, 2012, 11:41 |
|
#8 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
- 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" |
||
September 5, 2012, 05:24 |
|
#9 |
New Member
Sibusiso Mavuso
Join Date: Jul 2010
Location: South Africa/Pretoria
Posts: 22
Rep Power: 16 |
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 |
|
September 5, 2012, 05:53 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
|
||
September 5, 2012, 06:28 |
|
#11 |
New Member
Sibusiso Mavuso
Join Date: Jul 2010
Location: South Africa/Pretoria
Posts: 22
Rep Power: 16 |
thanks Bernhard will try it and keep you updated.
|
|
May 31, 2013, 07:34 |
|
#12 |
New Member
Join Date: Mar 2013
Posts: 10
Rep Power: 13 |
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 ); } |
|
May 31, 2013, 08:08 |
|
#13 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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);"; 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)"; 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 |
|
June 1, 2013, 05:32 |
|
#14 |
New Member
Join Date: Mar 2013
Posts: 10
Rep Power: 13 |
thanks heaps tobi that is very helpful indeed
|
|
October 18, 2013, 16:34 |
|
#15 |
New Member
Join Date: Apr 2013
Posts: 2
Rep Power: 0 |
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! |
|
October 19, 2013, 18:28 |
|
#16 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
__________________
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 20, 2013, 17:54 |
|
#17 |
New Member
Join Date: Apr 2013
Posts: 2
Rep Power: 0 |
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 |
|
August 14, 2019, 06:22 |
|
#18 |
Member
James
Join Date: Jan 2014
Posts: 38
Rep Power: 12 |
Hi there,
I am trying to tweak this sine wave inlet BC into generating square wave but I don't seem to figure outhow to generate square wave. The BC below gives me continuous flow. But what I want is inlet that opens say every 0.5s and last for 0.1s. Would really apperaeciate your feedback ! dropInlet { type groovyBC; variables "xp=pts().x;minX=min(xp);maxX=max(xp);unif=-0.2*normal();"; valueExpression "10*(1+0.5*sin(500*time()))*unif"; value uniform (0.0 0.0 0.0); } |
|
August 15, 2019, 13:35 |
|
#19 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
A quick way to generate a square wave with "frequency" and "height" 1 would be something like Code:
valueExpression "(time() % 1)>0 ? 0 : 1";
__________________
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 21, 2019, 16:43 |
|
#20 | |
Member
James
Join Date: Jan 2014
Posts: 38
Rep Power: 12 |
Quote:
Thank you gschaider, It does exactly what I wanted to do. I set it at the inlet BC with alpha.water and I get continuous water flow into domain for 0.5 s, then it stops for the next 0.5 s and repeats. But I don't really know how does it work and would really appreciate your feedback. It looks like "%" here is a different than a modulo operator in OF then how does the use of % repeat the cycle every 0.5 s? I have a new BC created in OF where I am trying to mimic exacty the same thing. I have a working BC code for continuous flow but when I tried to get it in cycle similar to groovy BC then it complains to compile: invalid operands of types double’ and ‘Int’ to binary ‘operator%’. I accessed time and used % operator inside the code as shown below. It doesn't look like % operator works the same way for groovy and OF. scalar t_ = this->db().time().value(); t_ % 1 > 0 Many thanks! |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Elastic or Plastic Deformations in OpenFOAM | NickolasPl | OpenFOAM Pre-Processing | 36 | September 23, 2023 09:22 |
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field | lakeat | OpenFOAM Community Contributions | 58 | December 23, 2021 03:36 |
pimpleDyMFoam computation randomly stops | babapeti | OpenFOAM Running, Solving & CFD | 5 | January 24, 2018 06:28 |
Help for the small implementation in turbulence model | shipman | OpenFOAM Programming & Development | 25 | March 19, 2014 11:08 |
Micro Scale Pore, icoFoam | gooya_kabir | OpenFOAM Running, Solving & CFD | 2 | November 2, 2013 14:58 |