UDF for mass-flow calculation does not print any value into console
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 |
Domain and Zone
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.
|
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 |
Hooking
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.
|
Great, it works now!
Thank you. |
most likely your code has problems, try this one
Code:
#include "udf.h" |
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 |
All times are GMT -4. The time now is 09:33. |