|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
on
Join Date: Nov 2018
Posts: 3
Rep Power: 9 ![]() |
Hello all,
I am trying to find the average temperature of a face of a cube which is going to be used as inlet temperature to another domain. I am modelling a cube of stagnant water with inlet boundary condition at 323K. The output of my udf to calculate average temperature is coming zero! DEFINE_ADJUST(avg_temp,d) /*calc outlet temp average of water*/ { real tavg=0.0; face_t f; real A[ND_ND]; real area = 0.0; real area_tot = 0.0; Thread *t = Lookup_Thread(d,7); begin_f_loop(f,t) { F_AREA(A,f,t); area = NV_MAG(A); area_tot+=area; tavg+=F_T(f,t)*AREA; } end_f_loop(f,t) tavg/=area_tot; printf("avergae temperature of outlet of water is %f\n", tavg); printf("area total = %f\n", area_tot); } I am new to udf and would appreciate any help with this udf. Thank you!
|
|
|
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 13 ![]() |
Hi Smukh,
Assuming you've pasted your code accurately, the first error to look at is tavg+=F_T(f,t)*AREA; because "AREA" is not the same as "area". (C language is case-sensitive.) This should not get past a compiler without some warnings, or maybe errors. Please can you debug this and tell us what happens next? Does your code report a sensible value of area_tot? This UDF is suitable only for serial Fluent, of course. I would discourage use of "printf" in UDFs -- "Message" is safer. The difference is possibly small, but not necessarily. Good luck! Ed |
|
|
|
|
|
|
|
|
#3 |
|
New Member
on
Join Date: Nov 2018
Posts: 3
Rep Power: 9 ![]() |
Hi Ed,
Thank you for your suggestions. I have successfully resolved it. It worked when I changed from DEFINE_ADJUST to DEFINE_EXCUTE_AT_END and AREA to area. I am not sure why I wasn't getting the value even after changing caps area, it was giving me no error while compiling. But as I did not need values for every iteration I was fine by replacing adjust by at end. |
|
|
|
|
|
![]() |
| Tags |
| fluent - udf, fluent 18.0, temperature average value, udf code |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| whats the cause of error? | immortality | OpenFOAM Running, Solving & CFD | 13 | March 24, 2021 08:15 |
| [blockMesh] Errors during blockMesh meshing | Madeleine P. Vincent | OpenFOAM Meshing & Mesh Conversion | 51 | May 30, 2016 11:51 |
| is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
| Atributting one face temperature to another face | nfspetronilho | FLUENT | 0 | March 28, 2011 13:13 |
| fluent add additional zones for the mesh file | SSL | FLUENT | 2 | January 26, 2008 12:55 |