|
[Sponsors] |
UDF: Given coordinates, How to identify the cell? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 4, 2008, 15:44 |
UDF: Given coordinates, How to identify the cell?
|
#1 |
Guest
Posts: n/a
|
Hello,
I have a question about UDF: given a point (x,y,z coordinates), how to identify the cell (cell ID and thread ID) the given point is in? Thanks in advance |
|
August 6, 2008, 04:32 |
Re: UDF: Given coordinates, How to identify the ce
|
#2 |
Guest
Posts: n/a
|
Hello,
you ought to use macro C_CENTROID(x,c,c_thread) I would expect enclose it in cell looping macro begin_c_loop(c, c_thread) - end_c_loop(...) -> then you can check if x=x[0],y=x[1],z=x[2] matches your coordinates via if-function. If it matches then use variable "c" which is passed to you by Fluent as reference to your cell. Variable "c" is the simple integer value and yoou can later use it as a reference to your cell together with thread id. Hopefully it'll be useful to you |
|
August 6, 2008, 13:15 |
Re: UDF: Given coordinates, How to identify the ce
|
#3 |
Guest
Posts: n/a
|
Thank you Jura.
What you described only works for a few points. The cell looping takes too much time if I have many many points to be located. I believe there must be faster way to do this. For instance, if we define a "file" injection for DPM model, we provide the location of each particle and FLUENT put these particles in corresponding cells. So, FLUENT needs to find the cell for each particle with given location. I do not think FLUENT performs cell looping for each particle. |
|
August 6, 2008, 19:48 |
Re: UDF: Given coordinates, How to identify the ce
|
#4 |
Guest
Posts: n/a
|
I have used RP_CELL and RP_THREAD which are macros in the surf.h header file. They are referenced in the UDF manual for DPM macros. There isn't much description but they work fine for cell temperature and other properties as a function of particle position.
|
|
August 7, 2008, 13:48 |
Re: UDF: Given coordinates, How to identify the ce
|
#5 |
Guest
Posts: n/a
|
Thank you Allan.
RP_CELL and RP_THREAD work with PARTICLE not POSITION. As particle moves, FLUENT somehow finds the cell and thread and stores this information in the particle structure. What RP_CELL and RP_THREAD do is just read and return this information. What I am trying to find is a function/macro that returns cell/thread for a given position (x, y, z coordinates). |
|
August 7, 2008, 18:48 |
Re: UDF: Given coordinates, How to identify the ce
|
#6 |
Guest
Posts: n/a
|
what you are trying to do is very difficult indeed. And if you could find a better way that let us know.
As far as fluent is concerned, as i understand it uses kd-tree structure to locate cell id for position. Now this brings us to question whether you could acess this with any macro or not. Because this is likely to be advanced feature and mostly likely not available to usual user. Fluent is unstructured grid solver so it is very difficult to find a simple formula to do this. |
|
August 7, 2008, 19:08 |
Re: UDF: Given coordinates, How to identify the ce
|
#7 |
Guest
Posts: n/a
|
I think I found the function. If you are interested, play with this function, CX_Find_Cell_With_Point. It is a FLUENT_EXPORT function defined in cxiface.h.
|
|
August 7, 2008, 23:49 |
Re: UDF: Given coordinates, How to identify the ce
|
#8 |
Guest
Posts: n/a
|
I think thats wonderful if you found the function. I personally really doubted it whether it will be available.
But for me, i need to do the same in my own code so for me this function is of no use. I am trying to find or devise an efficient algorithm to do so. So far I am only able to devise good function of non uniform cartesian type meshes. (gives me index in one function call). I have no idea how to do it in unstructured grids as contructing kd-tree is time consuming process and when grid sizes increase these search process is indeed difficult thing to do in real time. I am searching and searching. |
|
August 8, 2008, 11:26 |
Re: UDF: Given coordinates, How to identify the ce
|
#9 |
Guest
Posts: n/a
|
I tried the function I just mentioned and seems like it works.
I used kd-tree for 2-D grids in one of our small projects and the number of grids is small. I have no experience of how it works in large scale problems. Are you aware of the open source code VTK (The Visualization Toolkit)? You may find something interesting in their website: http://www.vtk.org/. I was very interesting in this code but did not get time to learn it. |
|
August 10, 2008, 22:07 |
Re: UDF: Given coordinates, How to identify the ce
|
#10 |
Guest
Posts: n/a
|
i have written kd-tree programs for nearest neighbor search and my programs were faster than any implementation i have seen. (i took around 100 minutes for 100 million randomly distributed points and it was finding 5 nearest neighbours).
but my program did not use the suggested nearest neighbour search algo for kd-tree method. instead i used a little modified version (i deviced a better way of implementing). Anyway i am still not happy with it, so want to get even faster method. For me, kd-tree method and nearest neighbour search part have little history. I first needed to solve this problem for some project i was thinking in 1999. So came up with a algorithm that i thought was the fastest algo to solve this problem. I was happy but discovered that the algo i came up with is called kd-tree algo. (i found it out after 1 year of i thought of this). Anyway, i was not happy that time about that algo and i am still not happy. So for the practical applications where i might need this type of search (for example, nearest neighbor search of points of one grid to another, -> chimera grids) i have come up with another method and that beats kd-tree search method hands down. If kd-tree takes 5 minutes , that algo would only take less than 1 minute). But still there is no universal algo and i still think about solving this problem sometimes. |
|
August 11, 2008, 11:58 |
Re: UDF: Given coordinates, How to identify the ce
|
#11 |
Guest
Posts: n/a
|
Sounds very interesting! You should publish your method if it is new and performs so greatly.
Other than kd-tree, I know little about searching algo. I would not be able to give you any suggestion regarding this. But what you are doing is very interesting. I hope you can publish it to benifit other people, including me of course Good luck. |
|
August 11, 2008, 23:24 |
Re: UDF: Given coordinates, How to identify the ce
|
#12 |
Guest
Posts: n/a
|
my company said we will patent it. :-D
|
|
August 12, 2008, 11:24 |
Re: UDF: Given coordinates, How to identify the ce
|
#13 |
Guest
Posts: n/a
|
That's not good, for us
By the way, I am wondering how you can patent an algorithm. What if someone else comes up with the same idea? |
|
August 12, 2008, 19:07 |
Re: UDF: Given coordinates, How to identify the ce
|
#14 |
Guest
Posts: n/a
|
i have no idea, how can we patent it, but it is very useful for us, and my boss probably meant the whole method of solving the problem. (kd-tree is main part of it).
|
|
March 11, 2010, 21:30 |
|
#15 | |
New Member
Join Date: Nov 2009
Posts: 8
Rep Power: 17 |
Quote:
Can you give me a simple code applying that function in the search of a cell ID, thread. I've found it in cxiface.h but I don't have much experience in UDF programming. I think if I have to use it inside a cell loop or something like that but I'm not sure. There is nothing in the manual, and if i search "CX_Find_Cell_With_Point" in google, the only result is this topic... thanks in advance! Pedro |
||
May 15, 2010, 14:00 |
code example
|
#16 |
New Member
User Simplename
Join Date: May 2010
Posts: 1
Rep Power: 0 |
I found this code (source: http://www.cfluid.com/bbs/viewthread...able&tid=76550)
Code:
cell_t c; Thread *t; CX_Cell_Id cx_cell; real NV_VEC(pt); real c_centroid[ND_ND]; NV_D(pt, =, 1,1,1); //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,T=%g\n",c_centroid[0],c_centroid[1],c_centroid[2],C_T(c,t)); [off] I know I'm late with answer, but hope it will be useful [/off] |
|
November 5, 2010, 05:48 |
Particle source in cell (PSI-C) UDF
|
#17 |
Member
john
Join Date: Nov 2010
Posts: 50
Rep Power: 16 |
Hi All,
Does any body know how to write UDF for averaging particle in the cell in Lagrangian Particle tracking method i.e., DPM. My problem is I wanted to moniter particle concentration at different locations in the domain uisng DPM, any clues? Thanks John |
|
March 8, 2011, 14:59 |
CX_Start_ND_Point_Search(); Error
|
#18 | |
New Member
Join Date: Mar 2011
Posts: 2
Rep Power: 0 |
Quote:
When I try to use: CX_Start_ND_Point_Search(); I get a define variable error. I included cxiface.h Does anyone know why this error arises? |
||
March 12, 2012, 11:33 |
|
#19 | |
New Member
JH
Join Date: Jan 2012
Posts: 4
Rep Power: 14 |
Hello I found the following lines in the header
"cxndsearch.h" Quote:
Can anyone explain what the input argument " ND_Search * " means? And how to use it for the problem described above? |
||
June 6, 2012, 18:23 |
|
#20 |
Member
Vitaly
Join Date: Jan 2012
Posts: 32
Rep Power: 14 |
Hello,
In my cxndsearch.h file, the input arguments are different: FLUENT_EXPORT CX_Cell_Id *CX_Find_Cell_With_Point(ND_Search *, double v[3], double time); I have no idea what "time" means, but I set it to 0.0 and it worked. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Technical] How to identify cell neighbours | booz | OpenFOAM Meshing & Mesh Conversion | 59 | November 20, 2017 01:40 |
How to identify boundary cell and internal cell | dbxmcf | OpenFOAM Running, Solving & CFD | 2 | November 6, 2016 10:11 |
?? How to get cell center coordinates? | erica | FLUENT | 0 | May 11, 2005 23:02 |
identify Cell face | Sunlight007 | Siemens | 3 | August 30, 2003 06:30 |
How to get nodes coordinates for a certain cell ? | mikhail | FLUENT | 2 | November 1, 2000 11:18 |