|
[Sponsors] |
February 9, 2015, 10:12 |
Get Cell by Coordinates in Fluent 15.0.0
|
#1 |
New Member
Join Date: Feb 2015
Posts: 2
Rep Power: 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! } |
|
February 11, 2015, 05:30 |
|
#2 |
Member
Join Date: Nov 2014
Posts: 31
Rep Power: 11 |
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. |
|
February 14, 2015, 11:14 |
Solution with DPM_Locate_Point
|
#3 |
New Member
Join Date: Feb 2015
Posts: 2
Rep Power: 0 |
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(); |
|
February 16, 2015, 05:44 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Thank you Haggis for posting the solution you found.
It might help somebody in the future! |
|
February 16, 2015, 10:52 |
|
#5 | |
Member
Join Date: Jul 2013
Posts: 80
Rep Power: 13 |
Quote:
I think the code is still incomplete. Is that a DEFINE_ON_DEMAND macro or what kind of macro are you using? Regards. |
||
April 8, 2015, 08:39 |
|
#6 |
New Member
Join Date: Apr 2015
Posts: 28
Rep Power: 11 |
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(); |
|
June 24, 2019, 00:02 |
|
#7 | |
New Member
alvin
Join Date: Aug 2018
Location: HONGKONG
Posts: 5
Rep Power: 8 |
Quote:
|
||
Tags |
cell, coordinates, point, search |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Two dimensional simulation of a PEMFC in Fluent fuel cell module | A CFD free user | FLUENT | 1 | July 3, 2024 00:19 |
UDF: Given coordinates, How to identify the cell? | Zhang | Fluent UDF and Scheme Programming | 26 | August 15, 2022 06:54 |
working in cylindrical coordinates in fluent | Randheer Yadav | FLUENT | 2 | January 18, 2015 17:25 |
[Workbench] Creation of Cell Zones for processing in FLUENT | kailingkk | ANSYS Meshing & Geometry | 0 | October 5, 2013 06:09 |
?? How to get cell center coordinates? | erica | FLUENT | 0 | May 11, 2005 23:02 |