I'm currently developing a simulation and I intend to use VTK for visualisation. Furthermore, I fell a bit stupid right now, as I do not find a good example on how to generate the data for VTK. There are many examples that start from reading the data and then do some visualisation with it.

BUT what is with the other side? I will have a FEM mesh with up to billions of nodes on many computing nodes. How do people feed this into "something" (probably a file) suitable as input for VTK? Is it possible with VTK to already do some pre-processing in the distributed simulation application in order to reduce the amount of data?

I think, a link to a good example or tutorial would be more than helpful. Currently I'm just lost in the amount of information available.

  • $\begingroup$ Let each rank write output for part of the mesh (including ghost nodes) it owns. $\endgroup$
    – stali
    Commented May 20, 2016 at 13:01
  • $\begingroup$ To add to @BillGreene answer: Depending on what programming language you are developing your simulation in you may find libraries which provide you with a means of outputting a vtk data file. $\endgroup$
    – nluigi
    Commented May 21, 2016 at 12:43
  • $\begingroup$ An important consideration is what kind of grid you're using. VTK has several different grid representations and using the most efficient one for your simulation's output can save considerably on storage size. $\endgroup$
    – andybauer
    Commented May 23, 2016 at 14:46
  • $\begingroup$ Did you ever end up getting this working? Any tips for someone trying to use vtk with DGFEM? $\endgroup$ Commented Jul 12, 2019 at 15:48

2 Answers 2


If you want to keep your FE code independent of the VTK API, writing a file that VTK can read is the most straightforward way to do that. The file formats are documented here:


The legacy format is simpler but the XML format provides access to some of the newer features of VTK. Creating VTK objects from files in either of these formats is straightforward.

Writing a file also allows you to use visualization applications built using the VTK API instead of writing your own, for example, ParaView:



As said above, the VTK legacy format is simple and straightforward and you should be able to write a subroutine to create the output file.

However in your case, you are dealing with billions of nodes, resulting in a huge (or several) file. For such amount of data, you must use compressed binary format. I assume you run your code in parallel on a cluster. The XML format provides interesting parallel features for reading multiple output from different processes for instance and has been especially designed to read data from massive parallel computations.

I do not know if VTK will suit your needs. You can take a look at the HDF5 library https://www.hdfgroup.org/HDF5/ which can be used with MPI to perform efficient I/O operations. It provides C and Fortran interfaces. NETCDF or CGNS libraries are also good alternatives. Depending on your data, you can choose to use an existing format or develop your own driver.

Finally, about visualization software, you should take a look at Paraview mentioned above and also Visit https://wci.llnl.gov/simulation/computer-codes/visit/ which both support massive data visualization through parallel pipelines and remote cluster access. Paraview is built with VTK so it should offer optimizations to read VTK files. Visit uses filters and ghost nodes to speed up the visualization displaying only the required cells. Both have a good documentation I advise you to read.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.