vtkStructuredGrid() and vtkStructuredGrid.FindCell()

Dear vtk-users,

During an internship at the Max Planck Institute for Plasma physics I have used your library a lot for interpolating from a structured grid of the fusion device we have here which has a very complicated geometrical structure(torus with a five-fold symmetry) onto an equidistant Cartesian grid. The purpose of this interpolation is to be able to easily calculate gradients of a given scalar parameter. Therefore I have generated the grid by using the StructuredGrid() object with dimensions (139,512,35) which corresponds to directions (r, theta, phi) in a torus shape. All vtkDataSets have the function FindCell() which the vtkStructuredGrid-object inherits. Using this function I want to find which cell in the warped torus-shaped grid a point in my cartesian grid belongs to. However to be able to this the parameter tol2 needs to be set to an unreasonably large value. My interpretation of this value is that it is the tolarance squared of the distance to the closest vertex of the resulting cell the point I am searching for is said to belong to. Please correct me if I am wrong.

I found the documentation of the FindCell-function a bit ambigous, is it possible to get a more thorough explanation of how the function works and especially how to interpret the tol2 parameter?

Also I would like to get an explanation on how cells are generated when constructing the vtkStructuredGrid?

Currently I am confirming the correct structure by plotting the gridplanes using mayavi, but I am not satisfied since I do not actually see the shape of the cells. Do you have an easy method of confirming the right cell structure and that there is no empty space in between cells?

Best regards,

Johan

Johan, if you are not using ParaView it’s worth adding it to your toolkit. Since ParaView is built on VTK, there is a natural synergy between the application and toolkit. Using methods for clipping, cutting and extracting you should be able to verify the grid pretty easily.

Are the points you are testing for inclusion located “inside” the grid, or near to the grid boundary? the answer may affect how you set tol2. (If I remember correctly, tol2 is the square of the distance to any part of a cell.)

Hi Will,

Thank you for your answer, I will check out paraview.

I am checking for arbitrary points, some of the points I am checking for should be interior to cells and some are exterior. You can imagine some toroidal grid being embedded in some Cartesian grid, where the Cartesian volume is largest.

So if I understand you correctly the tol2 parameter also takes edges into account, not only vertices?

Cheers,

Johan