|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Nasser
Join Date: Mar 2014
Posts: 7
Rep Power: 12 ![]() |
Dear friends,
I am trying to write a UDF to control my heating source surface boundary condition in a dish washer; it is a multi-phase problem and this UDF should check all cells to see if it contains water; if it is the UDF should get its temp and add it to a variable with the name of "temp"; also it should count the cell numbers if they contain water and add it to the "count" variable. After this it should divide "temp" variable by "count" variable to get the average temperature of all cells which contains water and write it to "twater" variable. Finally it should check if this average temperature is less or more than 338. If it is less than 338 it should set the boundary heat flux to 60000 and if its is higher than 338 it should set this "source" to zero. I have written the following code; but I get errors continuously. Also I need to use it in parallel processing which as I read somewhere requires some corrections in code. Please help me to correct and run the code. I appreciate your help in advance. #include "udf.h" DEFINE_PROFILE(wallheatfluxprofile,thread,i) { { Thread *t; real temp = 0; real count = 0; real twater; cell_t c; d = Get_Domain(2); thread_loop_c(t,d) { begin_c_loop(c,t) temp += C_T(c,t); count = count + 1; end_c_loop(c,t) } twater = temp/count; printf("temp is: %g\n", twater); } real source; face_t f; if (twater > 338) source = 0; else source = 60000; begin_f_loop(f,thread) F_PROFILE(f,thread,i) = source; end_f_loop(f,thread) } Regards, |
|
![]() |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 ![]() |
Quote:
Code:
#include "udf.h" DEFINE_PROFILE(wallheatfluxprofile,thread,i) { Thread *t; real temp = 0; real count = 0; real twater; cell_t c; d = Get_Domain(2); real source; face_t f; thread_loop_c(t,d) { begin_c_loop(c,t) temp += C_T(c,t); count = count + 1; } end_c_loop(c,t); twater = temp/count; printf("temp is: %g\n", twater); if (twater > 338) source = 0; else source = 60000; begin_f_loop(f,thread) { F_PROFILE(f,thread,i) = source; } end_f_loop(f,thread); } |
||
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
Nasser
Join Date: Mar 2014
Posts: 7
Rep Power: 12 ![]() |
Thank you very mcuh for your response; as I mentioned before I need to get the average temperature of water which is not included in all cells and as a result of tempreature increment reduces gradually. So what should I do to get the average temperature of water?
Regards, |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 ![]() |
If you want the volume-averaged temperature, the code should look something like this:
Code:
real sumtemp = 0; real sumvolume = 0; real twater; cell_t c; d = Get_Domain(2); /* loop through all cells that contain water */ { sumtemp += C_T(c,t) * C_VOLUME(c,t); sumvolume += C_VOLUME(c,t); } end_c_loop(c,t) twater = sumtemp /sumvolume; |
|
![]() |
![]() |
![]() |
![]() |
#5 | |
New Member
Nasser
Join Date: Mar 2014
Posts: 7
Rep Power: 12 ![]() |
Quote:
Does your written code do this? Best regards, |
||
![]() |
![]() |
![]() |
Tags |
fluent - udf, heat flux, multi phase flow |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for variable surface tension on VOF | OmarEGB | FLUENT | 3 | June 18, 2022 01:08 |
UDF Surface Reaction Basics | FreeFall79 | Fluent UDF and Scheme Programming | 2 | January 15, 2019 11:09 |
surface reaction UDF | taekyu8 | Fluent UDF and Scheme Programming | 1 | June 16, 2013 03:23 |
Ansys FLUENT UDF - Velocity profile (of known values) across edge / surface | emmkell | Fluent UDF and Scheme Programming | 2 | October 21, 2011 13:12 |
need help regarding error in surface rxn UDF | Ashish Jain | FLUENT | 0 | May 16, 2005 10:43 |