# a math operator in UDF

 Register Blogs Members List Search Today's Posts Mark Forums Read

 May 24, 2005, 12:22 a math operator in UDF #1 lichun Dong Guest   Posts: n/a Sponsored Links 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, 13:12 Re: a math operator in UDF #2 Mark 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, 13:13 Re: a math operator in UDF #3 Mark Guest   Posts: n/a Sorry, the example came out poorly formatted. Example: divide = div(numerator,denominator); remainder = divide.rem; Mark

 May 24, 2005, 15:34 Re: a math operator in UDF #4 lichun Dong Guest   Posts: n/a hi, Mark: Thanks a lot, so what is the data type of divide? Array of real? Lichun

 May 24, 2005, 15:56 Re: a math operator in UDF #5 Mark 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, 07:53 Re: a math operator in UDF #6 Saad Guest   Posts: n/a I think you can use the function rem(a,b). For example, rem(5,3) = 2. Saad

 June 7, 2005, 10:11 Re: a math operator in UDF #7 Mahesh 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, 22:04 Re: a math operator in UDF #8 manish mehta 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Qureshi FLUENT 7 March 23, 2017 08:37 shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14 S.Whitney FLUENT 0 October 15, 2007 11:29 Luc SEMINEL FLUENT 0 November 25, 2002 05:03 Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01