Groovy BC - time dependend Inlet
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 |
1 Attachment(s)
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. |
Quote:
|
Quote:
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 |
Quote:
Code:
valueExpression "(pos().y>0.2 && pos().y<0.8) ? 1 : 0"; |
Oh yes, this seems better. THX!
|
Time dependent inlet pressure
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 |
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" |
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 |
Quote:
|
thanks Bernhard will try it and keep you updated.
:) |
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 ); } |
thanks heaps tobi that is very helpful indeed
|
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! |
Quote:
Quote:
|
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 :) |
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); } |
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"; |
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! |
All times are GMT -4. The time now is 06:40. |