Resolved: Changing boundary condition with UDF according to pressure outlet boundary
Hello everybody, my problem was:
I was trying to set a temperature to a velocity inlet in my problem according to the average temperature of the air leaving the domain from a pressure outlet. I searched through the forum to find a solution to this but I could not find a clear answer. Now I managed to write a parallel UDF (for 8 cpus) as a remedy to this problem. Hope this helps if you have the same problem: Code:
#include "udf.h" |
help
Hi there,
Thank you very much for this. Can I know some of the function of the lines you have written? 1) Message("Node %d : Average exit temperature = %f\n", myid, sum_temp); and 2)compute_node_loop_not_zero(i) I am very new in UDF in ANSYS Fluent and will appreciate all the help I can get. Thank you. EH |
How can I do the same job as you did but not for parallel nodes?
Hi,
I am trying to do the same with my code, but since it's not parallel, I am omitting every line in your code that relates to parallel CPUs. Here is my code: #include "udf.h" DEFINE_ADJUST(average_exit_temp, domain) { face_t f; real tempa=0.0; real totalarea=0.0; real avetempa=0.0; real A[ND_ND]; int ID1 = 4; /* Zone ID for Outflow zone from Boundary Conditions panel */ Thread *outlet_thread = Lookup_Thread(domain, ID1); int ID2 = 7; /* Zone ID for Inlet zone from Boundary Conditions panel */ Thread *inlet_thread = Lookup_Thread(domain, ID2); /* Loop over faces in a face thread to get the information stored on faces.*/ begin_f_loop(f,outlet_thread) { /* F_T gets face temperature. += causes all face areas/temperatures to be added together. */ totalarea += F_AREA(A,f,outlet_thread); tempa += F_AREA(A,f,outlet_thread)*F_T(f,outlet_thread); } end_f_loop(f,outlet_thread) avetempa = tempa/totalarea + 30*200/(0.561*4182); printf("average temperature= %e\n",avetempa); begin_f_loop(f, inlet_thread) { F_UDMI(f,inlet_thread,1) = avetempa; } } DEFINE_PROFILE(Inlettemp,t,i) { real flow_time; flow_time = RP_Get_Real("flow-time"); face_t face; if(flow_time<=5.0) { printf("t= %e\n",flow_time); begin_f_loop(face, t) { F_PROFILE(face, t, i)=283.0; } end_f_loop(face, t) } else { begin_f_loop(face, t) { F_PROFILE(face, t, i) = F_UDMI(f,t,1); } end_f_loop(face, t) printf("t= %e\n",flow_time); } } and I get a parse error on the Define_Profile line. Note that my case file and my c file are in the same directory. Do you have any idea what might be wrong here? Thank you in advance for your help. CMA Quote:
|
Hi CMA,
Not sure if you have solved this ourself but as I am 'borrowing' your code I thought I better reply with the fix. I think the error you have is that you don't have an end_f_loop(f,inlet_thread) at the end of the DEFINE_ADJUST() The parse error kicks in once you leave the function so it looks like it is relatign to the next function, but it isn't as I am only using our first function and also got the parse error. Taff |
Hi Taff,
There are a couple of errors in the above code including the one you mentioned. For example where I calculate the area of a face, my code gets the vector area which creates another error. However, if you are only using the general structure of the code, you will be fine. I will be happy to hear your suggestions, if there's any. Quote:
|
I'm struggling a bit to be honest, first attempt at UDFs and not quite sure I have it worked out.
For some reason my system isn't processing the begin_f_loop loop, I think because I am running multi-processor i have included the if(I_AM_ NODE_ZERO_P) and for some reason this is stopping the loop occuring, maybe the thread isn't in the node_zero processors area? I'm sure I have something stupid going on. If you have a working version would wouldn't mind sharing i'd like to have a look at it. Thanks Taff Quote:
|
Thank you so much. It was really helpful
|
Hi. Sorry just one question. How can I find that my outlet thread is on which node? because in this code you said that "The thread on which the average temperature is calculated is on node zero"
thank you so much. |
answer to ehooi
Quote:
Quote:
|
answer to massoud
Quote:
Maybe you can try printing messages from different processors to determine it. Let me know if you learn how to do it. |
thank you so much dear alpemre, I found it by printing message.
|
pressure inlet boundary vs to value of mass flow rate
Hi all
I want to write a udf defining the value of the pressure in a pressure inlet boundary vs to value of mass flow rate passing that bouandary. can anyone help me or write this udf for me? thanks. M.Azizi |
additionnal question...
Hi all,
This post is quite old, but maybe someone will be able to answer this little question. In the code above, alpemre use user defined memory for each thread, and then assign sum_temp to each one, to finally re-read it in separate DEFINE_PROFILE loops.. This seems quite long, and I'm wondering (since my C skills are quite low..) if we couldn't just declare some global variable "sum_temp", assign to it the computed average temp, and then just use something like F_PROFILE(f,t,i) = sum_temp; . So no more UDM needed. Would that work ? Thank you, |
All times are GMT -4. The time now is 05:07. |