Get Cell by Coordinates in Fluent 15.0.0
Hi Everybody,
I'm working with Fluent 15.0.0 and need to find the cell of the domain that contains a certain point (specified by its coordinates). My approaches so far:
My Code: #include "dpm.h" #include "cxndsearch.h" CX_Cell_Id *cx_cell; double x[ND_ND]; int i; ND_Search *search; for (i = 0; i < ND_ND; i++) { x[i] = 0.0; } Message("sv_locat_point: %d\n", SV_locate_point(x, cx_cell)); //fails! search = CX_Start_ND_Point_Search(search, 1, 0); cx_cell = CX_Find_Cell_With_Point(search, x, 0); search = CX_End_ND_Point_Search(search); if (NULL != cx_cell) { Message("check\n"); Message("cx_find_cell id: %d\n", RP_CELL(cx_cell)); //fails! } |
Hi,
Could you please explain a bit more what exactly you want to do? As per mesh terminology fluent has, information about cells,their faces,centroids are accessible but I am not sure about point in cell. |
Solution with DPM_Locate_Point
Hi,
if finally found a solution for the problem using DPM_Locate_Point. As apparently nobody knows how to use it I'm going to answer my own question in case someone finds it interesting. #include "udf.h" CX_Cell_Id cx_cell; double x[ND_ND], A[ND_ND], center[ND_ND]; Thread *ft; face_t f; cell_t c; Thread *ct; domain = Get_Domain(1); DPM_Init_Oct_Tree_Search(); //for more than one point start the loop here for (i = 0; i < ND_ND; i++) { x[i] = 0.0; } cx_cell.ct.c = 0; cx_cell.ct.t = NULL; DPM_Locate_Point(x,&cx_cell,0.0,0); if (NNULLP(cx_cell.ct.t)) { c = RP_CELL(&cx_cell); ct = RP_THREAD(&cx_cell); } else Message("point not in domain\n"); //stop point loop here DPM_End_Oct_Tree_Search(); |
Thank you Haggis for posting the solution you found.
It might help somebody in the future! :) |
Quote:
I think the code is still incomplete. Is that a DEFINE_ON_DEMAND macro or what kind of macro are you using? Regards. |
If you are using this code outside of the macro DEFINE_ON_DEMAND, you need to correct the Get_Domain(1) line, because it doesn't know where to apply it. I've done the following modifications and it worked in the DEFINE_DPM_BC() macro :
#include "udf.h" CX_Cell_Id cx_cell; double x[ND_ND], A[ND_ND], center[ND_ND]; Thread *ft; face_t f; cell_t c; Thread *ct; Domain *domain; //Domain is declared as a variable domain = Get_Domain(1); //Returns fluid domain pointer DPM_Init_Oct_Tree_Search(); //for more than one point start the loop here for (i = 0; i < ND_ND; i++) { x[i] = 0.0; } cx_cell.ct.c = 0; cx_cell.ct.t = NULL; DPM_Locate_Point(x,&cx_cell,0.0,0); if (NNULLP(cx_cell.ct.t)) { c = RP_CELL(&cx_cell); ct = RP_THREAD(&cx_cell); } else Message("point not in domain\n"); //stop point loop here DPM_End_Oct_Tree_Search(); |
Quote:
|
All times are GMT -4. The time now is 16:41. |