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/)
-   -   adjacent cells (neighbor cells) (http://www.cfd-online.com/Forums/fluent-udf/98462-adjacent-cells-neighbor-cells.html)

onlyou1221 March 12, 2012 06:09

adjacent cells (neighbor cells)
 
Hi,
I want to obtain the adjacent cells of a cell (cells connected to each nodes not only faces), I loop over all cells, check to see if a cell shares any nodes with the cell of interest, and save a array of the ones that do. But I found taht the array (neighbourcell[Ncell][NeighC] in code) doesn't contain all the adjacent cells and I don't know why, please help me, thanks!
Code:

#include "udf.h"
#define Ncell 100000 /*number of cells*/
#define NeighC 26 /*maximun number of adjacent cells*/
cell_t c1,c2,neighbourcell[Ncell][NeighC];
Thread *t;
int ii,jj,kk;
DEFINE_INIT(init,domain)
{
 for(ii=0;ii<Ncell;ii++)
  for(jj=0;jj<NeighC;jj++)
  neighbourcell[ii][jj]=-1;
 thread_loop_c(t,domain)
 {
  begin_c_loop(c1,t)/*loop_c1*/
  {
  kk=0;
  begin_c_loop(c2,t)
  {
    for(ii=0;ii<C_NNODES(c1,t);++ii)
    for(jj=0;jj<C_NNODES(c2,t);++jj)
      if(C_NODE(c1,t,ii)==C_NODE(c2,t,jj))/*share Node;*/
      {
      neighbourcell[c1][kk]=c2;
      kk++;
      break;
      }
    if(C_NODE(c1,t,ii)==C_NODE(c,t,jj)) break;/*exit loop_c1*/
  }
  end_c_loop(c2,t)
  }
  end_c_loop(c1,t)
 }
}



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