|
[Sponsors] |
July 29, 2012, 14:59 |
FLUENT UDFs
|
#1 |
Senior Member
---------
Join Date: Oct 2010
Posts: 303
Rep Power: 18 |
Could some one please let me know how to write a UDF to assign a volume averaged temperature in a domain as the temperature at an outlet.
I think that the face loops in Fluent are meant to assign boundary conditions on a surface boundary and the cell loops are meant to access (or) set volumetric quantities. Please correct me if Im wrong
__________________
Best regards, Santhosh. |
|
July 30, 2012, 11:25 |
|
#2 | |
Senior Member
|
Quote:
Bests,
__________________
Amir |
||
July 31, 2012, 16:12 |
|
#3 |
Senior Member
---------
Join Date: Oct 2010
Posts: 303
Rep Power: 18 |
Thanks for the reply Amir. Could you please look into the attached .c file of udf and let me know if it is fine to go on with.
I've two outlets so I used the macro Lookup_Thread(domain,zone_id) to reference them and then assigned the volume averaged temperature using two begin_f_loop(f,t) loops I've interpreted it and found no errors. On a conceptual basis please correct me if I'm wrong and also suggest if there is any better way of doing this. As a newbie to the UDF programming in Fluent I'd certainly appreciate your help
__________________
Best regards, Santhosh. Last edited by saisanthoshm88; July 31, 2012 at 16:29. |
|
August 1, 2012, 04:11 |
|
#4 |
Senior Member
|
Dear Santhosh,
I don't think you're really a newbie in UDF, because it's handled well. But just a point; As you noticed, it's stated in the manual that we can also use DEFINE_ADJUST macro for BC manipulation but honestly I did it with DEFINE_PROFILE so far because I'm not sure that the values in BC override the DEFINE_ADJUST values or not. So if I wanted to write such UDF, I used 1 DEFINE_ADJUST and 2 DEFINE_PROFILE macros in a file with global variables. So check the BC certainly to see whether they're affected in this way or not. (just for checking!) Bests,
__________________
Amir |
|
August 1, 2012, 05:47 |
|
#5 |
Senior Member
---------
Join Date: Oct 2010
Posts: 303
Rep Power: 18 |
Hi Amir,
Thanks for the suggestions. In case you experienced that the DEFINE_PROFILE macro is more reliable then i'd like to go with it. Please find attached the modified UDF i've interpreted it and it has no errors but just to crosscheck please have a look into it and let me know if everything is fine there. Thanking you for the help !
__________________
Best regards, Santhosh. |
|
August 1, 2012, 07:14 |
|
#6 | |
Senior Member
|
Quote:
Unfortunately it's not correct. The procedure for DEFINE_PROFILE is not the same as DEFINE_ADJUST; i.e., you'll need F_PROFILE(...) statements in order to assign values to boundaries. Take a look over one of the examples of manual and it would be clear. Another point; it's better to use initialization for accumulative variables in programming; you did it for tavg but didn't for vol_tot. If you want to use DEFINE_PROFILE, you need global variables; something like this: Code:
#include .... real tavg, vol_tot; // global variables accessible via all macros DEFINE_ADJUST(.....) { .... //compute tavg } DEFINE_PROFILE(...) { .... // for face 1 } DEFINE_PROFILE(...) { .... // for face 2 } If everything is the same for assigning values to 2 faces, you can use just one DEFINE_PROFILE and use it for both faces. Bests,
__________________
Amir |
||
August 1, 2012, 08:57 |
|
#7 |
Senior Member
---------
Join Date: Oct 2010
Posts: 303
Rep Power: 18 |
Yaa I got your point Amir but now when I've prepared a udf following these suggestions, Fluent throws an error when I use the same udf name in both the macros viz.., DEFINE_ADJUST and DEFINE_PROFILE.
However the interpretation is successful with no errors only when different udf names were used in the DEFINE_ADJUST and DEFINE_PROFILE macros. So while defining the backflow temperature at the outlet is it enough to just hook up the udf of the DEFINE_PROFILE macro
__________________
Best regards, Santhosh. |
|
August 1, 2012, 09:22 |
|
#8 | ||
Senior Member
|
Quote:
Quote:
Bests,
__________________
Amir |
|||
August 1, 2012, 09:26 |
|
#9 |
Senior Member
---------
Join Date: Oct 2010
Posts: 303
Rep Power: 18 |
Many thanks for your help Amir. Your suggestions were really valuable.
__________________
Best regards, Santhosh. |
|
August 1, 2012, 12:28 |
|
#10 |
Senior Member
---------
Join Date: Oct 2010
Posts: 303
Rep Power: 18 |
I'm sorry for raising this again Amir but if the udf referenced in the macro DEFINE_PROFILE is hooked to the outlet boundary then does Fluent execute the macro DEFINE_ADJUST .
I wonder about this because the udf associated with the DEFINE_ADJUST macro is not hooked there. My worry is that in case Fluent doesn't execute the DEFINE_ADJUST macro then a value of 0 will be assigned to the outlet temperature as the global variable tavg is initialized to zero in the begining
__________________
Best regards, Santhosh. |
|
August 1, 2012, 12:48 |
|
#11 |
Senior Member
|
No, just the UDFs that are hooked, are executed. Note that each UDF should be hooked in its proper panel; you have to hook DEFINE_ADJUST in it's panel and DEFINE_PROFILE in BC panel.
But a point I forgot is that because you're using accumulative variables you have to set initialization in DEFINE_ADJUST macro too. (it's more conservative even if you've used static variables) Bests,
__________________
Amir |
|
August 8, 2012, 06:21 |
|
#12 |
New Member
zainab
Join Date: Mar 2012
Posts: 17
Rep Power: 14 |
Hi Amir
I am working on modeling 3D gas-liquid slug flow in horizontal pipe, and I cannot get the true slug phase distribution can you help me to write UDF for volume fraction where I wont the lower half of the cylindrical pipe being always filled with the secondary phase while the upper half taking its value from iterations. thank you. |
|
August 13, 2012, 04:59 |
a question about under relaxation factor
|
#13 |
New Member
B Aram
Join Date: Aug 2012
Posts: 9
Rep Power: 14 |
I have a question about setting under relaxation factor.
is changing the relaxation factor supposed to change the final answer?! when i changed it in a problem, the final solution that i was expected wasn't gained and when i decreased it again, the final solution changed again. |
|
August 13, 2012, 07:17 |
|
#14 | |
Senior Member
|
Quote:
It's a numerical setting tool. In some cases, with high relaxation factors few unstability may occur but in more stable cases, increasing these factors increases the rate of convergency. In these cases, if you provide enough iterations the same results will obtain. (The rate of convergency is changed) Bests,
__________________
Amir |
||
August 13, 2012, 18:39 |
|
#15 |
Senior Member
Ehsan Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18 |
Dear Saisanthoshm
Could you get it work by implementing define_profile for assigning boundary temperature? I have a similar problem regarding with assigning specific temperatures into wall boundaries. If so,would you please send me your UDF?! My email is syavash_azna@yahoo.com Thank you very much |
|
January 16, 2013, 11:51 |
F_PROFILE(f,t,i) = C_UDMI(c0,t0,2);
|
#16 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Hi,
I have problem to read the C_UDMI now it is saving but if I use it in F_profile it is always Zero I am simulating gas-solid flow. So I want to save velocity and volume fraction in outlet and then to use it in inlet so I managed to save it with C_UDMI but in inlet everything is zero it seems it doesnt work. here is my inlet profile: DEFINE_PROFILE(abs_vel,t,i) { Domain *d; cell_t c, c0; face_t f; Thread *ct,*t0; begin_f_loop(f,t) { c0 = F_C0(f, t); t0 = THREAD_T0(t); if (C_UDMI(c0,t0,2) =0) F_PROFILE(f,t,i)=0.001; else F_PROFILE(f,t,i) = C_UDMI(c0,t0,2); } end_f_loop(f,t) } thanks for your help!!! |
|
January 16, 2013, 12:02 |
|
#17 | |
Senior Member
|
Quote:
Bests,
__________________
Amir |
||
January 16, 2013, 12:06 |
|
#18 | |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Quote:
DEFINE_PROFILE(abs_vel,t,i) { Domain *d; Thread *ct,*t0; cell_t c, c0; face_t f; //d = Get_Domain(1); //t0= Lookup_Thread(d, 10014); begin_f_loop(f,t) { c0 = F_C0(f, t); t0 = THREAD_T0(t); //if (C_UDMI(c0,t0,2) =0) //F_PROFILE(c0,t0,i)=0.001; //else C_UDMI(c0,t0,2)=F_UDMI(f,t,2); F_PROFILE(f,t,i)=F_UDMI(f,t,2) ;/*C_UDMI(c0,t0,2);*/ } end_f_loop(f,t) } I tried this one bu doesnt work as well thanks again for your help! |
||
January 16, 2013, 12:22 |
|
#19 | |
Senior Member
|
Quote:
DEFINE_PROFILE(abs_vel,t,i) { face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i)=F_UDMI(f,t,0) ; } end_f_loop(f,t) }
__________________
Amir Last edited by Amir; January 16, 2013 at 12:40. |
||
January 16, 2013, 12:28 |
|
#20 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
[QUOTE=Amir;402252]#include "udf.h"
Last edited by Kanarya; January 16, 2013 at 13:01. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Commercial meshers] Fluent3DMeshToFoam | simvun | OpenFOAM Meshing & Mesh Conversion | 50 | January 19, 2020 16:33 |
heat transfer with RANS wall function, over a flat plate (validation with fluent) | bruce | OpenFOAM Running, Solving & CFD | 6 | January 20, 2017 07:22 |
Error in reading Fluent 13 case file in fluent 12 | apurv | FLUENT | 2 | July 12, 2013 08:46 |
solving ocean wave with Fluent or CFX? | gholamghar | Main CFD Forum | 1 | March 21, 2009 13:49 |
how to upload mutiple UDFs in FLUENT. | shunahshep | FLUENT | 8 | March 2, 2005 22:56 |