I’ve been trying to use a python script to render about ~1000 Line() objects. This is a simple task to perform, but it takes a long time. As a very bare bones example, if you process the following in the python shell:
test = [None]*1000
for i in xrange(len(test)):
…test[i] = Line()
it takes roughly 10 seconds (on my laptop anyway) for the objects to show up in the pipeline browser. It then takes about 3 times as long to render all the line objects. I’m looking for a way to speed this process up through parallelization, as this seems like an embarrassingly parallel routine.
I have tried running a script using pvbatch that was called by mpiexec.hydra -np 8. I didn’t really see nor expect a speed increase however, because my code uses standard python for-loops to create and render the source objects (lines). I considered playing around with the python joblib package to see if that sped things up, but for now joblib is not working in my pvbatch environment (at work I don’t have the privileges to fix this). Would this be a reasonable route to pursue to improve performance?
Finally, to articulate an actual question: is there a fast method, or efficient coding practices I can use to quickly instantiate and render > ~ 1000 simple source objects (e.g. lines, cones, boxes) in python? Any guidance would be greatly appreciated.
It is definitelly not recommended to create lots of sources. It will slow down rendering a lot.
Why not having a dataset with hundreds lines ? or maybe a multiblock with hundreds of blocks ?
The data set I’m working with is a large ascii format collection of start points and endpoints for disconnected line segments (I could convert to .csv), so my first thought was to create a python script with a loop that would draw a line segment for each pair of points. This became too slow once I included too many line segments.
I’m not sure how to render hundreds of lines with a single source object–the poly line isn’t quite what I need since the segments are disconnected. I might try playing around with the .csv reader because I’ve used that before to visualize very large (~1M points) data sets fairly quickly.
Just use line cells.
eg : 4 points, 2 cells.
cell 0 : line, point0, point1
cell 1 : line, point2, point3
Ok thanks Mathieu, I’ll look into that.
This is going to work. It also leads to the solution to my more general question in the OP. One followup question:
Right now I’m generating the point and cell data using the legacy vtk file format. Is there a wiki or document describing a better way that I should be doing this within paraview? Unfortunately I don’t have experience with xml (maybe this is a good time to learn).
Thanks again for the help!
You indeed should use the XML based vtk format.