Reading mesh from vtk file

30 views
Skip to first unread message

Andreas Rupp

unread,
Aug 5, 2019, 5:05:35 AM8/5/19
to deal.II User Group
Dear all,

I am trying to read a grid from a vtk file created by Paraview. Unfortunately, this does not work.
Moreover, reading a vtk file that has been created using deal.ii also does not work for me. It seems to me that deal.ii reads the file but does not connect the faces to form a mesh. This is underlined by the attached minimal toy example which creates a two dimensional cross, prints the cross' interior and boundary faces, writes it to a vtk file, reads the mesh from the file, and again prints the interior and boundary faces. Execution of the program gives the following output:

Self Interface  1  0 -0.5
Self Interface  2  -0.5 0
Self Interface  3  0.5 0
Self Boundaryface  1  1 -0.5
Self Interface  4  0 0.5
Self Boundaryface  2  -0.5 1
Self Boundaryface  3  1 0.5
Self Boundaryface  4  0.5 1
Self Boundaryface  5  -1 -0.5
Self Boundaryface  6  -1.5 0
Self Boundaryface  7  -1 0.5
Self Boundaryface  8  1.5 0
Self Boundaryface  9  -0.5 -1
Self Boundaryface  10  0 -1.5
Self Boundaryface  11  0.5 -1
Self Boundaryface  12  0 1.5

Read Boundaryface  1  0 -0.5
Read Boundaryface  2  -0.5 0
Read Boundaryface  3  0.5 0
Read Boundaryface  4  0 0.5
Read Boundaryface  5  -1 -0.5
Read Boundaryface  6  -1.5 0
Read Boundaryface  7  -0.5 0
Read Boundaryface  8  -1 0.5
Read Boundaryface  9  1 -0.5
Read Boundaryface  10  0.5 0
Read Boundaryface  11  1.5 0
Read Boundaryface  12  1 0.5
Read Boundaryface  13  0 -1.5
Read Boundaryface  14  -0.5 -1
Read Boundaryface  15  0.5 -1
Read Boundaryface  16  0 -0.5
Read Boundaryface  17  0 0.5
Read Boundaryface  18  -0.5 1
Read Boundaryface  19  0.5 1
Read Boundaryface  20  0 1.5

Is there any quick fix to this issue (except for not using vtk)? I failed with merging the mesh with itself to eliminate the double boundary faces (e.g. 1 and 16).
Thank you very much!

Best regards,
Andreas
vtkWriteRead.cc

Luca Heltai

unread,
Aug 5, 2019, 6:06:22 AM8/5/19
to dea...@googlegroups.com
Dear Andreas,

You are trying to read a vtk file that was generated by DataOut. 

Try to write the file with GridOut::write_vtk. 

DataOut produces files that are split cell wise (to allow for some flexibility in discontinuos fields. 

Luca
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/bfb4e975-63ab-4be0-9e3e-f9bf0a131ce6%40googlegroups.com.

Andreas Rupp

unread,
Aug 5, 2019, 6:37:31 AM8/5/19
to deal.II User Group
Dear Luca,

Thank you very much for your quick reply. However, I have to admit that I do not fully understand it. The vtk is created using

    GridOut grid_writer;
    std::ofstream output_file("./DealOutput.vtk");
    grid_writer.write_vtk(triangulationSelf, output_file);

Thus, I assume that GridOut::write_vtk is invoked. I am sorry if this is a silly question.

Best regards,
Andreas
Reply all
Reply to author
Forward
0 new messages