CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

a math operator in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 24, 2005, 13:22
Default a math operator in UDF
  #1
lichun Dong
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
  Reply With Quote

Old   May 24, 2005, 14:12
Default 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
  Reply With Quote

Old   May 24, 2005, 14:13
Default 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
  Reply With Quote

Old   May 24, 2005, 16:34
Default 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
  Reply With Quote

Old   May 24, 2005, 16:56
Default 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
  Reply With Quote

Old   May 29, 2005, 08:53
Default 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
  Reply With Quote

Old   June 7, 2005, 11:11
Default 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) }
  Reply With Quote

Old   June 18, 2005, 23:04
Default 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
  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
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


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