Fluent udf--spatial derivative of user-defined scalar
I would like to be able to take spatial derivatives of arbitrary scalar variables within a fluent udf. However, if for example, I put C_U(c,t) into user defined scalar 0 and then define user-defined scalar 1 as C_UDSI(c,t,1)=C_UDSI_G(c,t,0)[1], it produces erroneous values for scalar 1. Does anyone have any suggestions?
I would like to have such capability as I am attemping to add momentum source terms via udf that involve vorticity and vorticity magnitude, which are not explicitly defined field variables for use in udfs. |
I have the same question.
Do you know how to solve it now? I do need the anwser on my problem. |
Hi,
i am facing same problem in calculating derivatives. can you please help me getting rid of this. waiting for reply, Thanks |
Derivatives
Do you face issue with the calculation of gradients or are the numbers being calculated wrong?
|
Sir i get the gradients by using user defined scalar but numbers i get seems totally wrong. the core of code is
DUDY = fabs(C_DUDY(c,t)); C_UDSI(c,t,0) = C_T(c,t); C_UDSI(c,t,1) = C_R(c,t); C_UDSI(c,t,2) = C_CP(c,t); DTDY = abs(C_UDSI_G(c,t,0)[1]); DrhoDy = abs(C_UDSI_G(c,t,1)[1]); DCPDY = abs(C_UDSI_G(c,t,2)[1]); then i print the values but sometime it gives me positive values and sometimes negatives values are obtained regardless of using 'fabs' command. //Message0("\n Velocity Gradient is %f",DUDY); //Message0("\n Temp Gradient is %f",DTDY); //Message0("\n Density Gradient is %f",DrhoDy); //Message0("\n Heat capacity Gradient is %f",DCPDY); |
Thank you so much sir for your valuable advice . i will try this.. please tell me how can i access cell yPlus , because i need yplus in the code to compute turbulent prandtle number.
Thanks |
Yplus
|
Sir i have used it before but it ends up in segmentation fault right after very first iteration.
|
Segmentation Violation
|
Hi Sir,
so for i have progressed in storing yplus as a userdefined memory info and core of code is DEFINE_ADJUST(adjust_fcn,d) { Thread *tf1, *tc1; face_t f1; cell_t c1; real yplus; int zone_id1; /* Wall in the geometry */ zone_id1 = 6; tf1 = Lookup_Thread(d, zone_id1); begin_f_loop(f1, tf1) { c1 = F_C0(f1,tf1); tc1 = THREAD_T0(tf1); yplus = F_STORAGE_R(f1,tf1,SV_WALL_YPLUS_UTAU); C_UDMI(f1,tf1,0) = yplus; printf(" \n yplus is %f ", C_UDMI(f1,tf1,0)); } end_f_loop(f1, tf1) } But when i call this UDMI in Prandtl No Macro it gives me error which seems like i am not calling the right memory INFO . and i have tried many ways but could not succeed in this. Can you help me please.. |
Arguments
The reason is that you are using wrong arguments for C_UDMI. This has to be C_UDMI(c1, tc1,0)
|
Gradients
In your code for Prandtl number, you are trying to access gradients. Therefore, you have to do a little more work. Either assign the memory for gradients within the UDF or use the command
solve set expert to tell Fluent NOT to free up the temporary memory. Only then the gradients become available in a UDF. To assign memory within UDF, search the forum for Scalar_Reconstruction. You will find all the commands required. |
Quote:
You solved this on Prandtl number implementation based on yplus via UDF? Could you share the codes? Since I am stuck for a long time. Thanks, Bryce |
All times are GMT -4. The time now is 14:18. |