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/)
-   -   C_FACE(c,t,i) local face index i ????????? (http://www.cfd-online.com/Forums/fluent-udf/99998-c_face-c-t-i-local-face-index-i.html)

bharat.cmeri April 18, 2012 03:52

C_FACE(c,t,i) local face index i ?????????
 
Hi everyone....... can u pls tell me how would i know whether a face is top,bottom, right or left of a cell using this local face index ??

Regards,
Bharat

sbaffini April 19, 2012 09:29

You can't because, in general, there is no such information in the cell of an unstructured solver (like Fluent), which can also be a tetrahedron (nonetheless, the information on the cell type is written in the case file). Still, if you define your own directions in space you can still check how the face centroid-cell centroid vector is oriented with respect to them and make your conclusions.

bharat.cmeri April 20, 2012 01:15

Quote:

Originally Posted by sbaffini (Post 355623)
You can't because, in general, there is no such information in the cell of an unstructured solver (like Fluent), which can also be a tetrahedron (nonetheless, the information on the cell type is written in the case file). Still, if you define your own directions in space you can still check how the face centroid-cell centroid vector is oriented with respect to them and make your conclusions.

Thanks for replying...... I think I found d way out....... Below is what i hv done.... I hvnt ran it yet bt pls go thru it.........

V[0] = C_U(c,t);
V[1] = C_V(c,t);
mag = NV_MAG(V);
NV_D(xunit, = ,1,0,0);
NV_D(yunit, = ,0,1,0);

c_face_loop(c, t, n)
{
F_AREA(A, f,t);
C_CENTROID(dr0, F_C0(f,t),t->t0);
F_CENTROID(xf, f,t);
NV_VV(dr0, =, xf,-,dr0);
ds = NV_MAG(dr0);
NV_VS(es,=,dr0,/,ds);

XDOT = NV_DOT(es,xunit);
YDOT = NV_DOT(es,yunit);

if (XDOT <= 1.0 && XDOT > cos(15.0))
{
front = n;
}
else if( XDOT < -cos(15.0) && XDOT >= -1.0)
{
back = n;
}
else if( YDOT <= 1.0 && YDOT > cos(15.0))
{
top = n;
}
else if( YDOT < -cos(15.0) && YDOT >= -1.0)
{
bottom = n;
}

}

sbaffini April 21, 2012 06:46

Besides your choice of conditions to check (which i admit, now at first i don't get) you got the main point.

Just notice that:

- you may not need mag and A(F_AREA)

- i'm not very practical with the pointer stuff but, at first it seems that with C_CENTROID(dr0, F_C0(f,t),t->t0) you are picking up the centroid of c0 (correct me if i'm wrong as i'm interested in this). In this case you you should be aware that c0 may not correspond to c (whose faces you are looping) but to the neighbor cell trough the face. However, i don't see where you are picking up f (which still can be my foult, so correct me if i'm wrong). I usually do it by something like:

f = C_FACE(cn,tn,nf);
tf = C_FACE_THREAD(cn,tn,nf);
c0 = F_C0(f,tf);
t0 = THREAD_T0(tf);

bharat.cmeri April 23, 2012 10:35

f is being picked just before c_face_loop.
well as far as I know c0 means the parent cell where from f is being tracked(which is c). so basically c will be c0.

Now let me ask one question. can't we use these loops inside our own functions like say
static real
LINSEG(cell_t c, Thread *t)
{
----------loop-----------
}

I am having trouble as solver is giving MPI error.....viz... no such file or directory exists..... I am not able to make out how to do it. If you pls tell me........


And yes mag and AREA are not needed.........
Thanks & Regards,
Bharat....

sbaffini April 23, 2012 16:13

Dear bharat,

according to my knowledge of UDFs, what you are doing is not exactly correct, that is:

- f can't be picked up before the cell face loop because it is changing inside the loop. In practice, with F_CENTROID(xf, f,t) you are asking the centroid (which is put in xf) of the face f belonging to the face thread t (which, by the way are already used by the main c_face_loop and this is wrong), but for each face of the cell you can have a different face thread and face index, hence you need to ask for them just after the beginning of the c_face_loop.

- what you actually know about c0 and c1 is that the vector A is pointing from c0 toward c1 (on the boundaries, where c1 is missing, it is just pointing outside). There is no way to know in advance if the cell you are looping over is c0 or c1, except for boundaries where the ambiguity is resolved by c1 missing


As long as you pass your function all the arguments in the correct form there should be no issues in using loop or what else kind of Fluent internal macros in a separate function. However, i have to say it, i never did it and can't be of much help on this. I definitely suggest you to first debug your UDF in serial before going to parallel (where MPI errors are supposed to belong)

XJTH August 14, 2012 10:27

local face index
 
f = C_FACE(cn,tn,nf);
tf = C_FACE_THREAD(cn,tn,nf);
c0 = F_C0(f,tf);
t0 = THREAD_T0(tf);[/QUOTE]


nf is the local face index number, could u tell me it's meaning? and the return global face index face_t f .

ths

XJTH

sbaffini August 14, 2012 11:00

The meaning of the four lines above is:

- "f = C_FACE(cn,tn,nf);" = for a given cell cn belonging to the cell_thread tn, give me the global face index f corresponding to the local face index nf. It is assumed that the above statement is inside a cell_face loop "c_face_loop(cn, tn, nf)", a loop over the faces of the cell cn.

- "tf = C_FACE_THREAD(cn,tn,nf);" = as above, but now the request is for the face_thread tf containing the face f from above.

- "c0 = F_C0(f,tf);" given f and tf from above, this command asks for the so called cell c0 index. I described it in previous posts above; it is just one of at most two cells sharing the face f. Among the two (c0 and c1), c0 is the one which is always present.

- "t0 = THREAD_T0(tf);" this is just the cell_thread of the cell c0 above. Notice that, as the only input required is tf, all the faces on tf will have their c0 belonging to the same cell_thread t0.

Hope this is what you are looking for


All times are GMT -4. The time now is 21:42.