[Paraview] Set cells in unstructured grid

Petr Valenta valenpe7 at email.cz
Tue Dec 12 10:12:42 EST 2017


Hello,

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:





grid->Allocate(num_cells);

vtkIdType cell_id[1];

for(vtkIdType i = 0; i < num_cells; i++) {

cell_id[0] = i;

grid->InsertNextCell(VTK_VERTEX, 1, cell_id);

}







Then I wanted to speed up the process by replacing the Insert method:







vtkSmartPointer<vtkIdTypeArray> cell_ids = vtkSmartPointer<vtkIdTypeArray>::
New();

cell_ids->SetNumberOfComponents(2);

cell_ids->SetNumberOfTuples(num_cells);

for(vtkIdType i = 0; i < num_cells; i++) {

cell_ids->SetTuple2(i, 1, i);

}

vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();

cells->SetCells(num_cells, cell_ids);

grid->SetCells(VTK_VERTEX, cells);






Both approaches work, but when I want to dump the grid by putting the 
following lines in co-processing script,




particles_writer = servermanager.writers.XMLPUnstructuredGridWriter(Input=
particles)

coprocessor.RegisterWriter(particles_writer, filename='particles_%t.pvtu', 
freq=output_freq)




the first approach works and the latter causes error: 

Program received signal SIGSEGV: Segmentation fault - invalid memory 
reference.






What is wrong with the second approach? Thank you.




Best regards,

Petr Valenta




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171212/c1f12ee6/attachment.html>


More information about the ParaView mailing list