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

Seek help in writing UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 12, 2007, 09:05
Default Seek help in writing UDF
  #1
Jack Martinez
Guest
 
Posts: n/a
Hello everybody

I seek urgent help in writting a UDF.

I need to write a UDF that can extract temperature at the boundary wall face and an adjacent cell centroid in interior. The difference of these temperature is used with heat flux data (that has also to be extracted) at the boundary wall to calculate the heat transfer coefficient (HTC) over one particular face.

This heat transfer coefficient (HTC) will then be exported to a C++ program for further calculations.

OR

If there is some alternate way (using GUI or other) by which we can calculate the heat transfer coefficient (calculated with-in FLUENT) over a boundary face and can export it in a C++ program without using any TEXT USER INTERFACE (EXCEL; WORD; NOTEPAD file), this procedure then has to be repeated to calculate HTC over all the faces on the boundary..

Can someone please extend some help in writing this UDF.

Thanks in advance.

Jack.
  Reply With Quote

Old   June 12, 2007, 19:29
Default Re: Seek help in writing UDF
  #2
Tomasz Bednarz
Guest
 
Posts: n/a
This should help, kindest regards, Tomasz

d = Get_Domain(1);

tf = Lookup_Thread(d,Face_Id); tc = Lookup_Thread(d,Cell_Id);

c0=F_C0(f,tf);

begin_f_loop(f,tf) { face_wall_value = F_T(f,tf); neubouring_cell_value = C_T(c0,tc); } end_f_loop(f,tf)

  Reply With Quote

Old   June 13, 2007, 03:16
Default Re: Seek help in writing UDF
  #3
Jack Martinez
Guest
 
Posts: n/a
Hello Mr. Berdnarz

Thank you very much for your prompt reply.

Regarding your solution posted, kindly clarify my few queries:-

1. To my understanding, You have included separate Lookup_Thread for extracting thread pointer for wall face and the adjacent cell but the zone_id which, we need to define for using this Macro, is available only for wall faces (= zone_id at the particular boundary) how can we get the zone_id for adjacent cells.

2. Kindly suggest me some Macro to extract the wall heat flux at the same boundary face (Face_Id).

3. Do you have idea about script using which we can transfer the computed results, using this UDF, in the solver directly to a C++ program.

please give some input on:-

if we define a UDS for HTC and store it in UDM... will there be a possibity of accessing this HTC in other program while the solver is still running.
  Reply With Quote

Old   June 13, 2007, 03:49
Default Re: Seek help in writing UDF
  #4
Tomasz Bednarz
Guest
 
Posts: n/a
Sorry, it should be:

d = Get_Domain(1); tf = Lookup_Thread(d,Face_Id); tc = Lookup_Thread(d,Cell_Id); begin_f_loop(f,tf) { c0=F_C0(f,tf); face_wall_value = F_T(f,tf); neubouring_cell_value = C_T(c0,tc); } end_f_loop(f,tf)

Your queries: 1. face_id is id of your wall, cell_id is your interior region 2. you could estimate your heat flux by defining udf on the same matter, however Fluent has build-in functions for getting heat flux on the walls - please refer to the manual (also you can read on getting gradients in Fluent - http://warlock.amnesty.scene.pl) 3. surely - download Visual C/C++ from M$ website which is free of charge. then run Fluent having paths correctly defined for the compiler. then do your UDF in compiled version and you will be able to use any kind of C++ magic from your UDF... you can define time-points when your UDF function will be called - you can do it even for every inner iteration - again refer to the manual - all is there...

Hope it helps you a bit, kindest regards, Tomash

  Reply With Quote

Old   June 13, 2007, 04:55
Default Re: Seek help in writing UDF
  #5
Jack Martinez
Guest
 
Posts: n/a
hello.

In your proposed solution,

1. Does the face_ID & cell_ID hold different values? In that case how can we get the zone_ID for the cells.

2. If same, then then what is the advantage of using two Lookup_Thread. Can the below mentioned one be an alternative solution:-

d = Get_Domain(1);

t = Lookup_Thread(d,zone_ID);

begin_f_loop(f,t)

{

c0 = F_C0(f,t);

t0 = F_C0_THREAD(f,t);

temp_wall = F_T(f,t);

enthalpy_wall = F_H(f,t); \* for calculating the wall heat flux*\

if(FLUID_THREAD_P(t0))

return;

temp_adj = C_T(c0,t0);

}

end_f_loop(f,t)

Please give some more input on "run Fluent having paths correctly defined for the compiler. then do your UDF in compiled version and you will be able to use any kind of C++ magic from your UDF". I have not much experienced with C++...especially this stuff like exporting/importing data dynamically...

I need to transfer HTC values calculated on the face values after every iteration/time step to the C++ compiler.

Best Regrads Jack
  Reply With Quote

Old   June 13, 2007, 10:30
Default Re: Seek help in writing UDF
  #6
Tomasz Bednarz
Guest
 
Posts: n/a
Hi Jack,

> 1. Does the face_ID & cell_ID hold different values?
: In that case how can we get the zone_ID for the cells. '

Of course they are not the same... You can check ID in Fluent when defining BC for instance...

> 2. If same, then then what is the advantage of using two

no, they are not the same...

> Please give some more input on "run Fluent having paths correctly defined for the compiler. then do your UDF in

install visual studio, and there you have batch file which runs all env variables... from command prompt run fluent and you are there

> I need to transfer HTC values calculated on the face values after every iteration/time step to the C++ compiler.

shoudn't be a problem... please refer to the manual - you have examples and almost ready solutions there,

regards, Tomash

  Reply With Quote

Old   June 13, 2007, 11:51
Default Re: Seek help in writing UDF
  #7
Nitesh Goyal
Guest
 
Posts: n/a
Hi

Ok, if the zone id for cell is different then that of face at boundary, which one you would suggest to assign to the cell adjacent to the wall, the zone id of fluid or zone_id of interior. I checked in BC panel, they hold different ids.

I have to run my case in LINUX system. So I would be really thankful if you may please suggest me how to specify the path in FLUENT for GNU compiler to compile my UDF and also whether a dynamic library is neccesary or optional to link it with LINUX.

Regarding Exporting the HTC values, which example are you refering to. I checked the UDF manual 6.3 but couldn't find the appropriate manual in which they have mentioned any details about computing the HTC values or exporting values from solver to other compiler for post-processing.

Thanks in advance

Regards

Jack Martinez.
  Reply With Quote

Old   June 13, 2007, 11:56
Default Re: Seek help in writing UDF
  #8
Jack Martinez
Guest
 
Posts: n/a
Oh, I used my Friends computer so the message appeared with his name.
  Reply With Quote

Old   June 13, 2007, 21:42
Default Re: Seek help in writing UDF
  #9
Tomasz Bednarz
Guest
 
Posts: n/a
again: id_face should be your wall's zone id id_cell should be your fluid's zone id

Linux: under Linux you don't need to care about setting env variables as it is under XP. only be sure, that gcc/gc++ compiler is in your path... The procedure of compiling in fluent is then the same...

There are many examples of getting face values... writing them to the file then is not a big deal... for instance to save x location and the temperature:

begin_f_loop(f,t) {

F_CENTROID(xc,f,t);

fprintf(fout, "%.8f\t%.8f\t", xc[0], F_T(f,t)); ...

Hope it helps,

  Reply With Quote

Old   June 14, 2007, 10:24
Default Re: Seek help in writing UDF
  #10
Jack Martinez
Guest
 
Posts: n/a
Below mentioned is the UDF I hace conceptualised but due to problem in compiler I couldn't check it yet. Please give some input on it...

d=Get_Domain(1); t = Lookup_Thread(d,Face_Id); begin_f_loop(f,t) {

c0 = F_C0(f,t);

t0 = F_C0_THREAD(f,t);

temp_wall = F_T(f,t);

temp_grad = C_T_G(c0,t0)[1]*C_VOLUME(c0,t0);

heat_flux = k_cond*temp_grad;

if(!FLUID_THREAD_P(t0))

return;

temp_adj = C_T(c0,t0);

h = heat_flux/(temp_wall â€" temp_adj); /*printf("Temp_Wall: %g\n Temp_Cell_Centroid: %g \n HTC: %g",temp_wall, temp_adj, htc);*/ } end_f_loop(f,t) }

Looking forward for ur comment..

Also please let me know do u have experience with running Fluent in Batch Mode. I have some basic queries in that

Regards Jack Martinez...
  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
Writing UDF (DEFINE_PROFIL) for two surfaces Geisel Fluent UDF and Scheme Programming 5 June 21, 2010 08:38
writing UDF for modelig mass transfer for VOF ardalan soleymani FLUENT 0 July 11, 2007 01:09
New to writing UDF Sandilya FLUENT 0 May 31, 2007 12:03
Writing UDF for Robbins Bounday Condition KKLAU FLUENT 1 April 6, 2004 23:58
Macros for writing UDF for porosity umesh FLUENT 1 June 13, 2003 04:20


All times are GMT -4. The time now is 19:14.