# How to write a UDF

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

 June 25, 2012, 07:06 How to write a UDF #1 New Member   Balaji Join Date: Jun 2011 Posts: 9 Rep Power: 8 Dear all, I need to write a UDF for pressure inlet boundary condition where i knew 10 data points of time vs pressure. Can someone help me in detailing the procedure to write such a UDF. Thanks in advance

 June 26, 2012, 13:08 #2 Senior Member     Alex Join Date: Jun 2012 Location: Germany Posts: 1,486 Rep Power: 25 Assuming you want to interpolate the pressure linearly between the discrete values, something like this might do the trick Code: ```#include "udf.h" DEFINE_PROFILE(pressure_profile,t,i) { real tn[10]; real pn[10]; face_t f; int n; real time=RP_Get_Real("flow-time"); tn[1]=2; tn[2]=3; //...and so on, here you may enter your data points pn[1]=4; pn[2]=7; //...and so on begin_f_loop(f,t) { for(n=10;n>0;n=n-1) { if(tn[n]

 June 26, 2012, 21:33 #3 New Member   Balaji Join Date: Jun 2011 Posts: 9 Rep Power: 8 Thanks Alexander, will try your suggestion and post whether it worked for me or not. Thanks for your timely support Balaji

 June 27, 2012, 01:25 #4 Senior Member     Alex Join Date: Jun 2012 Location: Germany Posts: 1,486 Rep Power: 25 Sorry I just found a little mistake: Code: ```#include "udf.h" DEFINE_PROFILE(pressure_profile,t,i) { real tn[10]; real pn[10]; face_t f; int n; real time=RP_Get_Real("flow-time"); tn[1]=2; tn[2]=3; //...and so on, here you may enter your data points pn[1]=4; pn[2]=7; //...and so on begin_f_loop(f,t) { n=1; while(tn[n]<=time) { F_PROFILE(f,t,i)=pn[n]+(time-tn[n])/(tn[n+1]-tn[n])*(pn[n+1]-pn[n]); n++; } } end_f_loop(f,t) }```

 June 27, 2012, 09:00 #5 New Member   Balaji Join Date: Jun 2011 Posts: 9 Rep Power: 8 Thanks Alexander I have solved the problem using your help. Thanks Saeed For your help anyways i have solved the problem

 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 mani.rajendiran Fluent UDF and Scheme Programming 0 March 13, 2012 01:22 davesmith_01 FLUENT 1 November 20, 2011 22:20 lnjxhl FLUENT 3 March 3, 2010 09:32 venus FLUENT 1 October 28, 2008 03:46 Mcgregor FLUENT 4 June 9, 2003 13:21

All times are GMT -4. The time now is 02:13.