vtkGhostType segmentation fault with AMRexGridReader

I am working on replicating a working Paraview pipeline in python vtk and I am running into so many issues, the main stopping point is a segmentation fault created when I use vtkGhostType array with a cell data to point data filter. When I don’t include the vtkGhostType I don’t have segmentation faults but the output of my contour filter is None. Any help would be greatly appreciated. I have correctly read in the AMRex dataset and am using three cell arrays as given here:

amr_reader = vtkAMReXGridReader()
amr_reader.SetFileName(‘path/to/plt’)
amr_reader.SetCellArrayStatus(“magvel”,1)
amr_reader.SetCellArrayStatus(“Temp”,1)
amr_reader.SetCellArrayStatus(“vtkGhostType”,1)
amr_reader.SetMaxLevel(3)
amr_reader.Update()
print(amr_reader.GetCellDataArraySelection())
Result:
vtkDataArraySelection (0x7fae8c18af40)
Debug: Off
Modified Time: 115
Reference Count: 2
Registered Events:
Registered Observers:
vtkObserver (0x7fae8f70e2a0)
Event: 33
EventName: ModifiedEvent
Command: 0x7fae8c1fe140
Priority: 0
Tag: 1
UnknownArraySetting: 0
Number of Arrays: 3
Array: magvel is: enabled (1)
Array: Temp is: enabled (1)
Array: vtkGhostType is: enabled (1)

Code where segmentation fault arises:
celldata2point = vtkCellDataToPointData()
celldata2point.SetInputConnection(amr_reader.GetOutputPort())
celldata2point.PassCellDataOff()
celldata2point.AddCellDataArray(“Temp”)
celldata2point.AddCellDataArray(“magvel”)
celldata2point.AddCellDataArray(“vtkGhostType”)
celldata2point.Update()

I am also having trouble contouring the data by the “magvel” array, if anyone has insight on where I am going wrong that would be greatly appreciated:
contour = vtkContourFilter()
contour.SetInputConnection(celldata2point.GetOutputPort())
contour.SetNumberOfContours(1)
contour.SetValue(0, 1400.00)
contour.SetInputArrayToProcess(1,0,0,“CELL”,“magvel”)
contour.Update()
print(“contour output”,type(contour.GetOutput()))
contour output type = None

Thanks!

@Yohann_Bearzi

This is an odd usage of ghost elements. Ghost points and ghost cells don’t convert between each other so it doesn’t make much sense to try to convert them from cell to points. But there shouldn’t be a crash so we should fix this.

Thank you for your reply, I didn’t realize this was an odd usage of ghost cells, so I will try to implement my pipeline without them.

Here is the paraview code I am replicating that involves ghost cells:

plt = AMReXBoxLibGridReader(registrationName=‘plt…’, FileNames=['path/to/plt])

plt.Level = 3

plt.CellArrayStatus = [‘Temp’, ‘magvel’]

create a new ‘Cell Data to Point Data’

cellDatatoPointData1 = CellDatatoPointData(registrationName=‘CellDatatoPointData1’, Input=plt)

cellDatatoPointData1.CellDataArraytoprocess = [‘Temp’, ‘magvel’, ‘vtkGhostType’]

While I have your attention, is there anything wrong with my vtkcontour filter usage in my original post? Here is the paraview code for it:

create a new ‘Level Scalars(Overlapping AMR)’

levelScalarsOverlappingAMR1 = LevelScalarsOverlappingAMR(registrationName=‘LevelScalarsOverlappingAMR1’, Input=cellDatatoPointData1)

create a new ‘Contour’

contour1 = Contour(registrationName=‘Contour1’, Input=levelScalarsOverlappingAMR1)

contour1.ContourBy = [‘POINTS’, ‘magvel’]

contour1.Isosurfaces = [1424.5487986062867]

contour1.PointMergeMethod = ‘Uniform Binning’

Thanks for your time!

What is wrong with the Contour filter?

Regarding ghost cells and ghost points, they are not regular arrays, they have a geometrical / topological impact on the mesh. You need to look as them as part of the geometry definition, so processing them as regular arrays is unconventional. They pretty much label some meta-data on the cell / point. In the context of AMR, they are mostly used to tell if a cell is refined at a lower level (defined as REFINED_CELL), or to extend blocks with neighbors so blocks can have access to neighborhood information at a low cost (defined as DUPLICATE_CELL). You need one layer of duplicated cells if you want to compute a contour over multiple connected blocks in your AMR. Refer to vtkDataSetAttributes documentation for other ghost types.