# Writing pvtu files from Catalyst ...

**URL:** https://discourse.paraview.org/t/writing-pvtu-files-from-catalyst/1720
**Category:** Development
**Created:** [April 25, 2019, 12:42pm UTC](https://discourse.paraview.org/t/writing-pvtu-files-from-catalyst/1720 "2019-04-25T12:42:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Niklas](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@Niklas](https://discourse.paraview.org/u/Niklas)
#### Post date: [April 25, 2019, 12:42pm UTC](https://discourse.paraview.org/t/writing-pvtu-files-from-catalyst/1720/1 "2019-04-25T12:42:29Z")

</div>

Dear All,  
I am having difficulties with writing out pvtu files from a Catalyst process. Writing them out directly using for instance a threshold defined within the python script works great, but I do have another function for processing the data directly. I can access all fields and perform the computation and in the end would like to write out the results as a vtkIntArray. Using one thread and vtkXMLUnstructuredGridWriter this works great, but in parallel from within Catalyst and using vtkXMLPUnstructuredGridWriter it writes out data to disk, the \*.pvtu file also looks correct, but when reading the data back with ParaView, the XML reader complains about wrong formed tokens etc. Here is the part of C++ code I use to write out the files. The input data is a unstructured grid with one vtkUnsignedIntArray.:

vtkMultiProcessController\* ctrl = vtkMultiProcessController::GetGlobalController();

vtkNew completeArrays;  
completeArrays-\>SetController(ctrl);  
completeArrays-\>SetInputData(isccpData);

vtkNew writer;  
writer-\>SetInputConnection(completeArrays-\>GetOutputPort());  
writer-\>SetNumberOfPieces(ctrl-\>GetNumberOfProcesses());  
writer-\>SetStartPiece(0);  
writer-\>SetEndPiece(ctrl-\>GetNumberOfProcesses()-1);  
//writer-\>SetController(ctrl);  
writer-\>SetUseSubdirectory(true);  
writer-\>SetFileName(outputFile.c\_str());  
writer-\>Update();

I also looked into the Catalyst example and the test for vtkXMLPUnstructuredGridWriter. I also tried without using vtkCompleteArrays, but as it very well may be that process 0 does not have any points, I thought this will be on the safe side.

Thanks for any hints and Cheers,  
Niklas

---

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [April 25, 2019, 1:25pm UTC](https://discourse.paraview.org/t/writing-pvtu-files-from-catalyst/1720/2 "2019-04-25T13:25:53Z")

</div>

Hi Niklas,

Have you looked at using the [vtkCPXMLPWriterPipeline](https://kitware.github.io/paraview-docs/nightly/cxx/classvtkCPXMLPWriterPipeline.html)? That along with maybe the `CxxVTKPipelineExample` under the Examples/Catalyst subdirectory of the source code may get you where you want to go, which I assume is using Catalyst without Python.

Good luck!  
Andy

ps. I think the mistake you’re making with the `vtkXMLPUnstructuredGridWriter` is that it should be:

```auto
writer->SetStartPiece(ctrl->GetLocalProcessId());
writer->SetEndPiece(ctrl->GetLocalProcessId());

```

Also, I don’t think `vtkCompleteArrays` should be necessary here anymore, i.e. with ParaView 5.6.

---

<div class="post-metadata">

### Author: ![Niklas](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@Niklas](https://discourse.paraview.org/u/Niklas)
#### Post date: [April 25, 2019, 1:50pm UTC](https://discourse.paraview.org/t/writing-pvtu-files-from-catalyst/1720/3 "2019-04-25T13:50:23Z")

</div>

Thank you Andy, you are awesome!!!
