CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF, gradient (https://www.cfd-online.com/Forums/fluent-udf/151256-udf-gradient.html)

Harry321 April 7, 2015 14:38

UDF, gradient
 
Dear collegues,

I want to calculate for UDS source term formula like this:
\frac{5}{3}\phi\rho\stackrel{\leftarrow}{v}\bullet\nabla\alpha
\phi is the scalar solved for the UDS transport equation. In Fluent units for source in UDS are \frac{\phi kg}{m^{3} s}
\phi in this case is used as a unit for scalar
I assumed this equation could by written like that:
\frac{5}{3}\phi\rho\stackrel{\leftarrow}{v}\bullet\nabla\alpha = \frac{5}{3}\phi\rho(v_{x}\frac{\partial\alpha}{\partial x}+v_{y}\frac{\partial\alpha}{\partial y}+v_{z}\frac{\partial\alpha}{\partial z})
so I wrote a UDF (shown below) and I am not sure if I can use a gradient of UDSI like that. In Fluent in Solution Controls -> Equations I deselected equation for User Scalar 1, User Scalar 0 is selected.
This part is put in DEFINE_ADJUST
thread_loop_c (t,super_domain)
{
begin_c_loop_all (c, t)
{

t01 = THREAD_SUB_THREADS(t); /*this part is used only to show fluent proper phase */
t02 = t01[0];
t03 = t01[1];
C_UDSI(c,t03, 1) = C_VOF(c,t03);
/* C_UDSI(c,t03,0) is a phi for which I want to calculate source term */
C_UDMI(c,t03,1) = 5*C_R(c, t03)*C_UDSI(c,t03,0)*(C_U(c,t03)* C_UDSI_G(c,t03,1)[0]+C_V(c,t03)* C_UDSI_G(c,t03,1)[1]+C_W(c,t03)* C_UDSI_G(c,t03,1)[2])/3;

}
end_c_loop_all (c,t)
}
and then in DEFINE_SOURCE in return I put value of C_UDMI calculated in DEFINE_ADJUST.


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