4
$\begingroup$

The documentation is fairly confusing and I know that I need to keep track of the actual grid location of my data. Writing a python script to convert binary data into this vtk format. I want to leave the legacy VTK behind so that I can utilize the parallelism that XML will give. Any help here is appreciated.

$\endgroup$
4
  • $\begingroup$ You say "Writing a python script to convert binary data into this vtk format.". I'm not sure what you mean by that. Presumably you have some kind of analysis code that has a discrete model and produces results. The XML format has many subtleties and I finally gave up trying to understand them. It was easier to simply use the VTK API (C++ in my case) to create the data objects and then use the API to write the XML file. Assuming you understand the VTK data model, you can almost ignore the XML file format. $\endgroup$ Commented Jun 30, 2017 at 17:21
  • $\begingroup$ Where is the documentation for the VTK API? That would probably be a lot easier in the grand scheme of things. $\endgroup$ Commented Jun 30, 2017 at 19:26
  • $\begingroup$ If you simply go to vtk.org and look under Resources, there is a huge amount of documentation and examples. $\endgroup$ Commented Jun 30, 2017 at 21:10
  • $\begingroup$ I suppose we'd be remiss not to link to the primary source for vtk file formats here. It's always seemed clear enough to work from this document, at least when I've been writing Unstructured Grid file writers. The XML file formats are discussed starting about halfway down the document. vtk.org/wp-content/uploads/2015/04/file-formats.pdf $\endgroup$ Commented Jun 30, 2017 at 23:32

2 Answers 2

2
$\begingroup$

I recently came across a Python tool that claims to convert between all kinds of different mesh formats. I haven't gotten around to trying it yet, but maybe it can help you:

https://github.com/nschloe/meshio

$\endgroup$
0
$\begingroup$

I don't think there is a good argument to write a converter -- whatever it produces has the same information content as the existing VTK files you already have, and the usual visualization programs can visualize them just fine.

But there is a good case to be made for re-writing the code you have that produces VTK files. I agree that the VTU file is confusing and poorly documented, but take a look at some VTU files that you can find on the web. As an example, there are numerous VTU files in subdirectories here: https://github.com/geodynamics/aspect/tree/master/tests (you may just want to check out the entire git repository to look for them). You can also look at code that writes VTU files -- e.g., the write_vtu() function here: https://github.com/dealii/dealii/blob/master/source/base/data_out_base.cc

$\endgroup$
2
  • $\begingroup$ Thanks for the help. I wasn't planning on writing a converter, but having some idea of the file setup should definitely be useful. $\endgroup$ Commented Jun 29, 2017 at 18:23
  • $\begingroup$ Yes, I agree. Looking at files written by other programs usually helps me get things right. $\endgroup$ Commented Jun 30, 2017 at 14:53

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.