CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF: Given coordinates, How to identify the cell?

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 9, 2012, 16:35
Default
  #21
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
cx_cell=*CX_Find_Cell_With_Point(pt);

code:
#include"udf.h"
#include"cxndsearch.h"
DEFINE_ON_DEMAND(find_cell)
{
#if !RP_HOST
Domain *d;
cell_t c;
Thread *t;
CX_Cell_Id cx_cell;
real NV_VEC(pt);
real c_centroid[ND_ND];
NV_D(pt,=,0.009995,0.000175,0.0);
CX_Start_ND_Point_Search();
cx_cell=*CX_Find_Cell_With_Point(pt);
CX_End_ND_Point_Search();
c=RP_CELL(&cx_cell);
t=RP_THREAD(&cx_cell);
C_CENTROID(c_centroid,c,t);
Message(
"coordinate of the specified point: x=%g,y=%g\n",pt[0],pt[1]);
Message(
"coordinate of the cell found: x=%g,y=%g\n",c_centroid[0],c_centroid[1]);
#endif
}
Blackhawks84 is offline   Reply With Quote

Old   August 24, 2012, 16:30
Default
  #22
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:

cx_cell=*CX_Find_Cell_With_Point(pt);

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
Default
  #23
Member
 
Mat
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 :

Code:
  ...
  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.

Best,

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

Old   June 24, 2014, 13:21
Default
  #24
New Member
 
Garvit Goel
Join Date: May 2014
Posts: 11
Rep Power: 11
garvitgoel is on a distinguished road
Quote:
Originally Posted by md5encrypted View Post
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));
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
CX_Start_ND_Point_Search
CX_Find_Cell_With_Point
CX_End_ND_Point_Search
Thanks a lot
garvitgoel is offline   Reply With Quote

Old   October 16, 2016, 01:32
Default
  #25
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.


Quote:
Originally Posted by Vitaly View Post
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.
wond is offline   Reply With Quote

Old   December 11, 2018, 06:58
Default What should be put between brackets
  #26
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
Default
  #27
Member
 
George Pichurov
Join Date: Jul 2010
Posts: 52
Rep Power: 15
jorkolino is on a distinguished road
Quote:
Originally Posted by Jura
;152697
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.
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

Reply


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 19:42.