|
[Sponsors] |
Possible to loop a face thread inside a cell thread loop? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 6, 2012, 10:22 |
Possible to loop a face thread inside a cell thread loop?
|
#1 |
New Member
Marcus
Join Date: Mar 2012
Posts: 7
Rep Power: 14 |
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. |
|
March 6, 2012, 12:12 |
|
#2 |
New Member
Marcus
Join Date: Mar 2012
Posts: 7
Rep Power: 14 |
Well, does anyone know if it's definitely NOT possible to loop a face thread inside a cell thread loop or vice versa?
|
|
March 7, 2012, 05:15 |
|
#3 |
Senior Member
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17 |
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 |
|
March 7, 2012, 07:32 |
|
#4 |
New Member
Marcus
Join Date: Mar 2012
Posts: 7
Rep Power: 14 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to determine the direction of cell face vectors on processor patches | sebastian_vogl | OpenFOAM Programming & Development | 1 | October 11, 2016 14:17 |
Setting BC for each cell on face | Geisel | Fluent UDF and Scheme Programming | 3 | July 2, 2010 03:52 |
How to determine the direction of cell face vectors on processor patches | sebastian_vogl | OpenFOAM Running, Solving & CFD | 0 | October 27, 2009 09:47 |
how to access each cell of a face? (user fortran) | Katariina | CFX | 3 | January 28, 2008 10:16 |
Cell face values computation un unstructured grids | Sergio Rossi | Main CFD Forum | 2 | May 28, 2006 11:04 |