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

cell id in udf

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 4, 2022, 01:50
Default
  #21
New Member
 
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4
JINXIE is on a distinguished road
Quote:
Originally Posted by loving_cfd View Post
Dear vinerm,

Thanks for your reply.

I try to search the 4 neighbor cells of every cell in the domain and assign them according to the value of this cell. (cellular automaton)

So I set an array, the size of which is the same as the grids (such as x[40][20], while the mesh is 40*20), in order to record the relative position of the cells (such as x[i+1][j] is one the east of x[i][j]).

Thus, it is necessary to establish the relationship between the array and the cells. I attempt to employ cell IDs, but no macro can be found. So I partition the domain with X-coordinate and use the cell loop to record the sequence. It doesn't work properly on the first partition zone, while it works perfectly on the rest partition zones.

Part of my code is as follows (my program has to be performed on a parallel process):
#include "udf.h"
/* define the number of cells */
#define xnum 40
#define ynum 20
/* the array */
int cell[xnum+1][ynum+1];
/* initialize the cell IDs */
DEFINE_INIT(assign_array_neighbor,d)
{
#if RP_NODE
cell_t c;
Thread *t;
int x=1,y=0; /* the first row the cells in the current partition */
int partid=0; /* partition id */
int initx=0; /* to determine if it is the first row */
int counter=0; /* to count the cell id */
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
partid=C_PART(c,t);
counter=counter+1;
if(initx==0)
{x=x+partid*xnum/partnum;
initx=1;}
y=y+1;
if(y>ynum)
{y=y-ynum;x=x+1;} /* to calculate the cell position */
cell[x][y]=0; /* assign the value in the array, then the array will be employed to assign the cells in the domain */
C_UDMI(c,t,1)=counter; /* record the cell ID */
C_UDMI(c,t,2)=x; /* record x */
C_UDMI(c,t,3)=y; /* record y */
}
end_c_loop(c,t)
}
#endif
}
The result of udm3 is in the attachment. It can be discovered that the first two rows are wrongly ordered.

Hi


Could you please tell what the meaning of "partnum" and how to retrive this variable? Thank you!

I followed your idea but cannot get similar results as yours.
JINXIE is offline   Reply With Quote

Reply

Tags
cell id, udf


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
Neighboring cells in tetrahedral mesh vishwesh OpenFOAM Programming & Development 9 November 10, 2017 08:06
How to get the global index of a cell in UDF chuyi Fluent UDF and Scheme Programming 6 October 23, 2017 13:28
UDF Internal Reforming in Fuel Cell Kashif Rashid Fluent UDF and Scheme Programming 0 September 23, 2014 23:23
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 13:25
cell values in UDF gayatri FLUENT 2 February 27, 2007 19:18


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