CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   initial value and UDF (https://www.cfd-online.com/Forums/fluent/83864-initial-value-udf.html)

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

vig January 14, 2011 01:31

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.


All times are GMT -4. The time now is 12:15.