[Paraview] writing vtk file

Ivo Roghair ivoroghair at gmail.com
Thu Sep 24 03:42:42 EDT 2009


Sound like you have to write a conversion program or so that imports 
your simulation data, and exports a VTK file. I have also struggled with 
this problem of writing vtk files without linking to the library. I 
found two solutions:

1) Create .vtk files (the old format) -- I included subroutines 
(visit_writer.c and visit_writer.h) in this message which I found online 
at the LLNL/VisIt page [1]. Note that these are wrapper functions, so 
you'll have to write your own function in which you collect all 
necessary data into the required variables/arrays, then send it over to 
the wrapper functions. For a rectilinear grid, I've included my own 
function in example.c. The advantage is that this format can handle 
binary variables thus the files will be smaller and (I think) faster to 
load. For acsii file format, check also [2]

2) Write new VTK format (*.vtu/vtr/vti/etc) using your own routines. 
Take a look at the file-formats.pdf document, and at the link below [3] 
which contains a lot of example files. (I export such files from my code 
in ascii format only, since I don't know how to write in the base64 
format which is required for binary).

So just start by writing line-by-line similar files as the examples 
below. Do not immediately try to export your simulation, rather start 
with 3 datapoints in a 3D space (see included 
example-particles-and-vectors.vtu) to get used to the file format.

[1] https://wci.llnl.gov/codes/visit/
[2] http://www.visitusers.org/index.php?title=ASCII_VTK_Files
[3] 
http://www.geophysik.uni-muenchen.de/intranet/it-service/applications/paraview/vtk-file-formats 


Best,
Ivo



chukwudi chukwu wrote:
>  I am running a simulation written in C++ and I need to write the 
> output to a VTK file for visualization using Paraview. I have read the 
> VTK manual for writing VTK format files but this does not solve my 
> problem as my input data to the file will come from a imulation, not 
> manually written as is demonstrated in the manual. What I wish to do 
> is to write a subroutine in C++ that will create the VTK file and save 
> the data in my preferred geometry/topology.
>  I will appreciate if I you could refer me to materials and tutorials that
>  will help me achieve this.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>   
-------------- next part --------------
A non-text attachment was scrubbed...
Name: visit_writer.c
Type: text/x-csrc
Size: 29673 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090924/b9cea992/attachment-0002.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: visit_writer.h
Type: text/x-chdr
Size: 14046 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090924/b9cea992/attachment-0001.h>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example-particles-and-vectors.vtu
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090924/b9cea992/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.c
Type: text/x-csrc
Size: 2964 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090924/b9cea992/attachment-0003.c>


More information about the ParaView mailing list