CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Possible to loop a face thread inside a cell thread loop? (https://www.cfd-online.com/Forums/fluent/98231-possible-loop-face-thread-inside-cell-thread-loop.html)

MarcusW March 6, 2012 10:22

Possible to loop a face thread inside a cell thread loop?
 
Was just wondering if it is possible to loop a face thread inside a cell thread loop? I'm trying the code below but my computer keeps just loading indefinitely.

What I'm trying to do is to store the magnitude of the face area at the wall in a C_UDMI which I can use in a cell thread loop later (F_AREA needs to be in a face thread loop). The CENTROID bit is just a way of matching up the cells which align up with the wall faces (I'm using a structured hex mesh aligned with the xyz axis).

Here's the main bits from it:

Thread *t, *tf;
real xf[ND_ND], xc[ND_ND], A[ND_ND];

thread_loop_c(t,domain)
{
begin_c_loop(c,t)
c_face_loop(c,t,nn)
{
if(THREAD_ID(C_FACE_THREAD(c,t,nn)) == wall_id)
{
C_CENTROID(xc,c,t);

thread_loop_f(tf,domain)
{
begin_f_loop(f,tf)
{
F_CENTROID(xf,f,tf);

if(xc[0] == xf[0] && xc[2] == xf[2])
{
F_AREA(A,f,tf);
C_UDMI(c,t,5) = NV_MAG(A);
}
}
end_f_loop(f,tf)
}
}
}
end_c_loop(c,t)
}

If anyone sees a blunder here of if anyone knows another way of storing the area of a wall face in a C_UDMI I'd appreciate the feedback.

Thanks.

MarcusW March 6, 2012 12:12

Well, does anyone know if it's definitely NOT possible to loop a face thread inside a cell thread loop or vice versa?

coglione March 7, 2012 05:15

Basically you can loop over any thread anywhere within your code. The important point is to get the right cell or face thread pointer your are interested in.
In your code:
thread_loop_f(tf,domain)
means you are looping over all face threads and not just the faces belonging to the wall which may be the reason that your codes executes that long.

I would do it in this way:

c_face_loop(c,t,nn)
{
tf=C_FACE_THREAD(c,t,nf);
if(THREAD_ID(tf) == wall_id)
{
f=C_FACE(c,t,nn);
F_AREA(A,f,tf);
C_UDMI(c,t,5) = NV_MAG(A);
}
}

cheers

MarcusW March 7, 2012 07:32

Thanks a million coglione, works a charm and is much better than what I was trying to do. I'm new to fluent and I've spent ages trying to get this to work so I really appreciate your comment, you've saved me days!!

Just to note for anyone using the above code, nf should be nn or vice versa.


All times are GMT -4. The time now is 08:57.