ehooi |
January 13, 2011 09:41 |
initial value and UDF
Hi all,
Does anyone know, after initializing my problem, will the following command in my UDF:
T=C_T(c,t);
result in T being the initial value?
My problem is I have the following UDF:
Code:
#include "udf.h"
/* Mean temperature at outlet is calculated from the surrounding nodes */
/* Coordinate of the outlet is (x,y,z) = (0.275,-0.0138,-0.6747) */
DEFINE_ADJUST(outlet_temp,d)
{
double Tout=0.0;
double Temp;
double coord[ND_ND];
double xmin=0.273;
double xmax=0.277;
double ymin=-0.00675;
double ymax=0.0;
double zmin=-0.6858;
double zmax=-0.6628;
double x,y,z;
double ncell=1.0;
int nfaces=0;
cell_t c;
Thread *tt=Lookup_Thread(d, 31);
/* Begin loop to determine the temperature at the centroid of cells near the outlet */
begin_c_loop(c,tt)
{
C_CENTROID(coord,c,tt);
x=coord[0];
y=coord[1];
z=coord[2];
if ((x >= xmin) & (x <=xmax))
{
if ((y >= ymin) && (y <= ymax))
{
if ((z >= zmin) && (z <= zmax))
{
Temp = C_T(c,tt); /* Cell temperature */
Tout += Temp;
ncell ++; /* Number of cells */
printf("ncell= %d\n", ncell);
}
}
}
}
end_c_loop(c,tt)
Tout=Tout/(ncell-1); /* Average cell temperature surrounding outlet */
printf("Tout= %d\n", Tout);
}
the first printf statement gives ncell=0, when it should keep increasing while Tout = 0 when it should be the initial value that I initialize.
Does anyone know why?
Thanks.
Cheers,
EH
|