CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   cell_t c from point coorfdinates UDF (https://www.cfd-online.com/Forums/fluent-udf/65050-cell_t-c-point-coorfdinates-udf.html)

 andrea.dicarlo June 2, 2009 10:06

cell_t c from point coorfdinates UDF

Dear all I'm new of this forum.
Could you help me?
I was written a UDF(FLUENT), I should obtain the cell_t c that contain a point of known coordinate (x,y,z). I'm going to better explain. From UDF manual I know there is the macro
C_CENTROID(x,c,t) that from the knoledge of c and t give x,y,z coordinate of the cell centre. I would like to know if there is a macro that could do the opposite, know the point x,y,z that could return the number of cell that contain that point.
Thank you very much

 Bocliff June 2, 2009 18:06

Use Find_bounding_cell

Greetings,

You can use the function:

cell_t Find_bounding_cell(Domain *domain, real *x, Thread **t)

You provide the domain pointer, the coordinates of the point, and it returns the cell_t index and the thread pointer. Include dpm_tools.h before using it.

Regards,
Bocliff Sutter

 Bocliff June 2, 2009 18:12

Make sure you do not call this from some cell loop as you will end up with n^2 algorithm...

Bocliff Sutter

 andrea.dicarlo June 4, 2009 09:13

Thank you very much Bocliff
It works. You saved me from an nervous breakdown :)
thnk you again

 ian.maes October 15, 2012 12:04

Hi!

I see the communication in this topic was ended in 2009, but could somebody type an example of the use of this function?
Is it also possible in 3D and give coordinates of x,y and z to the function?

Kind regards,

Ian

 Payam89 October 15, 2012 12:39

Mhd

hello my dear!

I have a magnetic field in my flow and I read a lot of MHD tutorials but I am not able that in which format I should write this in c/c++ ....please if you have a similar c program me help.

regards

 nasser December 29, 2012 17:28

Quote:
 Originally Posted by Payam89 (Post 386730) hello my dear! I have a magnetic field in my flow and I read a lot of MHD tutorials but I am not able that in which format I should write this in c/c++ ....please if you have a similar c program me help. regards
hi
I have same problem , can you solve it my friends ?

Please share your equation. It's easy to write UDF for any equation.

 garvitgoel July 4, 2014 06:44

Lets say I first loop over the entire domain and store cell_t c and thread *t for every cell.
Can I later access a cell using these c and t?
For eg
i store cell_t c and thread *t of some cell in global variables c_global and t_global.
Then in some other function I do C_CENTROID ( xc , c_global, t_global );
Will xc hold the centroid of that original cell?
Thanks a lot
garvit goel
Imperial college

 garvitgoel July 4, 2014 12:05

Quote:
 Originally Posted by Bocliff (Post 217998) Make sure you do not call this from some cell loop as you will end up with n^2 algorithm... Bocliff Sutter "May your Yak live long"
Is it possible to obatin a n^1 or less algorithym?

 All times are GMT -4. The time now is 10:08.