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/)
-   -   Problem with assigning uds a value when calculating second derivative (https://www.cfd-online.com/Forums/fluent-udf/201482-problem-assigning-uds-value-when-calculating-second-derivative.html)

coewgb May 3, 2018 21:53

Problem with assigning uds a value when calculating second derivative
 
Hello,
I am trying to calculate the second derivative of temperature by assigning the first derivative to additional user defined scalars, i.e., uds 1~3 in the following code (uds 0 is another user defined scalar whose transport equation will be solved.
I also deselected the transport equations of uds 1~3 in solution controls to retain the values which were assigned by the code.
However, as the monitors indicated, the maximum values of uds 1~3 kept zero during the calculation, while the maximum temperature gradient in each direction is not zero as well as the minimum thermal conductivity.
Therefore, it seemed that the values of uds 1~3 were not correctly assigned as shown in the code.
Could anyone tell me the reason and the solution?
Thanks a lot.

DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;

domain = Get_Domain(1);

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
C_UDSI(c, t, 1) = C_K_EFF(c, t, 0.85)*C_T_G(c, t)[0];
C_UDSI(c, t, 2) = C_K_EFF(c, t, 0.85)*C_T_G(c, t)[1];
C_UDSI(c, t, 3) = C_K_EFF(c, t, 0.85)*C_T_G(c, t)[2];
}
end_c_loop(c, t)
}
}

DEFINE_SOURCE(cell_uds_source, cell, thread, dS, eqn)
{
real source;
source = 2.0*(C_UDSI_G(cell,thread,1)[0]+ C_UDSI_G(cell, thread, 2)[1]+ C_UDSI_G(cell, thread, 3)[2]);
dS[eqn] = 0;
return source;
}


All times are GMT -4. The time now is 08:11.