|
[Sponsors] |
January 13, 2011, 09:41 |
initial value and UDF
|
#1 |
Member
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15 |
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); } Does anyone know why? Thanks. Cheers, EH |
|
January 14, 2011, 01:31 |
|
#2 |
New Member
anonymous
Join Date: Jan 2011
Posts: 23
Rep Power: 15 |
One Problem could be with declaration of ncell as double and printing it with %d, which is meant for integer entry. Declare ncell as integer and cross check.
C_T(c,t) should give the initial value in the UDF. I do not see any problem there. |
|
|
|