CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   view factor (http://www.cfd-online.com/Forums/fluent-udf/113920-view-factor.html)

yoollooz March 1, 2013 01:44

view factor
 
Hello,

I want to compute view factor between two boundary mesh faces .I wrote one udf file but i dont know is it true or no?

the other problem is i don know how can i build one 2D matrix with udf?
plz help me.


#include "udf.h"
#include metric.h
#include SG_mem.h
DEFINE_SOURCE(ss,c,t,dS,eqn)

{

real X=0.1;
real p_co2_s=0.09627;
real p_h2o_s=0.18753;
real p_co2=p_co2_s*(10.875)/(10.785+(9.76*X)/100.);
real p_h2o=p_h2o_s*(10.875)/(10.785+(9.76*X)/100.);
real p_total;
real k1=0.;
real k2=.89;
real k3=15.5;
real k4=240;
real K1;
real K2;
real K3;
real K4;
real ss1;
real ss2;
real ss3;
real ss4;
real A1[ND_ND];
real A2[ND_ND];
real A3[ND_ND];
real x[ND_ND];
real x1[ND_ND];
real x2[ND_ND];
real x3[ND_ND];
real s1;
real s2;
real abs_s;
real epsilon=0.85;
real rho;
real m;
real n;
real r;
real x_ik[ND_ND];
real y[ND_ND];
real p;
real r_p[ND_ND];
real r_kmax;
real x_kmax;
real y_kmax;
real z_kmax;
real abs_r_p;
int g;
face_t f1;
face_t f2;
face_t f3;
cell_t c;


// k calculation
p_total=p_co2+p_h2o;
K1=k1*p_total;
K2=k2*p_total;
K3=k3*p_total;
K4=k4*p_total;

// ss calculation
begin_f_loop(f1,t)
{
begin_f_loop(f2,t)
{

F_CENTROID(x1,f1,t);
F_AREA(A1,f1,t);

F_CENTROID(x2,f2,t);
F_AREA(A2,f2,t);

x[ND_ND]=x1[ND_ND]-x2[ND_ND];
n=C_FACE(c,t,g);
begin_f_loop(f3,t)
{

F_CENTROID(x3,f3,t);
F_AREA(A3,f3,t);
NV_VV(x_ik,=,x,-,x1);

p=NV_DOT(x_ik,A3)/NV_DOT(x,A3);

f_node_loop(f3,t,r)
{

x_kmax=x3[0]-NODE_X(node);
y_kmax=x3[1]-NODE_Y(node);
z_kmax=x3[2]-NODE_Z(node);
r_kmax=sqrt (pow(x_kmax,2)+pow(y_kmax,2)+pow(z_kmax,2));

}

NV_VS (y,=,x,*,p);
NV_VV(r_p,=,x1,+,y);
abs_r_p=NV_MAG(r_p);
if(0<p && p<1 && abs_r_p<r_kmax)
{

s1=fabs(NV_DOT(x,A1));
s2=fabs(NV_DOT(x,A2));
abs_s=NV_MAG(x);
ss1=(exp(-K1*abs_s)*s1*s2)/(M_PI*pow(abs_s,4));
ss2=(exp(-K2*abs_s)*s1*s2)/(M_PI*pow(abs_s,4));
ss3=(exp(-K3*abs_s)*s1*s2)/(M_PI*pow(abs_s,4));
ss4=(exp(-K4*abs_s)*s1*s2)/(M_PI*pow(abs_s,4));

}
else ss1=ss2=ss3=ss4=0;


}
end_f_loop(f3,t)
}
end_f_loop(f2,t)
}
end_f_loop(f1,t)
return ss1, ss2 , ss3,ss4;
}


All times are GMT -4. The time now is 02:23.