find a cell from its centroid coordinates
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 |
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 |
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 https://www.cfd-online.com/Forums/fl...t-problem.html. Good luck! Ed |
All times are GMT -4. The time now is 16:50. |