CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDS (

Vale July 26, 2001 08:26

I am trying to write a UDF for the source term of a UDS equation. Is there any possibility to access gradient of the UDS (something like the macros C_DUDX(c,t), C_DUDY(c,t)... used for velocity components)?

Ugur July 26, 2001 13:19

Try the array C_UDSI_G(c,t,i)[j]. i is the user defined scalar number and j is the direction. 0 for x direction gradient, 1 for y direction and 2 for z direction.

Greg Perkins July 26, 2001 20:28

This works, but you may need to be careful how you use it. For example if you want to modify the pde by adding a term like d/dx_i(thi) where thi is your uds, adding the term above will not strictly be conservative and numerical errors could result.

For these applications, its better to apply the divergence theorem and determine the face fluxes yourself in the udf source term than use the pre-calculated gradient term. The section on the solver in the manual details this discretization process. This requires more programming and takes longer to compute inside Fluent, but it will give you the correct answer to your pde, which will not be the case if you add the gradient term.


Ugur July 27, 2001 09:48

Thanks for your note, I already noticed it, but i have been using dUDS0/dx for another source term in my momentum equation. WIll it create the same problem?


Greg Perkins July 27, 2001 09:54

I suggest checking against an analytical solution for a pde to see the difference. You will need to decide for your application.

You could always ask Fluent how that value is actually calculated - I think it might be cell to cell, rather than at faces, as required by the CV method etc.


All times are GMT -4. The time now is 01:10.