How to write an adaptor for legacyvtk data format in Paraview Catalyst

I am still struggling with writing my own adaptor for data in legacyvtk format. I found 2 examples written in Python, which is of my interest.

Example 1: can crash
input_ds = pvsimple.ExodusIIReader( FileName=[sys.argv[2]])
input_ds.ElementVariables = ['EQPS']
input_ds.EdgeBlocks = []
input_ds.GlobalVariables = ['KE', 'XMOM', 'YMOM', 'ZMOM', 'NSTEPS', 'TMSTEP']
input_ds.ElementBlocks = ['Unnamed block ID: 1 Type: HEX', 'Unnamed block ID: 2 Type: HEX']
input_ds.PointVariables = ['DISPL', 'VEL', 'ACCL']
input_ds.FaceBlocks = []
timeArray = input_ds.TimestepValues
for step in range(len(timeArray)):
time = input_ds.TimestepValues[step]
dataset = input_ds.GetClientSideObject().GetOutputDataObject(0)
# "perform" coprocessing. results are outputted nly if
# the passed in script says we should at time/step
coProcess(dataset, time, step, sys.argv[1])

Example 2: wavelet
pm = pvsimple.servermanager.vtkProcessModule.GetProcessModule()
rank = pm.GetPartitionId()
nranks = pm.GetNumberOfLocalPartitions()
for step in range(numsteps):
# assume simulation time starts at 0
time = step/float(numsteps)
print("[%d/%d]: Timestep %d of %d (time=%f)" % (rank, nranks, step, numsteps, time))
# create the input to the coprocessing library. normally
# this will come from the adaptor
wavelet = pvsimple.Wavelet()
wholeExtent = wavelet.WholeExtent
# put in some variation in the point data that changes with time
wavelet.Maximum = 255+200*math.sin(step * math.pi / 100)
imageData = pvsimple.servermanager.Fetch(wavelet)
# note that we delete wavelet now since. if not, it will
# get deleted automatically in the coprocessing script
wavelet = None
# "perform" coprocessing. results are outputted only if
# the passed in script says we should at time/step
coProcess(imageData, time, step, sys.argv[1], wholeExtent)
imageData = None
import time

I got the point that the results from the simulation will be transferred to Paraview by the “coProcess(data, time, step, coprocessing_file, …)” function. My question is how the first argument “data” looks like. What is the structure of the data (or data class)? I am a little confused since the given examples pass the results all in different formats. Example 1 uses a method in the classExodusIIReader - GetClientSideObject().GetOutputDataObject(0), which I did not find it in the class description ( Example 2 uses the server manager to extract the results - pvsimple.servermanager.Fetch(wavelet). I tried to search and dig into the source code to find possible similarities or hints, but I could not find the information I need.

In my case, the results are in vtk format. I presume I should use the LegacyVTKReader to load the results, which is most similar to the situation in example 1. What about next? Are there any methods I could use to convert/process the results so that the function “coProcess” can take it and pass it to Paraview?

Sorry for so many questions. I am actually a beginner of both Python and Paraview. I planed to upload the files of the can crash case, but it was too big to be accepted by the browser. BTW, I attached the wavelet source code again to this post in case you need more information. Looking forward to your reply. (3.1 KB) (3.3 KB)

(Just a quick note about your formatting, please use the whole block of code formatting style instead of line by line formatting)