# Writing UDF (DEFINE_PROFIL) for two surfaces

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

 June 18, 2010, 01:33 Writing UDF (DEFINE_PROFIL) for two surfaces #1 New Member   Luk Join Date: Jun 2009 Posts: 24 Rep Power: 10 Sponsored Links Hi everyone, I am a little bit confused, UDF is a new thing for me, never tried it (never need it) but now i have to calculate something different. The matter is a two different size surfaces inside some space (as on sketch), each has different temperature profil. I have tried to write UDF code in order to set proper termal distribution along two surfaces and only the upper one is evenly distributed, for bottom surface it is completly incorrect (I had a negative temperatures what is impossible for my case). I think the problem can lies on coordinates taken into consideration for both surfaces. Maybe for cases including more than one UDF functions (for couple things in Fluent) syntax looks completly different... I do not know, did not find that in UG. I appreciate for any help or tips. enclosured code and sketch: Code: ```#include "udf.h" DEFINE_PROFILE(GK_sp,thread,index) { real x[ND_ND]; real y; face_t f; begin_f_loop(f,thread) { F_CENTROID(x,f,thread); y=x[1]; F_PROFILE(f,thread,index)=191.8 + 178.474*y; } end_f_loop(f,thread) } DEFINE_PROFILE(ZK_sp,thread,index) { real x[ND_ND]; real y; face_t f; begin_f_loop(f,thread) { F_CENTROID(x,f,thread); y=x[1]; F_PROFILE(f,thread,index)=48.25 + 64.*y; } end_f_loop(f,thread) } Some explonations: I assume the centre in the middle of surface in that case I have adequately temperature in the middle +- temperature gradient*appriopriate length``` Legend: 1-GK 2-ZK Have a nice day __________________ *******************************

 June 18, 2010, 17:00 #2 New Member   omid Join Date: Mar 2010 Posts: 17 Rep Power: 9 dear friend I cant understand what ur model is,but i can told u that: x[0]= x coordinate x[1]= y coordinate x[2]= z coordinate. define_profile is used to specify values in BCs and as i can find out lines 1,2 r interior, and i think it's not correct to use this macro here. if u wanna specify temp in part of ur studied domain u can use define-adjust profile to do this. in addition u can test ur udf with printf() to see the answers in fluent graph window. F_CENTROID(x,f,thread); y=x[1]; F_PROFILE(f,thread,index)=191.8 + 178.474*y; printf("answers:%f\n:",F_PROFILE); the bold is important Last edited by om1234; June 18, 2010 at 19:29.

 June 19, 2010, 07:11 #3 New Member   Luk Join Date: Jun 2009 Posts: 24 Rep Power: 10 Thank you for your reply, Sketch was a rough interpretation of my work. My project is a plate heat exchanger with sophisticated shape of corrugations. I am trying to obtain a much simpler model of it trying to set a proper (analytical results) temperatures along the fluid flow. Actual those lines are rectangular shapes of plates. From the UDF UG examples chapter I know that 0,0 coordinates should be on the middle of surface, in my case 0,0 is at the bottom left end of outlet surface. Can this be a problem? I used F_centroid because i thought that UDF will take those coordinates as an origin for calculation, but the temperature distribution is not the same like in my code. I have tried to put: Code: `printf("answers:%f\n:",F_PROFILE);` into my code but Fluent says that F_profile is undeclared I am experienced with Fortran, but nonetheless it has a little bit different syntax EDIT: I found the reason. In UDF all variables must be in SI i.e. temperature in K, I set it in C grad. The second one was the length y. I thought that y in formula is (current surface length)/2 but it looks like y = the whole length. __________________ ******************************* Last edited by Geisel; June 19, 2010 at 14:00. Reason: stated in post

 June 20, 2010, 09:49 #5 New Member   omid Join Date: Mar 2010 Posts: 17 Rep Power: 9 u can use this simple udf to get the centroid(if lines 1&2 have been defined in control panel and had ID no.) #include"udf.h" #include"udf.h" DEFINE_ADJUST(pressure,domain) { face_t f; int ID=line 1 or 2 ID;/*u can get the ID in define boundary condition panel real x[ND_ND]; Thread *t=Lookup_Thread(domain,ID); begin_f_loop(f, t) { F_CENTROID(x,f,t); printf("cccccccccc:%f,%f,%f\n",x[0],x[1],x[2]); } end_f_loop(f, t) }

June 21, 2010, 08:38
#6
New Member

Luk
Join Date: Jun 2009
Posts: 24
Rep Power: 10
Quote:
 Originally Posted by om1234 (...)
Thank you, I will check it later.
UDF is still beyond my comprehension, but I made a progress, though I have just started to learn it.
__________________
*******************************

 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 golriz Fluent UDF and Scheme Programming 7 November 3, 2011 06:30 ardalan soleymani FLUENT 0 July 11, 2007 01:09 Jack Martinez FLUENT 9 June 14, 2007 10:24 Sandilya FLUENT 0 May 31, 2007 12:03 Henry Lee FLUENT 2 March 23, 2006 04:24