CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

initial value and UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 13, 2011, 10:41
Default initial value and UDF
  #1
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 7
ehooi is on a distinguished road
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
ehooi is offline   Reply With Quote

Old   January 14, 2011, 02:31
Default
  #2
vig
New Member
 
anonymous
Join Date: Jan 2011
Posts: 23
Rep Power: 7
vig is on a distinguished road
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.
vig is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 00:55.