CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Problem calcualting the mass flow entering each cell (http://www.cfd-online.com/Forums/fluent/102699-problem-calcualting-mass-flow-entering-each-cell.html)

javiercran May 31, 2012 15:24

Problem calcualting the mass flow entering each cell
 
Hello,
I have tried to calculate the mass flow entering inside a cell (for a DEFINE_SOURCE macro) with a loop over the faces of the cell but I have problems of "non-integer subscript expression: unsigned char".
This is my code

#include "udf.h"
#include <mem.h>
DEFINE_SOURCE(theta_momentum,c,t,dS,eqn)
{
//near peak operating point
real Ft; //Ft source term
real T01; //Inlet Total temperature
real T02; //Outlet Total temperature
real cp; //variable which will store the specific heat of air
real x[ND_ND]; //array for storing the centroid position
real pi=3.1416;
real omega=16043*2*pi/60;
real r;
face_t f;
real massflow=0;
real volume;
Thread *f_thread;
int n;

c_face_loop(c,t,n)//line 21 the one which gives problems
{f=C_FACE(c,t,n);
f_thread = C_FACE_THREAD(c,t,n);
if(F_FLUX(f,f_thread)>0)// only calculate the massflow entering
{massflow=massflow+F_FLUX(f,f_thread);
}
}

massflow=massflow*2*pi;//axisymmetric
volume=C_VOLUME(c,t);
T01=288.15;
cp=1006;
C_CENTROID(x,c,t);//we store in x the centroid position of each cell
r=x[1];// the radial position is the y-coordinate of the cell centroid
r = x[1];
T02=1.164*T01;
Ft=massflow*cp*(T02-T01)/(volume*omega*r);
dS[eqn]=0;
return Ft;
}

I need your help because I cant see the mistake I am doing.
Regards


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