probelm about UDF marco called "CX_Find_Cell_With_Point"
Hi, everybody in this wonderful community. :)
My recent research goal is to obtain the scalar values of neighborhood cells around a specific cell. To realize this, I wrote a UDF coupling CX_Find_Cell_With_Point and begin_c_loop. The UDF tries to obtain the pressure of a neighborhood cell around a specific cell. Unfortunately, the UDF failed to run. Can anybody give some advice? The UDF is posted as follows: #include <udf.h> #include "cxndsearch.h" static ND_Search *domain_table = NULL; DEFINE_ADJUST(test, domain) { cell_t c,c1; Thread *t, *t1; CX_Cell_Id *cx_cell; real P[3]; real P_Cell[3]; real PR; thread_loop_c (t,domain) { begin_c_loop(c,t) { domain_table = CX_Start_ND_Point_Search(domain_table,TRUE,-1); C_CENTROID(P_Cell,c,t); /*obtain the postion of specific cell*/ P[0]=P_Cell[0]+0.001; /* obtain the postion of cell on the right side*/ P[1]=P_Cell[1]; P[2]=0; cx_cell = CX_Find_Cell_With_Point(domain_table,P,0.0); c1 = RP_CELL(cx_cell); t1 = RP_THREAD(cx_cell); domain_table = CX_End_ND_Point_Search(domain_table); C_UDMI(c,t,0)=C_P(c1,t1); /* storage the value of pressure*/ } end_c_loop(c,t); } } |
Hello,friends.
I guess that I found the reason. The issue may come from the wrong use of CX_Start_ND_Point_Search. Whatever, I corrected my UDF. And it works. The corrected UDF is posted here: #include <udf.h> #include "cxndsearch.h" static ND_Search *domain_table = NULL; DEFINE_ADJUST(test, domain) { cell_t c,c1; Thread *t, *t1, **pt; CX_Cell_Id *cx_cell; real P[3]; real P_Cell[3]; real vof; real dx=0.2e-3; /*mesh size x direction*/ real dy=0.2e-3; /*mesh size y direction*/ domain_table = CX_Start_ND_Point_Search(domain_table,TRUE,-1); thread_loop_c (t,domain) { begin_c_loop(c,t) { C_CENTROID(P_Cell,c,t); /*position of speicific cell*/ P[0]=P_Cell[0]+dx; /*position of cell on the right side*/ P[1]=P_Cell[1]; P[2]=0; cx_cell = CX_Find_Cell_With_Point(domain_table,P,0.0); if(cx_cell) { c1 = RP_CELL(cx_cell); t1 = RP_THREAD(cx_cell); pt = THREAD_SUB_THREADS(t1); C_UDMI(c,t,0)=C_VOF(c1,pt[0]); } else { C_UDMI(c,t,0)=0; } end_c_loop(c,t); } } domain_table = CX_End_ND_Point_Search(domain_table); } |
All times are GMT -4. The time now is 15:57. |