CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > 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 Tree2Likes

Reply
 
LinkBack Thread Tools 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: 5
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, 09:13
Default
  #23
Member
 
Mat
Join Date: Jan 2012
Posts: 39
Rep Power: 5
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 likes 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: 3
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

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to identify cell neighbours booz OpenFOAM Meshing Format & General Technical 39 December 19, 2014 02:58
How to identify boundary cell and internal cell dbxmcf OpenFOAM Running, Solving & CFD 1 August 25, 2008 21:59
?? How to get cell center coordinates? erica FLUENT 0 May 11, 2005 22:02
identify Cell face Sunlight007 CD-adapco 3 August 30, 2003 05:30
How to get nodes coordinates for a certain cell ? mikhail FLUENT 2 November 1, 2000 11:18


All times are GMT -4. The time now is 09:27.