|
[Sponsors] |
[swak4Foam] how to repeat a cycle in groovyBC |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 26, 2013, 16:28 |
|
#21 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
yes.for instance in [0,.025) I have a value for the function.but in [.025,.05) its zero gradient and again in [.05,.075) that valueExpression again and so on.
__________________
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. |
|
April 27, 2013, 14:10 |
|
#22 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
I figured it out.but another issue is that I have a time duration in start of cycles that is fixed and doesn't repeat in later times.
how can I set it?(imagine in the example of Bruno I have a fixed value in a few seconds at start and then interval starts)
__________________
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. |
|
April 27, 2013, 17:56 |
|
#23 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
I've defined t_mapped as this considering to t1 as a non-repeating value at first of the cycle:
Code:
"t_mapped=(time()>=t1) ? ((time()-t1) % c4+c4/2+t1) : time();" Code:
fractionExpression "(t1<t_mapped&&t_mapped<t1+c1)||(t1+c2<t_mapped&&t_mapped<t1+c3) ? 1 : 0";
__________________
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. |
|
April 28, 2013, 08:00 |
|
#24 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Dear Bernhard.
It seems you supposed incorrectly the domain that % maps into. I removed c4/2 in the formula and now it works well. It seems more correct that the domain is [0,interval) in the module-operator.
__________________
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. |
|
July 30, 2013, 12:52 |
|
#25 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
HI Bernhard
could you modify it to be between 0 and b in a%b in next Swak4Foam? it has originated a lot of trouble for me. it seems it maps the time to [0,b/2) (although seems incorrect due to duration should be "b" but occurs in real world as I've examined) not to [-b/2,b/2) or [0, b). see it: Code:
"t_mappedr=((time())%(c5r));" that is used in: Code:
"port2=(t1+c1r<t_mappedr && t_mappedr<t1+c2r);" so it seems as I told before the mapped domain is [0,b/2). I'm waiting to your kind clarifications. thanks.
__________________
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. |
|
July 30, 2013, 13:26 |
|
#26 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
funkySetFields -time 0 -create -field test -expression "pos().x % 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 |
||
July 30, 2013, 14:04 |
|
#27 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi Bernhard
but negative time has no meaning and it seems it omits negative times in the modular code,doesn't?
__________________
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. |
|
July 31, 2013, 06:50 |
|
#28 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
mkdir -- "-0.25" funkySetFields -time "-0.25" -create -field test -expression "time() % 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 |
||
July 31, 2013, 16:18 |
|
#29 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
in this expression t_mappedl should be between [0,.000933) as the result right?
float number isn't a trouble? Code:
"t_mappedl=(time()>0) ? ((time())%.000933) : time();" whats the way to see t_mappedl values in each time step?
__________________
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. |
|
August 1, 2013, 11:45 |
|
#30 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
I have used this fields in replayTransientBCDict:
Code:
fields ( t1 t_mappedl t_mappedr ); useFunctionObjects false; addDummyPhi false;
__________________
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. |
|
August 1, 2013, 13:52 |
|
#31 | |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Quote:
I examined that and it doesn't give any negative value(everything is in the domain of [0,.5).it is notable that pos().x is between 0 and .069 meter that is lower than 1.may it be the cause of not having negative values as expected?
__________________
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. |
||
August 1, 2013, 14:02 |
|
#32 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
I think I have figure it out and if verify me I'm going to execute it in real case.
I tested : Code:
100*pos().x % 1 then I conclude that : in a%b if a<=b then the result will be in [0,b/2] and if a>b they will be in [-b/2,b/2] then I have to use two different expressions for first cycle and the others. -------------------------- dear Bernhard it would be very useful if you could guide me through finding the formula implemented for this operator in Swak4Foam codes.
__________________
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; August 1, 2013 at 16:52. |
|
August 1, 2013, 16:52 |
|
#33 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
I have seen these in my tests:
Code:
funkySetFields -time 0 -create -field test -expression "1.5 % 1" Code:
funkySetFields -time 0 -create -field test -expression "1 % 1" Code:
funkySetFields -time 0 -create -field test -expression "1.75 % 1" Code:
funkySetFields -time 0 -create -field test -expression "0.75 % 1" it seems be a bug if you agree because its not clear how this mapping is done.
__________________
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. |
|
August 1, 2013, 18:42 |
|
#34 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
A modulo-operator. Somehow differently defined from the standard C++ %-operator: the value of (x − ε) % x is − ε (not x − ε - if you don't understand what I mean, please test for yourself - for most applications of this operator this is in my opinion the more practical implementation)
__________________
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 |
||
August 1, 2013, 18:49 |
|
#35 | |
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 |
||
August 2, 2013, 06:51 |
|
#36 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi
thanks for explanations.but in http://openfoamwiki.net/index.php/Co...funkySetFields in .4%1 for example epsilon is .6 and the answer of .4%1(even in your method) becomes .4 not -.6 so I think maybe the formula you mentioned is only applicable for epsilons<x/2 OK then I should use a condition for a%b if its in [0,b/2) use itself(a%b) but if a%b becomes a number in [-b/2,0) then I have to use "a%b+b" so that all numbers be in [0,b].is my conclusion now right in your opinion dear Bernhard or not?
__________________
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. |
|
August 2, 2013, 15:51 |
|
#37 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
now I have modified the expression that implemented % in my case like the way I told in upper post and it seems to work nice till now.when it ends second cycle I'll let you know.
__________________
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. |
|
August 3, 2013, 07:59 |
|
#38 | |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Quote:
so I implemented this expression that maintain positive half and maps negative part forward after positive part of the modulo operation result: Code:
0<=(time())%(c) && (time())%(c)<=c/2 ? (time())%(c) : (time())%(c)+c)
__________________
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. |
||
August 30, 2013, 06:58 |
|
#39 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
dear Bernhard
it has been run for more than 50 cycles with correct timing,I suggest you define another modulo operator(like "%t"or "%%" for example) for time that maps exactly to [0,b) in the case of a%b so that the probability of mistakes of users reduces and use the notation of a%b that seems more clear than (x-epsilon)%x
__________________
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. |
|
September 2, 2013, 17:52 |
|
#40 | |
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 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] reactingMultiPhaseEulerFoam problems with groovyBC | zanilu70 | OpenFOAM Community Contributions | 4 | December 13, 2016 06:46 |
[swak4Foam] Change in alpha and U with groovyBC in twoPhaseEulerFoam | dani2702 | OpenFOAM Community Contributions | 0 | November 17, 2016 03:30 |
[swak4Foam] groovyBC issue - k and epsilon | sagnikmazumdar | OpenFOAM Community Contributions | 24 | March 1, 2015 07:16 |
one dimensional interpolation - repeat cycle. | kmgraju | CFX | 1 | March 3, 2013 05:20 |
[swak4Foam] groovyBC and Eqn.setReference() | benk | OpenFOAM Community Contributions | 3 | June 2, 2011 08:49 |