|
[Sponsors] |
May 24, 2005, 13:22 |
a math operator in UDF
|
#1 |
Guest
Posts: n/a
|
hi, All:
How to get the reminder of two number in UDF, like 7.2 % 2 = 1.2 in C. I need to input a asymmetric moving wall condition which has a period of 2*pi. I tried % in UDF, it does not work. Anybody has an experience? Thanks a lot |
|
May 24, 2005, 14:12 |
Re: a math operator in UDF
|
#2 |
Guest
Posts: n/a
|
I believe you use the div command to store the quotient and remainder. Then access the remainder using .rem
Example: divide = div(numerator,denominator); remainder = divide.rem; Mark |
|
May 24, 2005, 14:13 |
Re: a math operator in UDF
|
#3 |
Guest
Posts: n/a
|
Sorry, the example came out poorly formatted.
Example: divide = div(numerator,denominator); remainder = divide.rem; Mark |
|
May 24, 2005, 16:34 |
Re: a math operator in UDF
|
#4 |
Guest
Posts: n/a
|
hi, Mark:
Thanks a lot, so what is the data type of divide? Array of real? Lichun |
|
May 24, 2005, 16:56 |
Re: a math operator in UDF
|
#5 |
Guest
Posts: n/a
|
Hi,
Sorry, I should have included that with the example. I declared the variable using: div_t divide; So that would make it a type "div_t" (I think). Mark |
|
May 29, 2005, 08:53 |
Re: a math operator in UDF
|
#6 |
Guest
Posts: n/a
|
I think you can use the function rem(a,b). For example, rem(5,3) = 2.
Saad |
|
June 7, 2005, 11:11 |
Re: a math operator in UDF
|
#7 |
Guest
Posts: n/a
|
I have used once to define square wave velocity function as below. ================================= #include "udf.h" DEFINE_PROFILE(sq50_velocity, thread, nv) { face_t f; real t= RP_Get_Real("flow-time"); int p,q; real T=0.01; p=t/(T/2); q=p%2;
begin_f_loop(f, thread) { if(q==0) F_PROFILE(f, thread, nv) =30; else F_PROFILE(f, thread, nv) = 0; } end_f_loop(f, thread) } |
|
June 18, 2005, 23:04 |
Re: a math operator in UDF
|
#8 |
Guest
Posts: n/a
|
Dear Mahesh,
I am really new with UDF files. If my square wave needs to go from 180 psi to 0 psi, and it has a frequency of 10 Hz. How would I go about doing this? I thought of doing a Fourier Transform of a square wave that I need, but there are problems with that approach. Any advice would be benefical. Hope you can help. -Manish |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
I need UDF help. | S.Whitney | FLUENT | 0 | October 15, 2007 12:29 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |