|
[Sponsors] |
September 11, 2009, 18:20 |
F_UDMI problem
|
#1 |
Member
Ivan
Join Date: May 2009
Posts: 85
Rep Power: 17 |
I use the following UDF to calculate time-averaged pressure coefficient on a airfoil surface. the UDF is interpreted with no problem. after a number of time steps, I plot the user defined memory 0 and 1 in XY Plot panal, but everything is zero.
Can anyone tell me why and how to fix it? Thanks for all answers! ----------------------------------------------- /* be sure to allocate at least two UDMs*/ #include "udf.h" real n=0; /* number of time-step */ int zone_ID=5; /* zone ID of airfoil surface */ DEFINE_EXECUTE_AT_END(time_avr_PC) { Domain *domain = Get_Domain(1); Thread *t = Lookup_Thread(domain, zone_ID); real p_ref=0, q_ref=100; /* reference pressures */ face_t f; n += 1; begin_f_loop(f, t) { F_UDMI(f,t,0) += F_P(f,t); F_UDMI(f,t,1) = (F_UDMI(f,t,0)/n - p_ref)/q_ref; } end_f_loop(f, t) } ----------------------------------------------- |
|
November 25, 2009, 12:43 |
|
#2 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
Thy this function. I hope it works:
#include "udf.h" real n=0; /* number of time-step */ int zone_ID=5; /* zone ID of airfoil surface */ EXECUTE_ON_DEMAND(time_avr_PC) { Domain *domain = Get_Domain(1); Thread *t ; real p_ref=0, q_ref=100; /* reference pressures */ face_t f; n += 1; begin_f_loop(f, t) { F_UDMI(f,t,0) += F_P(f,t); F_UDMI(f,t,1) = (F_UDMI(f,t,0)/n - p_ref)/q_ref; } end_f_loop(f, t) } |
|
November 25, 2009, 12:45 |
|
#3 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
I have used "EXECUTE_ON_DEMAND" instead of "DEFINE_EXECUTE_AT_END"
|
|
November 30, 2012, 11:31 |
|
#4 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
||
December 4, 2012, 10:19 |
|
#5 | |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Quote:
did you find the solution for that because I have the same problem? thanks in advance!!! |
||
January 16, 2013, 11:08 |
|
#8 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Hi again,
I have problem to read the C_UDMI now it is saving but if I use it in F_profile it is always Zero I am simulating gas-solid flow. So I want to save velocity and volume fraction in outlet and then to use it in inlet so I managed to save it with C_UDMI but in inlet everything is zero it seems it doesnt work. here is my inlet profile: DEFINE_PROFILE(abs_vel,t,i) { Domain *d; cell_t c, c0; face_t f; Thread *ct,*t0; begin_f_loop(f,t) { c0 = F_C0(f, t); t0 = THREAD_T0(t); if (C_UDMI(c0,t0,2) =0) F_PROFILE(f,t,i)=0.001; else F_PROFILE(f,t,i) = C_UDMI(c0,t0,2); } end_f_loop(f,t) } thanks for your help!!! |
|
January 18, 2013, 05:32 |
|
#9 | |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Quote:
I saved massflow rate at outlet and I want to use it like inlet it seems doesnt work. inlet always is zero? begin_f_loop(f,t) { c0 = F_C0(f, t); t0 = THREAD_T0(t); mass_flow +=F_FLUX(f,pt[SOLID_PHASE_ID]); C_UDMI(c0,t0,0)=mass_flow; } end_f_loop(f,t) and my inlet profile is: DEFINE_PROFILE(B0, t, i) { cell_t c0; face_t f; Thread *ct; begin_f_loop(f, t) { c0 = F_C0(f,t); ct = t->t0; F_PROFILE(f,t,i) = C_UDMI(c0,ct,0); } end_f_loop(f,t) } but it doesnt work thanks in advance!!! |
||
March 18, 2013, 10:02 |
|
#10 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Hi argeus,
After your help I managed to do the code but it is working only for serial. i put at the beginning #if !PR_HOST and at the and #ifend but still not working.it seem it saves it but I can not use it in profile function. I try other variations but it seems not trivial. Last edited by Kanarya; March 18, 2013 at 18:58. |
|
March 18, 2013, 12:17 |
|
#11 |
New Member
Ján
Join Date: Mar 2010
Location: Slovakia
Posts: 24
Rep Power: 16 |
Hi Kanarya,
Firstly, I totally forgot to response to your previous answer. I apologize. To be honest, this stuff about memory storing ain't something I'm really familiar with.. However, I have two notes regarding the issue you are coping with: 1/ Do you really need to store the data using memory variable? (please clarify the purpose of your udf) 2/ To avoid "maybe" and "seems to be" use the printf function to check the value of each variable.. Then you will be sure what is still OK, and what already not. And I did not understand this syntax you used: ct = t->t0; |
|
March 18, 2013, 12:25 |
|
#12 | |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
thanks for the quick answer!
I need to save the data because I need to keep const. solid mass_flow_rate in the reactor. this is the reason, I save the velocity and volume fraction in outlet and then applying them in the inlet.ct=t->t0 is changing the threat name because I am saving the data in t0 then using in profile different one. it is working in serial perfect! do you have any idea why it doesnt work in parallel? Thanks again! Quote:
|
||
March 18, 2013, 13:04 |
|
#13 |
New Member
Ján
Join Date: Mar 2010
Location: Slovakia
Posts: 24
Rep Power: 16 |
I have no idea, why it does not work in parallel. Maybe you can find something about it in the help file. Anyway, I still do not understand why to use the memory variable. You can simply save the desired value into one global variable and the use it in another sub-udf.. What more, once you need to consider the time variable, you can use the time-dependent macros and save the variable in 2-dimensional field..
But maybe I just have bad experience with memory data storing and this is the only right way how to do it.. |
|
March 18, 2013, 13:06 |
|
#14 | |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
thanks
can you provide me an example? thanks in advance! Quote:
|
||
March 18, 2013, 14:55 |
|
#15 |
New Member
Ján
Join Date: Mar 2010
Location: Slovakia
Posts: 24
Rep Power: 16 |
Well.. I would really try to avoid to use the memory storing of the data (if not necessary)..
you can simply obtain the value for desired variable in a define_adjust macro, calculate whatever you want to and use it in define_profile sub-udf as follows: Code:
real xxx1; DEFINE_ADJUST(my_adjust, domain) { Thread *t; face_t f; int ID = ; Domain *domain; domain = Get_Domain(1); tf = Lookup_Thread(domain,ID); thread_loop_f (t,domain) { begin_f_loop (f,t) xxx1+="whatever you want to preserve for define_profile"; end_f_loop (f,t) } } DEFINE_PROFILE(my_profile, thread, index) { real x[ND_ND]; real y; face_t f; int ID = ; Thread *tf; Domain *domain; domain = Get_Domain(1); tf = Lookup_Thread(domain,ID); begin_f_loop(f, thread) { F_CENTROID(x, f, thread); y = x[1]; F_PROFILE(f, thread, index) = XXX1; } end_f_loop(f,thread) } I never did parallel yet, but regarding the manual, I would try following: 1/ include para.h header into your UDF 2/ consider use of this macro: node_to_host_real_2(velocity_s,vol_frac); for instance, the value of velocity_s is already hidden into the F_UDMI(f,t0,2) and thus once node_to_host macro is executed, it does not have an impact to the F_UDMI(f,t0,2). But not sure if I'm right now. 3/ you perform data transfer from node to host and then use the !RP_HOST macro - you exclude the host compute nodes from the calculation.. If I were you, I would just try som combinations of this macros and use the printf function to display the variables to see what's the matter. I never try it, so I'm just guessing.. |
|
March 18, 2013, 19:02 |
|
#16 | |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
hi aregus,
thanks a lot for help! I did it without memory storing as you said.but still working only in serial do you have any other suggestions? thanks for valuable help! Best! Kanarya Quote:
|
||
Tags |
udf f_udmi |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF compiling problem | Wouter | Fluent UDF and Scheme Programming | 6 | June 6, 2012 05:43 |
Incoherent problem table in hollow-fiber spinning | Gianni | FLUENT | 0 | April 5, 2008 11:33 |
natural convection problem for a CHT problem | Se-Hee | CFX | 2 | June 10, 2007 07:29 |
Adiabatic and Rotating wall (Convection problem) | ParodDav | CFX | 5 | April 29, 2007 20:13 |
Is this problem well posed? | Thomas P. Abraham | Main CFD Forum | 5 | September 8, 1999 15:52 |