|
[Sponsors] |
March 2, 2018, 04:34 |
find a cell from its centroid coordinates
|
#1 |
Member
annan
Join Date: Nov 2016
Posts: 72
Rep Power: 10 |
Dear all,
Does anyone know how to find a cell when its centroid coordinates are known ? I have the coordinates x[0] and x[1], and I want to find the corresponding cell in my UDF Thank's a lot |
|
March 2, 2018, 10:30 |
|
#2 |
New Member
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9 |
Hi Annan;
Here is how I would do it. I hope it gives you the idea. real a,b; int i; real x[N_D]; begin_c_loop (c,t) { C_CENTEROID(x,c,t); if(x[0]>a-0.00001 && x[1]>b-0.00001 && x[0]<a+0.00001 && x[1]<b+0.00001) // a and b are the coordinate values { i=c; } } end_c_loop(c,t) I dont know if the +-0.000001 (just a small value) would be able sufficient to find the cell you can work on it for your case. Ansys gives error if commands have real=real. In the end the integer "i" will be the number of the cell you are looking for. Best Regards, Doruk |
|
March 5, 2018, 07:36 |
|
#3 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Annan,
doruk's solution should work (in serial and 2D, but easily fixed to work in 3D). It is currently only a sketch -- for example, you would probably want a thread loop for all values of t. But this is clearly an O(N) process, where N is the number of cells. A more efficient algorithm is available built-in, but the syntax is slightly fiddly and version-dependent -- google for CX_Find_Cell_With_Point, for example CX_Find_Cell_With_Point: problem. Good luck! Ed |
|
Tags |
fluent, fluent udf, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to use "translation" in solidBodyMotionFunction in OpenFOAM | rupesh_w | OpenFOAM Running, Solving & CFD | 5 | August 16, 2016 05:27 |
Journal file error | magicalmarshmallow | FLUENT | 3 | April 4, 2014 13:25 |
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 | Attesz | OpenFOAM Installation | 45 | January 13, 2012 13:38 |
Problem Building OF on Centos cluster (no admin rights) | CKH | OpenFOAM Installation | 5 | November 13, 2011 07:32 |
Cells with t below lower limit | Purushothama | Siemens | 2 | May 31, 2010 22:58 |