CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Algorithm to find cell no. in O-grid for a point (https://www.cfd-online.com/Forums/main/13697-algorithm-find-cell-no-o-grid-point.html)

 Ben June 21, 2007 00:57

Algorithm to find cell no. in O-grid for a point

Hi,

I am looking for an effective algorithm which can determine the i,j cell number of a point on an O-grid.

Can someone enlighten me?

Thanks

 Mani June 21, 2007 08:50

Re: Algorithm to find cell no. in O-grid for a poi

How is the point defined? By physical coordinates?

The (in)efficiency of any search algorithm will depend on how general it needs to be. Your question implies a 2D grid. Are there any other conditions that may help to specify the problem?

 Ben June 21, 2007 09:49

Re: Algorithm to find cell no. in O-grid for a poi

Hi,

put it simply, I have a pt with coordinates (x,y). I also have an O-grid, in a 2D array xx(i,j), yy(i,j). There's no transformation and they'r all physical coordinates.

So I want to find the i,j cell on the O-grid where the pt (x,y) lies in. I am now looping through the O-grid cells, and check if the pt lies inside the cell (quadrilateral).

I am using overset grids so I'm trying to find the interpolation stencil for the cartesian pt on the O-grid.

Thanks

 TG June 21, 2007 13:37

Re: Algorithm to find cell no. in O-grid for a poi

What you need to do to speed up the process is create a set of zones covering the extent of the mesh, place each cell into a the zone (or zones) it falls into geometrically and then only search the cells in the zone that your point falls in to see if its in or out. You can experiment, but a 10x10 covering the 2-d mesh will probably speed you up a couple of orders of magnitude.

 Mani June 21, 2007 13:54

Re: Algorithm to find cell no. in O-grid for a poi