Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get neighbour cell or points? #2

Closed
pswpswpsw opened this issue Oct 20, 2018 · 7 comments
Closed

Is it possible to get neighbour cell or points? #2

pswpswpsw opened this issue Oct 20, 2018 · 7 comments
Labels
filtering General topics around filtering and usage of filters

Comments

@pswpswpsw
Copy link

I don't want to look deep into VTK but just simply using your vtkInterface to get the information for a cell or point, getting the index for nearby points.

For example, i can use grid.cell_arrays or grid.point_array together with grid.points to get a dict of all the "nearly useful" information. But I want to obtain the nearest neighbour for a given point, which enables much flexibility in postprocessing the vtk formatted data. Is it possible using the existing method in vtk? I am asking because I find something like GetCellNeighbors but since it requires going deep into vtk so I cound't do it on my own.

Alternatively, I know I can using another package such as kdTree to search for k-nearest neighour on my own but just curious if there is something already there.

By the way, I think using the kdTree would enable much more flexibility since if I want to compute a very high order finite difference, I need a large stencil which I think GetCellNeighbors won't give me but selecting a large enough k, k-nearest neighour might give me. I don't know if it is something also your interests.

update on the kdtree to find a large stencil.

Oh, I think if one can get neighour then one can easily use that to recursively get k-nearest neighour without using another package such as kdTree, since kdTree requires some sort of computational time.

@akaszynski
Copy link
Member

I’m not familiar with what a large stencil is, but I’d probably go with using a kdtree as you’ll be able to quickly query the tree once you’ve set it up. pykdtree is one of the best out there, and it carries no dependancies.

If you do need me to setup an adjency function, please comment with your intended pseudo-code.

@akaszynski
Copy link
Member

Still need help on this?

@supersubscript
Copy link
Member

I agree that it would be nice to have a few different adjacency/neighbourhood functions. These examples come to mind for neighbouring elements on a mesh:

And then this for a point cloud:

Would certainly be features that'd be useful to have.

@pswpswpsw
Copy link
Author

pswpswpsw commented Oct 23, 2018

Still need help on this?

it is not urgent for me but I think other people might be interested.
Btw I wrote a blog on postprocessing OpenFOAM data using VTK and then use your package for various purpose in Python:

So the pseudo-code I have in my mind would be


let's say we tried to find 2-level of Neighour for each cell

  • for loop over all the cells, say i-th cell for instance:

    • find the neighbour of i-th cell (I think VTK itself might have already done it for you), denote as set J_i

      • for loop over each cell in set J_i, for each cell, find the neighour of that cell, denote as J_{J_i}.
    • for each cell Let's do a union operation of all the set J_{J_i}.

Then This union set for i-cell is the 2-level neighour set. Note that we know all of the spatial information so we can do really fancy things like computing any partial derivatives on any directions, so getting curvature is trivially easy.

@akaszynski
Copy link
Member

This is different than a meshless kdtree as it requires knowledge of the mesh connectivity. I’d be happy to add in cell based neighbor querying.

BTW, I liked the blog. If you wish, you can also visualize within python without heading over to paraview with:

grid.Plot(scalars=p2_cell)

See help(grid.Plot) for more details on how you can change the color map and other plotting variables.

@banesullivan
Copy link
Member

@pswpswpsw, could we add your blog post to the Long Examples section of the website?

Also, is there a status on the proposed feature requests? Should we outline some features that should/could be added to vtki?

@pswpswpsw
Copy link
Author

@pswpswpsw, could we add your blog post to the Long Examples section of the website?

Also, is there a status on the proposed feature requests? Should we outline some features that should/could be added to vtki?

No problem! Indeed, I will have some more fancy figures later within 2 months on that post! I will keep you updated!

@banesullivan banesullivan transferred this issue from pyvista/pyvista May 14, 2019
@banesullivan banesullivan added the filtering General topics around filtering and usage of filters label Jun 13, 2019
@pyvista pyvista locked and limited conversation to collaborators Feb 12, 2022
@tkoyama010 tkoyama010 converted this issue into a discussion Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
filtering General topics around filtering and usage of filters
Projects
None yet
Development

No branches or pull requests

4 participants