[petsc-users] Reading VTK files in PETSc

Jed Brown jed at jedbrown.org
Thu Nov 30 00:02:48 CST 2023


Is it necessary that it be VTK format or can it be PETSc's binary format or a different mesh format? VTK (be it legacy .vtk or the XML-based .vtu, etc.) is a bad format for parallel reading, no matter how much effort might go into an implementation.

"Kevin G. Wang" <kevinw3 at vt.edu> writes:

> Good morning everyone.
>
> I use the following functions to output parallel vectors --- "globalVec" in
> this example --- to VTK files. It works well, and is quite convenient.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   PetscViewer viewer;
>   PetscViewerVTKOpen(PetscObjectComm((PetscObject)*dm), filename,
> FILE_MODE_WRITE, &viewer);
>   VecView(globalVec, viewer);
>   PetscViewerDestroy(&viewer);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Now, I am trying to do the opposite. I would like to read the VTK files
> generated by PETSc back into memory, and assign each one to a Vec. Could
> someone let me know how this can be done?
>
> Thanks!
> Kevin
>
>
> -- 
> Kevin G. Wang, Ph.D.
> Associate Professor
> Kevin T. Crofton Department of Aerospace and Ocean Engineering
> Virginia Tech
> 1600 Innovation Dr., VTSS Rm 224H, Blacksburg, VA 24061
> Office: (540) 231-7547  |  Mobile: (650) 862-2663
> URL: https://www.aoe.vt.edu/people/faculty/wang.html
> Codes: https://github.com/kevinwgy


More information about the petsc-users mailing list