|
[Sponsors] |
UDF for mass-flow calculation does not print any value into console |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 9, 2020, 14:00 |
UDF for mass-flow calculation does not print any value into console
|
#1 |
New Member
Jakub
Join Date: Mar 2018
Posts: 13
Rep Power: 8 |
Hi,
I am not good in fluent UDFs and I rarely use fluent to be honest, but I want to do some cross-check of my own code and first need to learn how to do something similar but simpler, e.g., integrate fluxes on the specified faces in fluent. Could anyone help me out with testing and correcting my apparently simple UDF which I am willing to use for integrating the mass-flow on a selected surface? After compiling in fluent v19.5 (without any warnings/errors) on SUSE Linux and running parallel it doesn't display any value in the console. It should be simple to test this UDF since it fits for most cases by selecting appropriate ID ZONE in the t= Lookup_Thread(d, 8);. #include "udf.h" DEFINE_EXECUTE_AT_END(mass_flow) { Domain *d; Thread *t; face_t f; real mf=0.; d = Get_Domain(1); t = Lookup_Thread(d, 8); begin_f_loop(f,t) { mf+=F_FLUX(f,t); } end_f_loop(f,t) Message("MASS Flow Rate: %g\n",mf); } I have also an additional question. How to be sure that 1 and 8 are the ID of the zones that I am interested in? I am asking because when I select my domain in Cell Zone Conditions it appears that ID of the domain is 3. But after reading the forum and manual I found it should be equal to 1 in case of a single phase flow. Anyway it doesn't work with 1 and 3 either. d = Get_Domain(1); t= Lookup_Thread(d, 8); Thank you for your time. Jakub |
|
May 10, 2020, 13:17 |
Domain and Zone
|
#2 |
Senior Member
|
The argument of Get_Domain is not ID of cell zone but ID of the domain. Domain is superstructure that contains whole of the case, including cell zones, boundary zones, materials, etc. For a single phase case, ID is always 1. Therefore, Get_Domain(1) is correct. However, the second argument of Lookup_Thread needs to be the ID of the boundary for which you want the mass flux. So, if 8 is the ID of the boundary, say, inlet or outlet, then the code should return a value. However, if 8 is the ID of the a cell zone, then it won't. So, go to Boundary Conditions and check the ID displayed for the boundary for which you want flow rate to be reported.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
May 10, 2020, 14:34 |
|
#3 |
New Member
Jakub
Join Date: Mar 2018
Posts: 13
Rep Power: 8 |
Vinerm thank you for your interest.
Actually I did as you mentioned and as logic tells, however my udf does not run properly. Maybe I am asking for too much, but would you be able to compile my udf and run it by yourself to see if it works. Im am also attaching screenshots of the procedure I follow, maybe I do some mistake somewhere. https://i.ibb.co/xHxnWPj/cfdonline.png |
|
May 10, 2020, 14:45 |
Hooking
|
#4 |
Senior Member
|
You need to hook the UDF library at appropriate location. Go to User-Defined Functions > Hooks and Hook the library that you compiled. Then run it.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
May 10, 2020, 14:49 |
|
#5 |
New Member
Jakub
Join Date: Mar 2018
Posts: 13
Rep Power: 8 |
Great, it works now!
Thank you. |
|
May 11, 2020, 04:41 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
most likely your code has problems, try this one
Code:
#include "udf.h" DEFINE_EXECUTE_AT_END(mass_flow) { Domain *d; Thread *t; face_t f; real mf=0.; d = Get_Domain(1); t = Lookup_Thread(d, 8); begin_f_loop(f,t) { mf+=F_FLUX(f,t); } end_f_loop(f,t) #if RP_NODE mf = PRF_GRSUM1(mf); #endif Message0("MASS Flow Rate: %f\n",mf); }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
May 11, 2020, 07:24 |
|
#7 | |
New Member
Jakub
Join Date: Mar 2018
Posts: 13
Rep Power: 8 |
Thank you AlexanderZ,
you are right. Actually, I know this already, since I studied manual extensively yesterday, btw. I must say that fluent’s UDF manual is just great and very self-explanatory. I did some progress and now my UDF is able to calculate the mass flow rate, integrated volumetric flow rate and the area of a specified surface. I share my code with extensive comments (which are maybe not always 100% precise, but they show the idea behind) if someone find this useful would be great. This I tested on parallel 3d case. Quote:
Best regards, Jakub |
||
Tags |
fluent, get_domain, lookup_thread, mass-flow, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to get Sutherland and JANAF coefficients of air? | immortality | OpenFOAM Running, Solving & CFD | 64 | October 18, 2022 11:17 |
UDF for Mass Flow at the Outlet: ERROR ACCESS VIOLATION | I-mech | Fluent UDF and Scheme Programming | 1 | May 23, 2014 13:37 |
UDF problems with porous flow | Nicolastheterminator | Fluent UDF and Scheme Programming | 0 | April 8, 2014 10:12 |
initialization of flow field in a transient flow calculation | zhengjg | FLUENT | 1 | January 15, 2014 07:01 |
fluid flow fundas | ram | Main CFD Forum | 5 | June 17, 2000 22:31 |