CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)

 gemini June 13, 2009 13:56

Hi everyone,

I want to calculate the gradient of a UDS by using Green Gauss theorem using cell based approximation for face values of UDS. Below you can see the corresponding c code. However i created a simple test case which contains a square domain (in which UDS solved using dirichlet type BCs) and test whether my gradient function and C_UDSI_G(c, t, uds_no) gives the same values. The result is that my function gives totally different and unrealistic gradient values while C_UDSI_G gives correct values,

So anybody can help me to correct the code below:

I used both uniform and nonuniform structured grids.

thanks so much

Code:

```real evaluate_gradient(cell_t c, Thread *t, int i_uds, real *x_vec, real *y_vec, real *z_vec) {     int n;     face_t f;     Thread *tf;     Thread *t0, *t1;     cell_t c0, c1;     real A[ND_ND];     real grad_phi[ND_ND];     ND_SET(grad_phi[0],grad_phi[1],grad_phi[2],0.0,0.0,0.0);         c_face_loop(c, t, n)     {         f  = C_FACE(c,t,n);         tf = C_FACE_THREAD(c,t,n);         c0 = F_C0(f,tf);         t0 = THREAD_T0(tf);         if (!BOUNDARY_FACE_THREAD_P(tf))         {             c1=F_C1(f,tf);             t1=THREAD_T1(tf);         }         else         {             c1=-1;             t1=NULL;         }         F_AREA(A,f,tf);         if (!BOUNDARY_FACE_THREAD_P(tf))             NV_V_VS(grad_phi,=,grad_phi,+,A,*,(0.5*(C_UDSI(c0,t0,i_uds)+C_UDSI(c1,t1,i_uds))));         else             NV_V_VS(grad_phi,=,grad_phi,+,A,*,C_UDSI(c0,t0,i_uds));     }     *x_vec = grad_phi[0]/C_VOLUME(c,t);     *y_vec = grad_phi[1]/C_VOLUME(c,t);     *z_vec = grad_phi[2]/C_VOLUME(c,t);     return 0.0; }```

 biker October 22, 2013 21:16

search help

hi, do you have solved the problem about how to get second order graident of UDS,i have the same problem now, and have no way to do it .could you give me some help ?,waiting for your reply,thanks

 ustbdynamic December 24, 2013 01:24

Dear liu:
Do you have solve this problem?
I meet the same problem as yours.
thank you

Quote:
 Originally Posted by biker (Post 458398) hi, do you have solved the problem about how to get second order graident of UDS,i have the same problem now, and have no way to do it .could you give me some help ?,waiting for your reply,thanks

 All times are GMT -4. The time now is 14:02.