根据坐标来得到cell
已有 1453 次阅读2013-4-17 13:43
|个人分类:UDF使用技巧
Here is the example, Note: the location of the specified point must be in the computational domain, otherwise error will occur.
#include "udf.h"
DEFINE_ON_DEMAND(find_cell)
{
cell_t c;
Thread *t;
CX_Cell_Id cx_cell;
real NV_VEC(pt);
real c_centroid[ND_ND];
NV_D(pt, =, 0.5, 0.3, 0.2); //coordinate of your specified location,it must be in the domain coordinate range
CX_Start_ND_Point_Search();
cx_cell=*CX_Find_Cell_With_Point(pt);
CX_End_ND_Point_Search();
c=RP_CELL(&cx_cell); //the right cell number
t = RP_THREAD(&cx_cell); // the thread
C_CENTROID(c_centroid,c,t);
Message0("coordinate of the specified point: x=%g,y=%g,z=%g\n",pt[0],pt[1],pt[2]);
Message0("coordinate of the cell found: x=%g,y=%g,z=%g\n",c_centroid[0],c_centroid[1],c_centroid[2]);
}