# Using VTK API in CFD code

**URL:** https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116
**Category:** ParaView Support
**Tags:** vtk
**Created:** [May 16, 2023, 5:49pm UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116 "2023-05-16T17:49:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Suman\_Vajjala](https://discourse.paraview.org/user_avatar/discourse.paraview.org/suman_vajjala/32/8560_2.png) [@Suman\_Vajjala](https://discourse.paraview.org/u/Suman_Vajjala)
#### Post date: [May 16, 2023, 5:49pm UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116/1 "2023-05-16T17:49:42Z")

</div>

I am Suman Vajjala and I am developing a parallel, high order, unstructured grid based CFD code in C++ for LES/DNS. As I will be using high order mesh elements, I decided to use Paraview as my main visualization software.

I’m new to the VTK API and I tried to find resources/articles on how to use them but I could not find any. I have, infact, written a VTK writer for my CFD code as a result. Could you please direct me to an example where the VTK library is used for writing CFD data using the VTK API? I plan to replace my code with it.

@danlipsa @berkgeveci

Thanks,

Regards  
Suman

---

<div class="post-metadata">

### Author: ![berkgeveci](https://discourse.paraview.org/user_avatar/discourse.paraview.org/berkgeveci/32/1464_2.png) [@berkgeveci](https://discourse.paraview.org/u/berkgeveci)
#### Post date: [May 16, 2023, 5:57pm UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116/2 "2023-05-16T17:57:48Z")

</div>

Hi Suman,  
There is a lot of VTK documentation out there.  
[https://examples.vtk.org/](https://examples.vtk.org/)  
[https://book.vtk.org](https://book.vtk.org)  
[https://vtk.org/documentation/](https://vtk.org/documentation/)

I suggest finding the examples that create unstructured meshes from scratch as well as ones that use writers. Having said that, there is not a writer for every format VTK supports. For example, there is not writer for the VTKHDF5 format. The assumption there is that the simulation would write VTKHDF5 directly using the HDF5 API.

---

<div class="post-metadata">

### Author: ![Suman\_Vajjala](https://discourse.paraview.org/user_avatar/discourse.paraview.org/suman_vajjala/32/8560_2.png) [@Suman\_Vajjala](https://discourse.paraview.org/u/Suman_Vajjala)
#### Post date: [May 16, 2023, 6:13pm UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116/3 "2023-05-16T18:13:39Z")

</div>

Thanks @berkgeveci for the links. I’ll follow the **WriteVTU.cxx** example.

Regards  
Suman

---

<div class="post-metadata">

### Author: ![Tox](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@Tox](https://discourse.paraview.org/u/Tox)
#### Post date: [May 17, 2023, 10:30am UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116/4 "2023-05-17T10:30:49Z")

</div>

Hi Suman,

You could also consider to write your solution in CGNS format, which is much more common than the VTK format. In fact, the VTK file documentation itself rightly suggests to use something else, unless… (cite from [VTK File Formats - VTK documentation](https://docs.vtk.org/en/latest/concepts/VTKFileFormats.html): “Whenever possible, we recommend that you use formats that are more widely used.”). We use CGNS as output (and input, by the way) and find that it works well with Paraview, as well as with other postprocessing tools. Benefit is also that you can easily exchange the files with other parties.

Good luck and best regards,  
Serge

---

<div class="post-metadata">

### Author: ![Suman\_Vajjala](https://discourse.paraview.org/user_avatar/discourse.paraview.org/suman_vajjala/32/8560_2.png) [@Suman\_Vajjala](https://discourse.paraview.org/u/Suman_Vajjala)
#### Post date: [May 17, 2023, 5:55pm UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116/5 "2023-05-17T17:55:49Z")

</div>

@Tox Thank you for the suggestion. Does CGNS support high order mesh element based solution visualization? Can you please suggest a reference for easy implementation of solution output to CGNS?

Thanks and Regards  
Suman

---

<div class="post-metadata">

### Author: ![Tox](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@Tox](https://discourse.paraview.org/u/Tox)
#### Post date: [May 19, 2023, 7:21am UTC](https://discourse.paraview.org/t/using-vtk-api-in-cfd-code/12116/6 "2023-05-19T07:21:56Z")

</div>

Here you can find all the info on CGNS: [CGNS Documentation](https://cgns.github.io/CGNS_docs_current/)

I am not familiar with higher order elements, but from [CGNS Standard Interface Data Structures - Conventions](https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_3d) it seems it is possible.

Good luck,  
Serge
