|
[Sponsors] |
Fluent udf--spatial derivative of user-defined scalar |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 29, 2009, 10:36 |
Fluent udf--spatial derivative of user-defined scalar
|
#1 |
Senior Member
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 220
Rep Power: 19 |
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. |
|
February 9, 2011, 04:05 |
|
#2 |
New Member
tom pan
Join Date: Nov 2010
Posts: 14
Rep Power: 16 |
I have the same question.
Do you know how to solve it now? I do need the anwser on my problem. |
|
March 14, 2020, 11:12 |
|
#3 |
Member
Tanvir
Join Date: Nov 2016
Posts: 45
Rep Power: 10 |
Hi,
i am facing same problem in calculating derivatives. can you please help me getting rid of this. waiting for reply, Thanks |
|
March 16, 2020, 12:37 |
Derivatives
|
#4 |
Senior Member
|
Do you face issue with the calculation of gradients or are the numbers being calculated wrong?
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
March 16, 2020, 12:49 |
|
#5 |
Member
Tanvir
Join Date: Nov 2016
Posts: 45
Rep Power: 10 |
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); |
|
March 16, 2020, 13:28 |
Derivatives
|
#6 |
Senior Member
|
To get the derivatives of temperature, density, and , you don't need to assign their values to scalars, until there is some other requirement. You can fetch their gradients using C_T_G and C_R_G. There are no gradient operators for . By assigning value of the variable to scalar does not assign its gradient to the gradient of the scalar. However, if you keep the solution of scalar disabled, then you might get correct values. I have never used the method of assigning field to a scalar and then fetching gradients of the scalar. But for sure, you have keep the solution for the scalar disabled otherwise the field will change and will no longer represent whatever field was assigned to the scalar.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
March 16, 2020, 14:04 |
|
#7 |
Member
Tanvir
Join Date: Nov 2016
Posts: 45
Rep Power: 10 |
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 |
|
March 16, 2020, 14:21 |
Yplus
|
#8 |
Senior Member
|
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
March 16, 2020, 14:41 |
|
#9 |
Member
Tanvir
Join Date: Nov 2016
Posts: 45
Rep Power: 10 |
Sir i have used it before but it ends up in segmentation fault right after very first iteration.
|
|
March 16, 2020, 16:13 |
Segmentation Violation
|
#10 |
Senior Member
|
Segmentation violation error implies that UDF is trying to access a memory that is unavailable. That most likely happens because is defined only for faces and not for cells. So, use F_STORAGE_R instead of C_STORAGE_R.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
March 17, 2020, 07:49 |
|
#11 |
Member
Tanvir
Join Date: Nov 2016
Posts: 45
Rep Power: 10 |
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.. |
|
March 17, 2020, 08:35 |
Arguments
|
#12 |
Senior Member
|
The reason is that you are using wrong arguments for C_UDMI. This has to be C_UDMI(c1, tc1,0)
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
March 19, 2020, 05:37 |
Gradients
|
#13 |
Senior Member
|
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.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
October 26, 2020, 22:05 |
|
#14 | |
New Member
Join Date: Jun 2020
Posts: 6
Rep Power: 6 |
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 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF in Fluent | Andrew | Fluent UDF and Scheme Programming | 5 | March 7, 2016 04:38 |
User defined scalar | Tomik | FLUENT | 0 | February 8, 2007 20:23 |
User defined function of mass flow rate | Eric | FLUENT | 1 | April 22, 2005 19:15 |
UDF of Zimont model in fluent | Z | Main CFD Forum | 0 | February 17, 2005 04:07 |
User defined rotational velocity in FLUENT | Abhinav | FLUENT | 1 | June 10, 2003 09:31 |