- **FLUENT**
(*https://www.cfd-online.com/Forums/fluent/*)

- - **a math operator in UDF
**
(*https://www.cfd-online.com/Forums/fluent/36759-math-operator-udf.html*)

a math operator in UDF
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 |

Re: a math operator in UDF
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 |

Re: a math operator in UDF
Sorry, the example came out poorly formatted.
Example: divide = div(numerator,denominator); remainder = divide.rem; Mark |

Re: a math operator in UDF
hi, Mark:
Thanks a lot, so what is the data type of divide? Array of real? Lichun |

Re: a math operator in UDF
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 |

Re: a math operator in UDF
I think you can use the function rem(a,b). For example, rem(5,3) = 2.
Saad |

Re: a math operator in UDF
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) } |

Re: a math operator in UDF
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 |

All times are GMT -4. The time now is 04:18. |