|
[Sponsors] |
[swak4Foam] how to repeat a cycle in groovyBC |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 6, 2013, 11:04 |
how to repeat a cycle in groovyBC
|
#1 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
hello
I want to repeat a time cycle boundary condition for about 10 cycles.as its obvious all things should repeat from first at the end of each cycle.how can I define a time like "virtual time" that can be add to real time without need to calculating time manually.how can I perform that?each cyle takes a small time period like .002s. thank you for replying and all advises are appreciated. thanks. |
|
January 6, 2013, 16:21 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
||
January 7, 2013, 03:50 |
|
#3 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thanks!but i can't understand how should i use % operator in a groovyBC condition for repeating a cycle of groovyBC conditions from starting.i should use it at the end of first time cycle?how?could you give or point me to an example?thank you very much!
|
|
January 7, 2013, 05:04 |
|
#4 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
I think this should get you started in learning how to work with modulo operators.
http://en.wikipedia.org/wiki/Modulo http://en.wikipedia.org/wiki/Modulo_operation The basic thing you want to to is something like "primetime=time%period" |
|
January 7, 2013, 05:21 |
|
#5 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
||
January 7, 2013, 13:13 |
|
#6 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thank you both Bernhards!
my case is like it: Code:
fractionExpression "(0<=time()&&time()<=t1)||(t1+c1<=time()&&time()<=t1+c2)||(t1+c3<=time()&&time()<=t1+c4)||(t2+c1<=time()&&time()<=t2+c2)||(t2+c3<=time()&&time()<=t2+c4)||(t3+c1<=time()&&time()<=t3+c2)||(t3+c3<=time()&&time()<=t3+c4)||(t4+c1<=time()&&time()<=t4+c2)||(t4+c3<=time()&&time()<=t4+c4)||(t5+c1<=time()&&time()<=t5+c2)||(t5+c3<=time()&&time()<=t5+c4)?1:0"; valueExpression "vector(0,-v_r,0)" gradientExpression "vector(0,0,0)"; value uniform (0 -39.13957133 0); the conditins are the same but for convergency they should repeat 20 cycles. then how can I write them by % modulo?since times are floats. is something like this correct?(only first condition doesn't repeat) Code:
fractionExpressin "(0<=time()&&time()<=t1)||(t1+c1<=time()%(t1+c4)&&time()%(t1+c4)<=t1+c2)||(t1+c3<=time()%(t1+c4)&&time()%(t1+c4)<=t1+c4) thanks. |
|
January 7, 2013, 15:44 |
|
#7 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
I know what your next posting is going to be: it asks for a dictionary file. There ARE example files in the Examples. Copy and adapt one
__________________
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 |
||
January 7, 2013, 17:35 |
|
#8 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thanks bernhard.you are right!i wanted to ask how use it and where an example is!
I'll do and will ask again! |
|
January 8, 2013, 07:00 |
|
#9 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
bernhard could you tell me if the way i wrote the conditions are right or not?
Thank you. |
|
January 8, 2013, 07:52 |
|
#10 | |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
Quote:
But, is your question either of the following 1. Did I implement my equation correct? 2. Did I implement the correct equation? The answer to 1: Does it work? Do you get errors? Why do have doubts? The answer to 2: See the above answer by Gschaider. We will not check this for ever. |
||
January 8, 2013, 08:33 |
|
#11 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thanks.yes!
i dont have enough time to learn a new tool. None of them! I just transformed one set to second.first set is correctly working(my question definitly) is:is second equivalent to the first? |
|
January 9, 2013, 07:59 |
|
#12 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
suppose we have two range of time: t1<t<t2 and t3<t<t4
how we can combine these two into one expression according to the % operator you had said? thanks for help. |
|
January 9, 2013, 08:08 |
|
#13 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
You can't. You can use it for a periodic signal.
Suppose you have a function f(t) denoting a single period of what you want, say, between t=0 and t=p. Also, f(t) itself is not periodic. Simple example f(t)=t. Putting in f(t) will give you a continuously increasing value f(t%p) will give you a sawtooth pattern: http://www.wolframalpha.com/input/?i=plot+t%251 |
|
January 9, 2013, 11:44 |
|
#14 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thank you for nice and complete explaining.I want to do same work when time is t1<t<t2,t3<t<t4,t5<t<t6,etc.when t2-t1=t4-t3=t6-t5 and t3-t1=t4-t2=t5-t3=... mean the range dimensions and their distance are equal.
for example 1<t<2,3<t<4,5<t<6,... there exist same BC fr all of them. i'm mixed up how to map them into 1<t<2 in spite of its simplicity. is it possible that 1<t%2<2 can be true?or it can't be done by the method of reminders? thank you for taking your time. |
|
January 9, 2013, 12:07 |
|
#15 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
Define your f(t) for t in the range 0 to 2. Then use f(t%2).
Suppose your function is 0 for 0..1, 2..3, 4..5 and 1 for 1..2, 3..4 and 5..6 etc, then you can do something like f(t)=(t%2)>1&&(t%2)<2. Good luck! |
|
April 25, 2013, 06:09 |
|
#16 |
Senior Member
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18 |
Dear OF-users,
I use a groovyBCFixedValue type BC for the inlet. With a kind of ramp profile for the velocity. "profile=(1.02*time()+0.03);" I want to repeat the above profile each 0.05s. For example: time(0.05)=time(0) time(0.051)=time(0.001) time(0.052)=time(0.002) ... time(0.1)=time(0) time(0.101)=time(0.001) time(0.102)=time(0.002) ... time(0.15)=time(0) time(0.151)=time(0.001) time(0.152)=time(0.002) ... How can I use the modulo-operator (%) to obtain what I want. Thanks for helping me. Regards, Stephane. |
|
April 25, 2013, 14:21 |
|
#17 |
Senior Member
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18 |
Dear OF-users,
Has someone already used the modulo-operator (%) successfully? Can someone post a short example ? Help s needed ! Regards, Stephane. |
|
April 25, 2013, 14:59 |
|
#18 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
So to generate a "parabolic sawtooth" you might do something like this (I'm using variables to make it clearer - I recommend this anyway). Note that tPeriodic is in the range [0,1) Code:
variables ( "intervall=42.;" "tPeriodic=((time() % intervall) + intervall/2)/intervall;" ); expression "tPeriodic*tPeriodic"; If you're unsure if you implemented your BC correctly I recommend using the replayBC-utility before running the actual simulation
__________________
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 |
||
April 25, 2013, 16:21 |
|
#19 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thank you openfoam_user.
I had same question for a long time before but didn't take a useful answer and I thought from answers I received that this is so easy to explain and just I don't figure it out and so disappointed! maybe didn't propound it clearly. anyway what does that expression mean(tperiodic*tperiodic)?is it just an example? but my cycle is somewhat more complicated,if anyone can help time(0.05)=time(0) time(0.051)=time(0.001) time(0.052)=time(0.002) ... time(.075)=time(.025) time(0.1)=time(0) time(0.101)=time(0.001) time(0.102)=time(0.002) ... time(.125)=time(.025) time(0.15)=time(0) time(0.151)=time(0.001) time(0.152)=time(0.002) ... time(.175)=time(.025) it means that pieces are not contiguous and intervals are apart. how can set an arrangement for that?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. Last edited by immortality; April 25, 2013 at 17:12. |
|
April 26, 2013, 15:26 |
|
#20 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
I don't understand why you're disappointed with getting no answers when you disappoint people by not reading their answers. You've got to live with it that people are getting selective with answering. Even if some kind soul answers one of your questions per day she would only answer half of your questions 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 |
|||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] reactingMultiPhaseEulerFoam problems with groovyBC | zanilu70 | OpenFOAM Community Contributions | 4 | December 13, 2016 07:46 |
[swak4Foam] Change in alpha and U with groovyBC in twoPhaseEulerFoam | dani2702 | OpenFOAM Community Contributions | 0 | November 17, 2016 04:30 |
[swak4Foam] groovyBC issue - k and epsilon | sagnikmazumdar | OpenFOAM Community Contributions | 24 | March 1, 2015 08:16 |
one dimensional interpolation - repeat cycle. | kmgraju | CFX | 1 | March 3, 2013 06:20 |
[swak4Foam] groovyBC and Eqn.setReference() | benk | OpenFOAM Community Contributions | 3 | June 2, 2011 09:49 |