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.
|
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) |
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"; |
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. |
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. |
Quote:
Code:
funkySetFields -time 0 -create -field test -expression "pos().x % 1" |
Hi Bernhard
but negative time has no meaning and it seems it omits negative times in the modular code,doesn't? |
Quote:
Code:
mkdir -- "-0.25" |
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?:) |
I have used this fields in replayTransientBCDict:
Code:
fields ( |
1 Attachment(s)
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? |
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. |
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. |
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) |
Quote:
|
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? :) |
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.
|
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) |
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:) |
Quote:
|
All times are GMT -4. The time now is 12:02. |