CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   flux around one specific cell (http://www.cfd-online.com/Forums/fluent/80826-flux-around-one-specific-cell.html)

solefire October 7, 2010 17:25

flux around one specific cell
 
Dear,

I have a question, probably it is very easy for u, if I have got a cell ID , source[0], I want to get the flux of faces of this cell, "just for this cell" , it is structured grid, could u help check what is wrong with my code, Thanks a lot!!


DEFINE_ON_DEMAND(get_mf)
{
Domain *d; /*pointer to the collection of all cells' threads (stored information) */
/* declare domain pointer since it is not passed as an argument to the DEFINE macro */
cell_t c; /* cell identifier */
Thread *t; /* pointer to a thread */
d = Get_Domain(1); /*domain is already available to your function (via define_adjust argument). */
mf=0.0;
int i=0.0;

/************try to get neighbouring faces of the cell********************************************** ***/

/* If face lies at domain boundary, use face values; */
/* If face lies IN the domain, use average of adjacent cells. */



c_face_loop(c, t, i)

{
face_t f;
Thread *tf;
f = C_FACE(c,t,i);
tf = C_FACE_THREAD(c,t,i);
c0 = F_C0(f,tf);
c1 = F_C1(f,tf);
t0 = THREAD_T0(tf);
t1 = THREAD_T1(tf);
real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0;
F_AREA(A, f, t);


if (!BOUNDARY_FACE_THREAD_P(tf))
{
/* c0 is current cell*/
if (c0 == source[0])
{

NV_DS(psi_vec, =, C_U(c,t),C_V(c,t),C_W(c,t),*,1.0);
NV_DS(psi_vec, +=, C_U(c1,t1),C_V(c1,t1),C_W(c1,t1),*,1.0);
flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */

}
else
{

NV_DS(psi_vec, =, C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),*,1.0);
NV_DS(psi_vec, +=, C_U(c,t),C_V(c,t),C_W(c,t),*,1.0);
flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */

}
}
}


}

hereby density is 1.0;


All times are GMT -4. The time now is 07:46.