udf to access variables from a different case
Hi all,
I would like to save some variables (for each cell) from one case and use those variables (as materials properties, for each cell) into another case. I am using the same mesh in both cases. Any hints on how to write a UDF for that? Cheers, Yashmash 
Quote:
I know a procedure for your purpose but I don't know it's the best or not. You can do that by interpolating your desired data in (file>interpolate) and then read that in a new case in a same manner; but as you can see, you're permitted to interpolate special variables for which conservation equation has been solved; so there's a trick with a temporary UDS! First store your desired data in a UDS and ensure you've deactivated this scalar equation in (solve>control>solution), then you can interpolate this type of data. Bests, 
Hello Amir,
Thanks for your help. I have used your method successfully, however, I was hoping you could help me on another issue. Now that I have my uds in my other case, I want to use that variable in the calculation of my material property (material absorption coefficient in that case). I have written a UDF as follows: DEFINE_PROPERTY(abs_coeff,cell,thread) { Thread *t; cell_t c; real value = 0; real abs_coeff = 0; Domain *d; d = Get_Domain(1); /* Calculating the scattering coefficient */ thread_loop_c(t,d) { begin_c_loop(c,t) { value = C_UDSI(c,t,0); } end_c_loop(c,t) } abs_coeff = 4.22*value; return abs_coeff; } I have turned off the uds solver and am NOT reinitializing (since that would make my uds values equal to zero). But the values of absorption coefficient that is returned by fluent are not what I am expecting (they are constant throughout my domain, which shouldnt be the case since the values of my uds are not constant). Are the steps that I'm following ok? Where am I going wrong? Thanks a lot, Yashmash 
Hi,
Your UDF is not correct. Do not use any loop in that .... Quote:

Sweet! It works now..
Your assistance was much appreciated Amir, enjoy your week end 
Hi Amir,
I was hoping you could help me with the following UDF. I am running atime dependent eulerian model with 3 phases. My udf is to store into a UDS the timeaveraged volume fraction of one of the phases. However the values that are returned are the timeaveraged volume fractions divided by a constant (constant is 74). Please see my UDF below: #include "udf.h" #define Rtio2 4260 DEFINE_ON_DEMAND(TiO2_loading_gm3) { Thread *thread_ti; Thread *t; Thread *mix_thread; cell_t c; real vof_ti = 0; Domain *d; d = Get_Domain(3); /* Loop over all cell threads in the domain */ thread_loop_c(thread_ti,d) { /*thread_ti = THREAD_SUB_THREAD(mix_thread, 3);*/ /* Loop over all cells */ begin_c_loop(c,thread_ti) { vof_ti = C_STORAGE_R(c,thread_ti,SV_VOF_MEAN); C_UDSI(c, thread_ti, 0) = vof_ti; } end_c_loop(c,thread_ti) } } Your assistance is much appreciated, Thanks, Yash 
Hi,
I'm not sure if I can help here because I don't know what the "C_STORAGE_R(c,thread_ti,SV_VOF_MEAN)" performs exactly. but it seems strange if you want the averaged field by using a DEFINE_ON_DEMAND macro! If I was you, with a simple DEFINE_ADJUST macro store the desired variable in a UDS and .... Bests, 
All times are GMT 4. The time now is 02:14. 