CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF: Given coordinates, How to identify the cell?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree11Likes

LinkBack Thread Tools Search this Thread Display Modes
Old   August 9, 2012, 16:35
New Member
Bradley J
Join Date: Jul 2012
Location: Cincinnati, OH
Posts: 12
Rep Power: 13
Blackhawks84 is on a distinguished road
Hello All.
I have tried running this code for a 2D axissymetric case and recieved this error:

..\..\src\find.c(14) : error C2100: illegal indirection
..\..\src\find.c(14) : error C2440: '=' : cannot convert from 'int' to 'CX_Cell_Id'

this is line 14

#if !RP_HOST
Domain *d;
cell_t c;
Thread *t;
CX_Cell_Id cx_cell;
real NV_VEC(pt);
real c_centroid[ND_ND];
"coordinate of the specified point: x=%g,y=%g\n",pt[0],pt[1]);
"coordinate of the cell found: x=%g,y=%g\n",c_centroid[0],c_centroid[1]);
Blackhawks84 is offline   Reply With Quote

Old   August 24, 2012, 16:30
New Member
Paul H
Join Date: Aug 2012
Posts: 1
Rep Power: 0
SupersonicHokie is on a distinguished road
I'm having compilation issues too- tried to compile on windows and linux, the compiler complains about the the same line:


Has anyone gotten this work? Any details on fluent version, environment?

This seems like an extremely useful function.
SupersonicHokie is offline   Reply With Quote

Old   October 28, 2013, 08:13
Join Date: Jan 2012
Posts: 60
Rep Power: 14
Mat_fr is on a distinguished road
Dear all,

I know is a bit a late, but it can be usefull for futur users.

I suppose the function "CX_Find_Cell_With_Point" was available with the previous versions of Fluent (Actually, I used it with succes in Fluent 6.0, but it doesnt work with Fluent 14.5).

If you want the same functionality, you can use the function "SV_locate_point" with the actual version of Fluent :

  cell_t c;
  Thread *t;
  CX_Cell_Id *cx_cell;
  float pos[3];
  SV_locate_point(pos, cx_cell);
  c = cx_cell->ct.c; 
  t = cx_cell->ct.t;
Unfortunately, it does not seem to work in parallel (only for serial calculation).
In the parallel case, I don't see another solution than doing the loop among the cell yourself, and communicate between the nodes.


mm.abdollahzadeh and wond like this.
Mat_fr is offline   Reply With Quote

Old   June 24, 2014, 13:21
New Member
Garvit Goel
Join Date: May 2014
Posts: 11
Rep Power: 12
garvitgoel is on a distinguished road
Originally Posted by md5encrypted View Post
I found this code (source:

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
c=RP_CELL(&cx_cell);  //the right cell number
t = RP_THREAD(&cx_cell);  //  the thread

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));
It works, but if requested point located outside mesh, CX_Find_Cell_With_Point returns NULL, and therefore causes access violation (dereferencing NULL).

[off] I know I'm late with answer, but hope it will be useful [/off]
I am getting the error -
invalid type argument of unary * (have int)
and warnings that -
implicit declaration of function
Thanks a lot
garvitgoel is offline   Reply With Quote

Old   October 16, 2016, 01:32
New Member
Join Date: Jun 2013
Posts: 18
Rep Power: 12
wond is on a distinguished road
the source code of the higher version is seem to be changed.
the 'search' is a struct type whose variables are not illustrated yet.

Originally Posted by Vitaly View Post

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.
wond is offline   Reply With Quote

Old   December 11, 2018, 06:58
Default What should be put between brackets
New Member
Join Date: Oct 2009
Posts: 25
Rep Power: 16
jacek is on a distinguished road
What should be put between brackets in CX statemetns in a real code?

CX_Start_ND_Point_Search(ND_Search *, cxboolean do_domain, int t_id);
CX_Find_Cell_With_Point(ND_Search *, float v[3]);
CX_End_ND_Point_Search(ND_Search *)

I would need a short example with the CX_... loop inside a code and CX_...(?) content.

Last edited by jacek; December 12, 2018 at 04:48.
jacek is offline   Reply With Quote

Old   August 15, 2022, 05:54
George Pichurov
Join Date: Jul 2010
Posts: 52
Rep Power: 15
jorkolino is on a distinguished road
Originally Posted by Jura

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.
Well, almost certainly it will not match. Even if your point is microns from the cell centre, machine arithmetic will still give a false. I suppose we need a way to find if a a point lies within the cell boundaries. Trying to pinpoint the cell centre is useless.
You can loop to find the cell centre closest to the desired point. I have done that. But, in parallel computation (and resp. compilation) each partition assigned to a process loops through that loop and finds it own point, closest to the desired coordinate, but belonging to its partition. So I end up with n cells (where n is the number of processes=partitions) that are not necessary close to the desired coordinate. So we need one of two things:
1. Either find a way if a coordinate lies within a cell entity (within the boundaries of a cell), or
2. Find a way to loop by a host process and not by compute processes. However, the ID will be duplicate (for example cell number lets say 140 will exist in all partitions of a parallel run)
jorkolino is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Technical] How to identify cell neighbours booz OpenFOAM Meshing & Mesh Conversion 59 November 20, 2017 00:40
How to identify boundary cell and internal cell dbxmcf OpenFOAM Running, Solving & CFD 2 November 6, 2016 09:11
?? How to get cell center coordinates? erica FLUENT 0 May 11, 2005 22:02
identify Cell face Sunlight007 Siemens 3 August 30, 2003 05:30
How to get nodes coordinates for a certain cell ? mikhail FLUENT 2 November 1, 2000 10:18

All times are GMT -4. The time now is 13:32.