vtkGradientFilter on vtkUnstructuredGrid created by custom reader:

Hello All,

I have a reader that constructs a vtkUnstructuredGrid object that consists of VTK_TETRA cells. I assign an array at each of the nodes in the vtkUnstructuredGrid object. I would like to use vtkGradientFilter to compute the gradient across the unstructured grid using the array as the input.

I have gone through the following page (https://vtk.org/doc/nightly/html/classvtkGradientFilter.html#abed5e8488ed308deed09cb5daf24838a), but the example provided relies on using ports, but I do not have ports on my unstructuredGrid object (to my knowledge).

This is how I am apptempting to Calculate the gradient:

    vtkNew<vtkGradientFilter> gradient;
    gradient->SetInputData(unstructuredGrid);
    gradient->SetInputScalars(3, "u");
    gradient->SetResultArrayName("u_grad");
    gradient->Update();

Any Help is greatly appreciated!

Hi @ramen_newdals

Your code looks OK. SetInputData is the correct method to fed the filter with a dataset instead of an upstream connexion.
Have tried to execute it?

Best,

Hello @Francois_Mazen, my error was in the naming of my arrays :sweat_smile: thank you for your clarification of the methods correctness!