CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Possible to loop a face thread inside a cell thread loop?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 6, 2012, 10:22
Default Possible to loop a face thread inside a cell thread loop?
  #1
New Member
 
Marcus
Join Date: Mar 2012
Posts: 7
Rep Power: 14
MarcusW is on a distinguished road
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 is offline   Reply With Quote

Old   March 6, 2012, 12:12
Default
  #2
New Member
 
Marcus
Join Date: Mar 2012
Posts: 7
Rep Power: 14
MarcusW is on a distinguished road
Well, does anyone know if it's definitely NOT possible to loop a face thread inside a cell thread loop or vice versa?
MarcusW is offline   Reply With Quote

Old   March 7, 2012, 05:15
Default
  #3
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
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
coglione is offline   Reply With Quote

Old   March 7, 2012, 07:32
Default
  #4
New Member
 
Marcus
Join Date: Mar 2012
Posts: 7
Rep Power: 14
MarcusW is on a distinguished road
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.
MarcusW is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 06:29.