# initial value and UDF

 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 13, 2011, 10:41 initial value and UDF #1 Member   EH Join Date: Dec 2010 Posts: 61 Rep Power: 8 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

 January 14, 2011, 02:31 #2 New Member   anonymous Join Date: Jan 2011 Posts: 23 Rep Power: 8 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.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

All times are GMT -4. The time now is 18:21.