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

**URL:** https://discourse.paraview.org/t/how-to-write-an-adaptor-for-legacyvtk-data-format-in-paraview-catalyst/4025
**Category:** ParaView Support
**Tags:** python
**Created:** [April 10, 2020, 7:37pm UTC](https://discourse.paraview.org/t/how-to-write-an-adaptor-for-legacyvtk-data-format-in-paraview-catalyst/4025 "2020-04-10T19:37:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![leoncwu](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/f17d59/32.png) [@leoncwu](https://discourse.paraview.org/u/leoncwu)
#### Post date: [April 10, 2020, 7:37pm UTC](https://discourse.paraview.org/t/how-to-write-an-adaptor-for-legacyvtk-data-format-in-paraview-catalyst/4025/1 "2020-04-10T19:37:47Z")

</div>

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]`  
`input_ds.UpdatePipeline(time)`  
`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)`  
` wavelet.UpdatePipeline()`  
` imageData = pvsimple.servermanager.Fetch(wavelet)`  
` # note that we delete wavelet now since. if not, it will`  
` # get deleted automatically in the coprocessing script`  
` pvsimple.Delete(wavelet)`  
` 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`  
` time.sleep(1)`

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 ([https://kitware.github.io/paraview-docs/latest/python/paraview.simple.ExodusIIReader.html](https://kitware.github.io/paraview-docs/latest/python/paraview.simple.ExodusIIReader.html)). 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.

[CatalystWaveletCoprocessing.py](https://discourse.paraview.org/uploads/short-url/3wjupQ1mMOAVss9KJssSnFY37kt.py) (3.1 KB)  
[CatalystWaveletDriver.py](https://discourse.paraview.org/uploads/short-url/vM0KzbOXaXVvsDcD064JIbhQJaC.py) (3.3 KB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 14, 2020, 3:34am UTC](https://discourse.paraview.org/t/how-to-write-an-adaptor-for-legacyvtk-data-format-in-paraview-catalyst/4025/2 "2020-04-14T03:34:24Z")

</div>

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