<html><body>Hello,<br><br>I have a particle code that is integrated with Catalyst. It exports particles using a vtkUnstructuredGrid containing only points and VTK_VERTEX cells that index them. Initially, the cells were created the following way:<br><br><div><div></div><span style="font-size:14px"><div>grid->Allocate(num_cells);</div><div>vtkIdType cell_id[1];</div><div>for(vtkIdType i = 0; i < num_cells; i++) {</div><div><span style="white-space:pre">      </span>cell_id[0] = i;</div><div><span style="white-space:pre">       </span>grid->InsertNextCell(VTK_VERTEX, 1, cell_id);</div><div>}</div></span><div></div></div><div><br></div><div>Then I wanted to speed up the process by replacing the Insert method:</div><div><br></div><div><div></div><span style="font-size:14px"><div>vtkSmartPointer<vtkIdTypeArray> cell_ids = vtkSmartPointer<vtkIdTypeArray>::New();</div><div>cell_ids->SetNumberOfComponents(2);</div><div>cell_ids->SetNumberOfTuples(num_cells);</div><div>for(vtkIdType i = 0; i < num_cells; i++) {</div><div><span style="white-space:pre">  </span>cell_ids->SetTuple2(i, 1, i);</div><div>}</div><div>vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();</div><div>cells->SetCells(num_cells, cell_ids);</div><div>grid->SetCells(VTK_VERTEX, cells);</div></span><div></div><span style="font-size:16px"></span><div><br></div><div>Both approaches work, but when I want to dump the grid by putting the following lines in co-processing script,</div><br><div></div><div style="font-size:14px">particles_writer = servermanager.writers.XMLPUnstructuredGridWriter(Input=particles)</div><div style="font-size:14px">coprocessor.RegisterWriter(particles_writer, filename='particles_%t.pvtu', freq=outp<span style="background-color:transparent">ut_freq)</span></div><div style="font-size:14px"><span style="background-color:transparent"><br></span></div><div><span style="font-size:14px;background-color:transparent"><span style="font-size:16px"></span><span style="font-size:16px">the first approach works and the latter causes error:</span> </span></div><div><span style="background-color:transparent;font-size:14px"><span style="font-size:14px">Program received signal SIGSEGV: Segmentation fault - invalid memory reference.</span></span></div><div><span style="background-color:transparent;font-size:14px"><span style="font-size:14px"><br></span></span></div><div><span style="background-color:transparent;font-size:14px"><span style="font-size:14px"><span style="font-size:16px"></span></span></span></div><span style="font-size:16px"><div><span style="background-color:transparent"><span>What is wrong with the second approach? Thank you.</span></span></div><div><span style="background-color:transparent"><span><br></span></span></div><div><span style="background-color:transparent"><span>Best regards,</span></span></div><div><span style="background-color:transparent"><span>Petr Valenta</span></span></div></span><div><span style="background-color:transparent;font-size:14px"><span style="font-size:14px"></span></span></div><div></div></div></body></html>