CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] how to repeat a cycle in groovyBC

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 26, 2013, 16:28
Default
  #21
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

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

Old   April 27, 2013, 17:56
Default
  #23
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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();"
but this expression doesn't work(always is zero)
Code:
fractionExpression "(t1<t_mapped&&t_mapped<t1+c1)||(t1+c2<t_mapped&&t_mapped<t1+c3) ? 1 : 0";
could somebody help?
__________________
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.
immortality is offline   Reply With Quote

Old   April 28, 2013, 08:00
Default
  #24
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   July 30, 2013, 12:52
Default
  #25
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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));"
where c5r is the interval.
that is used in:
Code:
"port2=(t1+c1r<t_mappedr && t_mappedr<t1+c2r);"
if t_mapped be between [-c5r/2,c5r) as you have told it should be a negative value in earlier times and port2 should be false always,but the expressions related to port2 condition execute then it seems the mapped domain starts from zero than a negative value,on the other hand expressions of conditions that t_mapped is bigger than c5r/2 are not execute.
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.
immortality is offline   Reply With Quote

Old   July 30, 2013, 13:26
Default
  #26
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
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.
Sorry no. Because making life easier for one would break existing cases for many others. And I rechecked: the %-operator works as expected. With
Code:
funkySetFields -time 0 -create -field test -expression "pos().x % 1"
I get a nice sawtooth between [-0.5,0.5] as specified. And "No": it doesn't matter whether it is time or position: the implementation of % is the same
__________________
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   July 30, 2013, 14:04
Default
  #27
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   July 31, 2013, 06:50
Default
  #28
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
Hi Bernhard
but negative time has no meaning and it seems it omits negative times in the modular code,doesn't?
As I verified in my above FSF-example negative values get correctly mapped. Always the same routine is used. So it doesn't matter whether it is a negative position or time. Check this by going to any case an there doing
Code:
mkdir -- "-0.25"
funkySetFields -time "-0.25" -create -field test -expression "time() % 1"
You will find that the file -0.25/test has a internal value -0.25 just as specified.
__________________
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   July 31, 2013, 16:18
Default
  #29
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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();"
but I don't know why it only put t_mappedl equal to zero for negative values of (time())%.000933) (it executes the condition for t-mappedl=0 in return of being negative until it become positive and then works fine)
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.
immortality is offline   Reply With Quote

Old   August 1, 2013, 11:45
Default
  #30
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
I have used this fields in replayTransientBCDict:
Code:
fields (
    t1
    t_mappedl
    t_mappedr
);

useFunctionObjects false;

addDummyPhi false;
but the variables are not printed in time folders.how to have them?
__________________
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.
immortality is offline   Reply With Quote

Old   August 1, 2013, 13:52
Default
  #31
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Sorry no. Because making life easier for one would break existing cases for many others. And I rechecked: the %-operator works as expected. With
Code:
funkySetFields -time 0 -create -field test -expression "pos().x % 1"
I get a nice sawtooth between [-0.5,0.5] as specified. And "No": it doesn't matter whether it is time or position: the implementation of % is the same
Hi
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?
Attached Files
File Type: gz test.tar.gz (25.7 KB, 1 views)
__________________
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.
immortality is offline   Reply With Quote

Old   August 1, 2013, 14:02
Default
  #32
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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
and every funky values were in (-.5, .5)
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.
immortality is offline   Reply With Quote

Old   August 1, 2013, 16:52
Default
  #33
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
I have seen these in my tests:
Code:
funkySetFields -time 0 -create -field test -expression "1.5 % 1"
resulted in ".5"
Code:
funkySetFields -time 0 -create -field test -expression "1 % 1"
resulted in "0"
Code:
funkySetFields -time 0 -create -field test -expression "1.75 % 1"
or even
Code:
funkySetFields -time 0 -create -field test -expression "0.75 % 1"
resulted in "-.25"
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.
immortality is offline   Reply With Quote

Old   August 1, 2013, 18:42
Default
  #34
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
I have seen these in my tests:
Code:
funkySetFields -time 0 -create -field test -expression "1.5 % 1"
resulted in ".5"
Code:
funkySetFields -time 0 -create -field test -expression "1 % 1"
resulted in "0"
Code:
funkySetFields -time 0 -create -field test -expression "1.75 % 1"
or even
Code:
funkySetFields -time 0 -create -field test -expression "0.75 % 1"
resulted in "-.25"
it seems be a bug if you agree because its not clear how this mapping is done.
No. It is not a bug. It is just different. To quote from http://openfoamwiki.net/index.php/Co...funkySetFields

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)
With your example (% 1) you get a straight line that starts at x=-0.5, y=-0.5 and goes to x=0.5,y=0.5. At x=0.5 it jumps to -0.5 and goes up again. For generating spatial distributions this definition is more convenient (I think). And as I said: I won't change it because it will break the expressions of everyone who used it up to now (and who obviously bothered to read the documentation and if he didn't understand it took it on himself to do some experimentation. I won't punish these people just because you didn't read and experiment)
__________________
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   August 1, 2013, 18:49
Default
  #35
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gschaider View Post
With your example (% 1) you get a straight line that starts at x=-0.5, y=-0.5 and goes to x=0.5,y=0.5. At x=0.5 it jumps to -0.5 and goes up again. For generating spatial distributions this definition is more convenient (I think). And as I said: I won't change it because it will break the expressions of everyone who used it up to now (and who obviously bothered to read the documentation and if he didn't understand it took it on himself to do some experimentation. I won't punish these people just because you didn't read and experiment)
OK. You experimented (only saw the last entry). You just got to the wrong conclusions
__________________
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   August 2, 2013, 06:51
Default
  #36
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   August 2, 2013, 15:51
Default
  #37
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   August 3, 2013, 07:59
Default
  #38
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Quote:
variables (
"intervall=42.;"
"tPeriodic=((time() % intervall) + intervall/2)/intervall;"
);
expression "tPeriodic*tPeriodic";
in your suggestion dear Bernhard it seems that the idea for position has implemented for time here.in time()=0 tPeriodic becomes .5,means it starts from middle of the interval while we expect that time be started from beginning. it may be appropriate for position when there is no importance in the order of values,they can map at first or at last no matter but in time the order is important.
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.
immortality is offline   Reply With Quote

Old   August 30, 2013, 06:58
Default
  #39
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   September 2, 2013, 17:52
Default
  #40
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
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
Write a feature request on the Mantis and I'll think about it. I'm not a big fan of bloating the grammar with stuff that can easily be written with a simple transformation. So if the %%-variant breaks the grammar I'll probably not add it
immortality likes this.
__________________
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


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 Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 05:22.