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

how to repeat a cycle in groovyBC

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

Like Tree2Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   January 6, 2013, 10:04
Default how to repeat a cycle in groovyBC
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   January 6, 2013, 15:21
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,744
Rep Power: 36
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
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.
That is not a groovyBC-question but basic mathematics. The question you should have asked is "is there a modul-operator in groovyBC?": yes there is http://openfoamwiki.net/index.php/Co...e_implemented: (the definition is a bit different from what you expect)
__________________
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   January 7, 2013, 02:50
Default
  #3
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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!
immortality is offline   Reply With Quote

Old   January 7, 2013, 04:04
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 782
Rep Power: 11
Bernhard is on a distinguished road
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"
Bernhard is offline   Reply With Quote

Old   January 7, 2013, 04:21
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,744
Rep Power: 36
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Bernhard View Post
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"
Thank you, Bernhard! I was so close from making an inappropriate remark
__________________
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   January 7, 2013, 12:13
Default
  #6
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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);
for each of t1,t2,t3,t4,t5,...(I should write untill t20)
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)
because (t1+c4) is the time of each cycle I wrote as above.is this mathematically true?
thanks.
immortality is offline   Reply With Quote

Old   January 7, 2013, 14:44
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,744
Rep Power: 36
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
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);
for each of t1,t2,t3,t4,t5,...(I should write untill t20)
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)
because (t1+c4) is the time of each cycle I wrote as above.is this mathematically true?
thanks.
Don't have the time to go through such long expressions. If you want to "try" your BC without running a full simulation have a look at the replayTransientBC-utility that comes with swak. This only updates the BCs and writes the files to disc. Then you can have a look at the boundaries in Paraview.

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
gschaider is offline   Reply With Quote

Old   January 7, 2013, 16:35
Default
  #8
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
thanks bernhard.you are right!i wanted to ask how use it and where an example is!
I'll do and will ask again!
immortality is offline   Reply With Quote

Old   January 8, 2013, 06:00
Default
  #9
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
bernhard could you tell me if the way i wrote the conditions are right or not?
Thank you.
immortality is offline   Reply With Quote

Old   January 8, 2013, 06:52
Default
  #10
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 782
Rep Power: 11
Bernhard is on a distinguished road
Quote:
Originally Posted by immortality View Post
bernhard could you tell me if the way i wrote the conditions are right or not?
Are you talking to me?

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.
Bernhard is offline   Reply With Quote

Old   January 8, 2013, 07:33
Default
  #11
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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?
immortality is offline   Reply With Quote

Old   January 9, 2013, 06:59
Default
  #12
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   January 9, 2013, 07:08
Default
  #13
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 782
Rep Power: 11
Bernhard is on a distinguished road
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
Bernhard is offline   Reply With Quote

Old   January 9, 2013, 10:44
Default
  #14
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   January 9, 2013, 11:07
Default
  #15
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 782
Rep Power: 11
Bernhard is on a distinguished road
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!
Bernhard is offline   Reply With Quote

Old   April 25, 2013, 05:09
Default
  #16
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 298
Rep Power: 8
openfoam_user is on a distinguished road
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.
immortality likes this.
openfoam_user is offline   Reply With Quote

Old   April 25, 2013, 13:21
Default
  #17
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 298
Rep Power: 8
openfoam_user is on a distinguished road
Dear OF-users,

Has someone already used the modulo-operator (%) successfully?

Can someone post a short example ?

Help s needed !

Regards,
Stephane.
openfoam_user is offline   Reply With Quote

Old   April 25, 2013, 13:59
Default
  #18
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,744
Rep Power: 36
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by openfoam_user View Post
Dear OF-users,

Has someone already used the modulo-operator (%) successfully?

Can someone post a short example ?

Help s needed !

Regards,
Stephane.
The only "problem" of the swak-% ist that it is a bit differently defined than the standard-%: while "a % b" in the standard-case maps into [0,b) in swak it maps into [-b/2,b/2) . Seemed to be a good idea at the time

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";
This is only an example and I didn't actually run it.

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
gschaider is offline   Reply With Quote

Old   April 25, 2013, 15:21
Default
  #19
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,173
Rep Power: 15
immortality is on a distinguished road
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 16:12.
immortality is offline   Reply With Quote

Old   April 26, 2013, 14:26
Default
  #20
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,744
Rep Power: 36
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
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?
Yeah. IT IS JUST AN EXAMPLE. The words "this is only an example" should have been a very clear hint. About "what does the expression mean": when you see "t^2" and in the text it says "parabolic sawtooth" you could sit down with a piece of paper and in 5 min you have it drawn: it is the rising arm of a parabola which after 42s drops to 0 and rises again.

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:
Originally Posted by immortality View Post
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?
That is not really clear. You mean it is undefined between the points you specify?
__________________
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

Reply

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
groovyBC and funkySetFields married and got a kid named swak4Foam gschaider OpenFOAM 161 March 30, 2014 08:04
Boundary Conditions with GroovyBC, Normal Gradient treima OpenFOAM Running, Solving & CFD 26 February 22, 2014 11:54
Boundary condition with a non-uniform gradient - groovyBC? STiss OpenFOAM Programming & Development 3 October 11, 2013 02:04
Boundary Conditions with GroovyBC, Normal Gradient treima OpenFOAM Programming & Development 2 January 26, 2013 02:37
groovyBC and Eqn.setReference() benk OpenFOAM 3 June 2, 2011 08:49


All times are GMT -4. The time now is 10:15.