CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   cells less than one (

Andrew Garrard January 25, 2005 07:15

cells less than one
I am looking at some UDF code that someone gave me and I am a litte confused, it is show below. My questionis why would a cell index (c1) be assigned a negative value (i.e. < 0). Any help would be super.

DEFINE_UDS_FLUX(conv_fluxes, f, thread, eqn)


cell_t c0, c1;

Thread *tc0, *tc1;

c0 = F_C0(f, thread);

tc0 = THREAD_T0(thread);

c1 = F_C1(f, thread);

tc1 = THREAD_T1(thread);

if( c1 < 0 )


return one thing




return another



Luca January 25, 2005 09:29

Re: cells less than one
According to me the cell_t index goes from 0 to n-1 cells. So the first if will never be executed. Luca

Andrew Garrard January 26, 2005 06:41

Re: cells less than one
I ran this code with a Message if c1<0 and it produced results. so at some point c1 does adopt a negative value. When this happens c1 adopts the value of -1 according to the output line. I am guessing this must be something to do with the boundary, but some more insight would be very helpful.

Luca January 26, 2005 06:48

Re: cells less than one
Try to discover where is the cell with index -1. For example export its node position with the macro NODE_X(node). I had never come across a negative index. Maybe it means something... Is it the only negative index you found? Please let me know. Luca

Luca January 26, 2005 06:54

Re: cells less than one
AH! Maybe C1<0 means that no c1 cell exist. If you're applying your function on a boundary face-thread, there's no C1 cell adjacent to it, only a C0 cell. I used the macro BOUNDARY... reported on the UDF guide. Let me know what you discover.Luca

Andrew Garrard January 26, 2005 08:29

Re: cells less than one
-1 is the only negative index retuned and from returning F_CENTROIDS, it looks like you are right. if c == -1 then it appears to be a boundary face and hence c1 dosen't exist.


Luca January 27, 2005 06:15

Re: cells less than one
OK then, we learned something more about UDF programming... Have a good day,Luca

All times are GMT -4. The time now is 00:56.