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

average temperature of a face

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 6, 2018, 18:12
Question average temperature of a face
  #1
New Member
 
on
Join Date: Nov 2018
Posts: 3
Rep Power: 8
smukh is on a distinguished road
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!
smukh is offline   Reply With Quote

Old   December 6, 2018, 20:21
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
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
obscureed is offline   Reply With Quote

Old   December 10, 2018, 16:57
Default
  #3
New Member
 
on
Join Date: Nov 2018
Posts: 3
Rep Power: 8
smukh is on a distinguished road
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.
smukh is offline   Reply With Quote

Reply

Tags
fluent - udf, fluent 18.0, temperature average value, udf code


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
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


All times are GMT -4. The time now is 20:11.