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

find a cell from its centroid coordinates

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2018, 03:34
Default find a cell from its centroid coordinates
  #1
Member
 
annan
Join Date: Nov 2016
Posts: 72
Rep Power: 9
annan is on a distinguished road
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
annan is offline   Reply With Quote

Old   March 2, 2018, 09:30
Default
  #2
New Member
 
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9
doruk is on a distinguished road
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
doruk is offline   Reply With Quote

Old   March 5, 2018, 06:36
Default
  #3
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
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 CX_Find_Cell_With_Point: problem.

Good luck!
Ed
obscureed is offline   Reply With Quote

Reply

Tags
fluent, fluent udf, udf and programming


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
How to use "translation" in solidBodyMotionFunction in OpenFOAM rupesh_w OpenFOAM Running, Solving & CFD 5 August 16, 2016 04:27
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 12:25
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 Attesz OpenFOAM Installation 45 January 13, 2012 12:38
Problem Building OF on Centos cluster (no admin rights) CKH OpenFOAM Installation 5 November 13, 2011 06:32
Cells with t below lower limit Purushothama Siemens 2 May 31, 2010 21:58


All times are GMT -4. The time now is 06:26.